From 5c91035fffd08e895641da41dae8eca18eb5298f Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Tue, 3 Nov 2015 16:29:07 +0100
Subject: [PATCH] Added CMake-file VtkModules.cmake which defines required vtk
 modules.

This is the used by ExternalProjectVTK / -Catalyst.cmake
---
 CMakeLists.txt                              |  5 +--
 scripts/cmake/ExternalProjectCatalyst.cmake | 35 ++-------------------
 scripts/cmake/ExternalProjectVtk.cmake      | 29 -----------------
 scripts/cmake/VtkModules.cmake              | 31 ++++++++++++++++++
 4 files changed, 36 insertions(+), 64 deletions(-)
 create mode 100644 scripts/cmake/VtkModules.cmake

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 554dc4f7191..77dad6f584a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -102,10 +102,11 @@ include(scripts/cmake/packaging/Pack.cmake)
 option(Boost_USE_STATIC_LIBS "This option has to be set from the command line (before boost gets found)!" OFF)
 include(scripts/cmake/ExternalProjectBoost.cmake)
 option(OGS_SYSTEM_VTK_ONLY "If On VTK / ParaView will be searched if installed and will not be build locally." OFF)
+include(VtkModules)
 if(OGS_INSITU)
-	include(scripts/cmake/ExternalProjectCatalyst.cmake)
+	include(ExternalProjectCatalyst)
 else()
-	include(scripts/cmake/ExternalProjectVtk.cmake)
+	include(ExternalProjectVtk)
 endif()
 
 include_directories( SYSTEM ${Boost_INCLUDE_DIRS} )
diff --git a/scripts/cmake/ExternalProjectCatalyst.cmake b/scripts/cmake/ExternalProjectCatalyst.cmake
index 974c6ddea55..b754b022e28 100644
--- a/scripts/cmake/ExternalProjectCatalyst.cmake
+++ b/scripts/cmake/ExternalProjectCatalyst.cmake
@@ -7,45 +7,14 @@ if(NOT DEFINED ParaView_DIR AND DEFINED ENV{ParaView_DIR})
 	set(ParaView_DIR $ENV{ParaView_DIR})
 endif()
 
-# CLI modules
-set(PARAVIEW_MODULES vtkIOXML)
-set(VTK_MODULES vtkIOXML)
-if(OGS_USE_MPI)
-	set(PARAVIEW_MODULES ${PARAVIEW_MODULES} vtkIOParallelXML)
-endif()
-
-# GUI modules
-if(OGS_BUILD_GUI)
-	set(PARAVIEW_MODULES ${PARAVIEW_MODULES}
-		vtkRenderingCore
-		vtkRenderingOpenGL
-		vtknetcdf
-		vtkIOLegacy
-		vtkIOImage
-		vtkGUISupportQt
-		vtkRenderingAnnotation
-		vtkFiltersExtraction
-		vtkFiltersGeometry
-		vtkFiltersTexture
-		vtkFiltersModeling
-		vtkFiltersSources
-		vtkImagingCore
-		vtkInteractionWidgets
-		vtkInteractionStyle
-		vtkIOExport
-		vtkRenderingFreeType
-	)
-	set(CATALYST_GIT_URL https://github.com/ufz/catalyst-gui.git)
-endif()
-
-set(VTK_LIBRARIES ${PARAVIEW_MODULES} CACHE STRING "" FORCE)
+set(VTK_LIBRARIES ${VTK_MODULES} CACHE STRING "" FORCE)
 if(OGS_BUILD_GUI)
 	# Replace vtknetcdf with vtkNetCDF vtkNetCDF_cxx
 	list(REMOVE_ITEM VTK_LIBRARIES vtknetcdf)
 	list(APPEND VTK_LIBRARIES vtkNetCDF vtkNetCDF_cxx)
 endif()
 
-find_package(ParaView 4.2 COMPONENTS ${PARAVIEW_MODULES} NO_MODULE QUIET)
+find_package(ParaView 4.2 COMPONENTS ${VTK_MODULES} NO_MODULE QUIET)
 
 find_library(VTKIO_LIB_FOUND vtkIOXML-pv4.2 HINTS ${ParaView_DIR}/lib PATH_SUFFIXES Release Debug)
 if(ParaView_FOUND AND VTKIO_LIB_FOUND)
diff --git a/scripts/cmake/ExternalProjectVtk.cmake b/scripts/cmake/ExternalProjectVtk.cmake
index a1194fe04ac..a8c6f4ba5dc 100644
--- a/scripts/cmake/ExternalProjectVtk.cmake
+++ b/scripts/cmake/ExternalProjectVtk.cmake
@@ -5,35 +5,6 @@ if(NOT DEFINED VTK_DIR AND DEFINED ENV{VTK_DIR})
 	set(VTK_DIR $ENV{VTK_DIR})
 endif()
 
-# CLI modules
-set(VTK_MODULES vtkIOXML)
-if(OGS_USE_MPI)
-	set(VTK_MODULES ${VTK_MODULES} vtkIOParallelXML)
-endif()
-
-# GUI modules
-if(OGS_BUILD_GUI)
-	set(VTK_MODULES ${VTK_MODULES}
-		vtkRenderingCore
-		vtkRenderingOpenGL
-		vtknetcdf
-		vtkIOLegacy
-		vtkIOImage
-		vtkGUISupportQt
-		vtkRenderingAnnotation
-		vtkFiltersExtraction
-		vtkFiltersGeometry
-		vtkFiltersTexture
-		vtkFiltersModeling
-		vtkFiltersSources
-		vtkImagingCore
-		vtkInteractionWidgets
-		vtkInteractionStyle
-		vtkIOExport
-		vtkRenderingFreeType
-	)
-endif()
-
 set(VTK_LIBRARIES ${VTK_MODULES} CACHE STRING "" FORCE)
 if(OGS_BUILD_GUI)
 	# Replace vtknetcdf with vtkNetCDF vtkNetCDF_cxx
diff --git a/scripts/cmake/VtkModules.cmake b/scripts/cmake/VtkModules.cmake
new file mode 100644
index 00000000000..c9df613e573
--- /dev/null
+++ b/scripts/cmake/VtkModules.cmake
@@ -0,0 +1,31 @@
+# CLI modules
+set(VTK_MODULES
+	vtkIOXML
+	CACHE INTERNAL "Required VTK / ParaView modules"
+)
+
+if(OGS_USE_MPI)
+	set(VTK_MODULES ${VTK_MODULES} vtkIOParallelXML)
+endif()
+
+if(OGS_BUILD_GUI)
+	set(VTK_MODULES ${VTK_MODULES}
+		vtkRenderingCore
+		vtkRenderingOpenGL
+		vtknetcdf
+		vtkIOLegacy
+		vtkIOImage
+		vtkGUISupportQt
+		vtkRenderingAnnotation
+		vtkFiltersExtraction
+		vtkFiltersGeometry
+		vtkFiltersTexture
+		vtkFiltersModeling
+		vtkFiltersSources
+		vtkImagingCore
+		vtkInteractionWidgets
+		vtkInteractionStyle
+		vtkIOExport
+		vtkRenderingFreeType
+	)
+endif()
-- 
GitLab