Files
ThirdParty-common/etc/tools/vtkFunctions
mark 59be96faed ENH: remove reliance on OpenFOAM etc/config.sh/functions file.
- similar functionality in etc/tools/ThirdPartyFunctions to improve
  the independence of ThirdParty while reducing clutter in the callers.

- add useGcc function for convenience
- mask seeing our own git-repo when building

STYLE: various items

- eliminate old user-editable configuration in files - now command-line only.
- use *_BUILD_DIR instead of *_BINARY_DIR for more clarity of the purpose
- drop use of '-q' option for wmakeCheckPwd (already has stderr redirect)
- drop checkVersion for makeParaView since it stopped working properly
  with newer paraview version

CONFIG: update list of versions
2017-03-20 12:42:44 +01:00

207 lines
5.3 KiB
Bash

#---------------------------------*- 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.
#
# 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 <http://www.gnu.org/licenses/>.
#
# 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 "<digits>.<digits>"
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
echo " Done make"
# Remove lib if it is a link
# (how this was previously handled before 'make install' worked)
[ -L lib ] && rm -f lib 2>/dev/null
}
#
# Install the program
#
installVTK()
{
cd $VTK_BUILD_DIR || exit 1 # Change to build folder
echo " Installing VTK to $VTK_DIR"
make install
/bin/cat<<INFO
====
Installation complete for vtk-$VTK_VERSION as
VTK_DIR=$VTK_DIR
====
INFO
}
#------------------------------------------------------------------------------
# Start with these general settings
addCMakeVariable "BUILD_SHARED_LIBS=ON" "BUILD_TESTING=OFF"
#------------------------------------------------------------------------------