Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Openssl 3.x.x conan v2 #16563

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0397aeb
[openssl 3.x.x] fix "official" OpenSSL vars for CMakeDeps gen
jngrb Nov 25, 2022
22ce88b
openssl 3.x.x test package: do not skip test for certain MacOS variants
jngrb Nov 25, 2022
24e21be
[openssl 3.x.x] raise ConanInvalidConfiguration for certain Macos con…
jngrb Nov 25, 2022
f33adef
Revert "[openssl 3.x.x] raise ConanInvalidConfiguration for certain M…
jngrb Feb 28, 2023
e33d879
openssl 3.x.x test package: changes as proposed in PR #14426
jngrb Mar 5, 2023
f83f90e
Apply suggestions from code review
jngrb Mar 6, 2023
4747491
openssl 3.x.x (v2) test package: readded openssl version test
jngrb Mar 6, 2023
e1eb0c0
openssl 3.x.x (v2) test package: removed superfluos existence test
jngrb Mar 7, 2023
1fe35ae
Merge branch 'master' into openssl_3.x.x_cmakedeps_fix
jngrb Mar 14, 2023
f1a433a
[openssl 3.x.x] changed recipes to be conan v2 compatible
jngrb Mar 14, 2023
4e23686
fixed syntax errors and linter reportings
jngrb Mar 14, 2023
a2c78a0
Merge remote-tracking branch 'origin/master' into openssl_3.x.x_conan_v2
jngrb Mar 14, 2023
22a0c08
openssl 3.x.x v1 test package: check for LICENSE (not LICENSE.txt)
jngrb Mar 14, 2023
f604f38
Merge remote-tracking branch 'origin/master' into openssl_3.x.x_conan_v2
jngrb Mar 15, 2023
70e3685
OpenSSL 3.x.x test pkg: do not check for zlib headers with conan v2
jngrb Mar 20, 2023
862b14d
OpenSSL 3.x.x recipe: move default MSVC CFLAGS and LDFLAGS to recipe
jngrb Mar 21, 2023
1b6f6b6
Merge remote-tracking branch 'origin/master' into openssl_3.x.x_conan_v2
jngrb Mar 21, 2023
f5be79a
OpenSSL 3.x.x recipe: use is_msvc tooling
jngrb Mar 21, 2023
3df73a2
OpenSSL 3.x.x: re-enable special Apple changes; no tool test
jngrb Mar 22, 2023
74ad4a1
attempt to fix Apple patch of Makefile
jngrb Mar 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
390 changes: 204 additions & 186 deletions recipes/openssl/3.x.x/conanfile.py

Large diffs are not rendered by default.

35 changes: 22 additions & 13 deletions recipes/openssl/3.x.x/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,29 +1,38 @@
cmake_minimum_required(VERSION 3.1)
project(test_package C)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

option(OPENSSL_WITH_ZLIB "OpenSSL with zlib support" ON)
option(TRANSITIVE_ZLIB_HEADERS "Headers of the (transitive) ZLIB will be visible for test package" ON)
option(OPENSSL_WITH_LEGACY "OpenSSL with support for the legacy provider" ON)
option(OPENSSL_WITH_MD4 "OpenSSL with MD4 support (needs legacy provider)" ON)
option(OPENSSL_WITH_RIPEMD160 "OpenSSL with RIPEMD16 support (needs legacy provider)" ON)

set(OpenSSL_DEBUG 1)
find_package(OpenSSL REQUIRED)

message("OPENSSL_FOUND: ${OPENSSL_FOUND}")
message("OPENSSL_INCLUDE_DIR: ${OPENSSL_INCLUDE_DIR}")
message("OPENSSL_CRYPTO_LIBRARY: ${OPENSSL_CRYPTO_LIBRARY}")
message("OPENSSL_CRYPTO_LIBRARIES: ${OPENSSL_CRYPTO_LIBRARIES}")
message("OPENSSL_SSL_LIBRARY: ${OPENSSL_SSL_LIBRARY}")
message("OPENSSL_SSL_LIBRARIES: ${OPENSSL_SSL_LIBRARIES}")
message("OPENSSL_LIBRARIES: ${OPENSSL_LIBRARIES}")
message("OPENSSL_VERSION: ${OPENSSL_VERSION}")
# 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} AND NOT "${${_custom_var}}" STREQUAL "" )
message(STATUS "${_custom_var}: ${${_custom_var}}")
else()
message(FATAL_ERROR "${_custom_var} not defined")
endif()
endforeach()

