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
CMAKE_BUILD_PARALLEL_LEVELis empty in your case. This can be easily seen from the error message. If you wonder why the variable is empty, why do not directly ask that in the question?ProcessorCountfunctionality, as in that question.