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")
|
|
|
|
|
|
|
|
if(NOT DEFINED arg_BUILD_PATHS)
|
2018-06-17 00:42:25 +08:00
|
|
|
set(
|
2021-03-01 05:17:19 +08:00
|
|
|
arg_BUILD_PATHS
|
|
|
|
"${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-03-01 05:17:19 +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)
|
|
|
|
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-03-01 05:17:19 +08:00
|
|
|
if(NOT error_code AND pdb_line MATCHES "PDB file found at")
|
|
|
|
string(REGEX MATCH [['.*']] pdb_path "${pdb_line}") # Extract the path which is in single quotes
|
|
|
|
string(REPLACE "'" "" pdb_path "${pdb_path}") # Remove single quotes
|
|
|
|
get_filename_component(dll_dir "${dll}" DIRECTORY)
|
|
|
|
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-03-01 05:17:19 +08:00
|
|
|
list(LENGTH dlls_without_matching_pdbs unmatched_dlls_length)
|
|
|
|
if(unmatched_dlls_length GREATER 0)
|
|
|
|
list(JOIN dlls_without_matching_pdbs "\n " message)
|
|
|
|
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()
|