At the moment, if PDB_NAME isn't set, the PDB name is correctly derived from OUTPUT_NAME, taking into account PREFIX. COMPILE_PDB_NAME, however, isn't. The documentation says "unspecified" - is there a reason for this behavior?
Setting it manually is complicated by the fact that it doesn't accept generator expressions, so it's not possible to just reference $<TARGET_FILE_BASE_NAME:${LIB}>. It does have configuration-specific variants, but when (as in my case) OUTPUT_NAME itself is a complex generator expression, this unfortunately doesn't help.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items ...
Show closed items
Linked items 0
Link issues together to show that they're related.
Learn more.
IIRC the reason the default is unspecified is that not setting it means we pass only the directory to the compiler and let MSVC generate the file name. This is what .vcxproj files and MSBuild do by default.
The behavior I'm seeing is that, when OUTPUT_NAME is set, the name of the produced .lib file changes, but that of the produced .pdb file does not.
When CMAKE_LIBRARY_OUTPUT_DIRECTORY is set, this has the secondary effect of not copying the produced .pdb file to the output directory (presumably because the name doesn't match.)
(When OUTPUT_NAME is not set, the .pdb file is copied to CMAKE_LIBRARY_OUTPUT_DIRECTORY.)
Thanks for the example. I tried that with the Visual Studio 16 2019 generator. The only difference between the lib1.vcxproj and lib2.vcxproj files is the names given. There is no change in the fields generated by CMake. In fact updating the example with
produces identical behavior for both targets even though one has OUTPUT_NAME set and the other does not. CMake is not changing behavior based on this setting.
This difference in behavior must be something about how MSBuild behaves.
Yes, you are correct, this does seem to be MSBuild behavior, rather than CMake behavior.
My problem remains though; I need lib2_mt_x64.pdb to appear in the output directory, when OUTPUT_NAME is a generator expression, and there doesn't seem to be a way to do that.
We hit a related issue in c-ares too, where we would get errors like:
fatal error C1041: cannot open program database 'C:\projects\c-ares\build\bin\vc140.pdb'; if multiple CL.EXE write to the same .PDB file, please use /FS
This was mainly observed in AppVeyor and only occasionally, but of course annoying as it makes our CI workflow report failures.
Its not related to /FS however, which CMake appears to automatically add already, its because multiple targets are being built in parallel, but are trying to use the same pdb file. Using the suggestion in the subject of this ticket would have alleviated this issue.