2020-12-02 05:37:26 +08:00
|
|
|
#[===[.md:
|
|
|
|
# vcpkg_copy_pdbs
|
|
|
|
|
|
|
|
Automatically locate pdbs in the build tree and copy them adjacent to all DLLs.
|
|
|
|
|
|
|
|
```cmake
|
2021-03-01 05:17:19 +08:00
|
|
|
vcpkg_copy_pdbs(
|
|
|
|
[BUILD_PATHS <glob>...])
|
2020-12-02 05:37:26 +08:00
|
|
|
```
|
|
|
|
|
2021-03-01 05:17:19 +08:00
|
|
|
The `<glob>`s are patterns which will be passed to `file(GLOB_RECURSE)`,
|
|
|
|
for locating DLLs. It defaults to using:
|
|
|
|
|
|
|
|
- `${CURRENT_PACKAGES_DIR}/bin/*.dll`
|
|
|
|
- `${CURRENT_PACKAGES_DIR}/debug/bin/*.dll`
|
2020-12-02 05:37:26 +08:00
|
|
|
|
2021-03-01 05:17:19 +08:00
|
|
|
since that is generally where DLLs are located.
|
2020-12-02 05:37:26 +08:00
|
|
|
|
2021-03-01 05:17:19 +08:00
|
|
|
## Notes
|
|
|
|
This command should always be called by portfiles after they have finished rearranging the binary output.
|
2020-12-02 05:37:26 +08:00
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
* [zlib](https://github.com/Microsoft/vcpkg/blob/master/ports/zlib/portfile.cmake)
|
|
|
|
* [cpprestsdk](https://github.com/Microsoft/vcpkg/blob/master/ports/cpprestsdk/portfile.cmake)
|
|
|
|
#]===]
|
2016-09-19 11:50:08 +08:00
|
|
|
function(vcpkg_copy_pdbs)
|
2021-03-01 05:17:19 +08:00
|
|
|
cmake_parse_arguments(PARSE_ARGV 0 "arg" "" "" "BUILD_PATHS")
|
|
|
|
|
2021-07-30 00:47:35 +08:00
|
|
|
if(DEFINED arg_UNPARSED_ARGUMENTS)
|
|
|
|
message(WARNING "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
|
|
|
|
endif()
|
|
|
|
|
2021-03-01 05:17:19 +08:00
|
|
|
if(NOT DEFINED arg_BUILD_PATHS)
|
2021-07-30 00:47:35 +08:00
|
|
|
set(arg_BUILD_PATHS
|
2021-03-01 05:17:19 +08:00
|
|
|
"${CURRENT_PACKAGES_DIR}/bin/*.dll"
|
|
|
|
"${CURRENT_PACKAGES_DIR}/debug/bin/*.dll"
|
2018-06-17 00:42:25 +08:00
|
|
|
)
|
|
|
|
endif()
|
2016-11-01 03:29:41 +08:00
|
|
|
|
2021-07-30 00:47:35 +08:00
|
|
|
set(dlls_without_matching_pdbs "")
|
2016-09-19 11:50:08 +08:00
|
|
|
|
2021-03-01 05: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-19 11:50:08 +08:00
|
|
|
|
2021-03-01 05:17:19 +08:00
|
|
|
set(vslang_backup "$ENV{VSLANG}")
|
2017-01-26 10:32:24 +08:00
|
|
|
set(ENV{VSLANG} 1033)
|
|
|
|
|
2021-03-01 05:17:19 +08:00
|
|
|
foreach(dll IN LISTS dlls)
|
2021-07-30 00:47:35 +08:00
|
|
|
execute_process(COMMAND dumpbin /PDBPATH "${dll}"
|
2016-11-01 03:29:41 +08:00
|
|
|
COMMAND findstr PDB
|
2021-03-01 05:17:19 +08:00
|
|
|
OUTPUT_VARIABLE pdb_line
|
2016-11-01 03:29:41 +08:00
|
|
|
ERROR_QUIET
|
|
|
|
RESULT_VARIABLE error_code
|
|
|
|
)
|
2016-09-19 11:50:08 +08:00
|
|
|
|
2021-07-30 00:47:35 +08: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-03-01 05:17:19 +08:00
|
|
|
file(COPY "${pdb_path}" DESTINATION "${dll_dir}")
|
2016-11-01 03:29:41 +08:00
|
|
|
else()
|
2021-03-01 05:17:19 +08:00
|
|
|
list(APPEND dlls_without_matching_pdbs "${dll}")
|
2016-11-01 03:29:41 +08:00
|
|
|
endif()
|
|
|
|
endforeach()
|
2016-09-19 11:50:08 +08:00
|
|
|
|
2021-03-01 05:17:19 +08:00
|
|
|
set(ENV{VSLANG} "${vslang_backup}")
|
2017-01-26 10:32:24 +08:00
|
|
|
|
2021-08-11 01:00:29 +08:00
|
|
|
if(NOT dlls_without_matching_pdbs STREQUAL "")
|
2021-03-01 05:17:19 +08:00
|
|
|
list(JOIN dlls_without_matching_pdbs "\n " message)
|
2021-07-30 00:47:35 +08:00
|
|
|
message(WARNING "Could not find a matching pdb file for:
|
|
|
|
${message}\n")
|
2016-11-01 03:29:41 +08:00
|
|
|
endif()
|
2016-09-19 11:50:08 +08:00
|
|
|
endif()
|
|
|
|
|
2020-12-02 05:37:26 +08:00
|
|
|
endfunction()
|