2016-09-18 20:50:08 -07:00
|
|
|
function(vcpkg_copy_pdbs)
|
2021-02-28 13:17:19 -08:00
|
|
|
cmake_parse_arguments(PARSE_ARGV 0 "arg" "" "" "BUILD_PATHS")
|
|
|
|
|
2021-07-29 11:47:35 -05:00
|
|
|
if(DEFINED arg_UNPARSED_ARGUMENTS)
|
|
|
|
message(WARNING "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
|
|
|
|
endif()
|
|
|
|
|
2021-02-28 13:17:19 -08:00
|
|
|
if(NOT DEFINED arg_BUILD_PATHS)
|
2021-07-29 11:47:35 -05:00
|
|
|
set(arg_BUILD_PATHS
|
2021-02-28 13:17:19 -08:00
|
|
|
"${CURRENT_PACKAGES_DIR}/bin/*.dll"
|
|
|
|
"${CURRENT_PACKAGES_DIR}/debug/bin/*.dll"
|
2018-06-16 16:42:25 +00:00
|
|
|
)
|
|
|
|
endif()
|
2016-10-31 12:29:41 -07:00
|
|
|
|
2021-07-29 11:47:35 -05:00
|
|
|
set(dlls_without_matching_pdbs "")
|
2016-09-18 20:50:08 -07:00
|
|
|
|
2021-02-28 13:17:19 -08:00
|
|
|
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic" AND VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
|
|
|
|
file(GLOB_RECURSE dlls ${arg_BUILD_PATHS})
|
2016-09-18 20:50:08 -07:00
|
|
|
|
2021-02-28 13:17:19 -08:00
|
|
|
set(vslang_backup "$ENV{VSLANG}")
|
2017-01-25 18:32:24 -08:00
|
|
|
set(ENV{VSLANG} 1033)
|
|
|
|
|
2021-02-28 13:17:19 -08:00
|
|
|
foreach(dll IN LISTS dlls)
|
2021-07-29 11:47:35 -05:00
|
|
|
execute_process(COMMAND dumpbin /PDBPATH "${dll}"
|
2016-10-31 12:29:41 -07:00
|
|
|
COMMAND findstr PDB
|
2021-02-28 13:17:19 -08:00
|
|
|
OUTPUT_VARIABLE pdb_line
|
2016-10-31 12:29:41 -07:00
|
|
|
ERROR_QUIET
|
|
|
|
RESULT_VARIABLE error_code
|
|
|
|
)
|
2016-09-18 20:50:08 -07:00
|
|
|
|
2021-07-29 11:47:35 -05:00
|
|
|
if(error_code EQUAL "0" AND pdb_line MATCHES "PDB file found at.*'(.*)'")
|
|
|
|
set(pdb_path "${CMAKE_MATCH_1}")
|
|
|
|
cmake_path(GET dll PARENT_PATH dll_dir)
|
2021-02-28 13:17:19 -08:00
|
|
|
file(COPY "${pdb_path}" DESTINATION "${dll_dir}")
|
2016-10-31 12:29:41 -07:00
|
|
|
else()
|
2021-02-28 13:17:19 -08:00
|
|
|
list(APPEND dlls_without_matching_pdbs "${dll}")
|
2016-10-31 12:29:41 -07:00
|
|
|
endif()
|
|
|
|
endforeach()
|
2016-09-18 20:50:08 -07:00
|
|
|
|
2021-02-28 13:17:19 -08:00
|
|
|
set(ENV{VSLANG} "${vslang_backup}")
|
2017-01-25 18:32:24 -08:00
|
|
|
|
2021-08-11 01:00:29 +08:00
|
|
|
if(NOT dlls_without_matching_pdbs STREQUAL "")
|
2021-02-28 13:17:19 -08:00
|
|
|
list(JOIN dlls_without_matching_pdbs "\n " message)
|
2021-07-29 11:47:35 -05:00
|
|
|
message(WARNING "Could not find a matching pdb file for:
|
|
|
|
${message}\n")
|
2016-10-31 12:29:41 -07:00
|
|
|
endif()
|
2016-09-18 20:50:08 -07:00
|
|
|
endif()
|
|
|
|
|
2020-12-01 13:37:26 -08:00
|
|
|
endfunction()
|