From a5dc6099b2e82c48cfd45b036e0033c6fcd404d4 Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Fri, 27 Mar 2020 11:51:43 +0100
Subject: [PATCH] [CMake] Use ogs_add_library()-function.

---
 Applications/ApplicationsLib/CMakeLists.txt   |  9 +------
 Applications/CLI/CMakeLists.txt               |  5 +---
 Applications/DataExplorer/Base/CMakeLists.txt |  9 +------
 .../DataExplorer/DataView/CMakeLists.txt      |  9 +------
 .../DataView/DiagramView/CMakeLists.txt       |  9 +------
 .../DataView/StratView/CMakeLists.txt         |  9 +------
 .../DataExplorer/NetCdfDialog/CMakeLists.txt  |  6 +----
 .../DataExplorer/VtkVis/CMakeLists.txt        |  9 +------
 Applications/DataHolderLib/CMakeLists.txt     |  9 +------
 Applications/FileIO/CMakeLists.txt            | 10 +------
 Applications/InSituLib/CMakeLists.txt         |  9 +------
 .../Utils/OGSFileConverter/CMakeLists.txt     | 10 +------
 BaseLib/CMakeLists.txt                        | 15 +----------
 ChemistryLib/CMakeLists.txt                   |  9 +------
 GeoLib/CMakeLists.txt                         |  9 +------
 InfoLib/CMakeLists.txt                        |  7 +----
 MaterialLib/CMakeLists.txt                    |  9 +------
 MaterialLib/SolidModels/MFront/CMakeLists.txt |  7 +----
 MathLib/CMakeLists.txt                        | 12 +--------
 MeshGeoToolsLib/CMakeLists.txt                |  9 +------
 MeshLib/CMakeLists.txt                        |  8 +-----
 NumLib/CMakeLists.txt                         | 11 +-------
 ParameterLib/CMakeLists.txt                   |  9 +------
 .../BoundaryCondition/Python/CMakeLists.txt   | 12 ++-------
 ProcessLib/CMakeLists.txt                     |  9 +------
 ProcessLib/ComponentTransport/CMakeLists.txt  |  6 +----
 ProcessLib/GroundwaterFlow/CMakeLists.txt     |  5 +---
 ProcessLib/HT/CMakeLists.txt                  |  5 +---
 ProcessLib/HeatConduction/CMakeLists.txt      |  5 +---
 ProcessLib/HeatTransportBHE/CMakeLists.txt    |  6 +----
 ProcessLib/HydroMechanics/CMakeLists.txt      |  5 +---
 ProcessLib/LIE/CMakeLists.txt                 |  5 +---
 ProcessLib/LIE/Common/CMakeLists.txt          |  5 +---
 ProcessLib/LiquidFlow/CMakeLists.txt          |  5 +---
 ProcessLib/PhaseField/CMakeLists.txt          |  5 +---
 .../RichardsComponentTransport/CMakeLists.txt |  6 +----
 ProcessLib/RichardsFlow/CMakeLists.txt        |  5 +---
 ProcessLib/RichardsMechanics/CMakeLists.txt   | 11 ++------
 ProcessLib/SmallDeformation/CMakeLists.txt    |  6 +----
 .../SmallDeformationNonlocal/CMakeLists.txt   |  6 +----
 ProcessLib/SourceTerms/Python/CMakeLists.txt  | 26 +++++++------------
 .../SteadyStateDiffusion/CMakeLists.txt       |  8 +++---
 ProcessLib/TES/CMakeLists.txt                 |  6 ++---
 .../ThermalTwoPhaseFlowWithPP/CMakeLists.txt  |  2 +-
 .../ThermoHydroMechanics/CMakeLists.txt       |  6 +----
 .../ThermoMechanicalPhaseField/CMakeLists.txt |  6 +----
 ProcessLib/ThermoMechanics/CMakeLists.txt     |  5 +---
 ProcessLib/TwoPhaseFlowWithPP/CMakeLists.txt  |  6 +----
 .../TwoPhaseFlowWithPrho/CMakeLists.txt       |  6 +----
 49 files changed, 62 insertions(+), 324 deletions(-)

diff --git a/Applications/ApplicationsLib/CMakeLists.txt b/Applications/ApplicationsLib/CMakeLists.txt
index da92d0680d8..49f077b1ff8 100644
--- a/Applications/ApplicationsLib/CMakeLists.txt
+++ b/Applications/ApplicationsLib/CMakeLists.txt
@@ -3,10 +3,7 @@ get_source_files(SOURCES_APPLICATIONSLIB)
 set(LIB_SOURCES ${SOURCES_APPLICATIONSLIB})
 
 # Library
