3

I am converting some projects to CMake and vcpkg. However when I use Debug or RelWithDebInfo build types the build only copies the .dll files and not the .pdb files from vcpkg.

Here is an example CMakeLists.txt:

cmake_minimum_required(VERSION 3.22)

project(PdbTest)

find_package(fmt CONFIG REQUIRED)

add_executable(Test main.cpp)
target_link_libraries(Test PRIVATE fmt::fmt)

After running:

cmake .. --toolchain C:\Tools\vcpkg\scripts\buildsystems\vcpkg.cmake
cmake --build . --config RelWithDebInfo

Gere are the files generated in <build-dir>\RelWithDebInfo, fmt.dll dos not have a corresponding fmt.pdb:

25/07/2022  06:54 am           134,144 fmt.dll
25/07/2022  07:04 am            41,984 Test.exe
25/07/2022  07:04 am         1,028,096 Test.pdb

Possible Solution:

I've searched around a bit and I did find an internal vcpkg script that finds the paths of the pdbs from the dlls and copies the pdbs into the vcpkg installed directory when vcpkg builds its libraries:

https://github.com/microsoft/vcpkg/blob/master/scripts/cmake/vcpkg_copy_pdbs.cmake

So I thought I may copy this script and use it for my own CMake builds, it may work if the vcpkg builds occur on the same machine. Probably will need a bit of tinkering to get it to work.

But maybe there is a better way?

wozname
  • 213
  • 3
  • 10
  • I too would like to know the answer to this, as I want to have the pdbs for dependent DLLs copied with the DLL to the output directory. I've looked into it a bit but haven't found a satisfactory solution (hence the comment not answer). From what I can deduce the post build step runs `vcpkg\scripts\buildsystems\msbuild\applocal.ps1` which deploys the dependencies to the output directory but it doesn't itself copy pdb files. The one question though is if you actually want to be debugging a dependency library or if you just want to debug your application. Might need to create a patch. – Dominik Grabiec Oct 01 '22 at 16:57

0 Answers0