diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-11-06 21:48:08 +0100 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-11-10 04:24:28 +0100 |
commit | 5b136abd21803988f96b9b66c992822efbef97ec (patch) | |
tree | b5266a5ba068f93bf57dc78ba744535dd6630a3f | |
parent | b8b75cdcfa71189c7726607be7b66d0ddeaae372 (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>
-rw-r--r-- | cmake/QtAppHelpers.cmake | 6 | ||||
-rw-r--r-- | cmake/QtBuild.cmake | 2 | ||||
-rw-r--r-- | cmake/QtExecutableHelpers.cmake | 15 | ||||
-rw-r--r-- | cmake/QtToolHelpers.cmake | 10 |
4 files changed, 27 insertions, 6 deletions
diff --git a/cmake/QtAppHelpers.cmake b/cmake/QtAppHelpers.cmake index e7f96b8c52..ff32be0b89 100644 --- a/cmake/QtAppHelpers.cmake +++ b/cmake/QtAppHelpers.cmake @@ -16,6 +16,7 @@ function(qt_internal_add_app target) endif() qt_internal_add_executable("${target}" + QT_APP DELAY_RC DELAY_TARGET_INFO OUTPUT_DIRECTORY "${output_directory}" @@ -48,11 +49,6 @@ function(qt_internal_add_app target) # if CONFIG += console was encountered during conversion. set_target_properties("${target}" PROPERTIES WIN32_EXECUTABLE TRUE) - if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.19.0" AND QT_FEATURE_debug_and_release) - set_property(TARGET "${target}" - PROPERTY EXCLUDE_FROM_ALL "$<NOT:$<CONFIG:${QT_MULTI_CONFIG_FIRST_CONFIG}>>") - endif() - qt_add_list_file_finalizer(qt_internal_finalize_app ${target}) endfunction() diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index 052f5ea3de..5fc98f033c 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -445,7 +445,7 @@ set(__qt_add_plugin_multi_args # Collection of arguments so they can be shared across qt_internal_add_executable # and qt_internal_add_test_helper. set(__qt_internal_add_executable_optional_args - "GUI;BOOTSTRAP;NO_QT;NO_INSTALL;EXCEPTIONS;DELAY_RC;DELAY_TARGET_INFO" + "GUI;BOOTSTRAP;NO_QT;NO_INSTALL;EXCEPTIONS;DELAY_RC;DELAY_TARGET_INFO;QT_APP" ) set(__qt_internal_add_executable_single_args "OUTPUT_DIRECTORY;INSTALL_DIRECTORY;VERSION" 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() diff --git a/cmake/QtToolHelpers.cmake b/cmake/QtToolHelpers.cmake index a54fbfa3de..3d9d53c49b 100644 --- a/cmake/QtToolHelpers.cmake +++ b/cmake/QtToolHelpers.cmake @@ -195,8 +195,18 @@ function(qt_internal_add_tool target_name) OUT_VAR install_targets_default_args CMAKE_CONFIG "${cmake_config}" ALL_CMAKE_CONFIGS "${cmake_configs}") + + # Make installation optional for targets that are not built by default in this config + if(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 "${target_name}" ${install_initial_call_args} + ${install_optional_arg} CONFIGURATIONS ${cmake_config} ${install_targets_default_args}) unset(install_initial_call_args) |