diff --git a/CMakeLists.txt b/CMakeLists.txt index 7faf37bf67359b4023c6d9a34dba7eb41e29171f..554dc4f719165bb0cca85118968f3941d3506421 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,7 +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(scripts/cmake/ExternalProjectCatalyst.cmake) +if(OGS_INSITU) + include(scripts/cmake/ExternalProjectCatalyst.cmake) +else() + include(scripts/cmake/ExternalProjectVtk.cmake) +endif() include_directories( SYSTEM ${Boost_INCLUDE_DIRS} ) if(OGS_USE_EIGEN) diff --git a/scripts/cmake/AddCatalystDependency.cmake b/scripts/cmake/AddCatalystDependency.cmake index df74386dccc12f5aaa4235d756c6042569a0f1e5..85c405a9ef63923d6b1a219179ab5371bccde13b 100644 --- a/scripts/cmake/AddCatalystDependency.cmake +++ b/scripts/cmake/AddCatalystDependency.cmake @@ -4,6 +4,8 @@ macro(ADD_CATALYST_DEPENDENCY target) # see http://stackoverflow.com/questions/18642155 set_property(TARGET ${target} APPEND PROPERTY COMPILE_DEFINITIONS ${VTK_DEFINITIONS}) + elseif(VTK_FOUND) + include( ${VTK_USE_FILE} ) endif() if(TARGET VtkRescan) diff --git a/scripts/cmake/ExternalProjectCatalyst.cmake b/scripts/cmake/ExternalProjectCatalyst.cmake index c008fff18f75a2e7d4cbb4d3a524de3eb00a81d0..d40c1e36637a2a815e78642fac6b80d564a64a06 100644 --- a/scripts/cmake/ExternalProjectCatalyst.cmake +++ b/scripts/cmake/ExternalProjectCatalyst.cmake @@ -53,21 +53,6 @@ if(ParaView_FOUND AND VTKIO_LIB_FOUND) message(STATUS "Using ParaView in ${ParaView_DIR}") return() elseif(NOT ParaView_DIR) - # If ParaView was not found check for VTK - find_package(VTK 6.1 COMPONENTS ${PARAVIEW_MODULES} NO_MODULE QUIET) - if(VTK_FOUND) - include( ${VTK_USE_FILE} ) - 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) - message(STATUS "Using VTK in ${VTK_DIR}") - return() - else() # If nothing was found build ParaView as an external project set(ParaView_DIR ${CMAKE_BINARY_DIR}/External/catalyst/src/Catalyst-build CACHE PATH "" FORCE) endif() @@ -96,9 +81,7 @@ else() endif() message(STATUS "Building ParaView as an external project in the build directory") -if(CMAKE_VERSION VERSION_LESS 3.0.0) - message(FATAL_ERROR "CMake 3.0.0 or higher is required for building VTK / ParaView!") -endif() + ExternalProject_Add(Catalyst PREFIX ${CMAKE_BINARY_DIR}/External/catalyst GIT_REPOSITORY ${CATALYST_GIT_URL} diff --git a/scripts/cmake/ExternalProjectVtk.cmake b/scripts/cmake/ExternalProjectVtk.cmake new file mode 100644 index 0000000000000000000000000000000000000000..19b7bbbeb84705680d0cff0507b2b8bf881509d6 --- /dev/null +++ b/scripts/cmake/ExternalProjectVtk.cmake @@ -0,0 +1,91 @@ +include(ThirdPartyLibVersions) +include(ExternalProject) + +if(NOT DEFINED VTK_DIR AND DEFINED ENV{VTK_DIR}) + set(VTK_DIR $ENV{VTK_DIR}) +endif() + +# CLI modules +set(VTK_MODULES vtkIOXML vtkIOParallelXML) + +# 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(CATALYST_LIBRARIES ${VTK_MODULES} CACHE STRING "" FORCE) +if(OGS_BUILD_GUI) + # Replace vtknetcdf with vtkNetCDF vtkNetCDF_cxx + list(REMOVE_ITEM CATALYST_LIBRARIES vtknetcdf) + list(APPEND CATALYST_LIBRARIES vtkNetCDF vtkNetCDF_cxx) +endif() + +find_package(VTK 6.1 COMPONENTS ${VTK_MODULES} NO_MODULE QUIET) + +if(VTK_FOUND) + message(STATUS "Using VTK in ${VTK_DIR}") + 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) + return() +endif() +set(VTK_DIR ${CMAKE_BINARY_DIR}/External/vtk/src/vtk-build CACHE PATH "" FORCE) + +message(STATUS "Building VTK as an external project in the build directory") + +if(WIN32) + set(VTK_MAKE_COMMAND + msbuild /p:Configuration=Release /m:${NUM_PROCESSORS} VTK.sln && + msbuild /p:Configuration=Debug /m:${NUM_PROCESSORS} /m VTK.sln) +else() + if($ENV{CI}) + set(VTK_MAKE_COMMAND make) + else() + set(VTK_MAKE_COMMAND make -j ${NUM_PROCESSORS}) + endif() +endif() + +# Enable just the modules we selected +set(VTK_CMAKE_ARGS -DVTK_Group_StandAlone:bool=off -DVTK_Group_Rendering:bool=off) +foreach(arg ${VTK_MODULES}) + list(APPEND VTK_CMAKE_ARGS -DModule_${arg}:bool=on) +endforeach() + +ExternalProject_Add(vtk + PREFIX ${CMAKE_BINARY_DIR}/External/vtk + URL ${OGS_VTK_URL} + CMAKE_ARGS -Wno-dev + CMAKE_CACHE_ARGS ${VTK_CMAKE_ARGS} + BUILD_COMMAND ${VTK_MAKE_COMMAND} + INSTALL_COMMAND "" +) + +if(NOT ${VTK_FOUND}) + # Rerun cmake in initial build + add_custom_target(VtkRescan ${CMAKE_COMMAND} ${CMAKE_SOURCE_DIR} DEPENDS vtk) +else() + add_custom_target(VtkRescan) # dummy target for caching +endif() diff --git a/scripts/cmake/ThirdPartyLibVersions.cmake b/scripts/cmake/ThirdPartyLibVersions.cmake index 877977d22fc8469bce10800899188ffe54d035f4..afde5e06961a59f940366c7300b9eb2bfd486be6 100644 --- a/scripts/cmake/ThirdPartyLibVersions.cmake +++ b/scripts/cmake/ThirdPartyLibVersions.cmake @@ -4,9 +4,9 @@ set(OGS_BOOST_MD5 "b8839650e61e9c1c0a89f371dd475546") set(OGS_EIGEN_URL "http://opengeosys.s3.amazonaws.com/ogs6-lib-sources/eigen-3.2.5.tar.gz") set(OGS_EIGEN_MD5 "8cc513ac6ec687117acadddfcacf551b") -set(OGS_VTK_VERSION 6.1.0) -set(OGS_VTK_URL "http://www.vtk.org/files/release/6.1/VTK-6.1.0.tar.gz") -set(OGS_VTK_MD5 "25e4dfb3bad778722dcaec80cd5dab7d") +set(OGS_VTK_VERSION 6.3.0) +set(OGS_VTK_URL "http://www.vtk.org/files/release/6.3/VTK-6.3.0.tar.gz") +set(OGS_VTK_MD5 "0231ca4840408e9dd60af48b314c5b6d") set(OGS_TIFF_URL "https://github.com/ufz/tiff/archive/4.0.1.zip") set(OGS_TIFF_MD5 "8d5c18654bda9c731d8a6e2dc958751b")