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
This commit is contained in:
Alex Neundorf
2016-02-23 22:37:44 +01:00
parent 7a45d91dc4
commit 84ccd4f746
3 changed files with 44 additions and 13 deletions

View File

@@ -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")