From 135dd2d5c93fcb1c5827cfbd2ef1d487aa4b4946 Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Wed, 22 Apr 2020 21:27:47 +0200
Subject: [PATCH] [CMake] Removed option OGS_USE_PCH.

Will be replaced by native CMake precompiled headers.
---
 Applications/CLI/CMakeLists.txt               |  4 ---
 Applications/DataExplorer/DataExplorer.cmake  |  4 ---
 CMakeLists.txt                                |  4 ---
 Jenkinsfile                                   | 25 ++++++-------------
 Tests/CMakeLists.txt                          |  4 ---
 azure-pipelines.yml                           |  2 +-
 scripts/cmake/CompilerSetup.cmake             |  7 ------
 scripts/cmake/Functions.cmake                 |  4 ---
 .../devguide/troubleshooting/build.pandoc     | 10 --------
 9 files changed, 9 insertions(+), 55 deletions(-)

diff --git a/Applications/CLI/CMakeLists.txt b/Applications/CLI/CMakeLists.txt
index 89c02475ad6..3035e44b6b7 100644
--- a/Applications/CLI/CMakeLists.txt
+++ b/Applications/CLI/CMakeLists.txt
@@ -71,10 +71,6 @@ if(OGS_INSITU)
     target_link_libraries(ogs PRIVATE InSituLib)
 endif()
 
-if(OGS_USE_PCH)
-    cotire(ogs)
-endif()
-
 # ---- Tests ----
 add_test(NAME ogs_no_args COMMAND ogs)
 set_tests_properties(ogs_no_args PROPERTIES WILL_FAIL TRUE)
diff --git a/Applications/DataExplorer/DataExplorer.cmake b/Applications/DataExplorer/DataExplorer.cmake
index 5feab093766..6deacb5c958 100644
--- a/Applications/DataExplorer/DataExplorer.cmake
+++ b/Applications/DataExplorer/DataExplorer.cmake
@@ -81,10 +81,6 @@ endif()
 
 set_property(TARGET DataExplorer PROPERTY FOLDER "DataExplorer")
 
