diff --git a/cmake/QtExecutableHelpers.cmake b/cmake/QtExecutableHelpers.cmake index c90eb2150c5..54910f300b1 100644 --- a/cmake/QtExecutableHelpers.cmake +++ b/cmake/QtExecutableHelpers.cmake @@ -167,7 +167,14 @@ function(qt_internal_add_executable name) ${install_targets_default_args}) endforeach() - qt_enable_separate_debug_info(${name} "${arg_INSTALL_DIRECTORY}") + if(NOT exclude_from_all AND arg_QT_APP AND QT_FEATURE_debug_and_release) + set(separate_debug_info_executable_arg "QT_EXECUTABLE") + else() + unset(separate_debug_info_executable_arg) + endif() + qt_enable_separate_debug_info(${name} "${arg_INSTALL_DIRECTORY}" + ${separate_debug_info_executable_arg} + ADDITIONAL_INSTALL_ARGS ${additional_install_args}) qt_internal_install_pdb_files(${name} "${arg_INSTALL_DIRECTORY}") endif() diff --git a/cmake/QtSeparateDebugInfo.cmake b/cmake/QtSeparateDebugInfo.cmake index c31d618d00a..00ac4519fe7 100644 --- a/cmake/QtSeparateDebugInfo.cmake +++ b/cmake/QtSeparateDebugInfo.cmake @@ -6,6 +6,11 @@ endif() # Enable separate debug information for the given target function(qt_enable_separate_debug_info target installDestination) + set(flags QT_EXECUTABLE) + set(options) + set(multiopts ADDITIONAL_INSTALL_ARGS) + cmake_parse_arguments(arg "${flags}" "${options}" "${multiopts}" ${ARGN}) + if (NOT QT_FEATURE_separate_debug_info) return() endif() @@ -66,7 +71,27 @@ function(qt_enable_separate_debug_info target installDestination) COMMAND ${CMAKE_COMMAND} -E copy "Info.dSYM.plist" "${debug_info_contents_dir}/Info.plist" ) set(debug_info_target "${debug_info_target_dir}/$") - qt_install(DIRECTORY ${debug_info_bundle_dir} DESTINATION ${installDestination}) + + if(arg_QT_EXECUTABLE AND QT_FEATURE_debug_and_release) + qt_get_cmake_configurations(cmake_configs) + foreach(cmake_config ${cmake_configs}) + # Make installation optional for targets that are not built by default in this config + if(NOT (cmake_config STREQUAL QT_MULTI_CONFIG_FIRST_CONFIG)) + set(install_optional_arg OPTIONAL) + else() + unset(install_optional_arg) + endif() + qt_install(DIRECTORY ${debug_info_bundle_dir} + ${arg_ADDITIONAL_INSTALL_ARGS} + ${install_optional_arg} + CONFIGURATIONS ${cmake_config} + DESTINATION ${installDestination}) + endforeach() + else() + qt_install(DIRECTORY ${debug_info_bundle_dir} + ${arg_ADDITIONAL_INSTALL_ARGS} + DESTINATION ${installDestination}) + endif() else() set(debug_info_target "$/$.${debug_info_suffix}") qt_install(FILES ${debug_info_target} DESTINATION ${installDestination}) diff --git a/cmake/QtToolHelpers.cmake b/cmake/QtToolHelpers.cmake index c1b6b0cdbff..77dae500277 100644 --- a/cmake/QtToolHelpers.cmake +++ b/cmake/QtToolHelpers.cmake @@ -257,7 +257,7 @@ function(qt_internal_add_tool target_name) endif() - qt_enable_separate_debug_info(${target_name} "${install_dir}") + qt_enable_separate_debug_info(${target_name} "${install_dir}" QT_EXECUTABLE) qt_internal_install_pdb_files(${target_name} "${install_dir}") endfunction()