Set CMAKE_BUILD_PARALLEL_LEVEL and CTEST_PARALLEL_LEVEL from CMake config file?
Hi,
I'm wondering if it's possible to set default values for CMAKE_BUILD_PARALLEL_LEVEL
and CTEST_PARALLEL_LEVEL
directly from the CMake file at config time. The problem right now is that they are environment variables, so I cannot really set them from the CMake file (I have to define their value in the parent process before calling cmake --build
or ctest
).
The problem I have is I am building on a machine with limited RAM, and I want to limit the parallelism based on available physical memory. Typically I'd like to limit to 2 parallel jobs even though the machine has 4 physical cores. I can do the math thanks to cmake_host_system_information()
, but I cannot set the env variables for later use directly from the CMake config file