diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-04-07 17:54:49 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-04-08 22:03:24 +0200 |
commit | e0346df1b21cb30b54ae8d4918addc9925fa8479 (patch) | |
tree | d45cfc3bc6a3d59507bc26f963d9eee57531b6b5 /util/cmake | |
parent | 0a13c3a3f0ef1eb7274badac000db9ec584faeca (diff) |
CMake: Handle finding of OpenSSL headers correctly
In Coin when provisioning for Android, we download and configure
the OpenSSL package, but don't actually build it. This means that
find_package(OpenSSL) can find the headers, but not the library,
and thus the package is marked as not found.
Previously the openssl_headers feature used the result of finding
the OpenSSL package, which led to it being disabled in the above
described Android case.
Introduce 2 new find scripts FindWrapOpenSSL and
FindWrapOpenSSLHeaders. FindWrapOpenSSLHeaders wraps FindOpenSSL,
and checks if the headers were found, regardless of the OpenSSL_FOUND
value, which can be used for implementing the openssl_headers feature.
FindWrapOpenSSL uses FindWrapOpenSSLHeaders, and simply wraps the
OpenSSL target if available.
The find scripts also have to set CMAKE_FIND_ROOT_PATH for Android.
Otherwise when someone passes in an OPENSSL_ROOT_DIR, its value will
always be prepended to the Android sysroot, causing the package not
to be found.
Adjust the mapping in helper.py to use the targets created by these
find scripts. This also replaces the openssl/nolink target.
Adjust the projects and tests to use the new target names.
Adjust the compile tests for dtls and oscp to use the
WrapOpenSSLHeaders target, so that the features can be enabled even
if the library is dlopen-ed (like on Android).
Task-number: QTBUG-83371
Change-Id: I738600e5aafef47a57e1db070be40116ca8ab995
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'util/cmake')
-rwxr-xr-x | util/cmake/configurejson2cmake.py | 4 | ||||
-rw-r--r-- | util/cmake/helper.py | 47 |
2 files changed, 45 insertions, 6 deletions
diff --git a/util/cmake/configurejson2cmake.py b/util/cmake/configurejson2cmake.py index b98aece55b..5a77c36b4e 100755 --- a/util/cmake/configurejson2cmake.py +++ b/util/cmake/configurejson2cmake.py @@ -40,6 +40,7 @@ from helper import ( map_platform, find_3rd_party_library_mapping, generate_find_package_info, + get_compile_test_dependent_library_mapping, ) knownTests = set() # type: Set[str] @@ -700,7 +701,8 @@ def write_compile_test( if len(library) == 0: continue - library_usage = get_library_usage_for_compile_test(library) + adjusted_library = get_compile_test_dependent_library_mapping(name, library) + library_usage = get_library_usage_for_compile_test(adjusted_library) if "fixme" in library_usage: qmakeFixme += library_usage["fixme"] continue diff --git a/util/cmake/helper.py b/util/cmake/helper.py index 56bf864adb..aae67555f6 100644 --- a/util/cmake/helper.py +++ b/util/cmake/helper.py @@ -44,6 +44,7 @@ class LibraryMapping: is_bundled_with_qt: bool = False, test_library_overwrite: str = "", run_library_test: bool = False, + no_link_so_name: str = "", ) -> None: self.soName = soName self.packageName = packageName @@ -66,6 +67,9 @@ class LibraryMapping: # Run the library compile test of configure.json self.run_library_test = run_library_test + # The custom nolink library mapping associated with this one. + self.no_link_so_name = no_link_so_name + def is_qt(self) -> bool: return self.packageName == "Qt" or self.packageName == "Qt5" or self.packageName == "Qt6" @@ -447,20 +451,21 @@ _library_map = [ LibraryMapping("opengl", "OpenGL", "OpenGL::GL", resultVariable="OpenGL_OpenGL"), LibraryMapping( "openssl_headers", - "OpenSSL", - "OpenSSL::SSL_nolink", + "WrapOpenSSLHeaders", + "WrapOpenSSLHeaders::WrapOpenSSLHeaders", resultVariable="TEST_openssl_headers", appendFoundSuffix=False, - test_library_overwrite="OpenSSL::SSL", + test_library_overwrite="WrapOpenSSLHeaders::WrapOpenSSLHeaders", run_library_test=True, ), LibraryMapping( "openssl", - "OpenSSL", - "OpenSSL::SSL", + "WrapOpenSSL", + "WrapOpenSSL::WrapOpenSSL", resultVariable="TEST_openssl", appendFoundSuffix=False, run_library_test=True, + no_link_so_name="openssl_headers", ), LibraryMapping("oci", "Oracle", "Oracle::OCI"), LibraryMapping( @@ -698,24 +703,56 @@ def map_platform(platform: str) -> str: def is_known_3rd_party_library(lib: str) -> bool: + handling_no_link = False if lib.endswith("/nolink") or lib.endswith("_nolink"): lib = lib[:-7] + handling_no_link = True mapping = find_3rd_party_library_mapping(lib) + if handling_no_link and mapping and mapping.no_link_so_name: + no_link_mapping = find_3rd_party_library_mapping(mapping.no_link_so_name) + if no_link_mapping: + mapping = no_link_mapping return mapping is not None def map_3rd_party_library(lib: str) -> str: + handling_no_link = False libpostfix = "" if lib.endswith("/nolink"): lib = lib[:-7] libpostfix = "_nolink" + handling_no_link = True + mapping = find_3rd_party_library_mapping(lib) + + if handling_no_link and mapping and mapping.no_link_so_name: + no_link_mapping = find_3rd_party_library_mapping(mapping.no_link_so_name) + if no_link_mapping: + mapping = no_link_mapping + libpostfix = "" + if not mapping or not mapping.targetName: return lib + return mapping.targetName + libpostfix +compile_test_dependent_library_mapping = { + "dtls": {"openssl": "openssl_headers"}, + "ocsp": {"openssl": "openssl_headers"}, +} + + +def get_compile_test_dependent_library_mapping(compile_test_name: str, dependency_name: str): + if compile_test_name in compile_test_dependent_library_mapping: + mapping = compile_test_dependent_library_mapping[compile_test_name] + if dependency_name in mapping: + return mapping[dependency_name] + + return dependency_name + + def generate_find_package_info( lib: LibraryMapping, use_qt_find_package: bool = True, |