diff --git a/Applications/ApplicationsLib/CMakeLists.txt b/Applications/ApplicationsLib/CMakeLists.txt
index e446674da71a1d67ac88933d621a4b316da444bc..e391d9c34a3f5fed4ac79c21d9736cb892dc8fd4 100644
--- a/Applications/ApplicationsLib/CMakeLists.txt
+++ b/Applications/ApplicationsLib/CMakeLists.txt
@@ -13,7 +13,9 @@ target_link_libraries(ApplicationsLib
                               MeshGeoToolsLib
                               ParameterLib
                               ProcessLib
-                              spdlog::spdlog)
+                              spdlog::spdlog
+                              $<$<BOOL:${OGS_USE_PYTHON}>:pybind11::pybind11>
+)
 
 # Set cpp definitions if the cmake option is enabled for the given process.
 foreach(process ${ProcessesList})
@@ -24,7 +26,3 @@ foreach(process ${ProcessesList})
                      PROPERTY COMPILE_DEFINITIONS ${EnableProcess})
     endif()
 endforeach()
-
-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 3035e44b6b7de9785b9aee584db84e0e8ef2f341..df79fbc5e32f184add1e7b38421c11987071cbea 100644
--- a/Applications/CLI/CMakeLists.txt
+++ b/Applications/CLI/CMakeLists.txt
@@ -1,14 +1,3 @@
-add_executable(ogs ogs.cpp)
-
-target_link_libraries(ogs
-    PRIVATE
-        ApplicationsLib
-        BaseLib
-        CMakeInfoLib
-        GitInfoLib
-        ProcessLib
-)
-
 if(OGS_USE_PYTHON)
     # Troubleshooting: If you get linker errors, such as   ogs.cpp:(.text+0xb4):
     # undefined reference to `_Py_ZeroStruct' it could be that OGS is compiled
@@ -43,33 +32,34 @@ if(OGS_USE_PYTHON)
     # provides the minimal set of parameters to ensure that the code using
     # pybind11 compiles, but it does not pass these extra compiler flags (i.e.
     # this is up to you). TODO: Enable further compiler/linker flags.
-    target_link_libraries(ogs_embedded_python PUBLIC pybind11::embed)
-    target_compile_definitions(ogs_embedded_python PUBLIC OGS_USE_PYTHON)
     target_link_libraries(ogs_embedded_python
-                          PRIVATE ProcessLibBoundaryConditionPythonModule
-                                  ProcessLibSourceTermPythonModule)
-
-    target_link_libraries(ogs PRIVATE ogs_embedded_python)
-
-    if(BUILD_SHARED_LIBS)
+        PUBLIC pybind11::embed
+        PRIVATE ProcessLibBoundaryConditionPythonModule
+                ProcessLibSourceTermPythonModule
+    )
+    target_compile_definitions(ogs_embedded_python
+        PUBLIC OGS_USE_PYTHON
         # Add macro definition, because static libs make special handling
         # necessary s.t. the embedded OpenGeoSys Python module won't be removed
         # by the linker.
-        target_compile_definitions(ogs_embedded_python PRIVATE
-                                   OGS_BUILD_SHARED_LIBS)
-    endif()
+        $<$<BOOL:${BUILD_SHARED_LIBS}>:PRIVATE OGS_BUILD_SHARED_LIBS>
+    )
 endif()
 
-if(OGS_USE_PETSC)
-    target_link_libraries(ogs PRIVATE ${PETSC_LIBRARIES})
-endif()
-if(OGS_USE_MPI AND TARGET MPI::MPI_CXX)
-    target_link_libraries(ogs PRIVATE MPI::MPI_CXX)
-endif()
+add_executable(ogs ogs.cpp)
 
-if(OGS_INSITU)
-    target_link_libraries(ogs PRIVATE InSituLib)
-endif()
+target_link_libraries(ogs
+    PRIVATE
+        ApplicationsLib
+        BaseLib
+        CMakeInfoLib
+        GitInfoLib
+        ProcessLib
+        $<$<BOOL:${OGS_USE_PETSC}>:${PETSC_LIBRARIES}>
+        $<$<TARGET_EXISTS:ogs_embedded_python>:ogs_embedded_python>
+        $<$<TARGET_EXISTS:MPI::MPI_CXX>:MPI::MPI_CXX>
+        $<$<TARGET_EXISTS:InSituLib>:InSituLib>
+)
 
 # ---- Tests ----
 add_test(NAME ogs_no_args COMMAND ogs)
