summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorAlex Neundorf <neundorf@kde.org>2016-02-23 21:37:44 (GMT)
committerAlex Neundorf <neundorf@kde.org>2016-02-23 21:37:44 (GMT)
commit84ccd4f7461ac2c2ee471a4d77f3e184c676c276 (patch)
tree8c608881dff41ab5f97c3d86a4bab58ec8e5b4bd /Modules
parent7a45d91dc4dcbf52a576cca37878bc5c37f293f3 (diff)
downloadCMake-84ccd4f7461ac2c2ee471a4d77f3e184c676c276.zip
CMake-84ccd4f7461ac2c2ee471a4d77f3e184c676c276.tar.gz
CMake-84ccd4f7461ac2c2ee471a4d77f3e184c676c276.tar.bz2
CodeBlocks: generate parallel project files (make -j)
This is done the same way as for Eclipse: cmake tries to determine the number of CPUs, and then adds the respective -jN to the make invocations in the project file. Alex
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CMakeFindCodeBlocks.cmake15
1 files changed, 15 insertions, 0 deletions
diff --git a/Modules/CMakeFindCodeBlocks.cmake b/Modules/CMakeFindCodeBlocks.cmake
index f8d8d59..bf85ea0 100644
--- a/Modules/CMakeFindCodeBlocks.cmake
+++ b/Modules/CMakeFindCodeBlocks.cmake
@@ -23,3 +23,18 @@ endif()
# Determine builtin macros and include dirs:
include(${CMAKE_CURRENT_LIST_DIR}/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake)
+
+# Try to find out how many CPUs we have and set the -j argument for make accordingly
+set(_CMAKE_CODEBLOCKS_INITIAL_MAKE_ARGS "")
+
+include(ProcessorCount)
+processorcount(_CMAKE_CODEBLOCKS_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_CODEBLOCKS_PROCESSOR_COUNT}" GREATER 1 AND CMAKE_HOST_UNIX AND "${CMAKE_MAKE_PROGRAM}" MATCHES make)
+ set(_CMAKE_CODEBLOCKS_INITIAL_MAKE_ARGS "-j${_CMAKE_CODEBLOCKS_PROCESSOR_COUNT}")
+endif()
+
+# This variable is used by the CodeBlocks generator and appended to the make invocation commands.
+set(CMAKE_CODEBLOCKS_MAKE_ARGUMENTS "${_CMAKE_CODEBLOCKS_INITIAL_MAKE_ARGS}" CACHE STRING "Additional command line arguments when CodeBlocks invokes make. Enter e.g. -j<some_number> to get parallel builds")