openfoam/etc/config.csh/paraview
Mark Olesen 628b2445fc ENH: improve setup for paraview
- removed reliance on ParaView_INCLUDE_DIR variable for conveying the
  major.minor version information when compiling. This can be somewhat
  fragile and also adds variable that is an unnecessary when running
  (only used when compiling).

  Instead use `have_pvplugin_support` function in paraviewFunctions
  wmake script to determine the maj.min from the PV_PLUGIN_PATH
  since we have already defined the output path there with paraview
  maj.min numbering.

  Can now build with paraview from the operating system,
  provided that it has develop headers available.

      ParaView_VERSION=system

  In the etc/config.sh/paraview setup, the maj.min is taken from
  the corresponding `paraview --version` output and used when
  defining the PV_PLUGIN_PATH.

  During the build, the include path taken from `paraview-config`
  for a system installation, from the guess installation root
  of the paraview binary, or ParaView_DIR otherwise.

NB: using a system ParaView for building runTimePostProcessing is unsupported.

- these types of builds appear to have various library resolution issues
  (eg, libexpat not being loaded). Additionally, the build logic does
  not yet cover this type of use case.
2018-11-29 01:48:00 +01:00

221 lines
7.2 KiB
Bash

#----------------------------------*-sh-*--------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
#
# File
# config.csh/paraview
# - sourced by OpenFOAM-*/etc/cshrc or via foamPV alias
#
# Description
# Setup for PARAVIEW (partially cmake, qt too)
#
# To disable use of the PV_PLUGIN_PATH:
# ParaView_VERSION=none
#
# For system-wide installations:
# cmake_version=cmake-system
# ParaView_QT=qt-system
# ParaView_VERSION=system [EXPERIMENTAL]
#
# Note
# The following env. variables are required for building plugins:
# ParaView_DIR
# PV_PLUGIN_PATH
# The OpenFOAM plugin must be the first in PV_PLUGIN_PATH and have
# paraview-major.minor version encoded in its name.
#
# For central installations not located under ThirdParty, the environment
# values must be set manually. For example,
#
# setenv ParaView_DIR /opt/paraview/paraview-5.6.0
# setenv PV_PLUGIN_PATH $FOAM_LIBBIN/paraview-5.6
#
# setenv PATH $ParaView_DIR/bin:${PATH}
# setenv LD_LIBRARY_PATH $ParaView_DIR/lib:$LD_LIBRARY_PATH
# unsetenv ParaView_VERSION # skip ThirdParty settings
#
# In paraview-5.4 and earlier, the libraries were in the sub-directory:
#
# setenv LD_LIBRARY_PATH $ParaView_DIR/lib/paraview-5.4:$LD_LIBRARY_PATH
#
#------------------------------------------------------------------------------
# USER EDITABLE PART: Changes made here may be lost with the next upgrade
set ParaView_VERSION=5.6.0
set ParaView_QT=qt-system
set cmake_version=cmake-system
# END OF (NORMAL) USER EDITABLE PART
#------------------------------------------------------------------------------
set pv_api=auto # Either auto or pair of (major.minor) digits
if (! $?ParaView_DIR ) setenv ParaView_DIR
if (! $?WM_COMPILER_LIB_ARCH ) setenv WM_COMPILER_LIB_ARCH
# Compiler-specific location for ThirdParty installations
set archDir="$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER"
# Clean PATH and LD_LIBRARY_PATH
eval `$WM_PROJECT_DIR/bin/foamCleanPath -csh-env=PATH "$ParaView_DIR $archDir/ParaView- $archDir/qt- $archDir/cmake-"`
eval `$WM_PROJECT_DIR/bin/foamCleanPath -csh-env=LD_LIBRARY_PATH "$ParaView_DIR $archDir/ParaView- $archDir/qt-"`
# ThirdParty cmake
set cmake="$archDir/$cmake_version"
if ( -r "$cmake/bin/cmake" ) then
# _foamAddPath not available when foamPV alias is used
setenv PATH "$cmake/bin:${PATH}"
endif
# Evaluate command-line parameters for ParaView
while ( $#argv > 0 )
switch ($argv[1])
case ParaView*=*:
# name=value -> setenv name value
eval "setenv $argv[1]:s/=/ /"
breaksw
endsw
shift
end
if (! $?ParaView_VERSION ) set ParaView_VERSION=''
switch ("$ParaView_VERSION")
case "":
# empty - do nothing
setenv ParaView_DIR # Defined but empty (used by foamPV alias)
breaksw
case "none":
unsetenv PV_PLUGIN_PATH
setenv ParaView_DIR # Defined but empty (used by foamPV alias)
if ($?FOAM_VERBOSE && $?prompt) then
echo "Using paraview (disabled)"
endif
breaksw
case "system":
# Obtain major.minor from `paraview --version`
set pv_api=`paraview --version | \
sed -ne 's/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/p'`
if ( "${%pv_api}" ) then
setenv PV_PLUGIN_PATH "$FOAM_LIBBIN/paraview-$pv_api"
else
unsetenv ParaView_DIR PV_PLUGIN_PATH
endif
if ($?FOAM_VERBOSE && $?prompt) then
echo "Using paraview (disabled)"
if ( $?PV_PLUGIN_PATH ) then
echo "Using paraview (system)"
echo " PV_PLUGIN_PATH : $PV_PLUGIN_PATH"
else
echo "system paraview (not found)"
endif
endif
breaksw
default:
# ParaView_VERSION set and non-empty
# Set API to correspond to VERSION
# pv_api is <digits>.<digits> from ParaView_VERSION
if (! $?pv_api ) set pv_api=auto
switch ("$ParaView_VERSION")
case "$pv_api".*:
# API and VERSION appear to correspond
breaksw
case [0-9]*:
# Extract API from VERSION
set pv_api=`echo "$ParaView_VERSION" | \
sed -ne 's/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/p'`
breaksw
endsw
setenv ParaView_DIR "$archDir/ParaView-$ParaView_VERSION"
# Set paths if binaries are present
if ( -r "$ParaView_DIR" ) then
# The OpenFOAM plugin directory must be the first in PV_PLUGIN_PATH
# and have paraview-major.minor encoded in its name
setenv PV_PLUGIN_PATH "$FOAM_LIBBIN/paraview-$pv_api"
setenv PATH "${ParaView_DIR}/bin:${PATH}"
set pvLibDir="${ParaView_DIR}/lib/paraview-$pv_api"
#OBSOLETE? set pvPython=$ParaView_DIR/Utilities/VTKPythonWrapping
#OBSOLETE? # Python libraries as required
#OBSOLETE? if ( -r $pvPython ) then
#OBSOLETE? if ($?PYTHONPATH) then
#OBSOLETE? setenv PYTHONPATH ${PYTHONPATH}:${pvPython}:$pvLibDir
#OBSOLETE? else
#OBSOLETE? setenv PYTHONPATH ${pvPython}:${pvLibDir}
#OBSOLETE? endif
#OBSOLETE? endif
# QT libraries as required
# Set Qt5_DIR to root directory.
# Another possibility: "qtpaths --qt-version"
set qtDir="$archDir/$ParaView_QT"
if ( -d "$qtDir" ) then
switch ("$ParaView_QT")
case *-5*:
setenv Qt5_DIR "$qtDir"
breaksw
endsw
foreach qtLibDir ("$qtDir/lib$WM_COMPILER_LIB_ARCH" "$qtDir/lib")
if ( -d "$qtLibDir" ) then
setenv LD_LIBRARY_PATH "${qtLibDir}:${LD_LIBRARY_PATH}"
break
endif
end
endif
# ParaView libraries
# - 5.4 and earlier: lib/paraview-X.X
# - 5.5 and later: lib/
switch ("$pv_api")
case 5.[0-4]*:
setenv LD_LIBRARY_PATH "${pvLibDir}:${LD_LIBRARY_PATH}"
breaksw
default:
setenv LD_LIBRARY_PATH "${ParaView_DIR}/lib:${LD_LIBRARY_PATH}"
breaksw
endsw
if ($?FOAM_VERBOSE && $?prompt) then
echo "Using paraview"
echo " ParaView_DIR : $ParaView_DIR"
echo " library dir : $pvLibDir"
echo " PV_PLUGIN_PATH : $PV_PLUGIN_PATH"
endif
else
if ($?FOAM_VERBOSE && $?prompt) then
echo "No paraview found"
echo " ParaView_DIR : $ParaView_DIR"
endif
unsetenv PV_PLUGIN_PATH
setenv ParaView_DIR # Defined but empty (used by foamPV alias)
endif
breaksw
endsw
unset cleaned archDir
unset cmake cmake_version
unset pv_api pvLibDir pvPython qtDir qtLibDir
unsetenv ParaView_VERSION ParaView_QT
#------------------------------------------------------------------------------