diff --git a/Applications/FileIO/CMakeLists.txt b/Applications/FileIO/CMakeLists.txt
index d3d3d45f5511005cbde6857fdd37803bbe62edad..b4f5777133ba0aeec9bf97e03349c47cb2ecda92 100644
--- a/Applications/FileIO/CMakeLists.txt
+++ b/Applications/FileIO/CMakeLists.txt
@@ -29,20 +29,12 @@ target_link_libraries(ApplicationsFileIO
                              DataHolderLib
                              GeoLib
                              MathLib
-                      PRIVATE MeshLib GitInfoLib std::filesystem spdlog::spdlog)
-
-if(OGS_BUILD_GUI)
-    # Needed for the XmlPrjInterface, which links the DE/Base/OGSError.h.
-    target_link_libraries(ApplicationsFileIO PUBLIC QtBase)
-endif()
-
-if(Shapelib_FOUND)
-    target_link_libraries(ApplicationsFileIO PRIVATE ${Shapelib_LIBRARIES})
-endif()
-
-if(OGS_BUILD_SWMM)
-    target_link_libraries(ApplicationsFileIO PRIVATE SwmmInterface)
-endif()
+                             # Needed for the XmlPrjInterface, which links the DE/Base/OGSError.h.
+                             $<$<BOOL:${OGS_BUILD_GUI}>:QtBase>
+                             $<$<BOOL:${Shapelib_FOUND}>:${Shapelib_LIBRARIES}>
+                             $<$<TARGET_EXISTS:SwmmInterface>:SwmmInterface>
+                      PRIVATE MeshLib GitInfoLib std::filesystem spdlog::spdlog
+)
 
 configure_file(XmlIO/OpenGeoSysCND.xsd
                ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/OpenGeoSysCND.xsd COPYONLY)
diff --git a/Applications/InSituLib/CMakeLists.txt b/Applications/InSituLib/CMakeLists.txt
index 9fe55669685ce134c5b1bd49f40bf82ef20346d6..e42084487e225ae00c98364ba8f994f31ae05641 100644
--- a/Applications/InSituLib/CMakeLists.txt
+++ b/Applications/InSituLib/CMakeLists.txt
@@ -8,10 +8,11 @@ if(BUILD_SHARED_LIBS)
 endif()
 
 target_link_libraries(InSituLib
+    PUBLIC
+        BaseLib
     INTERFACE
-      VTK::PythonUsed
+        VTK::PythonUsed
     PRIVATE
-      ParaView::PythonCatalyst
-      VTK::CommonDataModel)
-
-target_link_libraries(InSituLib PUBLIC BaseLib PRIVATE MeshLib)
+        MeshLib
+        ParaView::PythonCatalyst
+        VTK::CommonDataModel)
diff --git a/Applications/Utils/FileConverter/CMakeLists.txt b/Applications/Utils/FileConverter/CMakeLists.txt
index 4d5aec825fb3218386ab8a80c32419bd3e3fd5bd..26e2ccaffe9f6ab4ac89f265ab9bf4d166fc4eeb 100644
--- a/Applications/Utils/FileConverter/CMakeLists.txt
+++ b/Applications/Utils/FileConverter/CMakeLists.txt
@@ -46,7 +46,8 @@ if(TARGET NetCdfConverter)
                           ${NETCDF_LIBRARIES_CXX}
                           ${NETCDF_LIBRARIES_C}
                           ${HDF5_HL_LIBRARIES}
-                          ${HDF5_LIBRARIES})
+                          ${HDF5_LIBRARIES}
+    )
     if(OGS_USE_CONAN AND MSVC)
         target_link_libraries(NetCdfConverter ${CONAN_LIBS})
     endif()
diff --git a/BaseLib/CMakeLists.txt b/BaseLib/CMakeLists.txt
index a6ec00011927bb9bbd3c441a827628840286c115..e4165f9e1b53aa51e2bb8f72d5ccedff5035c043 100644
--- a/BaseLib/CMakeLists.txt
+++ b/BaseLib/CMakeLists.txt
@@ -8,13 +8,9 @@ endif()
 # Create the library
 ogs_add_library(BaseLib ${SOURCES})
 
