1
1
from conans import ConanFile , CMake , tools
2
+ import glob
2
3
import os
3
4
4
5
5
- class LibaecConan (ConanFile ):
6
+ class ProjConan (ConanFile ):
6
7
name = "proj"
7
8
license = "MIT"
8
9
url = "https://github.com/conan-io/conan-center-index"
@@ -13,14 +14,16 @@ class LibaecConan(ConanFile):
13
14
options = {
14
15
"shared" : [True , False ],
15
16
"fPIC" : [True , False ],
17
+ "threadsafe" : [True , False ]
16
18
}
17
19
default_options = {
18
20
"shared" : False ,
19
21
"fPIC" : True ,
22
+ "threadsafe" : True
20
23
}
21
24
22
25
generators = "cmake"
23
- exports_sources = ["CMakeLists.txt" , "sqlite_init.py" , " patches/*" ]
26
+ exports_sources = ["CMakeLists.txt" , "patches/*" ]
24
27
25
28
_cmake = None
26
29
@@ -37,7 +40,7 @@ def config_options(self):
37
40
del self .options .fPIC
38
41
39
42
def requirements (self ):
40
- self .requires ("sqlite3/3.31.0 " )
43
+ self .requires . add ("sqlite3/3.31.1 " )
41
44
42
45
def source (self ):
43
46
tools .get (** self .conan_data ["sources" ][self .version ])
@@ -50,30 +53,44 @@ def _configure_cmake(self):
50
53
self ._cmake = CMake (self )
51
54
self ._cmake .definitions ["PROJ_TESTS" ] = False
52
55
self ._cmake .definitions ["BUILD_LIBPROJ_SHARED" ] = self .options .shared
56
+ self ._cmake .definitions ["USE_THREAD" ] = self .options .threadsafe
57
+ self ._cmake .definitions ["ENABLE_LTO" ] = False
58
+ self ._cmake .definitions ["JNI_SUPPORT" ] = False
59
+ self ._cmake .definitions ["BUILD_CCT" ] = True
60
+ self ._cmake .definitions ["BUILD_CS2CS" ] = True
61
+ self ._cmake .definitions ["BUILD_GEOD" ] = True
62
+ self ._cmake .definitions ["BUILD_GIE" ] = True
63
+ self ._cmake .definitions ["BUILD_PROJ" ] = True
64
+ self ._cmake .definitions ["BUILD_PROJINFO" ] = True
65
+ self ._cmake .definitions ["PROJ_DATA_SUBDIR" ] = "res"
53
66
self ._cmake .configure (build_folder = self ._build_subfolder )
54
67
return self ._cmake
55
68
56
69
def build (self ):
57
70
for patch in self .conan_data ["patches" ][self .version ]:
58
71
tools .patch (** patch )
59
- tools .replace_in_file (os .path .join (self ._source_subfolder , "src" , "lib_proj.cmake" ),
60
- "include_directories(${CMAKE_SOURCE_DIR}/include)" ,
61
- "include_directories(${PROJ4_SOURCE_DIR}/include)" )
62
72
cmake = self ._configure_cmake ()
63
73
cmake .build ()
64
74
65
75
def package (self ):
66
76
self .copy (pattern = "COPYING" , dst = "licenses" , src = self ._source_subfolder )
67
77
cmake = self ._configure_cmake ()
68
78
cmake .install ()
69
- self .copy ("*.db" ,
70
- src = os .path .join (self .package_folder , "share" , "proj" ),
71
- dst = os .path .join (self .package_folder , "lib" , "proj" ))
72
79
tools .rmdir (os .path .join (self .package_folder , "share" ))
73
80
tools .rmdir (os .path .join (self .package_folder , "lib" , "cmake" ))
81
+ for data_file in glob .glob (os .path .join (self .package_folder , "res" , "*" )):
82
+ if not data_file .endswith ("proj.db" ):
83
+ os .remove (data_file )
74
84
75
85
def package_info (self ):
86
+ self .cpp_info .names ["cmake_find_package" ] = "PROJ4"
87
+ self .cpp_info .names ["cmake_find_package_multi" ] = "PROJ4"
76
88
self .cpp_info .libs = tools .collect_libs (self )
77
89
if self .settings .os == "Linux" :
78
- self .cpp_info .system_libs = ["pthread" , "dl" , "m" ]
79
- self .env_info .PROJ_LIB .append (os .path .join (self .package_folder , "lib" , "proj" ))
90
+ self .cpp_info .system_libs .append ("m" )
91
+ if self .options .threadsafe :
92
+ self .cpp_info .system_libs .append ("pthread" )
93
+ if self .options .shared and self .settings .compiler == "Visual Studio" :
94
+ self .cpp_info .defines .append ("PROJ_MSVC_DLL_IMPORT" )
95
+ self .env_info .PROJ_LIB .append (os .path .join (self .package_folder , "res" ))
96
+ self .env_info .PATH .append (os .path .join (self .package_folder , "bin" ))
0 commit comments