add_executable(digest digest.c)
if(OPENSSL_WITH_ZLIB)
target_compile_definitions(digest PRIVATE WITH_ZLIB)
if(OPENSSL_WITH_ZLIB AND TRANSITIVE_ZLIB_HEADERS)
target_compile_definitions(digest PRIVATE WITH_ZLIB_HEADERS)
endif()
target_link_libraries(digest OpenSSL::Crypto)

Expand Down
76 changes: 49 additions & 27 deletions recipes/openssl/3.x.x/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,62 @@
from conans import CMake, tools, ConanFile
from conan.tools.build import cross_building
from conan import ConanFile, conan_version
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain
from conan.tools.scm import Version
import os

required_conan_version = ">=1.50.2 <1.51.0 || >=1.51.2"


class TestPackageConan(ConanFile):
settings = "os", "compiler", "arch", "build_type"
generators = "cmake", "cmake_find_package", "pkg_config"
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "VirtualRunEnv"
test_type = "explicit"

@property
def _with_legacy(self):
return (not self.options["openssl"].no_legacy and
((not self.options["openssl"].no_md4) or
(not self.options["openssl"].no_rmd160)))
openssl = self.dependencies["openssl"]
return (not openssl.options.no_legacy and
((not openssl.options.no_md4) or
(not openssl.options.no_rmd160)))

def requirements(self):
self.requires(self.tested_reference_str)

def layout(self):
cmake_layout(self)

def generate(self):
tc = CMakeToolchain(self)
openssl = self.dependencies["openssl"]
tc.cache_variables["OPENSSL_WITH_ZLIB"] = not openssl.options.no_zlib
if Version(conan_version) >= 2:
tc.cache_variables["TRANSITIVE_ZLIB_HEADERS"] = "OFF"
tc.cache_variables["OPENSSL_WITH_LEGACY"] = self._with_legacy
tc.cache_variables["OPENSSL_WITH_MD4"] = not openssl.options.no_md4
tc.cache_variables["OPENSSL_WITH_RIPEMD160"] = not openssl.options.no_rmd160
if self.settings.os == "Android":
tc.cache_variables["CONAN_LIBCXX"] = ""
tc.generate()


def build(self):
cmake = CMake(self)
cmake.definitions["OPENSSL_WITH_ZLIB"] = not self.options["openssl"].no_zlib
cmake.definitions["OPENSSL_WITH_LEGACY"] = self._with_legacy()
cmake.definitions["OPENSSL_WITH_MD4"] = not self.options["openssl"].no_md4
cmake.definitions["OPENSSL_WITH_RIPEMD160"] = not self.options["openssl"].no_rmd160
if self.settings.os == "Android":
cmake.definitions["CONAN_LIBCXX"] = ""
cmake.verbose = True
cmake.configure()
cmake.build()

def test(self):
if not cross_building(self):
bin_path = os.path.join("bin", "digest")
self.run(bin_path, run_environment=True)

if not self.options["openssl"].no_legacy:
bin_legacy_path = os.path.join("bin", "digest_legacy")
self.run(bin_legacy_path, run_environment=True)

if not self.options["openssl"].no_stdio:
self.run("openssl version", run_environment=True)
assert os.path.exists(os.path.join(self.deps_cpp_info["openssl"].rootpath, "licenses", "LICENSE.txt"))

for fn in ("libcrypto.pc", "libssl.pc", "openssl.pc",):
assert os.path.isfile(os.path.join(self.build_folder, fn))
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "digest")
self.run(bin_path, env="conanrun")

