From b88a3147639e3abbd2f007e40b2dd1ba21eb3f93 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Fri, 17 Apr 2026 14:34:35 +1000 Subject: [PATCH] deps builld: Try to honour CMAKE_BUILD_PARALLEL_LEVEL (#13158) * deps: Use CMAKE_BUILD_PARALLEL_LEVEL for dependency builds. If set when initial CMake is run, don't hard-code the number of CPUs for all the recursive child builds. * build_linux: Pass -j1 for dependency build. This is recommended by the comment at the top of deps/CMakeLists.txt, and makes sense as the recursive build steps will pick up CMAKE_BUILD_PARALLEL_LEVEL (otherwise the number of parallel jobs is squared). --- build_linux.sh | 2 +- deps/CMakeLists.txt | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/build_linux.sh b/build_linux.sh index 45f0eebe8e..b23998b185 100755 --- a/build_linux.sh +++ b/build_linux.sh @@ -517,7 +517,7 @@ if [[ -n "${BUILD_DEPS}" ]] ; then fi print_and_run cmake -S deps -B deps/$BUILD_DIR "${CMAKE_C_CXX_COMPILER_CLANG[@]}" "${CMAKE_LLD_LINKER_ARGS[@]}" -G Ninja "${COLORED_OUTPUT}" "${BUILD_ARGS[@]}" - print_and_run cmake --build deps/$BUILD_DIR + print_and_run cmake --build deps/$BUILD_DIR -j1 fi if [[ -n "${BUILD_ORCA}" ]] || [[ -n "${BUILD_TESTS}" ]] ; then diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index a90de994db..13bde6b307 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -166,11 +166,18 @@ function(orcaslicer_add_cmake_project projectname) endif () endif () - set(_gen "") - set(_build_j "-j${NPROC}") if (MSVC) - set(_gen CMAKE_GENERATOR "${DEP_MSVC_GEN}" CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}") - set(_build_j "/m") + set(_gen CMAKE_GENERATOR "${DEP_MSVC_GEN}" CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}") + else() + set(_gen "") + endif() + + if ($ENV{CMAKE_BUILD_PARALLEL_LEVEL}) + set(_build_j "") # assume environment will control --build parallel setting + elseif(MSVC) + set(_build_j "/m") + else() + set(_build_j "-j${NPROC}") endif () if (NOT IS_CROSS_COMPILE OR NOT APPLE)