#---------------------------------*- sh -*------------------------------------- # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | # \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation # \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. #------------------------------------------------------------------------------ # License # This file is part of OpenFOAM. # # OpenFOAM is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # OpenFOAM is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License # along with OpenFOAM. If not, see . # # File # etc/tools/ParaViewFunctions # # Description # ParaView make/install helper functions # #------------------------------------------------------------------------------ # sourceBASE, buildBASE, installBASE defined in tools/ThirdPartyFunctions # # Where things are or should be put # ParaView_VERSION and ParaView_MAJOR should already have been set # # ParaView_SOURCE_DIR : location of the original sources # ParaView_BINARY_DIR : location of the build # ParaView_DIR : location of the installed program # setParaViewDirs() { set -- "ParaView-$ParaView_VERSION" "ParaView-v$ParaView_VERSION" unset ParaView_SOURCE_DIR for i do ParaView_SOURCE_DIR="$sourceBASE/$i" [ -d "$ParaView_SOURCE_DIR" ] && break done [ -d "$ParaView_SOURCE_DIR" ] || { echo "Did not locate ParaView version:" while [ "$#" -ge 1 ]; do echo " $1"; shift; done echo echo "In the directory:" echo " $sourceBASE" echo echo "abort build" exit 1 } # ParaView_BINARY_DIR=$buildBASE/ParaView-$ParaView_VERSION${OBJ_ADD:+-$OBJ_ADD} ParaView_BINARY_DIR=$buildBASE/ParaView-$ParaView_VERSION # ParaView_DIR=$installBASE/ParaView-$ParaView_VERSION${OBJ_ADD:+-$OBJ_ADD} ParaView_DIR=$installBASE/ParaView-$ParaView_VERSION export ParaView_SOURCE_DIR ParaView_BINARY_DIR ParaView_DIR echo echo "ParaView_SOURCE_DIR=$ParaView_SOURCE_DIR" echo "ParaView_BINARY_DIR=$ParaView_BINARY_DIR" echo "ParaView_DIR=$ParaView_DIR" # Forcefully override the .git path for the ParaView source code directory export GIT_DIR=$ParaView_SOURCE_DIR/.git } # # Set ParaView_VERSION and adjust ParaView_MAJOR accordingly # # $1 can contain something something like 4.4.0, paraview-4.4.0, ParaView-4.0.0 # setParaViewVersion() { [ $# -gt 0 ] || { echo "Error: function setParaViewVersion() called without an argument" exit 1 } ParaView_VERSION="${1##*-}" # The major version is "." ParaView_MAJOR=$(echo $ParaView_VERSION | \ sed -e 's/^\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/') export ParaView_VERSION ParaView_MAJOR } #------------------------------------------------------------------------------ # # Compare version information (specified vs what is found in CMakeLists.txt) # Parse this type of content: # set (PARAVIEW_VERSION_FULL "5.0.1") # checkVersion() { local ver=$( sed -ne 's/^ *set *( *PARAVIEW_VERSION_FULL[ "]*\([.0-9]*\).*$/\1/ip' \ $ParaView_SOURCE_DIR/CMakeLists.txt ) if [ "$ParaView_VERSION" != "$ver" ] then echo "(${ver:-none}) mismatch?" else echo "(${ver:-none})" fi } # # Set CMake cache variables # addCMakeVariable() { while [ -n "$1" ] do CMAKE_VARIABLES="$CMAKE_VARIABLES -D$1" shift done } # # Verbose makefiles # addVerbosity() { if [ "${withVERBOSE:=false}" = true ] then addCMakeVariable "CMAKE_VERBOSE_MAKEFILE=TRUE" fi } # # Define options for mpi support # addMpiSupport() { if [ "${withMPI:=false}" != true ] then return fi OBJ_ADD="$OBJ_ADD-mpi" addCMakeVariable "PARAVIEW_USE_MPI=ON VTK_USE_MPI=ON" if [ "${MPI_MAX_PROCS:=0}" -gt 1 ] then addCMakeVariable "VTK_MPI_MAX_NUMPROCS=$MPI_MAX_PROCS" fi } # # Define options for python support # addPythonSupport() { if [ "${withPYTHON:=false}" != true ] then return fi OBJ_ADD="$OBJ_ADD-py" if pythonBin=$(which python 2>/dev/null) then if [ -n "$PYTHON_LIBRARY" ] then # Check $PYTHON_LIBRARY if it has been set if [ ! -e "$PYTHON_LIBRARY" ] then echo "*** Error: libpython not found at location specified " \ "by -pythnon-lib input: PYTHON_LIBRARY=$PYTHON_LIBRARY" fi else # Try to get $PYTHON_LIBRARY from dynamically linked binary PYTHON_LIBRARY=$(ldd $pythonBin | \ sed -ne '/libpython/s/.* => \(.*\) (.*/\1/p') [ -e "$PYTHON_LIBRARY" ] || { echo "*** Error: Unable to determine path to python library." } fi [ -e "$PYTHON_LIBRARY" ] || { echo " Please set the full path to the python library " echo " (including libpython) using the -python-lib option, " echo " or deactivate python support by not using the -python " echo " option" exit 1 } pythonMajor=$(echo $PYTHON_LIBRARY | sed 's/.*libpython\(.*\)\.so.*/\1/') pythonInclude=/usr/include/python$pythonMajor # Note - we could also allow for a PYTHON_INCLUDE variable ... [ -d "$pythonInclude" -a -f "$pythonInclude/Python.h" ] || { echo " No python headers found in $pythonInclude/" echo " Please install python headers or deactivate " echo " python support by not using the -python option" exit 1 } addCMakeVariable "PARAVIEW_ENABLE_PYTHON=ON" addCMakeVariable "PYTHON_INCLUDE_DIRS=$pythonInclude" addCMakeVariable "PYTHON_LIBRARY=$PYTHON_LIBRARY" echo "----" echo "Python information:" echo " executable : $pythonBin" echo " version : $pythonMajor" echo " include path : $pythonInclude" echo " library : $PYTHON_LIBRARY" unset pythonBin pythonInclude pythonMajor else echo "*** Error: python not found" echo "*** Deactivate python support by not using the -python " echo "*** option" exit 1 fi } # # Define options for mesa support # addMesaSupport() { if [ "${withMESA:=false}" != true ] then return fi if [ -d "$MESA_INCLUDE" -a -f "$MESA_LIBRARY" ] then OBJ_ADD="$OBJ_ADD-mesa" addCMakeVariable "VTK_OPENGL_HAS_OSMESA:BOOL=ON" addCMakeVariable "OSMESA_INCLUDE_DIR=$MESA_INCLUDE" addCMakeVariable "OSMESA_LIBRARY=$MESA_LIBRARY" else echo "*** Error: no MESA information found" echo "*** Deactivate MESA support by not using the -mesa option, " echo "*** or set the correct paths for:" echo "*** -mesa-include ($MESA_INCLUDE)" echo "*** -mesa-lib ($MESA_LIBRARY)" exit 1 fi } # # new rendering backend # addGL2Support() { if [ "${withGL2:=false}" = true ] then addCMakeVariable "VTK_RENDERING_BACKEND=OpenGL2" fi } addQtSupport() { QtVersion=none if [ "${withQT:=false}" != true ] then return fi addCMakeVariable "PARAVIEW_BUILD_QT_GUI=ON" local qmake=$(findQtMake) # From somewhere other than in the path if [ "${qmake:=qmake}" != qmake ] then addCMakeVariable "QT_QMAKE_EXECUTABLE:FILEPATH=$qmake" fi # Check qmake can be found if type $qmake >/dev/null 2>&1 then # Check the Qt version selected # parse -> "Using Qt version X.Y.Z in ..." QtVersion=$($qmake -query QT_VERSION) case "$QtVersion" in 3.* | 4.[0-4]*) # QT is too old cat </dev/null fi } # # Install the program # installParaView() { cd $ParaView_BINARY_DIR || exit 1 # Change to build folder echo " Installing ParaView to $ParaView_DIR" make install cat<< INFO --- Installation complete for paraview-$ParaView_VERSION ParaView_DIR=$ParaView_DIR You may need to update the OpenFOAM environment by running: wmRefresh --- INFO } #------------------------------------------------------------------------------ # Clear the referenced variables before using any of the functions unset withMPI withVERBOSE unset withQT QMAKE_PATH unset withMESA MESA_INCLUDE MESA_LIBRARY unset withPYTHON PYTHON_INCLUDE PYTHON_LIBRARY unset CMAKE_VARIABLES unset OBJ_ADD unset buildType # Start with these general settings addCMakeVariable "BUILD_SHARED_LIBS:BOOL=ON VTK_USE_RPATH:BOOL=OFF" # Include development files in "make install" addCMakeVariable "PARAVIEW_INSTALL_DEVELOPMENT_FILES:BOOL=ON" # Don't build test tree addCMakeVariable "BUILD_TESTING:BOOL=OFF" #------------------------------------------------------------------------------