From 088733f7a6969b6a0808ff39dce1e299ef8e0414 Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Thu, 4 Aug 2022 10:26:54 +0200
Subject: [PATCH] [cmake] Silence spdlog warnings.

---
 Applications/DataExplorer/DataExplorer.cmake |  2 +-
 BaseLib/CMakeLists.txt                       |  2 +-
 scripts/cmake/CheckHeaderCompilation.cmake   |  2 +-
 scripts/cmake/Dependencies.cmake             | 14 +++++++++++++-
 4 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/Applications/DataExplorer/DataExplorer.cmake b/Applications/DataExplorer/DataExplorer.cmake
index a51492e06e8..dd6bbd50201 100644
--- a/Applications/DataExplorer/DataExplorer.cmake
+++ b/Applications/DataExplorer/DataExplorer.cmake
@@ -40,7 +40,7 @@ target_link_libraries(
     Qt5::Widgets
     Qt5::Xml
     Qt5::Network
-    spdlog::spdlog
+    spdlog
     VTK::IOExport
 )
 
diff --git a/BaseLib/CMakeLists.txt b/BaseLib/CMakeLists.txt
index e38818edc42..687d652434c 100644
--- a/BaseLib/CMakeLists.txt
+++ b/BaseLib/CMakeLists.txt
@@ -11,7 +11,7 @@ ogs_add_library(BaseLib GENERATE_EXPORT_HEADER ${SOURCES})
 target_link_libraries(
     BaseLib
     PUBLIC Boost::boost
-           spdlog::spdlog
+           spdlog
            tclap
            $<$<BOOL:${MSVC}>:WinMM> # needed for timeGetTime
            $<$<BOOL:${OGS_BUILD_GUI}>:Qt5::Xml>
diff --git a/scripts/cmake/CheckHeaderCompilation.cmake b/scripts/cmake/CheckHeaderCompilation.cmake
index b83b8216438..f18b5fe79e6 100644
--- a/scripts/cmake/CheckHeaderCompilation.cmake
+++ b/scripts/cmake/CheckHeaderCompilation.cmake
@@ -44,7 +44,7 @@ function(_check_header_compilation target)
     endif()
     get_target_property(LINK_LIBS ${target} LINK_LIBRARIES)
     # Transitive dependencies are not resolved
-    foreach(lib ${LINK_LIBS} spdlog::spdlog Boost::boost Eigen3::Eigen
+    foreach(lib ${LINK_LIBS} spdlog Boost::boost Eigen3::Eigen
                 nlohmann_json::nlohmann_json range-v3
     )
         # Ignore non-existing targets or interface libs
diff --git a/scripts/cmake/Dependencies.cmake b/scripts/cmake/Dependencies.cmake
index 6c6ec5ac0a2..c618ec071e2 100644
--- a/scripts/cmake/Dependencies.cmake
+++ b/scripts/cmake/Dependencies.cmake
@@ -50,7 +50,19 @@ if(OGS_BUILD_TESTING)
     endif()
 endif()
 
-CPMFindPackage(NAME spdlog GITHUB_REPOSITORY gabime/spdlog VERSION 1.10.0)
+CPMFindPackage(
+    NAME spdlog
+    GITHUB_REPOSITORY gabime/spdlog
+    VERSION 1.10.0
+    OPTIONS "BUILD_SHARED_LIBS OFF" "SPDLOG_BUILD_SHARED OFF"
+)
+if(spdlog_ADDED)
+    set_target_properties(
+        spdlog
+        PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES
+                   $<TARGET_PROPERTY:spdlog,INTERFACE_INCLUDE_DIRECTORIES>
+    )
+endif()
 
 CPMFindPackage(
     NAME tclap
-- 
GitLab