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>
This commit is contained in:
parent
b8b75cdcfa
commit
5b136abd21
@ -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()
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user