From 29841f98d8baaea0ff5fabe2236e1133d833774a Mon Sep 17 00:00:00 2001 From: Guillaume Egles Date: Thu, 28 Mar 2024 17:40:29 -0700 Subject: [PATCH 1/3] openssl: make things a bit more generic This removes some hardcoded names and allows for the package to be "renamed" more easily... For example if one wanted to create a distinct `openssl-fips` package so as to use it in conjunction with the standard `openssl` package without any collision. See https://github.com/conan-io/conan-center-index/issues/22796 for more context --- recipes/openssl/3.x.x/conanfile.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/recipes/openssl/3.x.x/conanfile.py b/recipes/openssl/3.x.x/conanfile.py index c858b3551b71d..84f1b5f008e26 100644 --- a/recipes/openssl/3.x.x/conanfile.py +++ b/recipes/openssl/3.x.x/conanfile.py @@ -590,12 +590,12 @@ def _create_cmake_module_variables(self, module_file): ${OpenSSL_Crypto_DEPENDENCIES} ${OpenSSL_Crypto_FRAMEWORKS} ${OpenSSL_Crypto_SYSTEM_LIBS}) - elseif(DEFINED openssl_OpenSSL_Crypto_LIBS_%(config)s) - set(OPENSSL_CRYPTO_LIBRARY ${openssl_OpenSSL_Crypto_LIBS_%(config)s}) - set(OPENSSL_CRYPTO_LIBRARIES ${openssl_OpenSSL_Crypto_LIBS_%(config)s} - ${openssl_OpenSSL_Crypto_DEPENDENCIES_%(config)s} - ${openssl_OpenSSL_Crypto_FRAMEWORKS_%(config)s} - ${openssl_OpenSSL_Crypto_SYSTEM_LIBS_%(config)s}) + elseif(DEFINED %(package_name)s_OpenSSL_Crypto_LIBS_%(config)s) + set(OPENSSL_CRYPTO_LIBRARY ${%(package_name)s_OpenSSL_Crypto_LIBS_%(config)s}) + set(OPENSSL_CRYPTO_LIBRARIES ${%(package_name)s_OpenSSL_Crypto_LIBS_%(config)s} + ${%(package_name)s_OpenSSL_Crypto_DEPENDENCIES_%(config)s} + ${%(package_name)s_OpenSSL_Crypto_FRAMEWORKS_%(config)s} + ${%(package_name)s_OpenSSL_Crypto_SYSTEM_LIBS_%(config)s}) endif() if(DEFINED OpenSSL_SSL_LIBS) set(OPENSSL_SSL_LIBRARY ${OpenSSL_SSL_LIBS}) @@ -603,12 +603,12 @@ def _create_cmake_module_variables(self, module_file): ${OpenSSL_SSL_DEPENDENCIES} ${OpenSSL_SSL_FRAMEWORKS} ${OpenSSL_SSL_SYSTEM_LIBS}) - elseif(DEFINED openssl_OpenSSL_SSL_LIBS_%(config)s) - set(OPENSSL_SSL_LIBRARY ${openssl_OpenSSL_SSL_LIBS_%(config)s}) - set(OPENSSL_SSL_LIBRARIES ${openssl_OpenSSL_SSL_LIBS_%(config)s} - ${openssl_OpenSSL_SSL_DEPENDENCIES_%(config)s} - ${openssl_OpenSSL_SSL_FRAMEWORKS_%(config)s} - ${openssl_OpenSSL_SSL_SYSTEM_LIBS_%(config)s}) + elseif(DEFINED %(package_name)s_OpenSSL_SSL_LIBS_%(config)s) + set(OPENSSL_SSL_LIBRARY ${%(package_name)s_OpenSSL_SSL_LIBS_%(config)s}) + set(OPENSSL_SSL_LIBRARIES ${%(package_name)s_OpenSSL_SSL_LIBS_%(config)s} + ${%(package_name)s_OpenSSL_SSL_DEPENDENCIES_%(config)s} + ${%(package_name)s_OpenSSL_SSL_FRAMEWORKS_%(config)s} + ${%(package_name)s_OpenSSL_SSL_SYSTEM_LIBS_%(config)s}) endif() if(DEFINED OpenSSL_LIBRARIES) set(OPENSSL_LIBRARIES ${OpenSSL_LIBRARIES}) @@ -616,7 +616,7 @@ def _create_cmake_module_variables(self, module_file): if(DEFINED OpenSSL_VERSION) set(OPENSSL_VERSION ${OpenSSL_VERSION}) endif() - """% {"config":str(self.settings.build_type).upper()}) + """% {"config":str(self.settings.build_type).upper(), "package_name":self.name}) save(self, module_file, content) @property @@ -631,6 +631,7 @@ def _module_file_rel_path(self): def package_info(self): self.cpp_info.set_property("cmake_file_name", "OpenSSL") self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_target_name", "openssl::openssl") self.cpp_info.set_property("pkg_config_name", "openssl") self.cpp_info.set_property("cmake_build_modules", [self._module_file_rel_path]) self.cpp_info.names["cmake_find_package"] = "OpenSSL" From dbc6fb6534c66adae949d86389c6e99320369120 Mon Sep 17 00:00:00 2001 From: Guillaume Egles Date: Sat, 30 Mar 2024 19:54:15 -0700 Subject: [PATCH 2/3] revert line based on feedback --- recipes/openssl/3.x.x/conanfile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/recipes/openssl/3.x.x/conanfile.py b/recipes/openssl/3.x.x/conanfile.py index 84f1b5f008e26..2e74848de90c7 100644 --- a/recipes/openssl/3.x.x/conanfile.py +++ b/recipes/openssl/3.x.x/conanfile.py @@ -631,7 +631,6 @@ def _module_file_rel_path(self): def package_info(self): self.cpp_info.set_property("cmake_file_name", "OpenSSL") self.cpp_info.set_property("cmake_find_mode", "both") - self.cpp_info.set_property("cmake_target_name", "openssl::openssl") self.cpp_info.set_property("pkg_config_name", "openssl") self.cpp_info.set_property("cmake_build_modules", [self._module_file_rel_path]) self.cpp_info.names["cmake_find_package"] = "OpenSSL" From 51b5af128923c4176818015ce981d131525544f8 Mon Sep 17 00:00:00 2001 From: Guillaume Egles Date: Sat, 30 Mar 2024 21:24:33 -0700 Subject: [PATCH 3/3] additional tweaks --- recipes/openssl/3.x.x/test_package/conanfile.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/recipes/openssl/3.x.x/test_package/conanfile.py b/recipes/openssl/3.x.x/test_package/conanfile.py index 76d2cc26c1df0..0dc8825448944 100644 --- a/recipes/openssl/3.x.x/test_package/conanfile.py +++ b/recipes/openssl/3.x.x/test_package/conanfile.py @@ -16,15 +16,15 @@ def requirements(self): self.requires(self.tested_reference_str) def _with_legacy(self): - return (not self.dependencies["openssl"].options.no_legacy and - ((not self.dependencies["openssl"].options.no_md4) or - (not self.dependencies["openssl"].options.no_rmd160))) + return (not self.dependencies[self.tested_reference_str].options.no_legacy and + ((not self.dependencies[self.tested_reference_str].options.no_md4) or + (not self.dependencies[self.tested_reference_str].options.no_rmd160))) def generate(self): tc = CMakeToolchain(self) tc.cache_variables["OPENSSL_WITH_LEGACY"] = self._with_legacy() - tc.cache_variables["OPENSSL_WITH_MD4"] = not self.dependencies["openssl"].options.no_md4 - tc.cache_variables["OPENSSL_WITH_RIPEMD160"] = not self.dependencies["openssl"].options.no_rmd160 + tc.cache_variables["OPENSSL_WITH_MD4"] = not self.dependencies[self.tested_reference_str].options.no_md4 + tc.cache_variables["OPENSSL_WITH_RIPEMD160"] = not self.dependencies[self.tested_reference_str].options.no_rmd160 tc.generate() def build(self):