From 70de8bd5ae95936b8187e1af707e2d0111c74329 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sun, 23 Oct 2011 14:33:25 +0200 Subject: [PATCH] Eclipse: detect number of CPUs, set CMAKE_ECLIPSE_MAKE_ARGUMENTS accordigly Using the new module ProcessorCount.cmake now the number of CPUs is detected, and if it is bigger than 1, make -jX is set accordingly. Alex --- Modules/CMakeFindEclipseCDT4.cmake | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Modules/CMakeFindEclipseCDT4.cmake b/Modules/CMakeFindEclipseCDT4.cmake index cf0984e1a..f7a6e29f0 100644 --- a/Modules/CMakeFindEclipseCDT4.cmake +++ b/Modules/CMakeFindEclipseCDT4.cmake @@ -54,8 +54,20 @@ ENDFUNCTION() _FIND_ECLIPSE_VERSION() +# Try to find out how many CPUs we have and set the -j argument for make accordingly +SET(_CMAKE_ECLIPSE_INITIAL_MAKE_ARGS "") + +INCLUDE(ProcessorCount) +PROCESSORCOUNT(_CMAKE_ECLIPSE_PROCESSOR_COUNT) + +# Only set -j if we are under UNIX and if the make-tool used actually has "make" in the name +# (we may also get here in the future e.g. for ninja) +IF("${_CMAKE_ECLIPSE_PROCESSOR_COUNT}" GREATER 1 AND UNIX AND "${CMAKE_MAKE_PROGRAM}" MATCHES make) + SET(_CMAKE_ECLIPSE_INITIAL_MAKE_ARGS "-j${_CMAKE_ECLIPSE_PROCESSOR_COUNT}") +ENDIF() + # This variable is used by the Eclipse generator and appended to the make invocation commands. -SET(CMAKE_ECLIPSE_MAKE_ARGUMENTS "" CACHE STRING "Additional command line arguments when Eclipse invokes make. Enter e.g. -j to get parallel builds") +SET(CMAKE_ECLIPSE_MAKE_ARGUMENTS "${_CMAKE_ECLIPSE_INITIAL_MAKE_ARGS}" CACHE STRING "Additional command line arguments when Eclipse invokes make. Enter e.g. -j to get parallel builds") # This variable is used by the Eclipse generator in out-of-source builds only. SET(ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT FALSE CACHE BOOL "If enabled, CMake will generate a source project for Eclipse in CMAKE_SOURCE_DIR")