From 4b5b7534aaa3eb8b5b148a8eedb70106e15ec323 Mon Sep 17 00:00:00 2001 From: BtbN Date: Tue, 15 Jul 2014 17:10:12 +0200 Subject: [PATCH] Copy and install PDB files on msvc builds --- cmake/Modules/ObsHelpers.cmake | 55 ++++++++++++++++++++++++++++++-- cmake/copy_on_debug_helper.cmake | 7 ++++ 2 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 cmake/copy_on_debug_helper.cmake diff --git a/cmake/Modules/ObsHelpers.cmake b/cmake/Modules/ObsHelpers.cmake index 14aa75868..5ce17a64f 100644 --- a/cmake/Modules/ObsHelpers.cmake +++ b/cmake/Modules/ObsHelpers.cmake @@ -191,6 +191,53 @@ macro(install_obs_headers) endforeach() endmacro() +function(obs_debug_copy_helper target dest) + add_custom_command(TARGET ${target} POST_BUILD + COMMAND "${CMAKE_COMMAND}" + "-DCONFIG=$" + "-DFNAME=$" + "-DINPUT=$" + "-DOUTPUT=${dest}" + -P "${CMAKE_SOURCE_DIR}/cmake/copy_on_debug_helper.cmake" + VERBATIM) +endfunction() + +function(install_obs_pdb ttype target) + if(NOT MSVC) + return() + endif() + + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(_bit_suffix "64bit") + else() + set(_bit_suffix "32bit") + endif() + + obs_debug_copy_helper(${target} "${CMAKE_CURRENT_BINARY_DIR}/pdbs") + + if("${ttype}" STREQUAL "PLUGIN") + obs_debug_copy_helper(${target} "${OBS_OUTPUT_DIR}/$/obs-plugins/${_bit_suffix}") + + if(DEFINED ENV{obsInstallerTempDir}) + obs_debug_copy_helper(${target} "$ENV{obsInstallerTempDir}/${OBS_PLUGIN_DESTINATION}") + endif() + + install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/pdbs/" + DESTINATION "${OBS_PLUGIN_DESTINATION}" + CONFIGURATIONS Debug RelWithDebInfo) + else() + obs_debug_copy_helper(${target} "${OBS_OUTPUT_DIR}/$/bin/${_bit_suffix}") + + if(DEFINED ENV{obsInstallerTempDir}) + obs_debug_copy_helper(${target} "$ENV{obsInstallerTempDir}/${OBS_EXECUTABLE_DESTINATION}") + endif() + + install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/pdbs/" + DESTINATION "${OBS_EXECUTABLE_DESTINATION}" + CONFIGURATIONS Debug RelWithDebInfo) + endif() +endfunction() + macro(install_obs_core target) if(CMAKE_SIZEOF_VOID_P EQUAL 8) set(_bit_suffix "64bit/") @@ -216,7 +263,6 @@ macro(install_obs_core target) "${OBS_OUTPUT_DIR}/$/bin/${_bit_suffix}$" VERBATIM) - if(DEFINED ENV{obsInstallerTempDir}) get_property(target_type TARGET ${target} PROPERTY TYPE) if("${target_type}" STREQUAL "EXECUTABLE") @@ -227,9 +273,12 @@ macro(install_obs_core target) add_custom_command(TARGET ${target} POST_BUILD COMMAND "${CMAKE_COMMAND}" -E copy - "$" "$ENV{obsInstallerTempDir}/${tmp_target_dir}/$" + "$" + "$ENV{obsInstallerTempDir}/${tmp_target_dir}/$" VERBATIM) endif() + + install_obs_pdb(CORE ${target}) endmacro() macro(install_obs_plugin target) @@ -258,6 +307,8 @@ macro(install_obs_plugin target) "$" "$ENV{obsInstallerTempDir}/${OBS_PLUGIN_DESTINATION}/$" VERBATIM) endif() + + install_obs_pdb(PLUGIN ${target}) endmacro() macro(install_obs_data target datadir datadest) diff --git a/cmake/copy_on_debug_helper.cmake b/cmake/copy_on_debug_helper.cmake new file mode 100644 index 000000000..dc28b9eac --- /dev/null +++ b/cmake/copy_on_debug_helper.cmake @@ -0,0 +1,7 @@ +string(REGEX REPLACE "\\.(dll|exe)$" ".pdb" FNAME "${FNAME}") + +if(CONFIG STREQUAL Debug OR CONFIG STREQUAL RelWithDebInfo) + file(COPY "${INPUT}/${FNAME}" DESTINATION "${OUTPUT}") +elseif(EXISTS "${OUTPUT}/${FNAME}") + file(REMOVE "${OUTPUT}/${FNAME}") +endif()