changeset 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 7d4e06beb1ec
children dd10fe965870
files NEWS Resources/CMake/Compiler.cmake Resources/CMake/OrthancFrameworkParameters.cmake
diffstat 3 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Thu Feb 21 10:24:59 2019 +0100
+++ b/NEWS	Thu Feb 21 12:05:48 2019 +0100
@@ -10,6 +10,7 @@
 * Fix issue #134 (/patient/modify gives 500, should really be 400)
 * Support of SOP classes: BreastProjectionXRayImageStorageForProcessing/Presentation
 * More tolerance wrt. missing DICOM tags that must be returned by Orthanc C-FIND SCP
+* New CMake option: "-DMSVC_MULTIPLE_PROCESSES=ON" for parallel build with Visual Studio
 
 
 Version 1.5.4 (2019-02-08)
--- 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
--- a/Resources/CMake/OrthancFrameworkParameters.cmake	Thu Feb 21 10:24:59 2019 +0100
+++ b/Resources/CMake/OrthancFrameworkParameters.cmake	Thu Feb 21 12:05:48 2019 +0100
@@ -71,6 +71,7 @@
 set(USE_PUGIXML ON CACHE BOOL "Use the Pugixml parser (turn off only for debug)")
 set(USE_LEGACY_JSONCPP OFF CACHE BOOL "Use the old branch 0.x.y of JsonCpp, that does not require a C++11 compiler (for LSB and old versions of Visual Studio)")
 set(USE_LEGACY_LIBICU OFF CACHE BOOL "Use icu icu4c-58_2, latest version not requiring a C++11 compiler (for LSB and old versions of Visual Studio)")
+set(MSVC_MULTIPLE_PROCESSES OFF CACHE BOOL "Add the /MP option to build with multiple processes if using Visual Studio")
 
 mark_as_advanced(USE_GOOGLE_TEST_DEBIAN_PACKAGE)
 mark_as_advanced(SYSTEM_MONGOOSE_USE_CALLBACKS)