You do not really answer my question.
- If you do invoke
make
then you may define make options in your environmentMAKEFLAGS=-j5
- if you do invoke
cmake --build
then you mayCMAKE_BUILD_PARALLEL_LEVEL=5
In any case this is a user choice so such config ought to stay in user’s hand not in the CMakeLists.txt
You may invoke such parallel build using a custom_target
if you prefer that:
add_custom_target(my_parallel_build
COMMAND ${CMAKE_COMMAND} --build -j 5
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "My parallel build with 5 cores")
and then you would invoke:
make my_parallel_build