summaryrefslogtreecommitdiffstats
path: root/cmake/QtExecutableHelpers.cmake
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2020-11-06 21:48:08 +0100
committerJoerg Bornemann <joerg.bornemann@qt.io>2020-11-10 04:24:28 +0100
commit5b136abd21803988f96b9b66c992822efbef97ec (patch)
treeb5266a5ba068f93bf57dc78ba744535dd6630a3f /cmake/QtExecutableHelpers.cmake
parentb8b75cdcfa71189c7726607be7b66d0ddeaae372 (diff)
CMake: Fix installation errors in multi-config build
In multi-config builds (which equals the debug-and-release feature) we exclude tools of the non-main configurations from the default build. But we still create installation rules for them. Mark those as optional to avoid "cmake --install" yielding errors if those tools weren't built. Fixes: QTBUG-85411 Change-Id: Ic2d3897d1a1c28a715d9a024ec8606fff00e0315 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake/QtExecutableHelpers.cmake')
-rw-r--r--cmake/QtExecutableHelpers.cmake15
1 files changed, 15 insertions, 0 deletions
diff --git a/cmake/QtExecutableHelpers.cmake b/cmake/QtExecutableHelpers.cmake
index 7bcad2ad7a..42bc05fb49 100644
--- a/cmake/QtExecutableHelpers.cmake
+++ b/cmake/QtExecutableHelpers.cmake
@@ -34,6 +34,11 @@ function(qt_internal_add_executable name)
add_executable("${name}" ${arg_EXE_FLAGS})
endif()
+ if(arg_QT_APP AND QT_FEATURE_debug_and_release AND CMAKE_VERSION VERSION_GREATER_EQUAL "3.19.0")
+ set_property(TARGET "${target}"
+ PROPERTY EXCLUDE_FROM_ALL "$<NOT:$<CONFIG:${QT_MULTI_CONFIG_FIRST_CONFIG}>>")
+ endif()
+
if (arg_VERSION)
if(arg_VERSION MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+")
# nothing to do
@@ -141,8 +146,18 @@ function(qt_internal_add_executable name)
RUNTIME "${arg_INSTALL_DIRECTORY}"
LIBRARY "${arg_INSTALL_DIRECTORY}"
BUNDLE "${arg_INSTALL_DIRECTORY}")
+
+ # Make installation optional for targets that are not built by default in this config
+ if(NOT exclude_from_all AND arg_QT_APP AND QT_FEATURE_debug_and_release
+ AND NOT (cmake_config STREQUAL QT_MULTI_CONFIG_FIRST_CONFIG))
+ set(install_optional_arg "OPTIONAL")
+ else()
+ unset(install_optional_arg)
+ endif()
+
qt_install(TARGETS "${name}"
${additional_install_args} # Needs to be before the DESTINATIONS.
+ ${install_optional_arg}
CONFIGURATIONS ${cmake_config}
${install_targets_default_args})
endforeach()