diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-02-26 11:41:20 +0100 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-03-06 13:38:37 +0100 |
commit | d0911d0a92f47996fcba5520a8a91fe47e10f4a6 (patch) | |
tree | 652064c2633931ea62441defc9a29dafd1ef773a /cmake | |
parent | a3d0ef019a2a592d55035adc784d5d0475f39a74 (diff) |
CMake: Port the 'separate_debug_info' feature
For this, we have to uninline the separate_debug_info configure test,
because supporting the conversion of this in configurejson2cmake is not
worth the hassle.
Separate debug information can be turned on for a target by calling the
function qt_enable_separate_debug_info. For Qt's shared libraries and
tools separate debug information is generated if the
'separate_debug_info' feature is manually turned on.
Change-Id: Ic2ffc15efef3794dc0aa42f3d853ef6d651a751c
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/QtBaseGlobalTargets.cmake | 2 | ||||
-rw-r--r-- | cmake/QtBuild.cmake | 9 | ||||
-rw-r--r-- | cmake/QtSeparateDebugInfo.Info.plist.in | 16 | ||||
-rw-r--r-- | cmake/QtSeparateDebugInfo.cmake | 73 |
4 files changed, 100 insertions, 0 deletions
diff --git a/cmake/QtBaseGlobalTargets.cmake b/cmake/QtBaseGlobalTargets.cmake index a788392bad..32f0fa8c5f 100644 --- a/cmake/QtBaseGlobalTargets.cmake +++ b/cmake/QtBaseGlobalTargets.cmake @@ -234,6 +234,8 @@ qt_copy_or_install(FILES cmake/QtPlatformSupport.cmake cmake/QtPlatformAndroid.cmake cmake/QtPostProcess.cmake + cmake/QtSeparateDebugInfo.Info.plist.in + cmake/QtSeparateDebugInfo.cmake cmake/QtSetup.cmake cmake/QtModuleConfig.cmake.in cmake/QtModuleDependencies.cmake.in diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index 8de0abf25f..defbe066d3 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -1,4 +1,5 @@ include(CMakePackageConfigHelpers) +include(QtSeparateDebugInfo) # Install locations: set(INSTALL_BINDIR "bin" CACHE STRING "Executables [PREFIX/bin]") @@ -1611,6 +1612,10 @@ function(qt_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() @@ -3339,6 +3344,10 @@ function(qt_add_tool name) EXPORT "${INSTALL_CMAKE_NAMESPACE}${arg_TOOLS_TARGET}ToolsTargets" DESTINATION ${INSTALL_TARGETS_DEFAULT_ARGS}) endif() + + if(QT_FEATURE_separate_debug_info AND (UNIX OR MINGW)) + qt_enable_separate_debug_info(${name} ${INSTALL_BINDIR}) + endif() endfunction() function(qt_create_tracepoints name tracePointsFile) diff --git a/cmake/QtSeparateDebugInfo.Info.plist.in b/cmake/QtSeparateDebugInfo.Info.plist.in new file mode 100644 index 0000000000..d3e8dfbe7f --- /dev/null +++ b/cmake/QtSeparateDebugInfo.Info.plist.in @@ -0,0 +1,16 @@ +<?xml version=\"1.0\" encoding=\"UTF-8\"?> +<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"> +<plist version=\"1.0\"> + <dict> + <key>CFBundleIdentifier</key> + <string>com.apple.xcode.dsym.${BUNDLE_ID}</string> + <key>CFBundlePackageType</key> + <string>dSYM</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleShortVersionString</key> + <string>${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}</string> + <key>CFBundleVersion</key> + <string>${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}</string> + </dict> +</plist> diff --git a/cmake/QtSeparateDebugInfo.cmake b/cmake/QtSeparateDebugInfo.cmake new file mode 100644 index 0000000000..5e71775431 --- /dev/null +++ b/cmake/QtSeparateDebugInfo.cmake @@ -0,0 +1,73 @@ +include(CMakeFindBinUtils) + +set(QtSeparateDebugInfo_cmake_DIR ${CMAKE_CURRENT_LIST_DIR}) + +# Enable separate debug information for the given target +function(qt_enable_separate_debug_info target installDestination) + unset(commands) + if(APPLE) + find_program(DSYMUTIL_PROGRAM dsymutil) + set(copy_bin ${DSYMUTIL_PROGRAM}) + set(strip_bin ${CMAKE_STRIP}) + set(debug_info_suffix dSYM) + set(copy_bin_out_arg --flat -o) + set(strip_args -S) + else() + set(copy_bin ${CMAKE_OBJCOPY}) + set(strip_bin ${CMAKE_OBJCOPY}) + if(QNX) + set(debug_info_suffix sym) + set(debug_info_keep --keep-file-symbols) + set(strip_args "--strip-debug -R.ident") + else() + set(debug_info_suffix debug) + set(debug_info_keep --only-keep-debug) + set(strip_args --strip-debug) + endif() + endif() + if(APPLE) + get_target_property(is_framework ${target} FRAMEWORK) + if(is_framework) + set(debug_info_bundle_dir "$<TARGET_BUNDLE_DIR:${target}>.${debug_info_suffix}") + set(BUNDLE_ID Qt${target}) + else() + set(debug_info_bundle_dir "$<TARGET_FILE:${target}>.${debug_info_suffix}") + set(BUNDLE_ID ${target}) + endif() + set(debug_info_contents_dir "${debug_info_bundle_dir}/Contents") + set(debug_info_target_dir "${debug_info_contents_dir}/Resources/DWARF") + configure_file( + "${QtSeparateDebugInfo_cmake_DIR}/QtSeparateDebugInfo.Info.plist.in" + "Info.dSYM.plist" + ) + list(APPEND commands + COMMAND ${CMAKE_COMMAND} -E make_directory ${debug_info_target_dir} + COMMAND ${CMAKE_COMMAND} -E copy "Info.dSYM.plist" "${debug_info_contents_dir}/Info.plist" + ) + set(debug_info_target "${debug_info_target_dir}/$<TARGET_FILE_BASE_NAME:${target}>") + qt_install(DIRECTORY ${debug_info_bundle_dir} DESTINATION ${installDestination}) + else() + set(debug_info_target "$<TARGET_FILE_DIR:${target}>/$<TARGET_FILE_BASE_NAME:${target}>.${debug_info_suffix}") + qt_install(FILES ${debug_info_target} DESTINATION ${installDestination}) + endif() + list(APPEND commands + COMMAND ${copy_bin} ${debug_info_keep} $<TARGET_FILE:${target}> + ${copy_bin_out_arg} ${debug_info_target} + COMMAND ${strip_bin} ${strip_args} $<TARGET_FILE:${target}> + ) + if(NOT APPLE) + list(APPEND commands + COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=${debug_info_target} $<TARGET_FILE:${target}> + ) + endif() + if(NOT CMAKE_HOST_WIN32) + list(APPEND commands + COMMAND chmod -x ${debug_info_target} + ) + endif() + add_custom_command( + TARGET ${target} + POST_BUILD + ${commands} + ) +endfunction() |