summaryrefslogtreecommitdiff
path: root/Modules/CMakeFindEclipseCDT4.cmake
diff options
context:
space:
mode:
authorAlex Neundorf <neundorf@kde.org>2011-10-23 14:33:25 +0200
committerAlex Neundorf <neundorf@kde.org>2011-10-23 14:33:25 +0200
commit70de8bd5ae95936b8187e1af707e2d0111c74329 (patch)
treef9784f1d3346992da6f3a8fcb145c284822418da /Modules/CMakeFindEclipseCDT4.cmake
parent117f2b8257d92328b32cb90ced3d85d88815130b (diff)
downloadcmake-70de8bd5ae95936b8187e1af707e2d0111c74329.tar.gz
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
Diffstat (limited to 'Modules/CMakeFindEclipseCDT4.cmake')
-rw-r--r--Modules/CMakeFindEclipseCDT4.cmake14
1 files changed, 13 insertions, 1 deletions
diff --git a/Modules/CMakeFindEclipseCDT4.cmake b/Modules/CMakeFindEclipseCDT4.cmake
index cf0984e1ad..f7a6e29f0f 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<some_number> 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<some_number> 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")