11from conan import ConanFile
22from conan .tools .build import check_min_cppstd , stdcpp_library
33from conan .tools .cmake import CMake , CMakeToolchain , cmake_layout
4- from conan .tools .files import apply_conandata_patches , copy , export_conandata_patches , get , replace_in_file , rmdir , save
4+ from conan .tools .files import apply_conandata_patches , copy , export_conandata_patches , get , replace_in_file , rmdir
55from conan .tools .scm import Version
66import os
7- import textwrap
87
9- required_conan_version = ">=1.54.0 "
8+ required_conan_version = ">=2 "
109
1110
1211class Libde265Conan (ConanFile ):
@@ -46,17 +45,19 @@ def layout(self):
4645 cmake_layout (self , src_folder = "src" )
4746
4847 def validate (self ):
49- if self .settings .compiler .get_safe ("cppstd" ):
50- check_min_cppstd (self , 11 )
48+ check_min_cppstd (self , 11 )
5149
5250 def source (self ):
5351 get (self , ** self .conan_data ["sources" ][self .version ], strip_root = True )
52+ self ._patch_sources ()
5453
5554 def generate (self ):
5655 tc = CMakeToolchain (self )
5756 tc .variables ["CMAKE_POSITION_INDEPENDENT_CODE" ] = self .options .get_safe ("fPIC" , True )
5857 tc .variables ["ENABLE_SDL" ] = False
5958 tc .variables ["DISABLE_SSE" ] = not self .options .get_safe ("sse" , False )
59+ if Version (self .version ) < "1.0.16" :
60+ tc .cache_variables ["CMAKE_POLICY_VERSION_MINIMUM" ] = "3.5" # CMake 4 support
6061 tc .generate ()
6162
6263 def _patch_sources (self ):
@@ -65,7 +66,6 @@ def _patch_sources(self):
6566 "set(CMAKE_POSITION_INDEPENDENT_CODE ON)" , "" )
6667
6768 def build (self ):
68- self ._patch_sources ()
6969 cmake = CMake (self )
7070 cmake .configure ()
7171 cmake .build ()
@@ -77,37 +77,12 @@ def package(self):
7777 rmdir (self , os .path .join (self .package_folder , "lib" , "cmake" ))
7878 rmdir (self , os .path .join (self .package_folder , "lib" , "pkgconfig" ))
7979
80- # TODO: to remove in conan v2 once legacy generators removed
81- self ._create_cmake_module_alias_targets (
82- os .path .join (self .package_folder , self ._module_file_rel_path ),
83- {
84- "de265" : "libde265::libde265" ,
85- "libde265" : "libde265::libde265" ,
86- }
87- )
88-
89- def _create_cmake_module_alias_targets (self , module_file , targets ):
90- content = ""
91- for alias , aliased in targets .items ():
92- content += textwrap .dedent (f"""\
93- if(TARGET { aliased } AND NOT TARGET { alias } )
94- add_library({ alias } INTERFACE IMPORTED)
95- set_property(TARGET { alias } PROPERTY INTERFACE_LINK_LIBRARIES { aliased } )
96- endif()
97- """ )
98- save (self , module_file , content )
99-
100- @property
101- def _module_file_rel_path (self ):
102- return os .path .join ("lib" , "cmake" , f"conan-official-{ self .name } -targets.cmake" )
103-
10480 def package_info (self ):
10581 self .cpp_info .set_property ("cmake_file_name" , "libde265" )
10682 self .cpp_info .set_property ("cmake_target_name" , "de265" )
107- self .cpp_info .set_property ("cmake_target_aliases" , ["libde265" ]) # official imported target before 1.0.10
83+ self .cpp_info .set_property ("cmake_target_aliases" , ["libde265" ]) # official imported target before 1.0.10
10884 self .cpp_info .set_property ("pkg_config_name" , "libde265" )
109- version = Version (self .version )
110- prefix = "lib" if (version < "1.0.10" or (version > "1.0.11" and self .settings .os == "Windows" and not self .options .shared )) else ""
85+ prefix = "lib" if self .settings .os == "Windows" and not self .options .shared else ""
11186 self .cpp_info .libs = [f"{ prefix } de265" ]
11287 if not self .options .shared :
11388 self .cpp_info .defines = ["LIBDE265_STATIC_BUILD" ]
@@ -117,8 +92,3 @@ def package_info(self):
11792 libcxx = stdcpp_library (self )
11893 if libcxx :
11994 self .cpp_info .system_libs .append (libcxx )
120-
121- # TODO: to remove in conan v2 once legacy generators removed
122- self .cpp_info .build_modules ["cmake_find_package" ] = [self ._module_file_rel_path ]
123- self .cpp_info .build_modules ["cmake_find_package_multi" ] = [self ._module_file_rel_path ]
124- self .env_info .PATH .append (os .path .join (self .package_folder , "bin" ))
0 commit comments