-target_link_libraries(BaseLib PUBLIC Boost::boost spdlog::spdlog
-                                     std::filesystem)
-
-if(MSVC)
-    target_link_libraries(BaseLib PUBLIC WinMM) # needed for timeGetTime
-endif()
-
-if(OGS_BUILD_GUI)
-    target_link_libraries(BaseLib PUBLIC Qt5::Xml Qt5::XmlPatterns)
-endif()
+target_link_libraries(BaseLib PUBLIC Boost::boost
+                                     spdlog::spdlog
+                                     std::filesystem
+                                     $<$<BOOL:${MSVC}>:WinMM> # needed for timeGetTime
+                                     $<$<BOOL:${OGS_BUILD_GUI}>:"Qt5::Xml Qt5::XmlPatterns">
+)
diff --git a/GeoLib/CMakeLists.txt b/GeoLib/CMakeLists.txt
index 0168f1789fab5c8822dc56b4d524539cfa7844bb..11f7f7f97a15171914e6ad332fb58b96857db995 100644
--- a/GeoLib/CMakeLists.txt
+++ b/GeoLib/CMakeLists.txt
@@ -12,11 +12,13 @@ endif()
 # Create the library
 ogs_add_library(GeoLib ${SOURCES})
 
-target_link_libraries(GeoLib PUBLIC BaseLib MathLib PRIVATE tet spdlog::spdlog)
-
-if(OGS_BUILD_GUI)
-    target_link_libraries(GeoLib PUBLIC Qt5::Xml Qt5::XmlPatterns)
-endif()
+target_link_libraries(GeoLib
+    PUBLIC BaseLib
+           MathLib
+           $<$<BOOL:${OGS_BUILD_GUI}>:"Qt5::Xml Qt5::XmlPatterns">
+    PRIVATE tet
+            spdlog::spdlog
+)
 
 configure_file(IO/XmlIO/OpenGeoSysGLI.xsd
                ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/OpenGeoSysGLI.xsd COPYONLY)
