11from conan import ConanFile
22from conan .tools .cmake import CMakeToolchain , CMake , cmake_layout
3+ from conan .tools .build import check_min_cppstd
34import re
45
6+ required_conan_version = ">=2.1.0"
7+
58
69def get_version ():
710 try :
@@ -16,30 +19,35 @@ def get_version():
1619class DsplibConan (ConanFile ):
1720 name = "dsplib"
1821 version = get_version ()
19-
2022 license = "MIT"
2123 author = "Vitaly Yulis ([email protected] )" 2224 url = "https://github.com/vitalsong/dsplib"
2325 description = "C++ DSP library for MATLAB/Octave similar programming"
2426 topics = ("dsp" , "matlab" , "c++17" , "audio" )
2527
2628 settings = "os" , "compiler" , "build_type" , "arch"
29+
2730 options = {
2831 "shared" : [True , False ],
2932 "fPIC" : [True , False ],
3033 "float32" : [True , False ],
3134 "noexcept" : [True , False ],
3235 }
36+
3337 default_options = {
3438 "shared" : False ,
3539 "fPIC" : True ,
3640 "float32" : False ,
3741 "noexcept" : False ,
3842 }
39- generators = "CMakeDeps"
4043
41- exports_sources = "cmake/*" , "CMakeLists.txt" , "lib/*" , "include/*"
44+ generators = [ "CMakeDeps" ]
4245
46+ exports_sources = "cmake/*" , "CMakeLists.txt" , "lib/*" , "include/*"
47+
48+ def validate (self ):
49+ check_min_cppstd (self , 17 )
50+
4351 def config_options (self ):
4452 if self .settings .os == "Windows" :
4553 del self .options .fPIC
@@ -49,10 +57,11 @@ def layout(self):
4957
5058 def generate (self ):
5159 tc = CMakeToolchain (self )
52- if self .options .float32 :
53- tc .variables ["DSPLIB_USE_FLOAT32" ] = "ON"
54- if self .options .noexcept :
55- tc .variables ["DSPLIB_NO_EXCEPTIONS" ] = "ON"
60+ tc .variables ["DSPLIB_USE_FLOAT32" ] = self .options .float32
61+ tc .variables ["DSPLIB_NO_EXCEPTIONS" ] = self .options .noexcept
62+ tc .variables ["BUILD_SHARED_LIBS" ] = self .options .shared
63+ if self .options .get_safe ("fPIC" ):
64+ tc .variables ["CMAKE_POSITION_INDEPENDENT_CODE" ] = self .options .fPIC
5665 tc .generate ()
5766
5867 def build (self ):
0 commit comments