Skip to content
Snippets Groups Projects
Commit febb3fe2 authored by Ben Boeckel's avatar Ben Boeckel
Browse files

ci: limit builds through the machine load

This allows other jobs to cooperatively schedule with a build.
parent ba7c8ff2
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,20 @@ ctest_read_custom_files("${CTEST_BINARY_DIRECTORY}")
# Pick up from where the configure left off.
ctest_start(APPEND)
include(ProcessorCount)
ProcessorCount(nproc)
if (NOT "$ENV{CTEST_MAX_PARALLELISM}" STREQUAL "")
if (nproc GREATER "$ENV{CTEST_MAX_PARALLELISM}")
set(nproc "$ENV{CTEST_MAX_PARALLELISM}")
endif ()
endif ()
if (CTEST_CMAKE_GENERATOR STREQUAL "Unix Makefiles")
set(CTEST_BUILD_FLAGS "-j${nproc} -l${nproc}")
elseif (CTEST_CMAKE_GENERATOR MATCHES "Ninja")
set(CTEST_BUILD_FLAGS "-l${nproc}")
endif ()
set(targets_to_build "all")
foreach (target IN LISTS targets_to_build)
......@@ -16,7 +30,7 @@ foreach (target IN LISTS targets_to_build)
if (CTEST_CMAKE_GENERATOR MATCHES "Make")
# Drop the `-i` flag without remorse.
set(CTEST_BUILD_COMMAND "make -j 4 ${CTEST_BUILD_FLAGS}")
set(CTEST_BUILD_COMMAND "make ${CTEST_BUILD_FLAGS}")
if (NOT target STREQUAL "all")
set(CTEST_BUILD_COMMAND "${CTEST_BUILD_COMMAND} ${target}")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment