From 8c05cc7766075f1b646f49b63cbbfc3009139908 Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Tue, 21 Nov 2023 13:42:43 +0100
Subject: [PATCH] [cmake] Link to netcdf-cxx4.

---
 Applications/DataExplorer/VtkVis/CMakeLists.txt | 12 +-----------
 Applications/Utils/FileConverter/CMakeLists.txt |  5 +----
 GeoLib/CMakeLists.txt                           |  2 +-
 3 files changed, 3 insertions(+), 16 deletions(-)

diff --git a/Applications/DataExplorer/VtkVis/CMakeLists.txt b/Applications/DataExplorer/VtkVis/CMakeLists.txt
index 6413386d71c..ce48d92411a 100644
--- a/Applications/DataExplorer/VtkVis/CMakeLists.txt
+++ b/Applications/DataExplorer/VtkVis/CMakeLists.txt
@@ -53,17 +53,7 @@ target_link_libraries(
 )
 
 if(OGS_USE_NETCDF)
-    target_link_libraries(
-        VtkVisFilter PUBLIC ${NETCDF_LIBRARIES_CXX} ${NETCDF_LIBRARIES_C}
-                            ${HDF5_HL_LIBRARIES} ${HDF5_LIBRARIES}
-    )
-    # Workaround for system installed VTK (tested on arch)
-    if(NOT OGS_USE_CONAN)
-        target_include_directories(
-            VtkVisFilter SYSTEM PUBLIC ${NETCDF_INCLUDES_C}
-                                       ${NETCDF_INCLUDES_CXX}
-        )
-    endif()
+    target_link_libraries(VtkVisFilter PUBLIC netcdf-cxx4)
     add_autogen_include(VtkVisFilter)
 endif()
 
diff --git a/Applications/Utils/FileConverter/CMakeLists.txt b/Applications/Utils/FileConverter/CMakeLists.txt
index 1050fcbe834..15a80eb11d7 100644
--- a/Applications/Utils/FileConverter/CMakeLists.txt
+++ b/Applications/Utils/FileConverter/CMakeLists.txt
@@ -36,8 +36,5 @@ if(TARGET ConvertSHPToGLI)
 endif()
 
 if(TARGET NetCdfConverter)
-    target_link_libraries(
-        NetCdfConverter ${NETCDF_LIBRARIES_CXX} ${NETCDF_LIBRARIES_C}
-        ${HDF5_HL_LIBRARIES} ${HDF5_LIBRARIES}
-    )
+    target_link_libraries(NetCdfConverter netcdf-cxx4)
 endif()
diff --git a/GeoLib/CMakeLists.txt b/GeoLib/CMakeLists.txt
index 2c45df07e50..886db753017 100644
--- a/GeoLib/CMakeLists.txt
+++ b/GeoLib/CMakeLists.txt
@@ -23,7 +23,7 @@ target_link_libraries(
 if(OGS_USE_NETCDF)
     target_link_libraries(
         GeoLib
-        PRIVATE ${NETCDF_LIBRARIES_CXX} ${NETCDF_LIBRARIES_C}
+        PRIVATE netcdf-cxx4
     )
     target_compile_definitions(GeoLib PRIVATE OGS_USE_NETCDF)
 endif()
-- 
GitLab