in cmake version 3.27.7
I would like to set number of jobs (for -j
) to jobs = jobs//2 + 1
in CMakeLists.txt
with line
math(EXPR CMAKE_BUILD_PARALLEL_LEVEL "${CMAKE_BUILD_PARALLEL_LEVEL} / 2 + 1" OUTPUT_FORMAT DECIMAL)
but cmake throws CMake Error at CMakeLists.txt:11 (math): math cannot parse the expression: " / 2 + 1": syntax error, unexpected exp_DIVIDE (2).
my code is wrong or variable CMAKE_BUILD_PARALLEL_LEVEL
deserves special treatment? my CPU has 8 threads and I would like to set jobs to 5(or n//2+1
) for this project