Skip to content

Commit

Permalink
Merge pull request #2705 from SunBlack/extended_MP_option
Browse files Browse the repository at this point in the history
Add `MSVC_MP` CMake option to adjust number of parallel build jobs
  • Loading branch information
SergioRAgostinho authored Dec 12, 2018
2 parents 5cef903 + d06d250 commit 9e05c4e
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,14 @@ if(CMAKE_COMPILER_IS_MSVC)
endif()
# /MANIFEST:NO") # please, don't disable manifest generation, otherwise crash at start for vs2008

if(MSVC_VERSION GREATER 1500)
include(ProcessorCount)
ProcessorCount(N)
if(NOT N EQUAL 0)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP${N}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP${N}")
endif()
include(ProcessorCount)
ProcessorCount(CPUCores)
set(MSVC_MP ${CPUCores} CACHE STRING "Number of simultaneously running compilers (0 = automatic detection by MSVC). See documentation of /MP flag.")
if(MSVC_MP EQUAL 0)
# MSVC_MP is 0 in case the information cannot be determined by ProcessorCount => fallback
add_compile_options("/MP")
elseif(MSVC_MP GREATER 1)
add_compile_options("/MP${MSVC_MP}")
endif()
endif()

Expand Down

0 comments on commit 9e05c4e

Please sign in to comment.