diff --git a/cmake/QtPublicAppleHelpers.cmake b/cmake/QtPublicAppleHelpers.cmake index 0731e765e57..b5307de0879 100644 --- a/cmake/QtPublicAppleHelpers.cmake +++ b/cmake/QtPublicAppleHelpers.cmake @@ -499,6 +499,42 @@ function(_qt_internal_set_xcode_install_path target) endif() endfunction() +# Explicitly set the debug information format for each build configuration to match the values +# of a new project created via Xcode directly. This ensures debug information is included during +# archiving. +function(_qt_internal_set_xcode_debug_information_format target) + if(NOT DEFINED CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT + AND NOT QT_NO_SET_XCODE_DEBUG_INFORMATION_FORMAT) + get_target_property(existing "${target}" XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT) + if(NOT existing) + # The CMake Xcode generator searches for [variant=${config}], removes that substring, + # and generates the attribute only for the config that is specified as the "variant". + set_target_properties("${target}" PROPERTIES + "XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT[variant=Debug]" "dwarf") + set_target_properties("${target}" PROPERTIES + "XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT[variant=Release]" "dwarf-with-dsym") + set_target_properties("${target}" PROPERTIES + "XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT[variant=MinSizeRel]" "dwarf-with-dsym") + set_target_properties("${target}" PROPERTIES + "XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT[variant=RelWithDebInfo]" + "dwarf-with-dsym") + endif() + endif() +endfunction() + +# Make sure to always generate debug symbols, to match the values of a new project created via +# Xcode directly. +function(_qt_internal_set_xcode_generate_debugging_symbols target) + if(NOT DEFINED CMAKE_XCODE_ATTRIBUTE_GCC_GENERATE_DEBUGGING_SYMBOLS + AND NOT QT_NO_SET_XCODE_GCC_GENERATE_DEBUGGING_SYMBOLS) + get_target_property(existing "${target}" XCODE_ATTRIBUTE_GCC_GENERATE_DEBUGGING_SYMBOLS) + if(NOT existing) + set_target_properties("${target}" PROPERTIES + "XCODE_ATTRIBUTE_GCC_GENERATE_DEBUGGING_SYMBOLS" "YES") + endif() + endif() +endfunction() + function(_qt_internal_set_xcode_bundle_display_name target) # We want the value of CFBundleDisplayName to be ${PRODUCT_NAME}, but we can't put that # into the Info.plist.in template file directly, because the implicit configure_file(Info.plist) @@ -922,6 +958,9 @@ function(_qt_internal_finalize_apple_app target) _qt_internal_set_xcode_code_sign_style("${target}") _qt_internal_set_xcode_bundle_display_name("${target}") _qt_internal_set_xcode_install_path("${target}") + _qt_internal_set_xcode_configuration_build_dir("${target}") + _qt_internal_set_xcode_debug_information_format("${target}") + _qt_internal_set_xcode_generate_debugging_symbols("${target}") endif() _qt_internal_set_xcode_bundle_name("${target}")