diff --git a/MaterialLib/CMakeLists.txt b/MaterialLib/CMakeLists.txt
index 6817abbfad6af254dacefdc3a8a0bb5d12b3fe8a..f54fe6f13ed12c6d3482d54b19813bd097e2335b 100644
--- a/MaterialLib/CMakeLists.txt
+++ b/MaterialLib/CMakeLists.txt
@@ -41,9 +41,12 @@ include(GenerateExportHeader)
 generate_export_header(MaterialLib)
 target_include_directories(MaterialLib PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
 
-target_link_libraries(MaterialLib PRIVATE MathLib MeshLib ParameterLib
-    spdlog::spdlog)
-
-if(OGS_USE_MFRONT)
-    target_link_libraries(MaterialLib PUBLIC MaterialLib_SolidModels_MFront)
-endif()
+target_link_libraries(MaterialLib
+    PUBLIC
+        $<$<TARGET_EXISTS:MaterialLib_SolidModels_MFront>:MaterialLib_SolidModels_MFront>
+    PRIVATE
+        MathLib
+        MeshLib
+        ParameterLib
+        spdlog::spdlog
+)
diff --git a/MathLib/CMakeLists.txt b/MathLib/CMakeLists.txt
index 0a1a2bbeec6562e33141fe33443300900c600d3c..ef8fde0cee9801a9b3494461e6f7570872c7f860 100644
--- a/MathLib/CMakeLists.txt
+++ b/MathLib/CMakeLists.txt
@@ -26,33 +26,25 @@ endif()
 
 # Create the library
 ogs_add_library(MathLib ${SOURCES})
-target_include_directories(MathLib PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
+target_include_directories(MathLib
+    PUBLIC
+        ${CMAKE_CURRENT_BINARY_DIR}
+        $<$<BOOL:${OGS_USE_PETSC}>:${PETSC_INCLUDE_DIRS}>
+    PRIVATE
+        $<$<BOOL:${CVODE_FOUND}>:${CVODE_INCLUDE_DIRS}>
+)
 
 set_target_properties(MathLib PROPERTIES LINKER_LANGUAGE CXX)
 
-target_link_libraries(
-    MathLib
-    PUBLIC BaseLib ${OpenMP_CXX_LIBRARIES}
-    PRIVATE spdlog::spdlog)
-
-if(CVODE_FOUND)
-    target_include_directories(MathLib PRIVATE ${CVODE_INCLUDE_DIRS})
-    target_link_libraries(MathLib PUBLIC ${CVODE_LIBRARIES})
-endif()
-
-if(LAPACK_FOUND)
-    target_link_libraries(MathLib PUBLIC ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
-endif()
-
-if(OGS_USE_LIS)
-    target_link_libraries(MathLib PUBLIC ${LIS_LIBRARIES})
-endif()
-
-if(OGS_USE_MKL)
-    target_link_libraries(MathLib PUBLIC ${MKL_LIBRARIES})
-endif()
-
-if(OGS_USE_PETSC)
-    target_include_directories(MathLib PUBLIC ${PETSC_INCLUDE_DIRS})
-    target_link_libraries(MathLib PUBLIC ${PETSC_LIBRARIES})
-endif()
+target_link_libraries(MathLib
+    PUBLIC
+        BaseLib
+        ${OpenMP_CXX_LIBRARIES}
+        $<$<BOOL:${CVODE_FOUND}>:${CVODE_LIBRARIES}>
+        $<$<BOOL:${LAPACK_FOUND}>:${BLAS_LIBRARIES} ${LAPACK_LIBRARIES}>
+        $<$<BOOL:${OGS_USE_LIS}>:${LIS_LIBRARIES}>
+        $<$<BOOL:${OGS_USE_MKL}>:${MKL_LIBRARIES}>
+        $<$<BOOL:${OGS_USE_PETSC}>:${PETSC_LIBRARIES}>
+    PRIVATE
+        spdlog::spdlog
+)
diff --git a/MeshLib/CMakeLists.txt b/MeshLib/CMakeLists.txt
index e73de0542b3b97ff81f9b59122c32ea9a943628c..492ef483a579f620b20c2b4c23899b681ebbf9bc 100644
--- a/MeshLib/CMakeLists.txt
+++ b/MeshLib/CMakeLists.txt
@@ -31,14 +31,11 @@ target_link_libraries(
     PUBLIC
         BaseLib GeoLib GitInfoLib MathLib ${VTK_LIBRARIES}
         $<$<TARGET_EXISTS:OgsXdmf>:OgsXdmf>
-    PRIVATE spdlog::spdlog)
-
-if(OGS_USE_MPI AND TARGET MPI::MPI_CXX)
-    target_link_libraries(MeshLib PUBLIC MPI::MPI_CXX)
-endif()
-if(OGS_USE_PETSC)
-    target_link_libraries(ogs PRIVATE ${PETSC_LIBRARIES})
-endif()
+        $<$<TARGET_EXISTS:MPI::MPI_CXX>:MPI::MPI_CXX>
+    PRIVATE
+        spdlog::spdlog
+        $<$<BOOL:${OGS_USE_PETSC}>:${PETSC_LIBRARIES}>
+)
 
 if($ENV{VTK_USE_64BIT_IDS})
     target_compile_definitions(MeshLib PUBLIC VTK_USE_64BIT_IDS)
diff --git a/ProcessLib/CMakeLists.txt b/ProcessLib/CMakeLists.txt
index 82d61309df07767f956e73cfb3c360ad56caa387..168d26f872921fc83ab0f4b97ad4c9fcb9cb58f8 100644
--- a/ProcessLib/CMakeLists.txt
+++ b/ProcessLib/CMakeLists.txt
@@ -19,24 +19,25 @@ append_source_files(SOURCES Utils)
 
 ogs_add_library(ProcessLib ${SOURCES})
 
-target_link_libraries(
-    ProcessLib
-    PUBLIC BaseLib MaterialLib MathLib MeshGeoToolsLib MeshLib NumLib
-    PRIVATE ParameterLib GitInfoLib spdlog::spdlog)
-
-if (OGS_BUILD_PROCESS_ComponentTransport
-    OR OGS_BUILD_PROCESS_RichardsComponentTransport)
-    target_link_libraries(ProcessLib PUBLIC ChemistryLib)
-endif()
-
 if(OGS_USE_PYTHON)
     add_subdirectory(BoundaryCondition/Python)
-    target_link_libraries(ProcessLib PUBLIC ProcessLibBoundaryConditionPython)
-
     add_subdirectory(SourceTerms/Python)
-    target_link_libraries(ProcessLib PUBLIC ProcessLibSourceTermPython)
 endif()
 
-if(OGS_INSITU)
-    target_link_libraries(ProcessLib PRIVATE InSituLib)
-endif()
+target_link_libraries(ProcessLib
+    PUBLIC
+        BaseLib
+        MaterialLib
+        MathLib
+        MeshGeoToolsLib
+        MeshLib
+        NumLib
+        $<$<OR:$<BOOL:${OGS_BUILD_PROCESS_ComponentTransport}>,$<BOOL:${OGS_BUILD_PROCESS_RichardsComponentTransport}>>:ChemistryLib>
+        $<$<TARGET_EXISTS:ProcessLibBoundaryConditionPython>:ProcessLibBoundaryConditionPython>
+        $<$<TARGET_EXISTS:ProcessLibSourceTermPython>:ProcessLibSourceTermPython>
+    PRIVATE
+        ParameterLib
+        GitInfoLib
+        spdlog::spdlog
+        $<$<TARGET_EXISTS:InSituLib>:InSituLib>
+)
diff --git a/ProcessLib/HeatTransportBHE/CMakeLists.txt b/ProcessLib/HeatTransportBHE/CMakeLists.txt
index 29edec17081b822849fee787ecb17f87615b2f22..bd5e6cdbd04f17fe13a165069ccff0b52aed3eee 100644
--- a/ProcessLib/HeatTransportBHE/CMakeLists.txt
+++ b/ProcessLib/HeatTransportBHE/CMakeLists.txt
@@ -5,12 +5,13 @@ append_source_files(SOURCES LocalAssemblers)
 
 ogs_add_library(HeatTransportBHE ${SOURCES})
 
-target_link_libraries(HeatTransportBHE PUBLIC ProcessLib)
-if (OGS_USE_PYTHON)
-    target_link_libraries(HeatTransportBHE PRIVATE pybind11::pybind11)
-endif()
-
-target_link_libraries(HeatTransportBHE PUBLIC ProcessLib PRIVATE ParameterLib)
+target_link_libraries(HeatTransportBHE
+    PUBLIC
+        ProcessLib
+    PRIVATE
+    ParameterLib
+    $<$<TARGET_EXISTS:pybind11::pybind11>:pybind11::pybind11>
+)
 
 if(BUILD_TESTING)
     include(Tests.cmake)
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index f3e902b7904e6ae0c71994ad8d9b4a8641109e0d..c1eb51b9474ded38ac5f39f5a4a868794050da94 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -49,49 +49,38 @@ add_executable(testrunner ${TEST_SOURCES})
 set_target_properties(testrunner PROPERTIES FOLDER Testing)
 
 target_link_libraries(testrunner
-                      ApplicationsFileIO
-                      gtest
-                      MeshGeoToolsLib
-                      MaterialLib
-                      MeshLib
-                      NumLib
-                      ParameterLib
-                      ProcessLib
-                      TestInfoLib
-                      Threads::Threads
-                      ${VTK_LIBRARIES})
-
-if(OGS_BUILD_PROCESS_LIE)
-    target_link_libraries(testrunner LIE)
-endif()
-
-if(OGS_USE_PETSC)
-    target_link_libraries(testrunner ${PETSC_LIBRARIES})
-endif()
-
-if(OGS_USE_MPI)
-    target_link_libraries(testrunner MPI::MPI_CXX)
-endif()
-
-if(OGS_BUILD_SWMM)
-    target_link_libraries(testrunner SwmmInterface)
-endif()
-
-if(OGS_INSITU)
-    target_link_libraries(testrunner InSituLib)
-endif()
+    PRIVATE
+        ApplicationsFileIO
+        gtest
+        MeshGeoToolsLib
+        MaterialLib
+        MeshLib
+        NumLib
+        ParameterLib
+        ProcessLib
+        TestInfoLib
+        Threads::Threads
+        ${VTK_LIBRARIES}
+        $<$<TARGET_EXISTS:LIE>:LIE>
+        $<$<TARGET_EXISTS:MPI::MPI_CXX>:MPI::MPI_CXX>
+        $<$<TARGET_EXISTS:SwmmInterface>:SwmmInterface>
+        $<$<TARGET_EXISTS:InSituLib>:InSituLib>
+        $<$<BOOL:${OGS_USE_PETSC}>:${PETSC_LIBRARIES}>
+)
 
 if(OGS_BUILD_GUI)
     target_link_libraries(testrunner
-                          GitInfoLib
-                          Qt5::Core
-                          Qt5::Gui
-                          Qt5::Xml
-                          Qt5::Network
-                          VtkVis
-                          QtDataView)
+        PRIVATE
+            GitInfoLib
+            Qt5::Core
+            Qt5::Gui
+            Qt5::Xml
+            Qt5::Network
+            VtkVis
+            QtDataView
+    )
     if(GEOTIFF_FOUND)
-        target_link_libraries(testrunner ${GEOTIFF_LIBRARIES})
+        target_link_libraries(testrunner PRIVATE ${GEOTIFF_LIBRARIES})
     endif()
 endif()