diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2021-04-06 14:43:49 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2021-04-06 15:16:09 (GMT) |
commit | 3fd2cffb4d4649f7773297d5af7a6bda5ef9a69b (patch) | |
tree | 817b2318a82040157114ab1e2e2c50676e0349ca /.gitlab | |
parent | 6317f92120bba15c6ea8ee02c47ebff4afb5c53c (diff) | |
download | CMake-3fd2cffb4d4649f7773297d5af7a6bda5ef9a69b.zip CMake-3fd2cffb4d4649f7773297d5af7a6bda5ef9a69b.tar.gz CMake-3fd2cffb4d4649f7773297d5af7a6bda5ef9a69b.tar.bz2 |
ci: limit builds by machine load
To avoid starving test jobs, the build jobs should also back off if
there is a lot of machine load.
Diffstat (limited to '.gitlab')
-rw-r--r-- | .gitlab/ci/ctest_build.cmake | 14 | ||||
-rw-r--r-- | .gitlab/ci/ctest_test_external.cmake | 4 |
2 files changed, 14 insertions, 4 deletions
diff --git a/.gitlab/ci/ctest_build.cmake b/.gitlab/ci/ctest_build.cmake index 6402a5d..e7a0985 100644 --- a/.gitlab/ci/ctest_build.cmake +++ b/.gitlab/ci/ctest_build.cmake @@ -8,10 +8,18 @@ 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") - include(ProcessorCount) - ProcessorCount(nproc) - set(CTEST_BUILD_FLAGS "-j${nproc}") + set(CTEST_BUILD_FLAGS "-j${nproc} -l${nproc}") +elseif (CTEST_CMAKE_GENERATOR MATCHES "Ninja") + set(CTEST_BUILD_FLAGS "-l${nproc}") endif () ctest_build( diff --git a/.gitlab/ci/ctest_test_external.cmake b/.gitlab/ci/ctest_test_external.cmake index 9de06d1..6576c26 100644 --- a/.gitlab/ci/ctest_test_external.cmake +++ b/.gitlab/ci/ctest_test_external.cmake @@ -42,7 +42,9 @@ if (NOT "$ENV{CTEST_MAX_PARALLELISM}" STREQUAL "") endif () if (CTEST_CMAKE_GENERATOR STREQUAL "Unix Makefiles") - set(CTEST_BUILD_FLAGS "-j${nproc}") + set(CTEST_BUILD_FLAGS "-j${nproc} -l${nproc}") +elseif (CTEST_CMAKE_GENERATOR MATCHES "Ninja") + set(CTEST_BUILD_FLAGS "-l${nproc}") endif () ctest_build( |