Issue
I have a cmake project and I'm using the msvc 2019 generator on windows 10.
I can successfully build with the following:
cmake -S . -B build
cd build
cmake --build . -- /m
I'm interested in passing the /m
switch to msbuild.exe within the CMakeLists.txt
itself.
I've tried the following without success as arguments get passed to cl.exe:
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /m")
message(STATUS "NOTICE: Setting parallel build for msbuild.exe")
add_definitions(/M)
endif()
Also bonus question: How does --
work in the last cmake command above? I'm struggling finding documentation on it.
Solution
The answer as @Johnny_xy pointed out is you can't. You need to use ninja as the cmake generator.
cmake -S . -B build -G Ninja Multi-Config
cd build
cmake --build .
link to ninja releases: https://github.com/ninja-build/ninja/releases
ninja build time: 17.51s cmake default build time: 44.54s
Answered By - David Answer Checked By - Robin (WPSolving Admin)