3
3
4
4
from pathlib import Path
5
5
6
- from conans import CMake , ConanFile , tools
7
- from conans .errors import ConanInvalidConfiguration
6
+ from conan import ConanFile
7
+ from conan .errors import ConanInvalidConfiguration
8
+ from conan .tools import cmake , files
9
+
10
+ required_conan_version = ">=1.52.0"
8
11
9
12
10
13
class VtdApiConan (ConanFile ):
@@ -31,36 +34,49 @@ class VtdApiConan(ConanFile):
31
34
build_requires = [
32
35
"vtd/2.2.0@cloe-restricted/stable" ,
33
36
]
34
- generators = "cmake"
35
-
36
- _cmake = None
37
+ generators = "CMakeDeps" , "CMakeToolchain"
37
38
38
39
def configure (self ):
39
40
if self .settings .os == "Windows" :
40
41
raise ConanInvalidConfiguration ("VTD binaries do not exist for Windows" )
41
42
42
- def imports (self ):
43
- self . copy ( "*" , dst = "src/Develop" , src = "Develop" , root_package = "vtd" )
43
+ def layout (self ):
44
+ cmake . cmake_layout ( self )
44
45
45
- def _configure_cmake (self ):
46
- if self ._cmake :
47
- return self ._cmake
48
- self ._cmake = CMake (self )
49
- self ._cmake .definitions ["CMAKE_EXPORT_COMPILE_COMMANDS" ] = True
50
- self ._cmake .configure ()
51
- return self ._cmake
46
+ def generate (self ):
47
+ files .copy (self , "Develop/*" , src = self .dependencies .build ["vtd" ].package_folder , dst = "../src" )
52
48
53
49
def build (self ):
54
- cmake = self ._configure_cmake ()
55
- cmake .build ()
50
+ cm = cmake .CMake (self )
51
+ cm .configure ()
52
+ cm .build ()
56
53
57
54
def package (self ):
58
- cmake = self . _configure_cmake ( )
59
- cmake .install ()
60
- self .copy ("Develop" , src = "src" , symlinks = True )
55
+ cm = cmake . CMake ( self )
56
+ cm .install ()
57
+ files .copy (self , "Develop" , src = "src" , dst = "." )
61
58
62
59
def package_info (self ):
63
- if self .in_local_cache :
64
- self .cpp_info .libs = tools .collect_libs (self )
65
- else :
60
+ self .cpp_info .set_property ("cmake_find_mode" , "both" )
61
+ self .cpp_info .set_property ("cmake_file_name" , "vtd-api" )
62
+ self .cpp_info .set_property ("cmake_target_name" , "vtd::api" )
63
+ self .cpp_info .set_property ("pkg_config_name" , "vtd-api" )
64
+
65
+ # This define takes the format:
66
+ #
67
+ # (EPOCH << 24) | (MAJOR_VERSION << 16) | (MINOR_VERSION << 8) | PATCH_VERSION
68
+ #
69
+ # Each version consists of at most 8 bits, so 256 potential values, including 0.
70
+ # The epoch starts with 0, and is bumped after each version naming scheme.
71
+ #
72
+ # When years are involved, such as in releases versioned YYYY.MM, use the last
73
+ # two years, since the full year will not fit in the 8 bits.
74
+ #
75
+ # VTD VERSION : (0) 2 . 2 . 0
76
+ vtd_api_version = (0 << 24 ) | (2 << 16 ) | (2 << 8 ) | 0
77
+ self .cpp_info .defines = ["VTD_API_VERSION={vtd_api_version}" ]
78
+
79
+ if not self .in_local_cache :
66
80
self .cpp_info .libs = ["vtd_api" ]
81
+ else :
82
+ self .cpp_info .libs = files .collect_libs (self )
0 commit comments