changeset 5262:bf304ee8dd80

revert precompiled headers, as they really help
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 12 Apr 2023 15:53:32 +0200
parents f66b8d70917e
children ae3f29be5ca5
files OrthancServer/CMakeLists.txt
diffstat 1 files changed, 52 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/CMakeLists.txt	Wed Apr 12 15:29:32 2023 +0200
+++ b/OrthancServer/CMakeLists.txt	Wed Apr 12 15:53:32 2023 +0200
@@ -74,6 +74,7 @@
   set(ENABLE_PROTOBUF_COMPILER ON)
 endif()
 
+include(${CMAKE_SOURCE_DIR}/../OrthancFramework/Resources/CMake/VisualStudioPrecompiledHeaders.cmake)
 include(${CMAKE_SOURCE_DIR}/../OrthancFramework/Resources/CMake/OrthancFrameworkConfiguration.cmake)
 
 # To export the proper symbols in the sample plugins
@@ -330,6 +331,33 @@
   )
 
 
+# Setup precompiled headers for Microsoft Visual Studio
+
+# WARNING: There must be NO MORE "add_definitions()", "include()" or
+# "include_directories()" below, otherwise the generated precompiled
+# headers might get broken!
+
+if (MSVC)
+  set(TMP
+    ${ORTHANC_CORE_SOURCES_INTERNAL}
+    ${ORTHANC_DICOM_SOURCES_INTERNAL}
+    )
+  
+  ADD_VISUAL_STUDIO_PRECOMPILED_HEADERS(
+    "PrecompiledHeaders.h" "${CMAKE_SOURCE_DIR}/../OrthancFramework/Sources/PrecompiledHeaders.cpp"
+    TMP ORTHANC_CORE_PCH)
+
+  ADD_VISUAL_STUDIO_PRECOMPILED_HEADERS(
+    "PrecompiledHeadersServer.h" "${CMAKE_SOURCE_DIR}/Sources/PrecompiledHeadersServer.cpp"
+    ORTHANC_SERVER_SOURCES ORTHANC_SERVER_PCH)
+
+  ADD_VISUAL_STUDIO_PRECOMPILED_HEADERS(
+    "PrecompiledHeadersUnitTests.h" "${CMAKE_SOURCE_DIR}/UnitTestsSources/PrecompiledHeadersUnitTests.cpp"
+    ORTHANC_SERVER_UNIT_TESTS ORTHANC_UNIT_TESTS_PCH)
+endif()
+
+
+
 #####################################################################
 ## Build the core of Orthanc
 #####################################################################
@@ -343,11 +371,19 @@
 # content of the "OrthancFramework" folder
 add_library(CoreLibrary
   STATIC
+  ${ORTHANC_CORE_PCH}
   ${ORTHANC_CORE_SOURCES}
   ${ORTHANC_DICOM_SOURCES}
   ${AUTOGENERATED_SOURCES}
   )
 
+if (MSVC)
+  set_target_properties(
+    CoreLibrary
+    PROPERTIES COMPILE_DEFINITIONS "ORTHANC_USE_PRECOMPILED_HEADERS=1"
+    )
+endif()
+
 add_dependencies(CoreLibrary AutogeneratedTarget)
 
 if (LIBICU_LIBRARIES)
@@ -385,9 +421,17 @@
 
 add_library(ServerLibrary
   STATIC
+  ${ORTHANC_SERVER_PCH}
   ${ORTHANC_SERVER_SOURCES}
   )
 
+if (MSVC)
+  set_target_properties(
+    ServerLibrary
+    PROPERTIES COMPILE_DEFINITIONS "ORTHANC_USE_PRECOMPILED_HEADERS=1"
+    )
+endif()
+
 # Ensure autogenerated code is built before building ServerLibrary
 add_dependencies(ServerLibrary CoreLibrary OrthancDatabaseProtobuf)
 
@@ -420,11 +464,19 @@
 
 add_executable(UnitTests
   ${GOOGLE_TEST_SOURCES}
+  ${ORTHANC_UNIT_TESTS_PCH}
   ${ORTHANC_FRAMEWORK_UNIT_TESTS}
   ${ORTHANC_SERVER_UNIT_TESTS}
   ${BOOST_EXTENDED_SOURCES}
   )
 
+if (MSVC)
+  set_target_properties(
+    UnitTests
+    PROPERTIES COMPILE_DEFINITIONS "ORTHANC_USE_PRECOMPILED_HEADERS=1"
+    )
+endif()
+
 target_link_libraries(UnitTests
   ServerLibrary
   CoreLibrary