summaryrefslogtreecommitdiffstats
path: root/cmake/QtTargetHelpers.cmake
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2021-07-08 09:59:05 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2021-07-08 16:40:35 +0200
commit7540b4bd5634c9104a99f9b219531b1e3dd7942d (patch)
tree9252b0e0733c9d71f58ccf364b6b1de6082aed0d /cmake/QtTargetHelpers.cmake
parent1a57a4974be9dbdeedef6f5c6eb4332eecf6f0c9 (diff)
Fix build of Debug projects against debug-and-release non-prefix Qt
Building a CMake project with CMAKE_BUILD_CONFIG=Debug was broken for non-prefix debug-and-release builds of Qt. In debug-and-release builds we set EXCLUDE_FROM_ALL on tools in the Debug configuration. In non-prefix builds we export(EXPORT) targets, and that also contains the non-existent Debug variants of the tools. In prefix builds, we install(EXPORT) instead, which only exports what is built and installed. Consequently, we now remove the DEBUG-related import information if the debug variant if the target binary does not exist. Pick-to: 6.2 Fixes: QTBUG-95027 Change-Id: I37766d5ab1e2795bcb91a348e7e72150e8a00f82 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake/QtTargetHelpers.cmake')
-rw-r--r--cmake/QtTargetHelpers.cmake23
1 files changed, 21 insertions, 2 deletions
diff --git a/cmake/QtTargetHelpers.cmake b/cmake/QtTargetHelpers.cmake
index 00c4482c75..44328aec3f 100644
--- a/cmake/QtTargetHelpers.cmake
+++ b/cmake/QtTargetHelpers.cmake
@@ -469,8 +469,26 @@ endif()
continue()
endif()
- # FIXME: Don't add IMPORTED_SOLIB and IMPORTED_SONAME properties for executables.
set(properties_retrieved TRUE)
+
+ # Non-prefix debug-and-release builds: add check for the existence of the debug binary of
+ # the target. It is not built by default.
+ if(NOT QT_WILL_INSTALL AND QT_FEATURE_debug_and_release)
+ get_target_property(excluded_genex ${target} EXCLUDE_FROM_ALL)
+ if(NOT excluded_genex STREQUAL "")
+ string(APPEND content "
+# ${full_target} is not built by default in the Debug configuration. Check existence.
+get_target_property(_qt_imported_location ${full_target} IMPORTED_LOCATION_DEBUG)
+if(NOT EXISTS \"$\\{_qt_imported_location}\")
+ get_target_property(_qt_imported_configs ${full_target} IMPORTED_CONFIGURATIONS)
+ list(REMOVE_ITEM _qt_imported_configs DEBUG)
+ set_property(TARGET ${full_target} PROPERTY IMPORTED_CONFIGURATIONS $\\{_qt_imported_configs})
+ set_property(TARGET ${full_target} PROPERTY IMPORTED_LOCATION_DEBUG)
+endif()\n\n")
+ endif()
+ endif()
+
+ # FIXME: Don't add IMPORTED_SOLIB and IMPORTED_SONAME properties for executables.
if(NOT "${uc_release_cfg}" STREQUAL "")
string(APPEND content "get_target_property(_qt_imported_location ${full_target} IMPORTED_LOCATION_${uc_release_cfg})\n")
string(APPEND content "get_target_property(_qt_imported_implib ${full_target} IMPORTED_IMPLIB_${uc_release_cfg})\n")
@@ -512,7 +530,8 @@ endif()
unset(_qt_imported_location)
unset(_qt_imported_location_default)
unset(_qt_imported_soname)
-unset(_qt_imported_soname_default)")
+unset(_qt_imported_soname_default)
+unset(_qt_imported_configs)")
endif()
qt_path_join(output_file "${arg_CONFIG_INSTALL_DIR}"