From c7974ef6da1642252181021af4bd596fbb3406f2 Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Thu, 29 Aug 2019 15:37:29 +0200
Subject: [PATCH] [CMake] Fix netcdf linker on Win.

---
 Applications/DataExplorer/NetCdfDialog/CMakeLists.txt | 9 ++++++---
 scripts/cmake/Find.cmake                              | 3 +--
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/Applications/DataExplorer/NetCdfDialog/CMakeLists.txt b/Applications/DataExplorer/NetCdfDialog/CMakeLists.txt
index c34b1332692..93c6e154361 100644
--- a/Applications/DataExplorer/NetCdfDialog/CMakeLists.txt
+++ b/Applications/DataExplorer/NetCdfDialog/CMakeLists.txt
@@ -4,9 +4,12 @@ if(BUILD_SHARED_LIBS)
             LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
 endif()
 target_link_libraries(NetCdfDialogLib
-                      PUBLIC Qt5::Widgets ${ZLIB_LIBRARIES}
-                      PRIVATE MathLib ${NETCDF_LIBRARIES_C}
-                              ${NETCDF_LIBRARIES_CXX} ${HDF5_LIBRARIES})
+                      PUBLIC Qt5::Widgets
+                             ${NETCDF_LIBRARIES_C}
+                             ${NETCDF_LIBRARIES_CXX}
+                             ${HDF5_LIBRARIES}
+                             ${HDF5_HL_LIBRARIES}
+                      PRIVATE MathLib)
 set_property(TARGET NetCdfDialogLib PROPERTY FOLDER "DataExplorer")
 
 # Workaround for system installed VTK (tested on arch)
diff --git a/scripts/cmake/Find.cmake b/scripts/cmake/Find.cmake
index ca1fe4811f2..2c7bfe9a156 100644
--- a/scripts/cmake/Find.cmake
+++ b/scripts/cmake/Find.cmake
@@ -106,8 +106,7 @@ if(OGS_USE_NETCDF)
     set(NETCDF_ROOT ${CONAN_NETCDF-C_ROOT})
     set(NETCDF_CXX_ROOT ${CONAN_NETCDF-CXX_ROOT})
     find_package(NetCDF REQUIRED)
-    find_package(HDF5 REQUIRED)
-    find_package(ZLIB REQUIRED)
+    find_package(HDF5 REQUIRED COMPONENTS C HL)
 endif()
 
 # lapack
-- 
GitLab