From dea37db94074be3721ac9af9964d4b267ef78588 Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Thu, 15 Feb 2018 14:20:59 +0100
Subject: [PATCH] [CMake] Switched to Conan VTK 8.1.0.

Linker error on DataExplorer to netcdfcpp remains on macOS.
---
 Applications/DataExplorer/DataExplorer.cmake        |  5 +----
 .../NetCdfDialog/NetCdfConfigureDialog.cpp          |  6 +++---
 Applications/DataExplorer/VtkVis/CMakeLists.txt     |  2 +-
 scripts/cmake/ConanSetup.cmake                      |  3 ---
 scripts/cmake/Find.cmake                            | 13 ++-----------
 scripts/cmake/VtkModules.cmake                      |  2 +-
 6 files changed, 8 insertions(+), 23 deletions(-)

diff --git a/Applications/DataExplorer/DataExplorer.cmake b/Applications/DataExplorer/DataExplorer.cmake
index 7a77712399d..cc121e25992 100644
--- a/Applications/DataExplorer/DataExplorer.cmake
+++ b/Applications/DataExplorer/DataExplorer.cmake
@@ -64,6 +64,7 @@ target_link_libraries(DataExplorer
     Qt5::Xml
     Qt5::Network
     logog
+    ${VTK_LIBRARIES}
 )
 
 # Workaround for Windows conan tiff-package
@@ -80,10 +81,6 @@ if(CMAKE_CROSSCOMPILING)
     )
 endif()
 
-if(VTK_NETCDF_FOUND)
-    target_link_libraries(DataExplorer vtkNetCDF vtkNetCDF_cxx )
-endif()
-
 if(GEOTIFF_FOUND)
     target_link_libraries(DataExplorer ${GEOTIFF_LIBRARIES} )
 endif()
diff --git a/Applications/DataExplorer/NetCdfDialog/NetCdfConfigureDialog.cpp b/Applications/DataExplorer/NetCdfDialog/NetCdfConfigureDialog.cpp
index 4a956f53cea..338d737b7dd 100644
--- a/Applications/DataExplorer/NetCdfDialog/NetCdfConfigureDialog.cpp
+++ b/Applications/DataExplorer/NetCdfDialog/NetCdfConfigureDialog.cpp
@@ -225,8 +225,8 @@ void NetCdfConfigureDialog::getDimEdges(int dimId, unsigned &size, double &first
         {
             int sizeOfDim = tmpVarOfDim->get_dim(0)->size();
             size = sizeOfDim;
-            double arrayOfDimStart[1] = {0};
-            std::size_t edgeOfArray[1] = {1};
+            double *arrayOfDimStart = new double[1]; //[1] = {0};
+            long edgeOfArray = 1; //[1] = {1};
             long edgeOrigin[1] = {0};
             tmpVarOfDim->set_cur(edgeOrigin);
             tmpVarOfDim->get(arrayOfDimStart,edgeOfArray);
@@ -306,7 +306,7 @@ double NetCdfConfigureDialog::getResolution()
 
 void NetCdfConfigureDialog::createDataObject()
 {
-    auto* length = new std::size_t[_currentVar->num_dims()];
+    auto* length = new long[_currentVar->num_dims()];
     double originLon = 0, originLat = 0;
     double lastLon = 0, lastLat = 0;
     unsigned sizeLon = 0, sizeLat = 0;
diff --git a/Applications/DataExplorer/VtkVis/CMakeLists.txt b/Applications/DataExplorer/VtkVis/CMakeLists.txt
index ef1894a6934..69dee55ba5f 100644
--- a/Applications/DataExplorer/VtkVis/CMakeLists.txt
+++ b/Applications/DataExplorer/VtkVis/CMakeLists.txt
@@ -135,7 +135,7 @@ if(GEOTIFF_FOUND)
 endif() # GEOTIFF_FOUND
 
 target_link_libraries(VtkVis
-    PUBLIC BaseLib GeoLib MeshLib DataHolderLib QtBase ${VTK_LIBRARIES} NetCdfDialogLib
+    PUBLIC BaseLib GeoLib MeshLib DataHolderLib QtBase
     PRIVATE MathLib ApplicationsFileIO Qt5::Gui logog
 )
 set_property(TARGET VtkVis PROPERTY FOLDER "DataExplorer")
diff --git a/scripts/cmake/ConanSetup.cmake b/scripts/cmake/ConanSetup.cmake
index 2d4c7232c34..11b32b59f8f 100644
--- a/scripts/cmake/ConanSetup.cmake
+++ b/scripts/cmake/ConanSetup.cmake
@@ -51,9 +51,6 @@ if(OGS_BUILD_GUI)
         Qt/5.11@bincrafters/stable
     )
     set(CONAN_OPTIONS ${CONAN_OPTIONS} VTK:qt=True)
-    if(UNIX AND NOT APPLE)
-        set(CONAN_OPTIONS ${CONAN_OPTIONS} VTK:x11=True)
-    endif()
 endif()
 
 # Find Conan and do version check
diff --git a/scripts/cmake/Find.cmake b/scripts/cmake/Find.cmake
index 681fa973161..7e9df447664 100644
--- a/scripts/cmake/Find.cmake
+++ b/scripts/cmake/Find.cmake
@@ -65,18 +65,9 @@ find_package(Boost REQUIRED)
 include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
 
 include(VtkModules)
-find_package(VTK COMPONENTS ${VTK_MODULES} REQUIRED)
+#find_package(VTK COMPONENTS ${VTK_MODULES} REQUIRED)
+find_package(VTK 8.0.0 REQUIRED)
 include(${VTK_USE_FILE})
-if(NOT OGS_USE_CONAN)
-    foreach(DIR ${VTK_INCLUDE_DIRS})
-        if("${DIR}" MATCHES ".*vtknetcdf.*")
-            include_directories(SYSTEM ${DIR}/../cxx ${DIR}/include)
-        elseif("${DIR}" MATCHES ".*vtk.*")
-            include_directories(SYSTEM ${DIR}/vtknetcdf/include)
-        endif()
-    endforeach()
-    include_directories(SYSTEM ${VTK_DIR}/../ThirdParty/netcdf/vtknetcdf/cxx)
-endif()
 
 find_package(Eigen3 3.2.9 REQUIRED)
 include_directories(SYSTEM ${EIGEN3_INCLUDE_DIR})
diff --git a/scripts/cmake/VtkModules.cmake b/scripts/cmake/VtkModules.cmake
index 5054da414cb..6ddd41b9fe4 100644
--- a/scripts/cmake/VtkModules.cmake
+++ b/scripts/cmake/VtkModules.cmake
@@ -11,7 +11,7 @@ endif()
 if(OGS_BUILD_GUI)
     set(VTK_MODULES ${VTK_MODULES}
         vtkRenderingCore
-        vtknetcdf
+        vtknetcdfcpp
         vtkIOLegacy
         vtkIOImage
         vtkRenderingAnnotation
-- 
GitLab