summaryrefslogtreecommitdiffstats
path: root/cmake/QtBuild.cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-08-03 16:28:16 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-08-06 19:15:39 +0200
commit92ee9bd6b885879090ba57e49c8bd84a06d42b2b (patch)
tree0c0c691394595bb5fff42d31632e1c9ea9a21ba7 /cmake/QtBuild.cmake
parentbd2bcd4e1d38f18d2716cbebf7d106c090564217 (diff)
CMake: Properly handle CONFIG += thread aka Threads::Threads
mkspecs/features/qt.prf adds a dependency on the system threading library if the Qt Core thread feature is enabled. Because qt.prf is loaded by any public or internal Qt project, it's essentially a public dependency for any Qt consumer. To mimic that in CMake, we check if the thread feature is enabled, and and set the Threads::Threads library as a dependency of Qt6::Platform, which is a public target used by all Qt modules and plugins and Qt consumers. We also need to create a Qt6Dependencies.cmake file so we find_package(Threads) every time find_package(Qt6) is called. For the .prl files to be usable, we have to filter out some CMake implementation specific directory separator tokens 'CMAKE_DIRECTORY_ID_SEP' aka '::@', which are added because we call target_link_libraries() with a target created in a different scope (I think). As a result of this change, we shouldn't have to hardcode Threads::Threads in other projects, because it's now a global public dependency. Task-number: QTBUG-85801 Task-number: QTBUG-85877 Change-Id: Ib5d662c43b28e63f7da49d3bd77d0ad751220b31 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Diffstat (limited to 'cmake/QtBuild.cmake')
-rw-r--r--cmake/QtBuild.cmake7
1 files changed, 6 insertions, 1 deletions
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake
index a20531e3cc..cac9e22c73 100644
--- a/cmake/QtBuild.cmake
+++ b/cmake/QtBuild.cmake
@@ -3256,7 +3256,12 @@ function(qt_internal_walk_libs target out_var dict_name operation)
set(lib_target ${lib})
endif()
- if(TARGET ${lib_target})
+ # Skip CMAKE_DIRECTORY_ID_SEP. If a target_link_libraries is applied to a target
+ # that was defined in a different scope, CMake appends and prepends a special directory
+ # id separator. Filter those out.
+ if(lib_target MATCHES "^::@")
+ continue()
+ elseif(TARGET ${lib_target})
if ("${lib_target}" MATCHES "^Qt::(.*)")
# If both, Qt::Foo and Foo targets exist, prefer the target name without
# namespace. Which one is preferred doesn't really matter. This code exists to