diff --git a/recipes/openssl/1.x.x/conanfile.py b/recipes/openssl/1.x.x/conanfile.py index 06e6a40cfc37cb..2daf4aa9ca0017 100644 --- a/recipes/openssl/1.x.x/conanfile.py +++ b/recipes/openssl/1.x.x/conanfile.py @@ -763,7 +763,7 @@ def _patch_install_name(self): old_str = '-install_name $(INSTALLTOP)/$(LIBDIR)/' new_str = '-install_name @rpath/' makefile = "Makefile" if self._full_version >= "1.1.1" else "Makefile.shared" - replace_in_file(self, makefile, old_str, new_str, strict=self.in_local_cache) + replace_in_file(self, makefile, old_str, new_str) if self._use_nmake: # NMAKE interprets trailing backslash as line continuation if self._full_version >= "1.1.0": diff --git a/recipes/openssl/1.x.x/test_package/CMakeLists.txt b/recipes/openssl/1.x.x/test_package/CMakeLists.txt index a28cd01bfb09b8..7109d02c5dd323 100644 --- a/recipes/openssl/1.x.x/test_package/CMakeLists.txt +++ b/recipes/openssl/1.x.x/test_package/CMakeLists.txt @@ -26,8 +26,6 @@ foreach(_custom_var ${_custom_vars}) endif() endforeach() -add_executable(digest digest.c) -target_link_libraries(digest OpenSSL::SSL) -if(OPENSSL_WITH_ZLIB) - target_compile_definitions(digest PRIVATE WITH_ZLIB) -endif() +add_executable(${PROJECT_NAME} digest.c) +target_link_libraries(${PROJECT_NAME} PRIVATE OpenSSL::SSL) +target_compile_definitions(${PROJECT_NAME} PRIVATE $<$:WITH_ZLIB>) diff --git a/recipes/openssl/1.x.x/test_package/conanfile.py b/recipes/openssl/1.x.x/test_package/conanfile.py index e42aaed0f7cf11..ef4c0e036136c3 100644 --- a/recipes/openssl/1.x.x/test_package/conanfile.py +++ b/recipes/openssl/1.x.x/test_package/conanfile.py @@ -2,9 +2,9 @@ from conan.tools.scm import Version from conan.tools.build import can_run from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain +from conan.tools.files import save, load import os - -required_conan_version = ">=1.50.2 <1.51.0 || >=1.51.2" +import json class TestPackageConan(ConanFile): @@ -13,7 +13,10 @@ class TestPackageConan(ConanFile): test_type = "explicit" @property - def _skip_test(self): + def _skip_test_filename(self): + return os.path.join(self.build_folder, "skip_test.json") + + def _generate_skip_test_file(self): # Attempting to use @rpath without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being # set. This could be because you are using a Mac OS X version less than 10.5 # or because CMake's platform configuration is corrupt. @@ -21,8 +24,14 @@ def _skip_test(self): # Actually the workaround should be to add cmake/3.22.0 to build requires, # but for the specific case of openssl it fails because it is also a requirement of cmake. # see https://github.com/conan-io/conan/pull/9839 - return self.settings.os == "Macos" and self.settings.arch == "armv8" \ - and self.options["openssl"].shared + dict_test = {"skip_test": self.settings.os == "Macos" and \ + self.settings.arch == "armv8" and \ + bool(self.dependencies[self.tested_reference_str].options.shared)} + save(self, self._skip_test_filename, json.dumps(dict_test)) + + @property + def _skip_test(self): + return bool(json.loads(load(self, self._skip_test_filename)).get("skip_test")) def requirements(self): self.requires(self.tested_reference_str) @@ -34,13 +43,14 @@ def generate(self): tc = CMakeToolchain(self) if self.settings.os == "Android": tc.cache_variables["CONAN_LIBCXX"] = "" - openssl = self.dependencies["openssl"] + openssl = self.dependencies[self.tested_reference_str] openssl_version = Version(openssl.ref.version) if openssl_version.major == "1" and openssl_version.minor == "1": tc.cache_variables["OPENSSL_WITH_ZLIB"] = False else: tc.cache_variables["OPENSSL_WITH_ZLIB"] = not openssl.options.no_zlib tc.generate() + self._generate_skip_test_file() def build(self): @@ -51,5 +61,5 @@ def build(self): def test(self): if not self._skip_test and can_run(self): - bin_path = os.path.join(self.cpp.build.bindirs[0], "digest") + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") self.run(bin_path, env="conanrun") diff --git a/recipes/openssl/1.x.x/test_v1_package/CMakeLists.txt b/recipes/openssl/1.x.x/test_v1_package/CMakeLists.txt index 0219031d704290..2f6b1a2f7ec79d 100644 --- a/recipes/openssl/1.x.x/test_v1_package/CMakeLists.txt +++ b/recipes/openssl/1.x.x/test_v1_package/CMakeLists.txt @@ -4,33 +4,5 @@ project(test_package C) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup(TARGETS) -option(OPENSSL_WITH_ZLIB "OpenSSL with zlib support" ON) - -set(OpenSSL_DEBUG 1) -find_package(OpenSSL REQUIRED) - -# Test whether variables from https://cmake.org/cmake/help/latest/module/FindOpenSSL.html -# are properly defined in conan generators -set(_custom_vars - OPENSSL_FOUND - OPENSSL_INCLUDE_DIR - OPENSSL_CRYPTO_LIBRARY - OPENSSL_CRYPTO_LIBRARIES - OPENSSL_SSL_LIBRARY - OPENSSL_SSL_LIBRARIES - OPENSSL_LIBRARIES - OPENSSL_VERSION -) -foreach(_custom_var ${_custom_vars}) - if(DEFINED _custom_var) - message(STATUS "${_custom_var}: ${${_custom_var}}") - else() - message(FATAL_ERROR "${_custom_var} not defined") - endif() -endforeach() - -add_executable(digest ../test_package/digest.c) -target_link_libraries(digest OpenSSL::SSL) -if(OPENSSL_WITH_ZLIB) - target_compile_definitions(digest PRIVATE WITH_ZLIB) -endif() +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ + ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/openssl/1.x.x/test_v1_package/conanfile.py b/recipes/openssl/1.x.x/test_v1_package/conanfile.py index 13150b440fe8af..468ca6bb29e988 100644 --- a/recipes/openssl/1.x.x/test_v1_package/conanfile.py +++ b/recipes/openssl/1.x.x/test_v1_package/conanfile.py @@ -3,8 +3,6 @@ from conan.tools.build import cross_building import os -required_conan_version = ">=1.50.2 <1.51.0 || >=1.51.2" - class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" @@ -37,6 +35,5 @@ def build(self): def test(self): if not self._skip_test and not cross_building(self): - bin_path = os.path.join("bin", "digest") + bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) - assert os.path.exists(os.path.join(self.deps_cpp_info["openssl"].rootpath, "licenses", "LICENSE"))