VS: COMPILE_PDB_OUTPUT_DIRECTORY is treated as file when CUDA is enabled
I setup the COMPILE_PDB_OUTPUT_DIRECTORY property for a static library:
set_target_properties(my_static_lib PROPERTIES COMPILE_PDB_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/pdb)
If CUDA language is not enabled, e.g. project(my_proj CXX)
, the ProgramDataBaseFileName
is correct in the generated my_static_lib.vcxproj
with CMake 3.29.0 and Visual Studio 17.9.5:
<ProgramDataBaseFileName>c:\build\pdb\Debug\</ProgramDataBaseFileName>
However, if CUDA language is enabled via project(my_proj CXX CUDA)
, the generated ProgramDataBaseFileName
would become a relative path WITHOUT the trailing backslash, and it would be treated as a file path:
<ProgramDataBaseFileName>pdb\Debug</ProgramDataBaseFileName>
I think the root cause may be that cmVisualStudio10TargetGenerator::ConvertPath
is called when CUDA is enabled (https://gitlab.kitware.com/cmake/cmake/-/blob/c3864d7f62710b8c16c6e8f1d2864472d374a5dd/Source/cmVisualStudio10TargetGenerator.cxx#L3613), but the method doesn't preserve the trailing backslash.