[cmake-developers] Ninja pools

Peter Kümmel syntheticpp at gmx.net
Tue Nov 5 14:15:21 EST 2013


I merged a proposal to next which adds support for Ninja's "pool":

   http://martine.github.io/ninja/manual.html#ref_pool

It adds three new properties, POOLS, LINK_POOL, COMPILE_POOL:

   http://www.cmake.org/cmake/help/git-next/manual/cmake-properties.7.html

With a "pool" it is possible to limit the number of concurrent
processes of a specific rule.

For instance if you have a project with multiple targets and
each target needs all your resources while linking (memory,
hard-disk bandwidth), it makes no sens to start multiple link
processes in parallel. To prevent this the pool feature was
introduced in ninja.

In concrete, with this patch:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 25cd576..d257c97 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -21,6 +21,8 @@ if(CMAKE_BOOTSTRAP)
    unset(CMAKE_BOOTSTRAP CACHE)
  endif()

+set_property(GLOBAL PROPERTY POOLS "compile=1")
+

  if("${CMake_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index c01245c..d7c68d5 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -393,6 +393,8 @@ target_link_libraries(CMakeLib cmsys
    ${CMAKE_TAR_LIBRARIES} ${CMAKE_COMPRESS_LIBRARIES}
    ${CMAKE_CURL_LIBRARIES} )

+set_property(TARGET CMakeLib PROPERTY COMPILE_POOL compile)
+


and the current next branch, ninja builds CMakeLib single threaded,
without passing -j1 to ninja.

Current patch adds only the essentials, but maybe there are more
comfortable ways to use pools.


Peter





More information about the cmake-developers mailing list