2
2
from conan .errors import ConanInvalidConfiguration
3
3
from conan .tools .build import check_min_cppstd
4
4
from conan .tools .cmake import CMake , CMakeToolchain , cmake_layout
5
- from conan .tools .files import apply_conandata_patches , collect_libs , copy , export_conandata_patches , get , rm , rmdir , save
5
+ from conan .tools .files import collect_libs , copy , get , rm , rmdir
6
6
from conan .tools .microsoft import is_msvc , is_msvc_static_runtime
7
- from conan .tools .scm import Version
8
7
import os
9
- import textwrap
10
8
11
- required_conan_version = ">=1.54.0 "
9
+ required_conan_version = ">=2.2 "
12
10
13
11
14
12
class FastCDRConan (ConanFile ):
@@ -30,33 +28,23 @@ class FastCDRConan(ConanFile):
30
28
"fPIC" : True ,
31
29
}
32
30
33
- def export_sources (self ):
34
- export_conandata_patches (self )
35
-
36
- def config_options (self ):
37
- if self .settings .os == "Windows" :
38
- del self .options .fPIC
39
-
40
- def configure (self ):
41
- if self .options .shared :
42
- self .options .rm_safe ("fPIC" )
31
+ implements = ["auto_shared_fpic" ]
43
32
44
33
def layout (self ):
45
34
cmake_layout (self , src_folder = "src" )
46
35
47
36
def build_requirements (self ):
48
- if Version (self .version ) >= "1.1.0" :
49
- self .tool_requires ("cmake/[>=3.16.3 <4]" )
37
+ self .tool_requires ("cmake/[>=3.16.3]" )
50
38
51
39
def validate (self ):
52
- if self . settings . compiler . get_safe ( "cppstd" ):
53
- check_min_cppstd ( self , 11 )
40
+ check_min_cppstd ( self , 11 )
41
+
54
42
if self .options .shared and is_msvc (self ) and is_msvc_static_runtime (self ):
55
43
# This combination leads to an fast-cdr error when linking
56
44
# linking dynamic '*.dll' and static MT runtime
57
45
# see https://github.com/eProsima/Fast-CDR/blob/v1.0.21/include/fastcdr/eProsima_auto_link.h#L37
58
46
# (2021-05-31)
59
- raise ConanInvalidConfiguration ("Mixing a dll eprosima library with a static runtime is a bad idea " )
47
+ raise ConanInvalidConfiguration ("Windows msvc static runtime is not supported " )
60
48
61
49
def source (self ):
62
50
get (self , ** self .conan_data ["sources" ][self .version ], strip_root = True )
@@ -67,7 +55,6 @@ def generate(self):
67
55
tc .generate ()
68
56
69
57
def build (self ):
70
- apply_conandata_patches (self )
71
58
cmake = CMake (self )
72
59
cmake .configure ()
73
60
cmake .build ()
@@ -81,27 +68,6 @@ def package(self):
81
68
rm (self , "*.pdb" , os .path .join (self .package_folder , "lib" ))
82
69
rm (self , "*.pdb" , os .path .join (self .package_folder , "bin" ))
83
70
84
- # TODO: to remove in conan v2 once cmake_find_package_* generators removed
85
- self ._create_cmake_module_alias_targets (
86
- os .path .join (self .package_folder , self ._module_file_rel_path ),
87
- {"fastcdr" : "fastcdr::fastcdr" }
88
- )
89
-
90
- def _create_cmake_module_alias_targets (self , module_file , targets ):
91
- content = ""
92
- for alias , aliased in targets .items ():
93
- content += textwrap .dedent (f"""\
94
- if(TARGET { aliased } AND NOT TARGET { alias } )
95
- add_library({ alias } INTERFACE IMPORTED)
96
- set_property(TARGET { alias } PROPERTY INTERFACE_LINK_LIBRARIES { aliased } )
97
- endif()
98
- """ )
99
- save (self , module_file , content )
100
-
101
- @property
102
- def _module_file_rel_path (self ):
103
- return os .path .join ("lib" , "cmake" , f"conan-official-{ self .name } -targets.cmake" )
104
-
105
71
def package_info (self ):
106
72
self .cpp_info .set_property ("cmake_file_name" , "fastcdr" )
107
73
self .cpp_info .set_property ("cmake_target_name" , "fastcdr" )
@@ -111,9 +77,3 @@ def package_info(self):
111
77
112
78
if self .settings .os in ["Linux" ]:
113
79
self .cpp_info .system_libs .append ("m" )
114
-
115
- # TODO: to remove in conan v2 once cmake_find_package_* generators removed
116
- self .cpp_info .names ["cmake_find_package" ] = "fastcdr"
117
- self .cpp_info .names ["cmake_find_package_multi" ] = "fastcdr"
118
- self .cpp_info .build_modules ["cmake_find_package" ] = [self ._module_file_rel_path ]
119
- self .cpp_info .build_modules ["cmake_find_package_multi" ] = [self ._module_file_rel_path ]
0 commit comments