"fatal error C1041" errors when using Ninja/MSVC and setting COMPILE_PDB_NAME
I'm reliably getting
[10/42] Building CXX object libs\conta...src\synchronized_pool_resource.cpp.obj
FAILED: libs/container/CMakeFiles/boost_container.dir/src/synchronized_pool_reso
urce.cpp.obj
"C:\PROGRA~2\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\bi
n\Hostx86\x86\cl.exe" /nologo /TP -DBOOST_CONTAINER_NO_LIB -I..\libs\container\
include -I..\libs\assert\include -I..\libs\config\include -I..\libs\container_ha
sh\include -I..\libs\core\include -I..\libs\detail\include -I..\libs\preprocesso
r\include -I..\libs\static_assert\include -I..\libs\type_traits\include -I..\lib
s\integer\include -I..\libs\throw_exception\include -I..\libs\intrusive\include
-I..\libs\move\include /DWIN32 /D_WINDOWS /GR /EHsc /Zi /Ob0 /Od /RTC1 -MTd /sho
wIncludes /Folibs\container\CMakeFiles\boost_container.dir\src\synchronized_pool
_resource.cpp.obj /Fdstage\lib\libboost_container-vc142-mt-sgd-x32-1_73.pdb /FS
-c ..\libs\container\src\synchronized_pool_resource.cpp
..\libs\container\src\synchronized_pool_resource.cpp: fatal error C1041: cannot
open program database 'C:\boost-git\develop\__build_ninja\stage\lib\libboost_con
tainer-vc142-mt-sgd-x32-1_73.pdb'; if multiple CL.EXE write to the same .PDB fil
e, please use /FS
ninja: build stopped: subcommand failed.
errors when using Ninja and MSVC and when COMPILE_PDB_NAME is set.
The error reliably disappears when /FS is added to CMAKE_CXX_FLAGS.
The interesting thing here is that /FS is already passed by CMake - it's visible in the error message above, the last argument on the command line before -c.
I can only conclude that the order of /FS and /Fd is significant, and that /FS must precede /Fd to have an effect.