diff options
author | Matt Smith <matt@offtopica.uk> | 2020-08-05 18:39:44 +0100 |
---|---|---|
committer | Matt Smith <matt@offtopica.uk> | 2020-08-29 16:34:42 +0100 |
commit | 12a78e5e745556c29e45b7716a8b038ecfbff800 (patch) | |
tree | 841b0760c3fd47dbe04494fda7b6fd0ae187e026 /CMakeLists.txt | |
parent | Merge pull request #6571 (diff) | |
download | monero-12a78e5e745556c29e45b7716a8b038ecfbff800.tar.xz |
cmake: Use job pool feature to limit concurrent jobs
Add two new options, MONERO_PARALLEL_COMPILE_JOBS and
MONERO_PARALLEL_LINK_JOBS to try and prevent running out of memory when
building everything.
Requires >= cmake 3.0.0, and the use of the Ninja generator.
Useful links:
* https://cmake.org/cmake/help/latest/prop_gbl/JOB_POOLS.html
* https://reviews.llvm.org/D6304
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index f63c07a35..3729a6b65 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,20 @@ else() message(STATUS "ccache deselected") endif() +if (${CMAKE_VERSION} VERSION_GREATER "3.0.0" AND CMAKE_MAKE_PROGRAM MATCHES "ninja") + set(MONERO_PARALLEL_COMPILE_JOBS "" CACHE STRING "The maximum number of concurrent compilation jobs.") + if (MONERO_PARALLEL_COMPILE_JOBS) + set_property(GLOBAL APPEND PROPERTY JOB_POOLS compile_job_pool=${MONERO_PARALLEL_COMPILE_JOBS}) + set(CMAKE_JOB_POOL_COMPILE compile_job_pool) + endif () + + set(MONERO_PARALLEL_LINK_JOBS "" CACHE STRING "The maximum number of concurrent link jobs.") + if (MONERO_PARALLEL_LINK_JOBS) + set_property(GLOBAL APPEND PROPERTY JOB_POOLS link_job_pool=${MONERO_PARALLEL_LINK_JOBS}) + set(CMAKE_JOB_POOL_LINK link_job_pool) + endif () +endif() + enable_language(C ASM) function (die msg) |