-add_library(ApplicationsLib ${LIB_SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS ApplicationsLib LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(ApplicationsLib ${LIB_SOURCES})
 
 target_link_libraries(ApplicationsLib
                       PUBLIC BaseLib GeoLib NumLib Processes logog
@@ -26,10 +23,6 @@ foreach(process ${ProcessesList})
     endif()
 endforeach()
 
-if(OGS_USE_PCH)
-    cotire(ApplicationsLib)
-endif()
-
 if(OGS_USE_PYTHON)
     target_link_libraries(ApplicationsLib PRIVATE pybind11::pybind11)
 endif()
diff --git a/Applications/CLI/CMakeLists.txt b/Applications/CLI/CMakeLists.txt
index 06eceb456d8..89c02475ad6 100644
--- a/Applications/CLI/CMakeLists.txt
+++ b/Applications/CLI/CMakeLists.txt
@@ -33,7 +33,7 @@ if(OGS_USE_PYTHON)
     # appropriate message should be presented. The note is kept for the case
     # that the automatic detection does not work due to whatever reason.
 
-    add_library(ogs_embedded_python ogs_embedded_python.cpp)
+    ogs_add_library(ogs_embedded_python ogs_embedded_python.cpp)
 
     # Performance warning from
     # https://github.com/pybind/pybind11/blob/master/docs/compiling.rst: Since
@@ -57,9 +57,6 @@ if(OGS_USE_PYTHON)
         # by the linker.
         target_compile_definitions(ogs_embedded_python PRIVATE
                                    OGS_BUILD_SHARED_LIBS)
-        install(TARGETS ogs_embedded_python
-                LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-
     endif()
 endif()
 
diff --git a/Applications/DataExplorer/Base/CMakeLists.txt b/Applications/DataExplorer/Base/CMakeLists.txt
index 112e81c89b6..6a0843fb91f 100644
--- a/Applications/DataExplorer/Base/CMakeLists.txt
+++ b/Applications/DataExplorer/Base/CMakeLists.txt
@@ -29,15 +29,8 @@ source_group("UI Files" REGULAR_EXPRESSION "\\w*\\.ui")
 source_group("Moc Files" REGULAR_EXPRESSION "moc_.*")
 
 # Create the library
-add_library(QtBase ${SOURCES} ${HEADERS})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS QtBase LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(QtBase ${SOURCES} ${HEADERS})
 
 target_link_libraries(QtBase Qt5::Widgets)
 
 set_property(TARGET QtBase PROPERTY FOLDER "DataExplorer")
-
-if(OGS_USE_PCH)
-    cotire(QtBase)
-endif()
diff --git a/Applications/DataExplorer/DataView/CMakeLists.txt b/Applications/DataExplorer/DataView/CMakeLists.txt
index 216248285f4..11b6e866ad8 100644
--- a/Applications/DataExplorer/DataView/CMakeLists.txt
+++ b/Applications/DataExplorer/DataView/CMakeLists.txt
@@ -121,10 +121,7 @@ if(GEOTIFF_FOUND)
     include_directories(${GEOTIFF_INCLUDE_DIRS})
 endif() # GEOTIFF_FOUND
 
-add_library(QtDataView ${SOURCES} ${HEADERS} ${UIS})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS QtDataView LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(QtDataView ${SOURCES} ${HEADERS} ${UIS})
 
 target_link_libraries(QtDataView
                       PUBLIC GeoLib
@@ -149,7 +146,3 @@ endif() # GEOTIFF_FOUND
 add_autogen_include(QtDataView)
 
 set_property(TARGET QtDataView PROPERTY FOLDER "DataExplorer")
-
-if(OGS_USE_PCH)
-    cotire(QtDataView)
-endif()
diff --git a/Applications/DataExplorer/DataView/DiagramView/CMakeLists.txt b/Applications/DataExplorer/DataView/DiagramView/CMakeLists.txt
index 3da36416dcf..96c1a84c45a 100644
--- a/Applications/DataExplorer/DataView/DiagramView/CMakeLists.txt
+++ b/Applications/DataExplorer/DataView/DiagramView/CMakeLists.txt
@@ -29,10 +29,7 @@ include_directories(${SOURCE_DIR_REL}/BaseLib
 file(GLOB_RECURSE UIS CONFIGURE_DEPENDS *.ui)
 source_group("UI Files" FILES ${UIS})
 
-add_library(QtDiagramView ${SOURCES} ${HEADERS} ${UIS})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS QtDiagramView LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(QtDiagramView ${SOURCES} ${HEADERS} ${UIS})
 
 target_link_libraries(QtDiagramView
                       PRIVATE BaseLib
@@ -45,7 +42,3 @@ target_link_libraries(QtDiagramView
 add_autogen_include(QtDiagramView)
 
 set_property(TARGET QtDiagramView PROPERTY FOLDER "DataExplorer")
-
-if(OGS_USE_PCH)
-    cotire(QtDiagramView)
-endif()
diff --git a/Applications/DataExplorer/DataView/StratView/CMakeLists.txt b/Applications/DataExplorer/DataView/StratView/CMakeLists.txt
index e88986209ca..348af52b269 100644
--- a/Applications/DataExplorer/DataView/StratView/CMakeLists.txt
+++ b/Applications/DataExplorer/DataView/StratView/CMakeLists.txt
@@ -13,10 +13,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
 file(GLOB_RECURSE UI_FILES CONFIGURE_DEPENDS *.ui)
 source_group("UI Files" FILES ${UI_FILES})
 
-add_library(QtStratView ${SOURCES} ${HEADERS} ${UIS})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS QtStratView LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(QtStratView ${SOURCES} ${HEADERS} ${UIS})
 
 target_link_libraries(QtStratView
                       PRIVATE BaseLib
@@ -27,7 +24,3 @@ target_link_libraries(QtStratView
 add_autogen_include(QtStratView)
 
 set_property(TARGET QtStratView PROPERTY FOLDER "DataExplorer")
-
-if(OGS_USE_PCH)
-    cotire(QtStratView)
-endif()
diff --git a/Applications/DataExplorer/NetCdfDialog/CMakeLists.txt b/Applications/DataExplorer/NetCdfDialog/CMakeLists.txt
index b932c64fef1..79faf9ddb48 100644
--- a/Applications/DataExplorer/NetCdfDialog/CMakeLists.txt
+++ b/Applications/DataExplorer/NetCdfDialog/CMakeLists.txt
@@ -1,8 +1,4 @@
-add_library(NetCdfDialogLib NetCdfConfigureDialog.cpp NetCdfConfigureDialog.h)
-if(BUILD_SHARED_LIBS)
-    install(TARGETS NetCdfConfigureDialog
-            LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(NetCdfDialogLib NetCdfConfigureDialog.cpp NetCdfConfigureDialog.h)
 target_link_libraries(NetCdfDialogLib
                       PUBLIC Qt5::Widgets
                              ${NETCDF_LIBRARIES_CXX}
diff --git a/Applications/DataExplorer/VtkVis/CMakeLists.txt b/Applications/DataExplorer/VtkVis/CMakeLists.txt
index cb0841b1950..35580d42642 100644
--- a/Applications/DataExplorer/VtkVis/CMakeLists.txt
+++ b/Applications/DataExplorer/VtkVis/CMakeLists.txt
@@ -119,10 +119,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
                     ${GUI_SOURCE_DIR_REL}/DataView
                     ${GUI_SOURCE_DIR_REL}/VtkModules/Qt)
 
-add_library(VtkVis ${SOURCES} ${HEADERS} ${UIS})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS VtkVis LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(VtkVis ${SOURCES} ${HEADERS} ${UIS})
 
 if(GEOTIFF_FOUND)
     include_directories(${GEOTIFF_INCLUDE_DIRS})
@@ -145,7 +142,3 @@ endif()
 set_property(TARGET VtkVis PROPERTY FOLDER "DataExplorer")
 
 add_autogen_include(VtkVis)
-
-if(OGS_USE_PCH)
-    cotire(VtkVis)
-endif()
diff --git a/Applications/DataHolderLib/CMakeLists.txt b/Applications/DataHolderLib/CMakeLists.txt
index 40e7e38bd43..606d95218fd 100644
--- a/Applications/DataHolderLib/CMakeLists.txt
+++ b/Applications/DataHolderLib/CMakeLists.txt
@@ -2,13 +2,6 @@
 get_source_files(SOURCES_DataHolderLib)
 
 # Library
-add_library(DataHolderLib ${SOURCES_DataHolderLib})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS DataHolderLib LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(DataHolderLib ${SOURCES_DataHolderLib})
 
 target_link_libraries(DataHolderLib PUBLIC GeoLib MeshLib PRIVATE BaseLib logog)
-
-if(OGS_USE_PCH)
-    cotire(DataHolderLib)
-endif()
diff --git a/Applications/FileIO/CMakeLists.txt b/Applications/FileIO/CMakeLists.txt
index d8fd5e927cd..e20207a6897 100644
--- a/Applications/FileIO/CMakeLists.txt
+++ b/Applications/FileIO/CMakeLists.txt
@@ -23,11 +23,7 @@ endif()
 include(${PROJECT_SOURCE_DIR}/scripts/cmake/OGSEnabledElements.cmake)
 
 # Create the library
-add_library(ApplicationsFileIO ${SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS ApplicationsFileIO
-            LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(ApplicationsFileIO ${SOURCES})
 target_link_libraries(ApplicationsFileIO
                       PUBLIC BaseLib
                              DataHolderLib
@@ -49,10 +45,6 @@ if(OGS_BUILD_SWMM)
     target_link_libraries(ApplicationsFileIO PRIVATE SwmmInterface)
 endif()
 
-if(OGS_USE_PCH)
-    cotire(ApplicationsFileIO)
-endif()
-
 configure_file(XmlIO/OpenGeoSysCND.xsd
                ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/OpenGeoSysCND.xsd COPYONLY)
 configure_file(XmlIO/OpenGeoSysNum.xsd
diff --git a/Applications/InSituLib/CMakeLists.txt b/Applications/InSituLib/CMakeLists.txt
index 3103fa1a1c2..6502bb0fdf5 100644
--- a/Applications/InSituLib/CMakeLists.txt
+++ b/Applications/InSituLib/CMakeLists.txt
@@ -2,13 +2,6 @@
 get_source_files(SOURCES)
 
 # Library
-add_library(InSituLib ${SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS InSituLib LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(InSituLib ${SOURCES})
 
 target_link_libraries(PUBLIC BaseLib PRIVATE MeshLib)
-
-if(OGS_USE_PCH)
-    cotire(InSituLib)
-endif()
diff --git a/Applications/Utils/OGSFileConverter/CMakeLists.txt b/Applications/Utils/OGSFileConverter/CMakeLists.txt
index 8fca073290d..e7ead14d312 100644
--- a/Applications/Utils/OGSFileConverter/CMakeLists.txt
+++ b/Applications/Utils/OGSFileConverter/CMakeLists.txt
@@ -1,12 +1,8 @@
-add_library(OGSFileConverterLib FileListDialog.h OGSFileConverter.h
+ogs_add_library(OGSFileConverterLib FileListDialog.h OGSFileConverter.h
                                 FileListDialog.cpp OGSFileConverter.cpp)
 target_link_libraries(OGSFileConverterLib
                       PUBLIC ApplicationsFileIO MathLib QtBase ${VTK_LIBRARIES}
                       INTERFACE MeshLib)
-if(BUILD_SHARED_LIBS)
-    install(TARGETS OGSFileConverterLib
-            LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
 
 set_target_properties(OGSFileConverterLib PROPERTIES AUTOMOC TRUE AUTOUIC TRUE)
 
@@ -20,8 +16,4 @@ add_autogen_include(OGSFileConverterLib)
 set_target_properties(OGSFileConverter OGSFileConverterLib
                       PROPERTIES FOLDER "Utilities")
 
-if(OGS_USE_PCH)
-    cotire(OGSFileConverterLib)
-endif()
-
 install(TARGETS OGSFileConverter RUNTIME DESTINATION bin COMPONENT Utilities)
diff --git a/BaseLib/CMakeLists.txt b/BaseLib/CMakeLists.txt
index 462833dcfdb..390520d234a 100644
--- a/BaseLib/CMakeLists.txt
+++ b/BaseLib/CMakeLists.txt
@@ -1,21 +1,12 @@
 get_source_files(SOURCES)
 append_source_files(SOURCES IO)
-
 append_source_files(SOURCES IO/XmlIO)
-
 if(OGS_BUILD_GUI)
     append_source_files(SOURCES IO/XmlIO/Qt)
 endif()
 
 # Create the library
-add_library(BaseLib ${SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS BaseLib LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
-
-include(GenerateExportHeader)
-generate_export_header(BaseLib)
-target_include_directories(BaseLib PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
+ogs_add_library(BaseLib ${SOURCES})
 
 target_link_libraries(BaseLib PUBLIC logog Boost::boost)
 
@@ -26,7 +17,3 @@ endif()
 if(OGS_BUILD_GUI)
     target_link_libraries(BaseLib PUBLIC Qt5::Xml Qt5::XmlPatterns)
 endif()
-
-if(OGS_USE_PCH)
-    cotire(BaseLib)
-endif()
diff --git a/ChemistryLib/CMakeLists.txt b/ChemistryLib/CMakeLists.txt
index c4f43c333a9..c9461b3baf5 100644
--- a/ChemistryLib/CMakeLists.txt
+++ b/ChemistryLib/CMakeLists.txt
@@ -5,10 +5,7 @@ append_source_files(SOURCES PhreeqcKernelData)
 append_source_files(SOURCES Common)
 
 # Create the library
-add_library(ChemistryLib ${SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS ChemistryLib LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(ChemistryLib ${SOURCES})
 
 include(GenerateExportHeader)
 generate_export_header(ChemistryLib)
@@ -16,7 +13,3 @@ generate_export_header(ChemistryLib)
 target_link_libraries(ChemistryLib PUBLIC iphreeqc PRIVATE NumLib)
 
 set_target_properties(ChemistryLib PROPERTIES CXX_STANDARD 14)
-
-if(OGS_USE_PCH)
-    cotire(ChemistryLib)
-endif()
diff --git a/GeoLib/CMakeLists.txt b/GeoLib/CMakeLists.txt
index a3360c98fdd..d6118a16d65 100644
--- a/GeoLib/CMakeLists.txt
+++ b/GeoLib/CMakeLists.txt
@@ -10,10 +10,7 @@ if(OGS_BUILD_GUI)
 endif()
 
 # Create the library
-add_library(GeoLib ${SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS GeoLib LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(GeoLib ${SOURCES})
 
 target_link_libraries(GeoLib PUBLIC BaseLib MathLib logog PRIVATE tet)
 
@@ -21,10 +18,6 @@ if(OGS_BUILD_GUI)
     target_link_libraries(GeoLib PUBLIC Qt5::Xml Qt5::XmlPatterns)
 endif()
 
-if(OGS_USE_PCH)
-    cotire(GeoLib)
-endif()
-
 configure_file(IO/XmlIO/OpenGeoSysGLI.xsd
                ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/OpenGeoSysGLI.xsd COPYONLY)
 configure_file(IO/XmlIO/OpenGeoSysSTN.xsd
diff --git a/InfoLib/CMakeLists.txt b/InfoLib/CMakeLists.txt
index 6b549876c48..8930756290f 100644
--- a/InfoLib/CMakeLists.txt
+++ b/InfoLib/CMakeLists.txt
@@ -2,13 +2,8 @@ foreach(lib Git CMake Test)
     configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${lib}Info.cpp.in
                    ${CMAKE_CURRENT_BINARY_DIR}/${lib}Info.cpp @ONLY)
 
-    add_library(${lib}InfoLib ${CMAKE_CURRENT_BINARY_DIR}/${lib}Info.cpp
+    ogs_add_library(${lib}InfoLib ${CMAKE_CURRENT_BINARY_DIR}/${lib}Info.cpp
                               ${lib}Info.h)
 
-    include(GenerateExportHeader)
-    generate_export_header(${lib}InfoLib)
     target_include_directories(${lib}InfoLib PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
-    if(BUILD_SHARED_LIBS)
-        install(TARGETS ${lib}InfoLib LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-    endif()
 endforeach(lib)
diff --git a/MaterialLib/CMakeLists.txt b/MaterialLib/CMakeLists.txt
index 3b1e47b060a..69ba77725b8 100644
--- a/MaterialLib/CMakeLists.txt
+++ b/MaterialLib/CMakeLists.txt
@@ -34,10 +34,7 @@ if(OGS_USE_MFRONT)
     add_subdirectory(SolidModels/MFront)
 endif()
 
-add_library(MaterialLib ${SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS MaterialLib LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(MaterialLib ${SOURCES})
 
 include(GenerateExportHeader)
 generate_export_header(MaterialLib)
@@ -48,7 +45,3 @@ target_link_libraries(MaterialLib PRIVATE MathLib MeshLib ParameterLib)
 if(OGS_USE_MFRONT)
     target_link_libraries(MaterialLib PUBLIC MaterialLib_SolidModels_MFront)
 endif()
-
-if(OGS_USE_PCH)
-    cotire(MaterialLib)
-endif()
diff --git a/MaterialLib/SolidModels/MFront/CMakeLists.txt b/MaterialLib/SolidModels/MFront/CMakeLists.txt
index d197cc6c023..6facf3fc141 100644
--- a/MaterialLib/SolidModels/MFront/CMakeLists.txt
+++ b/MaterialLib/SolidModels/MFront/CMakeLists.txt
@@ -2,12 +2,7 @@ set(SOURCES CreateMFront.cpp CreateMFront.h)
 
 list(APPEND SOURCES MFront.cpp MFront.h)
 
-add_library(MaterialLib_SolidModels_MFront ${SOURCES})
-
-if(BUILD_SHARED_LIBS)
-    install(TARGETS MaterialLib_SolidModels_MFront
-            LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(MaterialLib_SolidModels_MFront ${SOURCES})
 
 target_link_libraries(MaterialLib_SolidModels_MFront
                       PUBLIC BaseLib NumLib logog OgsMFrontBehaviour
diff --git a/MathLib/CMakeLists.txt b/MathLib/CMakeLists.txt
index 4b1030bcd5e..a27d9fa6cee 100644
--- a/MathLib/CMakeLists.txt
+++ b/MathLib/CMakeLists.txt
@@ -25,13 +25,7 @@ if(OGS_USE_PETSC)
 endif()
 
 # Create the library
-add_library(MathLib ${SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS MathLib LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
-
-include(GenerateExportHeader)
-generate_export_header(MathLib)
+ogs_add_library(MathLib ${SOURCES})
 target_include_directories(MathLib PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
 
 set_target_properties(MathLib PROPERTIES LINKER_LANGUAGE CXX)
@@ -59,7 +53,3 @@ if(OGS_USE_PETSC)
     target_include_directories(MathLib PUBLIC ${PETSC_INCLUDE_DIRS})
     target_link_libraries(MathLib PUBLIC ${PETSC_LIBRARIES})
 endif()
-
-if(OGS_USE_PCH)
-    cotire(MathLib)
-endif()
diff --git a/MeshGeoToolsLib/CMakeLists.txt b/MeshGeoToolsLib/CMakeLists.txt
index 8a6ea49d716..4bafd9791be 100644
--- a/MeshGeoToolsLib/CMakeLists.txt
+++ b/MeshGeoToolsLib/CMakeLists.txt
@@ -2,15 +2,8 @@
 get_source_files(SOURCES)
 
 # Create the library
-add_library(MeshGeoToolsLib ${SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS MeshGeoToolsLib LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(MeshGeoToolsLib ${SOURCES})
 
 target_link_libraries(MeshGeoToolsLib
                       PUBLIC GeoLib MathLib
                       PRIVATE BaseLib MeshLib logog)
-
-if(OGS_USE_PCH)
-    cotire(MeshGeoToolsLib)
-endif()
diff --git a/MeshLib/CMakeLists.txt b/MeshLib/CMakeLists.txt
index e92236424e0..b739688c335 100644
--- a/MeshLib/CMakeLists.txt
+++ b/MeshLib/CMakeLists.txt
@@ -21,13 +21,7 @@ if(OGS_USE_PETSC)
 endif()
 
 # Create the library
-add_library(MeshLib ${SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS MeshLib LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
-if(OGS_USE_PCH)
-    cotire(MeshLib)
-endif()
+ogs_add_library(MeshLib ${SOURCES})
 
 target_link_libraries(MeshLib
                       PUBLIC BaseLib
diff --git a/NumLib/CMakeLists.txt b/NumLib/CMakeLists.txt
index 7c744d1536b..7d66a36d90b 100644
--- a/NumLib/CMakeLists.txt
+++ b/NumLib/CMakeLists.txt
@@ -14,12 +14,7 @@ append_source_files(SOURCES ODESolver)
 append_source_files(SOURCES Extrapolation)
 
 # Create the library
-add_library(NumLib ${SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS NumLib LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
-include(GenerateExportHeader)
-generate_export_header(NumLib)
+ogs_add_library(NumLib ${SOURCES})
 target_include_directories(NumLib PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
 
 set_target_properties(NumLib PROPERTIES LINKER_LANGUAGE CXX)
@@ -31,7 +26,3 @@ target_link_libraries(NumLib
                              MeshLib
                              logog
                       PRIVATE MeshGeoToolsLib)
-
-if(OGS_USE_PCH)
-    cotire(NumLib)
-endif()
diff --git a/ParameterLib/CMakeLists.txt b/ParameterLib/CMakeLists.txt
index b13a5dd19c4..9c54b8e304b 100644
--- a/ParameterLib/CMakeLists.txt
+++ b/ParameterLib/CMakeLists.txt
@@ -1,17 +1,10 @@
 # Source files
 get_source_files(SOURCES)
 
-add_library(ParameterLib ${SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS ParameterLib LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(ParameterLib ${SOURCES})
 
 include(GenerateExportHeader)
 generate_export_header(ParameterLib)
 target_include_directories(ParameterLib PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
 
 target_link_libraries(ParameterLib PUBLIC MathLib PRIVATE BaseLib MeshLib)
-
-if(OGS_USE_PCH)
-    cotire(ParameterLib)
-endif()
diff --git a/ProcessLib/BoundaryCondition/Python/CMakeLists.txt b/ProcessLib/BoundaryCondition/Python/CMakeLists.txt
index 2c3615ed9b3..caa5e62b1ea 100644
--- a/ProcessLib/BoundaryCondition/Python/CMakeLists.txt
+++ b/ProcessLib/BoundaryCondition/Python/CMakeLists.txt
@@ -1,14 +1,10 @@
-add_library(ProcessLibBoundaryConditionPython
+ogs_add_library(ProcessLibBoundaryConditionPython
             PythonBoundaryCondition.cpp
             PythonBoundaryCondition.h
             PythonBoundaryConditionLocalAssembler.h
             PythonBoundaryConditionPythonSideInterface.h
             BHEInflowPythonBoundaryCondition.h
             BHEInflowPythonBoundaryConditionPythonSideInterface.h)
-if(BUILD_SHARED_LIBS)
-    install(TARGETS ProcessLibBoundaryConditionPython
-            LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
 
 target_compile_definitions(ProcessLibBoundaryConditionPython PUBLIC
                            OGS_USE_PYTHON)
@@ -23,14 +19,10 @@ target_link_libraries(ProcessLibBoundaryConditionPython
                       PRIVATE pybind11::pybind11)
 
 # For the embedded Python module
-add_library(ProcessLibBoundaryConditionPythonModule
+ogs_add_library(ProcessLibBoundaryConditionPythonModule
             PythonBoundaryConditionModule.cpp PythonBoundaryConditionModule.h
             BHEInflowPythonBoundaryConditionModule.cpp
             BHEInflowPythonBoundaryConditionModule.h)
-if(BUILD_SHARED_LIBS)
-    install(TARGETS ProcessLibBoundaryConditionPythonModule
-            LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
 
 target_link_libraries(ProcessLibBoundaryConditionPythonModule
                       PUBLIC ProcessLibBoundaryConditionPython
diff --git a/ProcessLib/CMakeLists.txt b/ProcessLib/CMakeLists.txt
index 59708f4d487..ce79822dcbe 100644
--- a/ProcessLib/CMakeLists.txt
+++ b/ProcessLib/CMakeLists.txt
@@ -17,10 +17,7 @@ append_source_files(SOURCES Output)
 append_source_files(SOURCES SourceTerms)
 append_source_files(SOURCES Utils)
 
-add_library(ProcessLib ${SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS ProcessLib LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(ProcessLib ${SOURCES})
 
 target_link_libraries(ProcessLib
                       PUBLIC BaseLib
@@ -50,7 +47,3 @@ endif()
 if(OGS_INSITU)
     target_link_libraries(ProcessLib InSituLib)
 endif()
-
-if(OGS_USE_PCH)
-    cotire(ProcessLib)
-endif()
diff --git a/ProcessLib/ComponentTransport/CMakeLists.txt b/ProcessLib/ComponentTransport/CMakeLists.txt
index a805d778717..e7694fa4248 100644
--- a/ProcessLib/ComponentTransport/CMakeLists.txt
+++ b/ProcessLib/ComponentTransport/CMakeLists.txt
@@ -1,10 +1,6 @@
 append_source_files(SOURCES)
 
-add_library(ComponentTransport ${SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS ComponentTransport
-            LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(ComponentTransport ${SOURCES})
 
 target_link_libraries(ComponentTransport PUBLIC ProcessLib PRIVATE ParameterLib)
 
diff --git a/ProcessLib/GroundwaterFlow/CMakeLists.txt b/ProcessLib/GroundwaterFlow/CMakeLists.txt
index aa41559e83a..ec13ffc7259 100644
--- a/ProcessLib/GroundwaterFlow/CMakeLists.txt
+++ b/ProcessLib/GroundwaterFlow/CMakeLists.txt
@@ -1,9 +1,6 @@
 append_source_files(SOURCES)
 
-add_library(GroundwaterFlow ${SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS GroundwaterFlow LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(GroundwaterFlow ${SOURCES})
 
 target_link_libraries(GroundwaterFlow PUBLIC ProcessLib PRIVATE ParameterLib)
 
diff --git a/ProcessLib/HT/CMakeLists.txt b/ProcessLib/HT/CMakeLists.txt
index 17818b31a0f..dfc62fb7782 100644
--- a/ProcessLib/HT/CMakeLists.txt
+++ b/ProcessLib/HT/CMakeLists.txt
@@ -1,9 +1,6 @@
 append_source_files(SOURCES)
 
-add_library(HT ${SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS HT LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(HT ${SOURCES})
 target_link_libraries(HT PUBLIC ProcessLib PRIVATE ParameterLib)
 
 if(BUILD_TESTING)
diff --git a/ProcessLib/HeatConduction/CMakeLists.txt b/ProcessLib/HeatConduction/CMakeLists.txt
index 60321def8d2..0c405947a06 100644
--- a/ProcessLib/HeatConduction/CMakeLists.txt
+++ b/ProcessLib/HeatConduction/CMakeLists.txt
@@ -1,9 +1,6 @@
 append_source_files(SOURCES)
 
-add_library(HeatConduction ${SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS HeatConduction LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(HeatConduction ${SOURCES})
 target_link_libraries(HeatConduction PUBLIC ProcessLib PRIVATE ParameterLib)
 
 if(BUILD_TESTING)
diff --git a/ProcessLib/HeatTransportBHE/CMakeLists.txt b/ProcessLib/HeatTransportBHE/CMakeLists.txt
index e7604af78b3..29edec17081 100644
--- a/ProcessLib/HeatTransportBHE/CMakeLists.txt
+++ b/ProcessLib/HeatTransportBHE/CMakeLists.txt
@@ -3,17 +3,13 @@ append_source_files(SOURCES BHE)
 append_source_files(SOURCES BoundaryConditions)
 append_source_files(SOURCES LocalAssemblers)
 
-add_library(HeatTransportBHE ${SOURCES})
+ogs_add_library(HeatTransportBHE ${SOURCES})
 
 target_link_libraries(HeatTransportBHE PUBLIC ProcessLib)
 if (OGS_USE_PYTHON)
     target_link_libraries(HeatTransportBHE PRIVATE pybind11::pybind11)
 endif()
 
-if(BUILD_SHARED_LIBS)
-    install(TARGETS HeatTransportBHE
-            LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
 target_link_libraries(HeatTransportBHE PUBLIC ProcessLib PRIVATE ParameterLib)
 
 if(BUILD_TESTING)
diff --git a/ProcessLib/HydroMechanics/CMakeLists.txt b/ProcessLib/HydroMechanics/CMakeLists.txt
index 7f4a3532626..36b6d27a15f 100644
--- a/ProcessLib/HydroMechanics/CMakeLists.txt
+++ b/ProcessLib/HydroMechanics/CMakeLists.txt
@@ -1,9 +1,6 @@
 append_source_files(SOURCES)
 
-add_library(HydroMechanics ${SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS HydroMechanics LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(HydroMechanics ${SOURCES})
 target_link_libraries(HydroMechanics PUBLIC ProcessLib PRIVATE ParameterLib)
 
 if(BUILD_TESTING)
diff --git a/ProcessLib/LIE/CMakeLists.txt b/ProcessLib/LIE/CMakeLists.txt
index 82d04ba4e4b..da00cec0e52 100644
--- a/ProcessLib/LIE/CMakeLists.txt
+++ b/ProcessLib/LIE/CMakeLists.txt
@@ -4,10 +4,7 @@ append_source_files(SOURCES HydroMechanics/LocalAssembler)
 append_source_files(SOURCES SmallDeformation)
 append_source_files(SOURCES SmallDeformation/LocalAssembler)
 
-add_library(LIE ${SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS LIE LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(LIE ${SOURCES})
 target_link_libraries(LIE PUBLIC ProcessLib LIECommon PRIVATE ParameterLib)
 
 if(BUILD_TESTING)
diff --git a/ProcessLib/LIE/Common/CMakeLists.txt b/ProcessLib/LIE/Common/CMakeLists.txt
index 807b396591c..67cba9650fa 100644
--- a/ProcessLib/LIE/Common/CMakeLists.txt
+++ b/ProcessLib/LIE/Common/CMakeLists.txt
@@ -1,7 +1,4 @@
 append_source_files(SOURCES)
 
-add_library(LIECommon ${SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS LIECommon LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(LIECommon ${SOURCES})
 target_link_libraries(LIECommon PUBLIC MeshLib)
diff --git a/ProcessLib/LiquidFlow/CMakeLists.txt b/ProcessLib/LiquidFlow/CMakeLists.txt
index aff39704071..f3ef35b6ba8 100644
--- a/ProcessLib/LiquidFlow/CMakeLists.txt
+++ b/ProcessLib/LiquidFlow/CMakeLists.txt
@@ -1,9 +1,6 @@
 append_source_files(SOURCES)
 
-add_library(LiquidFlow ${SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS LiquidFlow LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(LiquidFlow ${SOURCES})
 target_link_libraries(LiquidFlow PUBLIC ProcessLib PRIVATE ParameterLib)
 
 if(BUILD_TESTING)
diff --git a/ProcessLib/PhaseField/CMakeLists.txt b/ProcessLib/PhaseField/CMakeLists.txt
index 310e2d432f7..63b39f5e18b 100644
--- a/ProcessLib/PhaseField/CMakeLists.txt
+++ b/ProcessLib/PhaseField/CMakeLists.txt
@@ -1,9 +1,6 @@
 append_source_files(SOURCES)
 
-add_library(PhaseField ${SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS PhaseField LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(PhaseField ${SOURCES})
 target_link_libraries(PhaseField PUBLIC ProcessLib PRIVATE ParameterLib)
 
 if(BUILD_TESTING)
diff --git a/ProcessLib/RichardsComponentTransport/CMakeLists.txt b/ProcessLib/RichardsComponentTransport/CMakeLists.txt
index 41de747e740..594c3d1a041 100644
--- a/ProcessLib/RichardsComponentTransport/CMakeLists.txt
+++ b/ProcessLib/RichardsComponentTransport/CMakeLists.txt
@@ -1,10 +1,6 @@
 append_source_files(SOURCES)
 
-add_library(RichardsComponentTransport ${SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS RichardsComponentTransport
-            LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(RichardsComponentTransport ${SOURCES})
 target_link_libraries(RichardsComponentTransport
                       PUBLIC ProcessLib
                       PRIVATE ParameterLib)
diff --git a/ProcessLib/RichardsFlow/CMakeLists.txt b/ProcessLib/RichardsFlow/CMakeLists.txt
index e6f84adaf99..b474e6de3d7 100644
--- a/ProcessLib/RichardsFlow/CMakeLists.txt
+++ b/ProcessLib/RichardsFlow/CMakeLists.txt
@@ -1,9 +1,6 @@
 append_source_files(SOURCES)
 
-add_library(RichardsFlow ${SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS RichardsFlow LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(RichardsFlow ${SOURCES})
 target_link_libraries(RichardsFlow PUBLIC ProcessLib PRIVATE ParameterLib)
 
 if(BUILD_TESTING)
diff --git a/ProcessLib/RichardsMechanics/CMakeLists.txt b/ProcessLib/RichardsMechanics/CMakeLists.txt
index 15ca94b70dd..2850a9a05aa 100644
--- a/ProcessLib/RichardsMechanics/CMakeLists.txt
+++ b/ProcessLib/RichardsMechanics/CMakeLists.txt
@@ -1,14 +1,7 @@
 append_source_files(SOURCES)
 
-add_library(RichardsMechanics ${SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS RichardsMechanics
-            LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
-target_link_libraries(
-    RichardsMechanics
-    PUBLIC ProcessLib
-    PRIVATE ParameterLib)
+ogs_add_library(RichardsMechanics ${SOURCES})
+target_link_libraries(RichardsMechanics PUBLIC ProcessLib PRIVATE ParameterLib)
 
 if(BUILD_TESTING)
     include(Tests.cmake)
diff --git a/ProcessLib/SmallDeformation/CMakeLists.txt b/ProcessLib/SmallDeformation/CMakeLists.txt
index 062f9666e79..d8155b447a3 100644
--- a/ProcessLib/SmallDeformation/CMakeLists.txt
+++ b/ProcessLib/SmallDeformation/CMakeLists.txt
@@ -1,10 +1,6 @@
 append_source_files(SOURCES)
 
-add_library(SmallDeformation ${SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS SmallDeformation
-            LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(SmallDeformation ${SOURCES})
 target_link_libraries(SmallDeformation PUBLIC ProcessLib PRIVATE ParameterLib)
 
 if(BUILD_TESTING)
diff --git a/ProcessLib/SmallDeformationNonlocal/CMakeLists.txt b/ProcessLib/SmallDeformationNonlocal/CMakeLists.txt
index 741858e8617..a00485ff530 100644
--- a/ProcessLib/SmallDeformationNonlocal/CMakeLists.txt
+++ b/ProcessLib/SmallDeformationNonlocal/CMakeLists.txt
@@ -1,13 +1,9 @@
 append_source_files(SOURCES)
 
-add_library(SmallDeformationNonlocal ${SOURCES})
+ogs_add_library(SmallDeformationNonlocal ${SOURCES})
 target_link_libraries(SmallDeformationNonlocal
                       PUBLIC ProcessLib
                       PRIVATE ParameterLib)
-if(BUILD_SHARED_LIBS)
-    install(TARGETS SmallDeformationNonlocal
-            LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
 
 if(BUILD_TESTING)
     include(Tests.cmake)
diff --git a/ProcessLib/SourceTerms/Python/CMakeLists.txt b/ProcessLib/SourceTerms/Python/CMakeLists.txt
index c5f55ad0208..0406ad087e4 100644
--- a/ProcessLib/SourceTerms/Python/CMakeLists.txt
+++ b/ProcessLib/SourceTerms/Python/CMakeLists.txt
@@ -1,14 +1,10 @@
-add_library(ProcessLibSourceTermPython
-            CreatePythonSourceTerm.cpp
-            CreatePythonSourceTerm.h
-            PythonSourceTerm.cpp
-            PythonSourceTerm.h
-            PythonSourceTermLocalAssembler.h
-            PythonSourceTermPythonSideInterface.h)
-if(BUILD_SHARED_LIBS)
-    install(TARGETS ProcessLibSourceTermPython
-            LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(ProcessLibSourceTermPython
+                CreatePythonSourceTerm.cpp
+                CreatePythonSourceTerm.h
+                PythonSourceTerm.cpp
+                PythonSourceTerm.h
+                PythonSourceTermLocalAssembler.h
+                PythonSourceTermPythonSideInterface.h)
 
 target_compile_definitions(ProcessLibSourceTermPython PUBLIC OGS_USE_PYTHON)
 
@@ -22,12 +18,8 @@ target_link_libraries(ProcessLibSourceTermPython
                       PRIVATE pybind11::pybind11)
 
 # For the embedded Python module
-add_library(ProcessLibSourceTermPythonModule PythonSourceTermModule.cpp
-                                             PythonSourceTermModule.h)
-if(BUILD_SHARED_LIBS)
-    install(TARGETS ProcessLibSourceTermPythonModule
-            LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(ProcessLibSourceTermPythonModule PythonSourceTermModule.cpp
+                                                 PythonSourceTermModule.h)
 
 target_link_libraries(ProcessLibSourceTermPythonModule
                       PUBLIC ProcessLibSourceTermPython pybind11::pybind11)
diff --git a/ProcessLib/SteadyStateDiffusion/CMakeLists.txt b/ProcessLib/SteadyStateDiffusion/CMakeLists.txt
index 44edb0f9601..34202c747e8 100644
--- a/ProcessLib/SteadyStateDiffusion/CMakeLists.txt
+++ b/ProcessLib/SteadyStateDiffusion/CMakeLists.txt
@@ -1,10 +1,8 @@
 append_source_files(SOURCES)
 
-add_library(SteadyStateDiffusion ${SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS SteadyStateDiffusion LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(SteadyStateDiffusion ${SOURCES})
 
-target_link_libraries(SteadyStateDiffusion PUBLIC ProcessLib PRIVATE ParameterLib)
+target_link_libraries(SteadyStateDiffusion PUBLIC ProcessLib
+    PRIVATE ParameterLib)
 
 include(Tests.cmake)
diff --git a/ProcessLib/TES/CMakeLists.txt b/ProcessLib/TES/CMakeLists.txt
index 6ed8040b8e0..94a321bb0d8 100644
--- a/ProcessLib/TES/CMakeLists.txt
+++ b/ProcessLib/TES/CMakeLists.txt
@@ -1,9 +1,7 @@
 append_source_files(SOURCES)
 
-add_library(TES ${SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS TES LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(TES ${SOURCES})
+
 target_link_libraries(TES PUBLIC ProcessLib PRIVATE ParameterLib)
 
 if(BUILD_TESTING)
diff --git a/ProcessLib/ThermalTwoPhaseFlowWithPP/CMakeLists.txt b/ProcessLib/ThermalTwoPhaseFlowWithPP/CMakeLists.txt
index 628c0760420..ca66cf505c4 100644
--- a/ProcessLib/ThermalTwoPhaseFlowWithPP/CMakeLists.txt
+++ b/ProcessLib/ThermalTwoPhaseFlowWithPP/CMakeLists.txt
@@ -1,6 +1,6 @@
 append_source_files(SOURCES)
 
-add_library(ThermalTwoPhaseFlowWithPP ${SOURCES})
+ogs_add_library(ThermalTwoPhaseFlowWithPP ${SOURCES})
 if(BUILD_SHARED_LIBS)
     install(TARGETS ThermalTwoPhaseFlowWithPP
             LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
diff --git a/ProcessLib/ThermoHydroMechanics/CMakeLists.txt b/ProcessLib/ThermoHydroMechanics/CMakeLists.txt
index b6eb5a78730..f80f5b788ea 100644
--- a/ProcessLib/ThermoHydroMechanics/CMakeLists.txt
+++ b/ProcessLib/ThermoHydroMechanics/CMakeLists.txt
@@ -1,10 +1,6 @@
 append_source_files(SOURCES)
 
-add_library(ThermoHydroMechanics ${SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS ThermoHydroMechanics
-            LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(ThermoHydroMechanics ${SOURCES})
 target_link_libraries(ThermoHydroMechanics
                       PUBLIC ProcessLib
                       PRIVATE ParameterLib)
diff --git a/ProcessLib/ThermoMechanicalPhaseField/CMakeLists.txt b/ProcessLib/ThermoMechanicalPhaseField/CMakeLists.txt
index 59571260b99..d53db208ff3 100644
--- a/ProcessLib/ThermoMechanicalPhaseField/CMakeLists.txt
+++ b/ProcessLib/ThermoMechanicalPhaseField/CMakeLists.txt
@@ -1,10 +1,6 @@
 append_source_files(SOURCES)
 
-add_library(ThermoMechanicalPhaseField ${SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS ThermoMechanicalPhaseField
-            LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(ThermoMechanicalPhaseField ${SOURCES})
 target_link_libraries(ThermoMechanicalPhaseField
                       PUBLIC ProcessLib
                       PRIVATE ParameterLib)
diff --git a/ProcessLib/ThermoMechanics/CMakeLists.txt b/ProcessLib/ThermoMechanics/CMakeLists.txt
index 41c6f654eee..7ecb35b34bc 100644
--- a/ProcessLib/ThermoMechanics/CMakeLists.txt
+++ b/ProcessLib/ThermoMechanics/CMakeLists.txt
@@ -1,9 +1,6 @@
 append_source_files(SOURCES)
 
-add_library(ThermoMechanics ${SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS ThermoMechanics LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(ThermoMechanics ${SOURCES})
 target_link_libraries(ThermoMechanics PUBLIC ProcessLib PRIVATE ParameterLib)
 
 if(BUILD_TESTING)
diff --git a/ProcessLib/TwoPhaseFlowWithPP/CMakeLists.txt b/ProcessLib/TwoPhaseFlowWithPP/CMakeLists.txt
index 685c97cf1c5..62de80bb32c 100644
--- a/ProcessLib/TwoPhaseFlowWithPP/CMakeLists.txt
+++ b/ProcessLib/TwoPhaseFlowWithPP/CMakeLists.txt
@@ -1,10 +1,6 @@
 append_source_files(SOURCES)
 
-add_library(TwoPhaseFlowWithPP ${SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS TwoPhaseFlowWithPP
-            LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(TwoPhaseFlowWithPP ${SOURCES})
 target_link_libraries(TwoPhaseFlowWithPP PUBLIC ProcessLib PRIVATE ParameterLib)
 
 if(BUILD_TESTING)
diff --git a/ProcessLib/TwoPhaseFlowWithPrho/CMakeLists.txt b/ProcessLib/TwoPhaseFlowWithPrho/CMakeLists.txt
index 3d0eb0ee3d2..41ab460fc98 100644
--- a/ProcessLib/TwoPhaseFlowWithPrho/CMakeLists.txt
+++ b/ProcessLib/TwoPhaseFlowWithPrho/CMakeLists.txt
@@ -1,10 +1,6 @@
 append_source_files(SOURCES)
 
-add_library(TwoPhaseFlowWithPrho ${SOURCES})
-if(BUILD_SHARED_LIBS)
-    install(TARGETS TwoPhaseFlowWithPrho
-            LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-endif()
+ogs_add_library(TwoPhaseFlowWithPrho ${SOURCES})
 target_link_libraries(TwoPhaseFlowWithPrho
                       PUBLIC ProcessLib
                       PRIVATE ParameterLib)
-- 
GitLab