-if(OGS_USE_PCH)
-    cotire(DataExplorer)
-endif()
-
 # ---- Installation ----
 install(TARGETS DataExplorer RUNTIME DESTINATION bin COMPONENT ogs_gui)
 
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 248955335ac..a35067acd7b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -23,10 +23,6 @@ set(CMAKE_LIBRARY_SEARCH_PATH
 set(OGS_CPU_ARCHITECTURE "native" CACHE STRING "Processor architecture, \
     defaults to native (*nix) / blend (MSVC).")
 option(OGS_ENABLE_AVX2 "Enable the use of AVX2 instructions" OFF)
-option(OGS_USE_PCH "Should pre-compiled headers be used?" ON)
-if(DEFINED CMAKE_CXX_CLANG_TIDY)
-    set(OGS_USE_PCH OFF CACHE INTERNAL "")
-endif()
 option(OGS_USE_CONAN "Should Conan package manager be used?" ON)
 set(OGS_CONAN_BUILD "missing" CACHE STRING "Possible values: all, missing, \
     never or list of libs to build")
diff --git a/Jenkinsfile b/Jenkinsfile
index 1ec41a864aa..3ce3a08b20f 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -115,8 +115,7 @@ pipeline {
                   '-DOGS_CONAN_BUILD=missing ' +
                   '-DOGS_USE_CVODE=ON ' +
                   '-DOGS_USE_MFRONT=ON ' +
-                  '-DOGS_USE_PYTHON=ON ' +
-                  '-DOGS_USE_PCH=OFF '
+                  '-DOGS_USE_PYTHON=ON '
               }
               // Workaround some MGIS CMake logic flaws
               configure {
@@ -197,13 +196,11 @@ pipeline {
                 cmakeOptions =
                   "-DBUILD_SHARED_LIBS=${build_shared} " +
                   '-DOGS_CPU_ARCHITECTURE=generic ' +
-                  '-DOGS_USE_PCH=OFF ' +     // see #1992
                   '-DOGS_BUILD_GUI=ON ' +
                   '-DOGS_BUILD_UTILS=ON ' +
                   '-DOGS_CONAN_BUILD=missing ' +
                   '-DOGS_BUILD_TESTS=OFF ' +
-                  '-DOGS_USE_NETCDF=ON ' +
-                  '-DOGS_USE_PCH=OFF '
+                  '-DOGS_USE_NETCDF=ON '
               }
               build {
                 target="package"
@@ -259,8 +256,7 @@ pipeline {
                   "-DBUILD_SHARED_LIBS=${build_shared} " +
                   '-DOGS_CONAN_BUILD=missing ' +
                   '-DOGS_CONAN_BUILD_TYPE=Release ' +
-                  '-DOGS_CPU_ARCHITECTURE=generic ' +
-                  '-DOGS_USE_PCH=OFF '
+                  '-DOGS_CPU_ARCHITECTURE=generic '
                 config = 'Debug'
               }
               build { }
@@ -293,8 +289,7 @@ pipeline {
                   '-DBUILD_SHARED_LIBS=ON ' +
                   '-DOGS_CPU_ARCHITECTURE=sandybridge ' +
                   '-DCMAKE_INSTALL_PREFIX=/global/apps/ogs/head/standard ' +
-                  '-DOGS_MODULEFILE=/global/apps/modulefiles/ogs/head/standard ' +
-                  '-DOGS_USE_PCH=OFF '
+                  '-DOGS_MODULEFILE=/global/apps/modulefiles/ogs/head/standard '
                 env = 'eve/cli.sh'
               }
               build {
@@ -350,8 +345,7 @@ pipeline {
                   '-DBUILD_SHARED_LIBS=ON ' +
                   '-DOGS_CPU_ARCHITECTURE=sandybridge ' +
                   '-DCMAKE_INSTALL_PREFIX=/global/apps/ogs/head/petsc ' +
-                  '-DOGS_MODULEFILE=/global/apps/modulefiles/ogs/head/petsc ' +
-                  '-DOGS_USE_PCH=OFF '
+                  '-DOGS_MODULEFILE=/global/apps/modulefiles/ogs/head/petsc '
                 env = 'eve/petsc.sh'
               }
               build {
@@ -414,8 +408,7 @@ pipeline {
                   '-DOGS_BUILD_UTILS=ON ' +
                   '-DOGS_CONAN_BUILD=missing ' +
                   '-DOGS_BUILD_SWMM=ON ' +
-                  '-DOGS_USE_NETCDF=ON ' +
-                  '-DOGS_USE_PCH=OFF '
+                  '-DOGS_USE_NETCDF=ON '
               }
               build {
                 target="package"
@@ -470,8 +463,7 @@ pipeline {
                   '-DOGS_CPU_ARCHITECTURE=core2 ' +
                   '-DOGS_BUILD_UTILS=ON ' +
                   '-DOGS_CONAN_BUILD=missing ' +
-                  '-DCMAKE_OSX_DEPLOYMENT_TARGET="10.15" ' +
-                  '-DOGS_USE_PCH=OFF '
+                  '-DCMAKE_OSX_DEPLOYMENT_TARGET="10.15" '
               }
               build {
                 target="package"
@@ -519,8 +511,7 @@ pipeline {
                   '-DOGS_BUILD_GUI=ON ' +
                   '-DOGS_USE_CONAN=OFF ' +
                   '-DCMAKE_OSX_DEPLOYMENT_TARGET="10.15" ' +
-                  '-DOGS_USE_NETCDF=ON ' +
-                  '-DOGS_USE_PCH=OFF '
+                  '-DOGS_USE_NETCDF=ON '
               }
               build {
                 target="package"
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index d08e3e753a0..46cb824af5a 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -85,10 +85,6 @@ if(OGS_BUILD_GUI)
     endif()
 endif()
 
-if(OGS_USE_PCH)
-    cotire(testrunner)
-endif()
-
 # cmake-format: off
 # Add make-target tests which runs the testrunner
 if(IS_CI AND NOT OGS_COVERAGE)
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 623251b6c8a..7cf41d07a9c 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -20,6 +20,6 @@ jobs:
       mkdir build
       cd build
       call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\vsdevcmd" -arch=x64
-      cmake .. -G Ninja -DCMAKE_C_COMPILER=cl.exe -DCMAKE_CXX_COMPILER=cl.exe -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -DOGS_EIGEN_DYNAMIC_SHAPE_MATRICES=ON -DOGS_USE_PCH=OFF
+      cmake .. -G Ninja -DCMAKE_C_COMPILER=cl.exe -DCMAKE_CXX_COMPILER=cl.exe -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -DOGS_EIGEN_DYNAMIC_SHAPE_MATRICES=ON
       ninja -j 2
       ninja -j 2 tests
diff --git a/scripts/cmake/CompilerSetup.cmake b/scripts/cmake/CompilerSetup.cmake
index 84ff00df250..0cac5604136 100644
--- a/scripts/cmake/CompilerSetup.cmake
+++ b/scripts/cmake/CompilerSetup.cmake
@@ -3,13 +3,6 @@ set(CMAKE_CXX_STANDARD 17)
 set(CMAKE_CXX_STANDARD_REQUIRED ON)
 set(CMAKE_CXX_EXTENSIONS OFF)
 
-if(${CMAKE_CXX_COMPILER} MATCHES "clcache")
-    set(OGS_USE_PCH OFF CACHE INTERNAL "")
-endif()
-if(OGS_USE_PCH)
-    include(cotire) # compile time reducer
-endif()
-
 if(${CMAKE_CXX_COMPILER} MATCHES "clcache" AND CMAKE_BUILD_TYPE STREQUAL "Debug")
     message(WARNING "clcache does not cache in Debug config!")
 endif()
diff --git a/scripts/cmake/Functions.cmake b/scripts/cmake/Functions.cmake
index 8ef50c4b226..765d12fa538 100644
--- a/scripts/cmake/Functions.cmake
+++ b/scripts/cmake/Functions.cmake
@@ -98,10 +98,6 @@ function(ogs_add_library targetName)
     generate_export_header(${targetName})
     target_include_directories(${targetName} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
 
-    if(OGS_USE_PCH AND NOT ${targetName} STREQUAL "ChemistryLib")
-        cotire(${targetName})
-    endif()
-
     if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.16)
         set_target_properties(${targetName} PROPERTIES
             UNITY_BUILD ${OGS_USE_UNITY_BUILDS})
diff --git a/web/content/docs/devguide/troubleshooting/build.pandoc b/web/content/docs/devguide/troubleshooting/build.pandoc
index f7cd43e02f2..cbd96298b28 100644
--- a/web/content/docs/devguide/troubleshooting/build.pandoc
+++ b/web/content/docs/devguide/troubleshooting/build.pandoc
@@ -29,13 +29,3 @@ If this still fails you can disable building of the failing processes, e.g.:
 ```
 cmake . -DOGS_BUILD_PROCESS_HT=OFF
 cmake --build . --config Release -j 1
-
-## Cotire-related (pre-compiled headers)
-
-If you get some error during build which mentions `cotire` or `*.prefix.hxx.gch` you can try to clean the pre-compiled headers with:
-
-```bash
-make clean_cotire
-```
-
-This may occur after updating the compiler or system libraries. Related to configurations with `OGS_USE_PCH=ON` only.
-- 
GitLab