summaryrefslogtreecommitdiffstats
path: root/cmake/QtBuild.cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-08-12 12:34:06 +0000
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-08-12 16:29:35 +0200
commit52fdb9dc93c9e9c372d8d4a95b97a32bf091579d (patch)
tree6acad9b930786689cbda9ce82fd73fe9b19f9aad /cmake/QtBuild.cmake
parent6b488d89507e4d252b05225a203183b5e83e92ac (diff)
CMake: Fix Threads::Threads dependency handling with CMake < 3.18
Apparently CMake encods targets from different scopes with a different encoding scheme for earlier CMake versions. CMake 3.16.3: Threads::Threads::@<0x5604cb3f6b50> CMake 3.18.0: ::@(0x5604cb3f6b50);Threads::Threads;::@ Handle the earlier version approach as well. It needs to be done both when writing out 3rd party dependencies, as well as for lib prl files. Possibly in more places as well, but I didn't detect additional places yet. Amends 92ee9bd6b885879090ba57e49c8bd84a06d42b2b Task-number: QTBUG-85801 Task-number: QTBUG-85877 Change-Id: Ib348b51b2d623fb50d9080dba2beeb931d47a69c Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Diffstat (limited to 'cmake/QtBuild.cmake')
-rw-r--r--cmake/QtBuild.cmake20
1 files changed, 20 insertions, 0 deletions
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake
index 959581e288..6d5e7175b8 100644
--- a/cmake/QtBuild.cmake
+++ b/cmake/QtBuild.cmake
@@ -3253,6 +3253,9 @@ function(qt_internal_walk_libs target out_var dict_name operation)
continue()
endif()
+ # Strip any directory scope tokens.
+ qt_internal_strip_target_directory_scope_token("${lib}" lib)
+
if(lib MATCHES "^\\$<TARGET_OBJECTS:")
# Skip object files.
continue()
@@ -6122,6 +6125,23 @@ function(qt_internal_apply_win_prefix_and_suffix target)
endif()
endfunction()
+function(qt_internal_strip_target_directory_scope_token target out_var)
+ # In CMake versions earlier than CMake 3.18, a subdirectory scope id is appended to the
+ # target name if the target is referenced in a target_link_libraries command from a
+ # different directory scope than where the target was created.
+ # Strip it.
+ #
+ # For informational purposes, in CMake 3.18, the target name looks as follows:
+ # ::@(0x5604cb3f6b50);Threads::Threads;::@
+ # This case doesn't have to be stripped (at least for now), because when we iterate over
+ # link libraries, the tokens appear as separate target names.
+ #
+ # Example: Threads::Threads::@<0x5604cb3f6b50>
+ # Output: Threads::Threads
+ string(REGEX REPLACE "::@<.+>$" "" target "${target}")
+ set("${out_var}" "${target}" PARENT_SCOPE)
+endfunction()
+
include(QtApp)
# Compatibility macros that should be removed once all their usages are removed.