Skip to content

Commit

Permalink
openssl: add missing options + various reformatting
Browse files Browse the repository at this point in the history
  • Loading branch information
madebr committed Sep 10, 2021
1 parent 32911da commit deb945b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 20 deletions.
14 changes: 8 additions & 6 deletions recipes/openssl/3.x.x/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class OpenSSLConan(ConanFile):
"no_gost": [True, False],
"no_idea": [True, False],
"no_legacy": [True, False],
"no_md2": [True, False],
"no_md4": [True, False],
"no_mdc2": [True, False],
"no_ocsp": [True, False],
Expand All @@ -64,6 +65,7 @@ class OpenSSLConan(ConanFile):
"no_sm4": [True, False],
"no_srp": [True, False],
"no_srtp": [True, False],
"no_sse2": [True, False],
"no_ssl": [True, False],
"no_stdio": [True, False],
"no_seed": [True, False],
Expand Down Expand Up @@ -152,9 +154,9 @@ def source(self):
def _target(self):
target = f"conan-{self.settings.build_type}-{self.settings.os}-{self.settings.arch}-{self.settings.compiler}-{self.settings.compiler.version}"
if self._use_nmake:
target = "VC-" + target # VC- prefix is important as it's checked by Configure
target = f"VC-{target}" # VC- prefix is important as it's checked by Configure
if self._is_mingw:
target = "mingw-" + target
target = f"mingw-{target}"
return target

@property
Expand Down Expand Up @@ -480,7 +482,7 @@ def _create_targets(self):
targets = "my %targets"
includes = ", ".join(['"%s"' % include for include in env_build.include_paths])
if self.settings.os == "Windows":
includes = includes.replace("\\", "/") # OpenSSL doesn't like backslashes
includes = includes.replace("\\", "/") # OpenSSL doesn't like backslashes

if self._asm_target:
ancestor = '[ "%s", asm("%s") ]' % (self._ancestor_target, self._asm_target)
Expand Down Expand Up @@ -616,13 +618,13 @@ def _make_program(self):
if self._use_nmake:
return "nmake"
make_program = tools.get_env("CONAN_MAKE_PROGRAM", tools.which("make") or tools.which("mingw32-make"))
make_program = tools.unix_path(make_program) if tools.os_info.is_windows else make_program
if not make_program:
raise Exception('could not find "make" executable. please set "CONAN_MAKE_PROGRAM" environment variable')
make_program = tools.unix_path(make_program)
return make_program

def _replace_runtime_in_file(self, filename):
for e in ["MDd", "MTd", "MD", "MT"]:
for e in ("MDd", "MTd", "MD", "MT"):
tools.replace_in_file(filename, "/%s " % e, "/%s " % self.settings.compiler.runtime, strict=False)
tools.replace_in_file(filename, "/%s\"" % e, "/%s\"" % self.settings.compiler.runtime, strict=False)

Expand Down Expand Up @@ -714,7 +716,7 @@ def package_info(self):
self.cpp_info.components["ssl"].requires = ["crypto"]

if not self.options.no_zlib:
self.cpp_info.components["crypto"].requires = ["zlib::zlib"]
self.cpp_info.components["crypto"].requires.append("zlib::zlib")

if self.settings.os == "Windows":
self.cpp_info.components["crypto"].system_libs.extend(["crypt32", "ws2_32", "advapi32", "user32"])
Expand Down
9 changes: 4 additions & 5 deletions recipes/openssl/3.x.x/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ conan_basic_setup(TARGETS)

option(OPENSSL_WITH_ZLIB "OpenSSL with zlib support" ON)

add_executable(digest digest.c)
if(OPENSSL_WITH_ZLIB)
target_compile_definitions(digest PRIVATE WITH_ZLIB)
endif()

set(OpenSSL_DEBUG 1)
find_package(OpenSSL REQUIRED)

Expand All @@ -23,4 +18,8 @@ message("OPENSSL_SSL_LIBRARIES: ${OPENSSL_SSL_LIBRARIES}")
message("OPENSSL_LIBRARIES: ${OPENSSL_LIBRARIES}")
message("OPENSSL_VERSION: ${OPENSSL_VERSION}")

add_executable(digest digest.c)
if(OPENSSL_WITH_ZLIB)
target_compile_definitions(digest PRIVATE WITH_ZLIB)
endif()
target_link_libraries(digest OpenSSL::Crypto)
11 changes: 4 additions & 7 deletions recipes/openssl/3.x.x/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,12 @@ class TestPackageConan(ConanFile):

def build(self):
cmake = CMake(self)

cmake.definitions["OPENSSL_WITH_ZLIB"] = not self.options["openssl"].no_zlib
if self.settings.os == "Android":
cmake.definitions["CONAN_LIBCXX"] = ""

cmake.definitions["OPENSSL_WITH_ZLIB"] = not self.options["openssl"].no_zlib

cmake.configure()
cmake.build()

for fn in ("libcrypto.pc", "libssl.pc", "openssl.pc",):
assert os.path.isfile(os.path.join(self.build_folder, fn))

def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "digest")
Expand All @@ -28,3 +22,6 @@ def test(self):
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))
2 changes: 0 additions & 2 deletions recipes/openssl/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,3 @@ versions:
folder: "1.x.x"
1.0.2s:
folder: "1.x.x"
3.0.0:
folder: "3.x.x"

0 comments on commit deb945b

Please sign in to comment.