1
+ from conan import ConanFile
2
+ from conan .errors import ConanInvalidConfiguration
3
+ from conan .tools .cmake import CMake , CMakeToolchain , cmake_layout
4
+ from conan .tools .files import apply_conandata_patches , copy , export_conandata_patches , get
1
5
import os
2
- from conans import ConanFile , CMake , tools
3
- from conans .errors import ConanInvalidConfiguration
4
6
5
- required_conan_version = ">=1.29.1"
7
+ required_conan_version = ">=1.53.0"
8
+
6
9
7
10
class BaicalP7Conan (ConanFile ):
8
11
name = "baical-p7"
@@ -11,64 +14,59 @@ class BaicalP7Conan(ConanFile):
11
14
homepage = "http://baical.net/p7.html"
12
15
topics = ("p7" , "baical" , "logging" , "telemetry" )
13
16
description = "Baical P7 client"
14
- settings = "os" , "compiler" , "build_type" , "arch"
15
- options = {"shared" : [True , False ], "fPIC" : [True , False ]}
16
- default_options = {"shared" : False , "fPIC" : True }
17
- exports_sources = "CMakeLists.txt"
18
- generators = "cmake"
19
17
20
- _cmake = None
18
+ settings = "os" , "arch" , "compiler" , "build_type"
19
+ options = {
20
+ "shared" : [True , False ],
21
+ "fPIC" : [True , False ],
22
+ }
23
+ default_options = {
24
+ "shared" : False ,
25
+ "fPIC" : True ,
26
+ }
21
27
22
- @property
23
- def _source_subfolder (self ):
24
- return "source_subfolder"
28
+ def export_sources (self ):
29
+ export_conandata_patches (self )
25
30
26
31
def config_options (self ):
27
32
if self .settings .os == "Windows" :
28
33
del self .options .fPIC
29
34
30
35
def configure (self ):
31
36
if self .options .shared :
32
- del self .options .fPIC
37
+ self .options .rm_safe ("fPIC" )
38
+
39
+ def layout (self ):
40
+ cmake_layout (self , src_folder = "src" )
41
+
42
+ def validate (self ):
33
43
if self .settings .os not in ["Linux" , "Windows" ]:
34
44
raise ConanInvalidConfiguration ("P7 only supports Windows and Linux at this time" )
35
45
36
46
def source (self ):
37
- tools . get (** self .conan_data ["sources" ][self .version ], destination = self . _source_subfolder )
47
+ get (self , ** self .conan_data ["sources" ][self .version ])
38
48
39
- def _configure_cmake (self ):
40
- if self ._cmake :
41
- return self ._cmake
42
- self ._cmake = CMake (self )
43
- self ._cmake .definitions ["P7_TESTS_BUILD" ] = False
44
- self ._cmake .definitions ["P7_BUILD_SHARED" ] = self .options .shared
45
- self ._cmake .definitions ["P7_EXAMPLES_BUILD" ] = False
46
- self ._cmake .configure ()
47
- return self ._cmake
49
+ def generate (self ):
50
+ tc = CMakeToolchain (self )
51
+ tc .variables ["P7_TESTS_BUILD" ] = False
52
+ tc .cache_variables ["P7_BUILD_SHARED" ] = self .options .shared
53
+ tc .variables ["P7_EXAMPLES_BUILD" ] = False
54
+ tc .generate ()
48
55
49
56
def build (self ):
50
- cmake = self ._configure_cmake ()
57
+ apply_conandata_patches (self )
58
+ cmake = CMake (self )
59
+ cmake .configure ()
51
60
cmake .build ()
52
61
53
62
def package (self ):
54
- self .copy (pattern = "LICENSE.txt" , dst = "licenses" , src = self ._source_subfolder )
55
- self .copy (pattern = "*" , dst = "include" , src = os .path .join (self ._source_subfolder , "Headers" ))
56
- cmake = self ._configure_cmake ()
63
+ copy (self , "License.txt" , src = self .source_folder , dst = os .path .join (self .package_folder , "licenses" ))
64
+ cmake = CMake (self )
57
65
cmake .install ()
58
- tools .remove_files_by_mask (os .path .join (self .package_folder , "include" ), "*.cmake" )
59
66
60
67
def package_info (self ):
61
- self .cpp_info .names ["cmake_find_package" ] = "p7"
62
- self .cpp_info .names ["cmake_find_package_multi" ] = "p7"
63
-
64
- if self .options .shared :
65
- self .cpp_info .components ["p7" ].name = "p7-shared"
66
- self .cpp_info .components ["p7" ].libs = ["p7-shared" ]
67
- else :
68
- self .cpp_info .components ["p7" ].name = "p7"
69
- self .cpp_info .components ["p7" ].libs = ["p7" ]
70
-
71
- if self .settings .os == "Linux" :
72
- self .cpp_info .components ["p7" ].system_libs .extend (["rt" , "pthread" ])
73
- if self .settings .os == "Windows" :
74
- self .cpp_info .components ["p7" ].system_libs .append ("Ws2_32" )
68
+ self .cpp_info .libs = ["p7-shared" if self .options .shared else "p7" ]
69
+ if self .settings .os in ["Linux" , "FreeBSD" ]:
70
+ self .cpp_info .system_libs .extend (["m" , "rt" , "pthread" ])
71
+ elif self .settings .os == "Windows" :
72
+ self .cpp_info .system_libs .append ("ws2_32" )
0 commit comments