CMake Build: Enable separate debug info for all target types

Now all shared libraries and executables will get .debug files on
the platforms that support FEATURE_separate_debug_info

With the directory property _qt_skip_separate_debug_info certain
targets can retain the debug symbols in the binary e.g. lupdate with
MinGW 8.1.0 will cause objcopy / strip to fail.

Fixes: QTBUG-87015
Change-Id: I03b106e68ef0a42011d1ba641e6f686b2e7b7fb4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Cristian Adam 2020-11-02 12:40:57 +01:00
parent f6418343f1
commit 68f3e37449
5 changed files with 32 additions and 7 deletions

View File

@ -244,6 +244,12 @@ function(qt_internal_add_3rdparty_library target)
CONFIG_INSTALL_DIR "${config_install_dir}"
)
endif()
set(debug_install_dir "${INSTALL_LIBDIR}")
if (MINGW)
set(debug_install_dir "${INSTALL_BINDIR}")
endif()
qt_enable_separate_debug_info(${target} "${debug_install_dir}")
qt_internal_install_pdb_files("${target}" "${INSTALL_LIBDIR}")
endfunction()

View File

@ -79,10 +79,6 @@ function(qt_internal_add_module target)
endif()
endif()
if(QT_FEATURE_separate_debug_info AND is_shared_lib AND (UNIX OR MINGW))
qt_enable_separate_debug_info(${target} ${INSTALL_LIBDIR})
endif()
if (ANDROID)
qt_android_apply_arch_suffix("${target}")
endif()
@ -612,6 +608,11 @@ set(QT_CMAKE_EXPORT_NAMESPACE ${QT_CMAKE_EXPORT_NAMESPACE})")
qt_finalize_framework_headers_copy(${target})
endif()
set(debug_install_dir "${INSTALL_LIBDIR}")
if (MINGW)
set(debug_install_dir "${INSTALL_BINDIR}")
endif()
qt_enable_separate_debug_info(${target} "${debug_install_dir}")
set(pdb_install_dir "${INSTALL_BINDIR}")
if(NOT is_shared_lib)
set(pdb_install_dir "${INSTALL_LIBDIR}")

View File

@ -286,6 +286,8 @@ function(qt_internal_add_plugin target)
qt_internal_add_linker_version_script(${target})
qt_add_list_file_finalizer(qt_finalize_plugin ${target} "${install_directory}")
qt_enable_separate_debug_info(${target} "${install_directory}")
qt_internal_install_pdb_files(${target} "${install_directory}")
endfunction()

View File

@ -6,6 +6,24 @@ endif()
# Enable separate debug information for the given target
function(qt_enable_separate_debug_info target installDestination)
if (NOT QT_FEATURE_separate_debug_info)
return()
endif()
if (NOT UNIX AND NOT MINGW)
return()
endif()
get_target_property(target_type ${target} TYPE)
if (NOT target_type STREQUAL "MODULE_LIBRARY" AND
NOT target_type STREQUAL "SHARED_LIBRARY" AND
NOT target_type STREQUAL "EXECUTABLE")
return()
endif()
get_property(target_source_dir TARGET ${target} PROPERTY SOURCE_DIR)
get_property(skip_separate_debug_info DIRECTORY "${target_source_dir}" PROPERTY _qt_skip_separate_debug_info)
if (skip_separate_debug_info)
return()
endif()
unset(commands)
if(APPLE)
find_program(DSYMUTIL_PROGRAM dsymutil)

View File

@ -206,9 +206,7 @@ function(qt_internal_add_tool target_name)
endif()
if(QT_FEATURE_separate_debug_info AND (UNIX OR MINGW))
qt_enable_separate_debug_info(${target_name} ${INSTALL_BINDIR})
endif()
qt_enable_separate_debug_info(${target_name} "${INSTALL_BINDIR}")
qt_internal_install_pdb_files(${target_name} "${INSTALL_BINDIR}")
endfunction()