openssl_options = self.options["openssl"] if Version(conan_version) < 2 else self.dependencies["openssl"].options
if not openssl_options.no_legacy:
bin_legacy_path = os.path.join(self.cpp.build.bindirs[0], "digest_legacy")
self.run(bin_legacy_path, env="conanrun")

if not openssl_options.no_stdio and Version(conan_version) < 2:
# NOTE: this test is not suitable for conan v2 where the build profile can differ from the host profile
self.run("openssl version", env="conanrun")
# cannot be checked with Conan v2
#assert os.path.exists(os.path.join(self.deps_cpp_info["openssl"].rootpath, "licenses", "LICENSE.txt"))
4 changes: 2 additions & 2 deletions recipes/openssl/3.x.x/test_package/digest.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <openssl/sha.h>
#include <openssl/crypto.h>
#include <openssl/ssl.h>
#if defined(WITH_ZLIB)
#if defined(WITH_ZLIB_HEADERS)
#include <zlib.h>
#endif

Expand Down Expand Up @@ -65,7 +65,7 @@ int main()
printf("sha3 256 digest: %s\n", sha3_256_string);
printf("sha3 512 digest: %s\n", sha3_512_string);
printf("OpenSSL version: %s\n", OpenSSL_version(OPENSSL_VERSION));
#if defined(WITH_ZLIB)
#if defined(WITH_ZLIB_HEADERS)
printf("ZLIB version: %s\n", ZLIB_VERSION);
#endif

Expand Down
4 changes: 2 additions & 2 deletions recipes/openssl/3.x.x/test_package/digest_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <openssl/err.h>
#include <openssl/crypto.h>
#include <openssl/ssl.h>
#if defined(WITH_ZLIB)
#if defined(WITH_ZLIB_HEADERS)
#include <zlib.h>
#endif

Expand Down Expand Up @@ -140,7 +140,7 @@ int main()
printf("RIPEMD160 digest (variant 2): %s\n", ripemd160_string2);
#endif
printf("OpenSSL version: %s\n", OpenSSL_version(OPENSSL_VERSION));
#if defined(WITH_ZLIB)
#if defined(WITH_ZLIB_HEADERS)
printf("ZLIB version: %s\n", ZLIB_VERSION);
#endif

Expand Down
8 changes: 8 additions & 0 deletions recipes/openssl/3.x.x/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package C)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/
${CMAKE_CURRENT_BINARY_DIR}/test_package/)
40 changes: 40 additions & 0 deletions recipes/openssl/3.x.x/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from conans import CMake, tools, ConanFile
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "arch", "build_type"
generators = "cmake", "cmake_find_package", "pkg_config"

def _with_legacy(self):
return (not self.options["openssl"].no_legacy and
((not self.options["openssl"].no_md4) or
(not self.options["openssl"].no_rmd160)))

def build(self):
cmake = CMake(self)
cmake.definitions["OPENSSL_WITH_ZLIB"] = not self.options["openssl"].no_zlib
cmake.definitions["OPENSSL_WITH_LEGACY"] = self._with_legacy()
cmake.definitions["OPENSSL_WITH_MD4"] = not self.options["openssl"].no_md4
cmake.definitions["OPENSSL_WITH_RIPEMD160"] = not self.options["openssl"].no_rmd160
if self.settings.os == "Android":
cmake.definitions["CONAN_LIBCXX"] = ""
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "digest")
self.run(bin_path, run_environment=True)

if not self.options["openssl"].no_legacy:
bin_legacy_path = os.path.join("bin", "digest_legacy")
self.run(bin_legacy_path, run_environment=True)

if not self.options["openssl"].no_stdio:
self.run("openssl version", run_environment=True)
assert os.path.exists(os.path.join(self.deps_cpp_info["openssl"].rootpath, "licenses", "LICENSE"))

# check for pkg_config files in build folder of this test package
for fn in ("libcrypto.pc", "libssl.pc", "openssl.pc",):
assert os.path.isfile(os.path.join(self.build_folder, fn))