3
3
import os
4
4
import shutil
5
5
6
- required_conan_version = ">=1.33 .0"
6
+ required_conan_version = ">=1.43 .0"
7
7
8
8
9
9
class WtConan (ConanFile ):
10
10
name = "wt"
11
11
description = "Wt is a C++ library for developing web applications"
12
12
url = "https://github.com/conan-io/conan-center-index"
13
13
homepage = "https://github.com/emweb/wt"
14
- topics = ("conan" , " wt" , "web" , "webapp" )
14
+ topics = ("wt" , "web" , "webapp" )
15
15
license = "GPL-2.0-only"
16
- exports_sources = ["patches/*" , "CMakeLists.txt" ]
17
- generators = "cmake"
18
16
19
17
settings = "os" , "arch" , "compiler" , "build_type"
20
18
options = {
@@ -34,7 +32,7 @@ class WtConan(ConanFile):
34
32
"multi_threaded" : [True , False ],
35
33
"connector_http" : [True , False ],
36
34
"connector_isapi" : [True , False ],
37
- "connector_fcgi" : [True , False ]
35
+ "connector_fcgi" : [True , False ],
38
36
}
39
37
default_options = {
40
38
"shared" : False ,
@@ -53,9 +51,10 @@ class WtConan(ConanFile):
53
51
"multi_threaded" : True ,
54
52
"connector_http" : True ,
55
53
"connector_isapi" : True ,
56
- "connector_fcgi" : False
54
+ "connector_fcgi" : False ,
57
55
}
58
56
57
+ generators = "cmake"
59
58
_cmake = None
60
59
61
60
@property
@@ -66,6 +65,11 @@ def _source_subfolder(self):
66
65
def _build_subfolder (self ):
67
66
return "build_subfolder"
68
67
68
+ def export_sources (self ):
69
+ self .copy ("CMakeLists.txt" )
70
+ for patch in self .conan_data .get ("patches" , {}).get (self .version , []):
71
+ self .copy (patch ["patch_file" ])
72
+
69
73
def config_options (self ):
70
74
if self .settings .os == "Windows" :
71
75
del self .options .fPIC
@@ -95,17 +99,20 @@ def _required_boost_components(self):
95
99
return ["program_options" , "filesystem" , "thread" ]
96
100
97
101
def requirements (self ):
98
- self .requires ("boost/1.76.0" )
102
+ if tools .Version (self .version ) >= "4.6.0" :
103
+ self .requires ("boost/1.78.0" )
104
+ else :
105
+ self .requires ("boost/1.76.0" )
99
106
if self .options .connector_http :
100
107
self .requires ("zlib/1.2.11" )
101
108
if self .options .with_ssl :
102
- self .requires ("openssl/1.1.1k " )
109
+ self .requires ("openssl/1.1.1m " )
103
110
if self .options .get_safe ("with_sqlite" ):
104
- self .requires ("sqlite3/3.35.5 " )
111
+ self .requires ("sqlite3/3.37.2 " )
105
112
if self .options .get_safe ("with_mysql" ):
106
113
self .requires ("libmysqlclient/8.0.17" )
107
114
if self .options .get_safe ("with_postgres" ):
108
- self .requires ("libpq/13.2 " )
115
+ self .requires ("libpq/13.4 " )
109
116
if self .options .get_safe ("with_mssql" ) and self .settings .os != "Windows" :
110
117
self .requires ("odbc/2.3.9" )
111
118
if self .options .get_safe ("with_unwind" ):
@@ -120,6 +127,24 @@ def source(self):
120
127
tools .get (** self .conan_data ["sources" ][self .version ],
121
128
destination = self ._source_subfolder , strip_root = True )
122
129
130
+ def _patch_sources (self ):
131
+ for patch in self .conan_data .get ("patches" , {}).get (self .version , []):
132
+ tools .patch (** patch )
133
+
134
+ cmakelists = os .path .join (self ._source_subfolder , "CMakeLists.txt" )
135
+ tools .replace_in_file (cmakelists , "find_package(OpenSSL)" , "#find_package(OpenSSL)" )
136
+ tools .replace_in_file (cmakelists , "INCLUDE(cmake/WtFindMysql.txt)" , "#INCLUDE(cmake/WtFindMysql.txt)" )
137
+ tools .replace_in_file (cmakelists , "INCLUDE(cmake/WtFindPostgresql.txt)" , "#INCLUDE(cmake/WtFindPostgresql.txt)" )
138
+ if self .settings .os != "Windows" :
139
+ tools .replace_in_file (cmakelists , "INCLUDE(cmake/WtFindOdbc.txt)" , "#INCLUDE(cmake/WtFindOdbc.txt)" )
140
+
141
+ # Do not pollute rpath of shared libs of the install tree on macOS please
142
+ tools .replace_in_file (
143
+ cmakelists ,
144
+ "IF(APPLE)\n SET(CMAKE_INSTALL_RPATH \" ${CMAKE_INSTALL_PREFIX}/lib\" )" ,
145
+ "if(0)" ,
146
+ )
147
+
123
148
def _configure_cmake (self ):
124
149
if self ._cmake :
125
150
return self ._cmake
@@ -198,16 +223,7 @@ def _gather_libs(p):
198
223
return self ._cmake
199
224
200
225
def build (self ):
201
- tools .replace_in_file (os .path .join (self ._source_subfolder , "CMakeLists.txt" ), "find_package(OpenSSL)" , "#find_package(OpenSSL)" )
202
- tools .replace_in_file (os .path .join (self ._source_subfolder , "CMakeLists.txt" ), "INCLUDE(cmake/WtFindMysql.txt)" , "#INCLUDE(cmake/WtFindMysql.txt)" )
203
- tools .replace_in_file (os .path .join (self ._source_subfolder , "CMakeLists.txt" ), "INCLUDE(cmake/WtFindPostgresql.txt)" , "#INCLUDE(cmake/WtFindPostgresql.txt)" )
204
- if self .settings .os != "Windows" :
205
- tools .replace_in_file (os .path .join (self ._source_subfolder , "CMakeLists.txt" ), "INCLUDE(cmake/WtFindOdbc.txt)" , "#INCLUDE(cmake/WtFindOdbc.txt)" )
206
-
207
-
208
- for patch in self .conan_data .get ("patches" , {}).get (self .version , []):
209
- tools .patch (** patch )
210
-
226
+ self ._patch_sources ()
211
227
cmake = self ._configure_cmake ()
212
228
cmake .build ()
213
229
@@ -221,15 +237,14 @@ def package(self):
221
237
tools .rmdir (os .path .join (self .package_folder , "lib" , "cmake" ))
222
238
223
239
def package_info (self ):
224
- self .cpp_info .filenames [ "cmake_find_package" ] = "wt"
225
- self . cpp_info . filenames [ "cmake_find_package_multi" ] = "wt"
226
- self .cpp_info . names [ "cmake_find_package" ] = "Wt "
227
- self . cpp_info . names [ "cmake_find_package_multi" ] = "Wt"
240
+ self .cpp_info .set_property ( "cmake_file_name" , "wt" )
241
+
242
+ suffix = "d" if self .settings . build_type == "Debug" else " "
243
+
228
244
# wt
229
- self .cpp_info .components ["wtmain" ].names ["cmake_find_package" ] = "Wt"
230
- self .cpp_info .components ["wtmain" ].names ["cmake_find_package_multi" ] = "Wt"
231
- self .cpp_info .components ["wtmain" ].libs = [self ._lib_name ("wt" )]
232
- if self .settings .os == "Linux" :
245
+ self .cpp_info .components ["wtmain" ].set_property ("cmake_target_name" , "Wt::Wt" )
246
+ self .cpp_info .components ["wtmain" ].libs = ["wt{}" .format (suffix )]
247
+ if self .settings .os in ["Linux" , "FreeBSD" ]:
233
248
self .cpp_info .components ["wtmain" ].system_libs = ["m" , "rt" ]
234
249
elif self .settings .os == "Windows" :
235
250
self .cpp_info .components ["wtmain" ].system_libs = ["ws2_32" , "mswsock" , "winmm" ]
@@ -238,73 +253,103 @@ def package_info(self):
238
253
self .cpp_info .components ["wtmain" ].requires .append ("openssl::openssl" )
239
254
if self .options .get_safe ("with_unwind" ):
240
255
self .cpp_info .components ["wtmain" ].requires .append ("libunwind::libunwind" )
256
+
241
257
# wttest
242
258
if self .options .with_test :
243
- self .cpp_info .components ["wttest" ].names ["cmake_find_package" ] = "Test"
244
- self .cpp_info .components ["wttest" ].names ["cmake_find_package_multi" ] = "Test"
245
- self .cpp_info .components ["wttest" ].libs = [self ._lib_name ("wttest" )]
259
+ self .cpp_info .components ["wttest" ].set_property ("cmake_target_name" , "Wt::Test" )
260
+ self .cpp_info .components ["wttest" ].libs = ["wttest{}" .format (suffix )]
246
261
self .cpp_info .components ["wttest" ].requires = ["wtmain" ]
262
+
247
263
# wthttp
248
264
if self .options .connector_http :
249
- self .cpp_info .components ["wthttp" ].names ["cmake_find_package" ] = "HTTP"
250
- self .cpp_info .components ["wthttp" ].names ["cmake_find_package_multi" ] = "HTTP"
251
- self .cpp_info .components ["wthttp" ].libs = [self ._lib_name ("wthttp" )]
265
+ self .cpp_info .components ["wthttp" ].set_property ("cmake_target_name" , "Wt::HTTP" )
266
+ self .cpp_info .components ["wthttp" ].libs = ["wthttp{}" .format (suffix )]
252
267
self .cpp_info .components ["wthttp" ].requires = ["wtmain" , "boost::boost" , "zlib::zlib" ]
253
268
if self .options .with_ssl :
254
269
self .cpp_info .components ["wthttp" ].requires .append ("openssl::openssl" )
270
+
255
271
# wtisapi
256
272
if self .options .get_safe ("connector_isapi" ):
257
- self .cpp_info .components ["wtisapi" ].names ["cmake_find_package" ] = "Isapi"
258
- self .cpp_info .components ["wtisapi" ].names ["cmake_find_package_multi" ] = "Isapi"
259
- self .cpp_info .components ["wtisapi" ].libs = [self ._lib_name ("wtisapi" )]
273
+ self .cpp_info .components ["wtisapi" ].set_property ("cmake_target_name" , "Wt::Isapi" )
274
+ self .cpp_info .components ["wtisapi" ].libs = ["wtisapi{}" .format (suffix )]
260
275
self .cpp_info .components ["wtisapi" ].requires = ["wtmain" ]
276
+
261
277
# wtfcgi
262
278
if self .options .get_safe ("connector_fcgi" ):
263
- self .cpp_info .components ["wtfcgi" ].names ["cmake_find_package" ] = "FCGI"
264
- self .cpp_info .components ["wtfcgi" ].names ["cmake_find_package_multi" ] = "FCGI"
265
- self .cpp_info .components ["wtfcgi" ].libs = [self ._lib_name ("wtfcgi" )]
279
+ self .cpp_info .components ["wtfcgi" ].set_property ("cmake_target_name" , "Wt::FCGI" )
280
+ self .cpp_info .components ["wtfcgi" ].libs = ["wtfcgi{}" .format (suffix )]
266
281
self .cpp_info .components ["wtfcgi" ].requires = ["wtmain" ]
267
282
if self .options .with_ssl :
268
283
self .cpp_info .components ["wtfcgi" ].requires .append ("openssl::openssl" )
284
+
269
285
# wtdbo
270
286
if self .options .with_dbo :
271
- self .cpp_info .components ["wtdbo" ].names ["cmake_find_package" ] = "Dbo"
272
- self .cpp_info .components ["wtdbo" ].names ["cmake_find_package_multi" ] = "Dbo"
273
- self .cpp_info .components ["wtdbo" ].libs = [self ._lib_name ("wtdbo" )]
287
+ self .cpp_info .components ["wtdbo" ].set_property ("cmake_target_name" , "Wt::Dbo" )
288
+ self .cpp_info .components ["wtdbo" ].libs = ["wtdbo{}" .format (suffix )]
274
289
if self .options .get_safe ("with_unwind" ):
275
290
self .cpp_info .components ["wtdbo" ].requires .append ("libunwind::libunwind" )
291
+
276
292
# wtdbosqlite3
277
293
if self .options .get_safe ("with_sqlite" ):
278
- self .cpp_info .components ["wtdbosqlite3" ].names ["cmake_find_package" ] = "DboSqlite3"
279
- self .cpp_info .components ["wtdbosqlite3" ].names ["cmake_find_package_multi" ] = "DboSqlite3"
280
- self .cpp_info .components ["wtdbosqlite3" ].libs = [self ._lib_name ("wtdbosqlite3" )]
294
+ self .cpp_info .components ["wtdbosqlite3" ].set_property ("cmake_target_name" , "Wt::DboSqlite3" )
295
+ self .cpp_info .components ["wtdbosqlite3" ].libs = ["wtdbosqlite3{}" .format (suffix )]
281
296
self .cpp_info .components ["wtdbosqlite3" ].requires = ["wtdbo" , "sqlite3::sqlite3" ]
282
- if self .settings .os == "Linux" :
297
+ if self .settings .os in [ "Linux" , "FreeBSD" ] :
283
298
self .cpp_info .components ["wtdbosqlite3" ].system_libs = ["m" ]
299
+
284
300
# wtdbopostgres
285
301
if self .options .get_safe ("with_postgres" ):
286
- self .cpp_info .components ["wtdbopostgres" ].names ["cmake_find_package" ] = "DboPostgres"
287
- self .cpp_info .components ["wtdbopostgres" ].names ["cmake_find_package_multi" ] = "DboPostgres"
288
- self .cpp_info .components ["wtdbopostgres" ].libs = [self ._lib_name ("wtdbopostgres" )]
302
+ self .cpp_info .components ["wtdbopostgres" ].set_property ("cmake_target_name" , "Wt::DboPostgres" )
303
+ self .cpp_info .components ["wtdbopostgres" ].libs = ["wtdbopostgres{}" .format (suffix )]
289
304
self .cpp_info .components ["wtdbopostgres" ].requires = ["wtdbo" , "libpq::libpq" ]
305
+
290
306
# wtdbomysql
291
307
if self .options .get_safe ("with_mysql" ):
292
- self .cpp_info .components ["wtdbomysql" ].names ["cmake_find_package" ] = "DboMySQL"
293
- self .cpp_info .components ["wtdbomysql" ].names ["cmake_find_package_multi" ] = "DboMySQL"
294
- self .cpp_info .components ["wtdbomysql" ].libs = [self ._lib_name ("wtdbomysql" )]
308
+ self .cpp_info .components ["wtdbomysql" ].set_property ("cmake_target_name" , "Wt::DboMySQL" )
309
+ self .cpp_info .components ["wtdbomysql" ].libs = ["wtdbomysql{}" .format (suffix )]
295
310
self .cpp_info .components ["wtdbomysql" ].requires = ["wtdbo" , "libmysqlclient::libmysqlclient" ]
311
+
296
312
# wtdbomssqlserver
297
313
if self .options .get_safe ("with_mssql" ):
298
- self .cpp_info .components ["wtdbomssqlserver" ].names ["cmake_find_package" ] = "DboMSSQLServer"
299
- self .cpp_info .components ["wtdbomssqlserver" ].names ["cmake_find_package_multi" ] = "DboMSSQLServer"
300
- self .cpp_info .components ["wtdbomssqlserver" ].libs = [self ._lib_name ("wtdbomssqlserver" )]
314
+ self .cpp_info .components ["wtdbomssqlserver" ].set_property ("cmake_target_name" , "Wt::DboMSSQLServer" )
315
+ self .cpp_info .components ["wtdbomssqlserver" ].libs = ["wtdbomssqlserver{}" .format (suffix )]
301
316
self .cpp_info .components ["wtdbomssqlserver" ].requires = ["wtdbo" ]
302
317
if self .settings .os == "Windows" :
303
318
self .cpp_info .components ["wtdbomssqlserver" ].system_libs .append ("odbc32" )
304
319
else :
305
320
self .cpp_info .components ["wtdbomssqlserver" ].requires .append ("odbc::odbc" )
306
321
307
- def _lib_name (self , name ):
308
- if self .settings .build_type == "Debug" :
309
- return name + "d"
310
- return name
322
+ # TODO: to remove in conan v2 once cmake_find_package* generators removed
323
+ self .cpp_info .filenames ["cmake_find_package" ] = "wt"
324
+ self .cpp_info .filenames ["cmake_find_package_multi" ] = "wt"
325
+ self .cpp_info .names ["cmake_find_package" ] = "Wt"
326
+ self .cpp_info .names ["cmake_find_package_multi" ] = "Wt"
327
+ self .cpp_info .components ["wtmain" ].names ["cmake_find_package" ] = "Wt"
328
+ self .cpp_info .components ["wtmain" ].names ["cmake_find_package_multi" ] = "Wt"
329
+ if self .options .with_test :
330
+ self .cpp_info .components ["wttest" ].names ["cmake_find_package" ] = "Test"
331
+ self .cpp_info .components ["wttest" ].names ["cmake_find_package_multi" ] = "Test"
332
+ if self .options .connector_http :
333
+ self .cpp_info .components ["wthttp" ].names ["cmake_find_package" ] = "HTTP"
334
+ self .cpp_info .components ["wthttp" ].names ["cmake_find_package_multi" ] = "HTTP"
335
+ if self .options .get_safe ("connector_isapi" ):
336
+ self .cpp_info .components ["wtisapi" ].names ["cmake_find_package" ] = "Isapi"
337
+ self .cpp_info .components ["wtisapi" ].names ["cmake_find_package_multi" ] = "Isapi"
338
+ if self .options .get_safe ("connector_fcgi" ):
339
+ self .cpp_info .components ["wtfcgi" ].names ["cmake_find_package" ] = "FCGI"
340
+ self .cpp_info .components ["wtfcgi" ].names ["cmake_find_package_multi" ] = "FCGI"
341
+ if self .options .with_dbo :
342
+ self .cpp_info .components ["wtdbo" ].names ["cmake_find_package" ] = "Dbo"
343
+ self .cpp_info .components ["wtdbo" ].names ["cmake_find_package_multi" ] = "Dbo"
344
+ if self .options .get_safe ("with_sqlite" ):
345
+ self .cpp_info .components ["wtdbosqlite3" ].names ["cmake_find_package" ] = "DboSqlite3"
346
+ self .cpp_info .components ["wtdbosqlite3" ].names ["cmake_find_package_multi" ] = "DboSqlite3"
347
+ if self .options .get_safe ("with_postgres" ):
348
+ self .cpp_info .components ["wtdbopostgres" ].names ["cmake_find_package" ] = "DboPostgres"
349
+ self .cpp_info .components ["wtdbopostgres" ].names ["cmake_find_package_multi" ] = "DboPostgres"
350
+ if self .options .get_safe ("with_mysql" ):
351
+ self .cpp_info .components ["wtdbomysql" ].names ["cmake_find_package" ] = "DboMySQL"
352
+ self .cpp_info .components ["wtdbomysql" ].names ["cmake_find_package_multi" ] = "DboMySQL"
353
+ if self .options .get_safe ("with_mssql" ):
354
+ self .cpp_info .components ["wtdbomssqlserver" ].names ["cmake_find_package" ] = "DboMSSQLServer"
355
+ self .cpp_info .components ["wtdbomssqlserver" ].names ["cmake_find_package_multi" ] = "DboMSSQLServer"
0 commit comments