diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2024-01-19 16:00:11 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2024-01-22 18:53:16 +0000 |
commit | 3411f2984a5325a35e3bed1f961e5973d8a565b9 (patch) | |
tree | 0014874d63f03a2c9a788d0c113510e377e4c86e | |
parent | 7e789b2998a9d6dc00ec99f89aadb43e96efb669 (diff) |
CMake: Fix Threads global promotion issue when using static openssl
and an older CMake 3.22, which is shipped by default on Ubuntu 22.04.
If for some reason there's a static openssl library lying around in
the default sysroot (or any ssl search path), like in
/usr/lib/libssl.a,
then CMake's _OpenSSL_test_and_find_dependencies
will try to find_package(Threads) because it assumes it has a
dependency on the Threads package.
Because we do qt_find_package(WrapOpenSSLHeaders) in
qtbase/configure.cmake
and we do qt_find_package(Threads) in
src/corelib/CMakeLists.txt,
we would create the Threads target in the root directory scope, and
then try to promote it to global in the corelib subdirectory,
which fails with
CMake Error at qtbase/cmake/QtPublicTargetHelpers.cmake:260
(set_property):
Attempt to promote imported target "Threads::Threads" to global scope
(by setting IMPORTED_GLOBAL) which is not built in this directory.
Call Stack (most recent call first):
qtbase/cmake/QtFindPackageHelpers.cmake:211
(__qt_internal_promote_target_to_global)
qtbase/src/corelib/CMakeLists.txt:4 (qt_find_package)
Newer versions of CMake's FindOpenSSL actually try to determine if
the Threads package is really needed.
To avoid the issue entirely, just look up Threads before we look up
the OpenSSL package.
Pick-to: 6.5
Change-Id: Ia3cde93e26ba004f64105a5b457098e1b9870885
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit 85c462855be95afd2afebd345cb4655c00f9824e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 9348368772fb983d44b18864ce2e37af966cc977)
-rw-r--r-- | configure.cmake | 4 | ||||
-rw-r--r-- | src/corelib/CMakeLists.txt | 1 |
2 files changed, 4 insertions, 1 deletions
diff --git a/configure.cmake b/configure.cmake index cbfe142069..3d9288122b 100644 --- a/configure.cmake +++ b/configure.cmake @@ -18,6 +18,10 @@ if(TARGET ZLIB::ZLIB) set_property(TARGET ZLIB::ZLIB PROPERTY IMPORTED_GLOBAL TRUE) endif() +# Look for Threads in the same scope as OpenSSL package, because OpenSSL sometimes depends on +# Threads (for static OpenSSL builds) and we want to promote the target to global in the same +# directory scope. +qt_find_package(Threads PROVIDED_TARGETS Threads::Threads) qt_find_package(WrapOpenSSLHeaders PROVIDED_TARGETS WrapOpenSSLHeaders::WrapOpenSSLHeaders MODULE_NAME core) # openssl_headers # OPENSSL_VERSION_MAJOR is not defined for OpenSSL 1.1.1 diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt index 96eb47dc35..1296ff0408 100644 --- a/src/corelib/CMakeLists.txt +++ b/src/corelib/CMakeLists.txt @@ -1,7 +1,6 @@ # Copyright (C) 2022 The Qt Company Ltd. # SPDX-License-Identifier: BSD-3-Clause -qt_find_package(Threads PROVIDED_TARGETS Threads::Threads) qt_find_package(WrapPCRE2 PROVIDED_TARGETS WrapPCRE2::WrapPCRE2) qt_find_package(WrapZLIB PROVIDED_TARGETS WrapZLIB::WrapZLIB) |