diff Resources/CMake/Compiler.cmake @ 3278:ce6a98f8ed85

New CMake option: "-DMSVC_MULTIPLE_PROCESSES=ON" for parallel build with Visual Studio
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 21 Feb 2019 12:05:48 +0100
parents fcfd4f73228c
children cbbe0bb80bd4
line wrap: on
line diff
--- a/Resources/CMake/Compiler.cmake	Thu Feb 21 10:24:59 2019 +0100
+++ b/Resources/CMake/Compiler.cmake	Thu Feb 21 12:05:48 2019 +0100
@@ -39,6 +39,18 @@
   # Add /Zm256 compiler option to Visual Studio to fix PCH errors
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zm256")
 
+  # New in Orthanc 1.5.5
+  if (MSVC_MULTIPLE_PROCESSES)
+    # "If you omit the processMax argument in the /MP option, the
+    # compiler obtains the number of effective processors from the
+    # operating system, and then creates one process per effective
+    # processor"
+    # https://blog.kitware.com/cmake-building-with-all-your-cores/
+    # https://docs.microsoft.com/en-us/cpp/build/reference/mp-build-with-multiple-processes
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
+  endif()
+    
   add_definitions(
     -D_CRT_SECURE_NO_WARNINGS=1
     -D_CRT_SECURE_NO_DEPRECATE=1