clang-cl: No PDB generated for libraries with ClangCL on MSVC
I'm using cmake 3.18.1 with Visual Studio 2019 x64 and the clang-cl shipped with Visual Studio. Generally the build works quite well when setting CC=clang-cl.exe
and CXX=clang-cl.exe
after adding the clang-cl directory to PATH
. I can see that cmake detects also lld-link.exe
for CMAKE_LINKER
, and most of my builds "just work".
However I've just realized that no PDB
files are generated for any libraries, not shared nor static ones. I'm using the following code to generate PDB's (that works on "classic" MSVC successfully):
if(TARGET_TYPE STREQUAL "SHARED_LIBRARY")
set_target_properties("${LIBRARYNAME}" PROPERTIES
PDB_NAME "${LIBRARYNAME}"
PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
elseif(TARGET_TYPE STREQUAL "STATIC_LIBRARY")
set_target_properties("${LIBRARYNAME}" PROPERTIES
COMPILE_PDB_NAME "${LIBRARYNAME}"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endif()
Are PDB's for libraries already supported with clang-cl and cmake? Is there some way to enable them?
We try to preserve PDB debug information so we can later get back to debugging released binaries.
Edited by Brad King