#---------------------------------*- sh -*------------------------------------- # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | # \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------ # License # This file is part of OpenFOAM, licensed under GNU General Public License # . # # File # etc/tools/vtkFunctions # # Description # VTK (library) make/install helper functions. # To be loaded *after* etc/tools/ParaViewFunctions # #------------------------------------------------------------------------------ # Variables referenced by the functions. Initialization at the end of the file. unset CMAKE_VARIABLES # sourceBASE, buildBASE, installBASE and BUILD_SUFFIX # are defined in tools/ThirdPartyFunctions #------------------------------------------------------------------------------ # # Where things are or should be put # VTK_VERSION and VTK_MAJOR should already have been set # # VTK_SOURCE_DIR : location of the original sources # VTK_BUILD_DIR : location of the build # VTK_DIR : location of the installed program # setVtkDirs() { set -- "VTK-$VTK_VERSION" "VTK-v$VTK_VERSION" unset VTK_SOURCE_DIR for i do VTK_SOURCE_DIR="$sourceBASE/$i" [ -d "$VTK_SOURCE_DIR" ] && break done [ -d "$VTK_SOURCE_DIR" ] || { echo "Did not locate VTK version:" while [ "$#" -ge 1 ]; do echo " $1"; shift; done echo echo "In the directory:" echo " $sourceBASE" echo echo "abort build" exit 1 } VTK_BUILD_DIR=$buildBASE/VTK-$VTK_VERSION$BUILD_SUFFIX VTK_DIR=$installBASE/VTK-$VTK_VERSION$BUILD_SUFFIX export VTK_SOURCE_DIR VTK_BUILD_DIR VTK_DIR echo echo "VTK_SOURCE_DIR=$VTK_SOURCE_DIR" echo "VTK_BUILD_DIR=$VTK_BUILD_DIR" echo "VTK_DIR=$VTK_DIR" export GIT_DIR=$VTK_SOURCE_DIR/.git # Mask seeing our own git-repo } # # Set VTK_VERSION and adjust VTK_MAJOR accordingly # # $1 can contain something something like 4.4.0, vtk-4.4.0, VTK-4.0.0 # setVtkVersion() { [ $# -gt 0 ] || { echo "Error: function setVtkVersion() called without an argument" exit 1 } VTK_VERSION="${1##*-}" # The major version is "." VTK_MAJOR=$(echo $VTK_VERSION | \ sed -e 's/^\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/') export VTK_VERSION VTK_MAJOR } #------------------------------------------------------------------------------ # # Apply source-code patch if possible # patchVTK() { applyPatch "vtk-$VTK_VERSION" "$VTK_SOURCE_DIR" } # # Configure via cmake, but don't actually build anything # configVTK() { local cmake=$(findCMake) # Remove any existing build folder and recreate if [ -d $VTK_BUILD_DIR ] then echo "removing old build directory" echo " $VTK_BUILD_DIR" rm -rf $VTK_BUILD_DIR fi mkdir -p $VTK_BUILD_DIR addCMakeVariable "CMAKE_BUILD_TYPE=$BUILD_TYPE" cd $VTK_BUILD_DIR || exit 1 # change to build folder echo "----" echo "Configuring VTK-$VTK_VERSION" echo " MESA support : ${withMESA:-false}" echo " Source : $VTK_SOURCE_DIR" echo " Build : $VTK_BUILD_DIR" echo " Target : $VTK_DIR" echo " cmake : $cmake" echo " Build suffix : ${BUILD_SUFFIX:-none}" echo "----" echo echo "$cmake" \ -DCMAKE_INSTALL_PREFIX=$VTK_DIR \ $CMAKE_VARIABLES \ $VTK_SOURCE_DIR echo echo "----" echo # Run cmake to create Makefiles $cmake \ -DCMAKE_INSTALL_PREFIX=$VTK_DIR \ $CMAKE_VARIABLES \ $VTK_SOURCE_DIR } # # Invoke make # also link bin/ to lib/paraview-* for development without installation # makeVTK() { cd $VTK_BUILD_DIR || exit 1 # Change to build folder echo " Starting make" time make -j $WM_NCOMPPROCS # Remove lib if it is a link # (how this was previously handled before 'make install' worked) [ -L lib ] && rm -f lib 2>/dev/null echo " Done make" # Last statement for clean return code } # # Install the program # installVTK() { cd $VTK_BUILD_DIR || exit 1 # Change to build folder echo " Installing VTK to $VTK_DIR" make install /bin/cat<