The Visual Studio compiler generates and modifies many large project-wide binary files during compilation,
so normally you can only have one instance of cl
running per project. If you use the awesome Ninja tool,
it will happily run many instances in parallel on multicore systems. When run this way however, MSVC will
throw errors like this:
fatal error C1041: cannot open program database 'sample_project_pathname.pdb';
if multiple CL.EXE write to the same .PDB file, please use /FS
To avoid these annoying errors, add the following to your top-level CMakeLists.txt
script to enable strict file locking:
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
if(CMAKE_GENERATOR MATCHES "Ninja")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /FS")
endif()
endif()