0

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

2
  • So, the variable CMAKE_BUILD_PARALLEL_LEVEL is 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? Commented Nov 17, 2023 at 22:54
  • It is you (as a project's author) who should set the variable. If you want to detect the number of processors in the current system, then you could use ProcessorCount functionality, as in that question. Commented Nov 17, 2023 at 22:59

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.