33# file, You can obtain one at https://mozilla.org/MPL/2.0/.
44
55from conan import ConanFile
6- from conan .tools .cmake import CMake , CMakeToolchain
7- from conan .tools .files import collect_libs
6+ from conan .tools .cmake import CMake , CMakeToolchain , cmake_layout , CMakeDeps
7+ from conan .tools .build import valid_min_cppstd
88
99
1010class CDTConan (ConanFile ):
1111 name = "cdt"
12- version = "1.3.0 "
12+ version = "1.4.4 "
1313 license = "MPL-2.0 License"
1414 url = "https://github.com/artem-ogre/CDT"
1515 description = "Numerically robust C++ implementation of constrained Delaunay triangulation (CDT)"
1616 settings = "os" , "compiler" , "build_type" , "arch"
17- generators = "CMakeDeps"
1817 options = {
1918 "shared" : [True , False ],
20- "use_boost" : [True , False ],
21- "as_compiled_library" : [True , False ],
22- "enable_testing" : [True , False ],
19+ "fPIC" : [True , False ],
20+ "header_only" : [True , False ],
2321 "enable_callback_handler" : [True , False ],
22+ "enable_testing" : [True , False ],
2423 }
2524 default_options = {
2625 "shared" : False ,
27- "use_boost" : False ,
28- "as_compiled_library" : False ,
29- "enable_testing" : False ,
26+ "fPIC" : True ,
27+ "header_only" : False ,
3028 "enable_callback_handler" : False ,
29+ "enable_testing" : False ,
3130 }
3231 exports_sources = "*" , "!.idea" , "!conanfile.py"
3332
33+ @property
34+ def _needs_boost (self ):
35+ #Versions below C++11 require boost
36+ return not valid_min_cppstd (self , "11" )
37+
38+ def config_options (self ):
39+ if self .settings .os == "Windows" :
40+ del self .options .fPIC
41+
42+ def configure (self ):
43+ if self ._needs_boost :
44+ self .options ["boost" ].header_only = True
45+
46+ if self .options .get_safe ("shared" ) or self .options .header_only :
47+ self .options .rm_safe ("fPIC" )
48+ if self .options .header_only :
49+ self .options .rm_safe ("shared" )
50+
3451 def requirements (self ):
35- if self .options .use_boost :
36- self .requires ("boost/1.83.0" )
52+ if self ._needs_boost :
53+ self .requires ("boost/[^1.83.0]" )
54+
55+ def build_requirements (self ):
3756 self .requires ("catch2/3.4.0" )
3857
39- def configure (self ):
40- if self .options .use_boost :
41- self .options ["boost" ].header_only = True
58+ def layout (self ):
59+ cmake_layout (self )
4260
4361 def generate (self ):
4462 tc = CMakeToolchain (self )
45- tc .variables ["CDT_USE_BOOST" ] = self .options . use_boost
63+ tc .variables ["CDT_USE_BOOST" ] = self ._needs_boost
4664 tc .cache_variables ["CDT_USE_AS_COMPILED_LIBRARY" ] = (
47- self .options .as_compiled_library
65+ not self .options .header_only
4866 )
4967 tc .cache_variables ["CMAKE_PROJECT_CDT_INCLUDE" ] = "conan_basic_setup.cmake"
5068 tc .cache_variables ["CDT_ENABLE_TESTING" ] = self .options .enable_testing
5169 tc .cache_variables ["CDT_ENABLE_CALLBACK_HANDLER" ] = self .options .enable_callback_handler
5270 tc .generate ()
5371
72+ deps = CMakeDeps (self )
73+ deps .generate ()
74+
5475 def build (self ):
5576 cmake = CMake (self )
5677 cmake .configure ()
@@ -63,4 +84,8 @@ def package(self):
6384 cmake .install ()
6485
6586 def package_info (self ):
66- self .cpp_info .libs = collect_libs (self )
87+ if self ._needs_boost :
88+ self .cpp_info .requires = ["boost::boost" ]
89+ self .cpp_info .defines .append ("CDT_USE_BOOST" )
90+ if not self .options .header_only :
91+ self .cpp_info .defines .append ("CDT_USE_AS_COMPILED_LIBRARY" )
0 commit comments