Use ninja pools to limit the number of concurrent compile/link jobs.
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Wed, 19 Nov 2014 10:30:02 +0000 (10:30 +0000)
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Wed, 19 Nov 2014 10:30:02 +0000 (10:30 +0000)
This change makes use of the new "job pool" capability in cmake 3.0
with ninja generator to allow limiting the number of concurrent jobs
of a certain type.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222341 91177308-0d34-0410-b5e6-96231b3b80d8

CMakeLists.txt
docs/CMake.rst

index e3ddb267966352299bcb78a73ed604d0c3181199..6691189b724ef5ab9085435357e7fa03c31a3ee8 100644 (file)
@@ -24,6 +24,21 @@ endif()
 
 project(LLVM)
 
+# The following only works with the Ninja generator in CMake >= 3.0.
+set(LLVM_PARALLEL_COMPILE_JOBS "" CACHE STRING
+  "Define the maximum number of concurrent compilation jobs.")
+if(LLVM_PARALLEL_COMPILE_JOBS)
+  set_property(GLOBAL APPEND PROPERTY JOB_POOLS compile_job_pool=${LLVM_PARALLEL_COMPILE_JOBS})
+  set(CMAKE_JOB_POOL_COMPILE compile_job_pool)
+endif()
+
+set(LLVM_PARALLEL_LINK_JOBS "" CACHE STRING
+  "Define the maximum number of concurrent link jobs.")
+if(LLVM_PARALLEL_LINK_JOBS)
+  set_property(GLOBAL APPEND PROPERTY JOB_POOLS link_job_pool=${LLVM_PARALLEL_LINK_JOBS})
+  set(CMAKE_JOB_POOL_LINK link_job_pool)
+endif()
+
 # Add path for custom modules
 set(CMAKE_MODULE_PATH
   ${CMAKE_MODULE_PATH}
index 4a5165b7a13e66e90ed6892181522b9151e1a785..653fa16a67568b2e67c872d7f7eeeb496ab03382 100644 (file)
@@ -291,6 +291,12 @@ LLVM-specific variables
   are ``Address``, ``Memory``, ``MemoryWithOrigins`` and ``Undefined``.
   Defaults to empty string.
 
+**LLVM_PARALLEL_COMPILE_JOBS**:STRING
+  Define the maximum number of concurrent compilation jobs.
+
+**LLVM_PARALLEL_LINK_JOBS**:STRING
+  Define the maximum number of concurrent link jobs.
+
 **LLVM_BUILD_DOCS**:BOOL
   Enables all enabled documentation targets (i.e. Doxgyen and Sphinx targets) to
   be built as part of the normal build. If the ``install`` target is run then