buildParaView changes

- set CMAKE_INSTALL_PREFIX:PATH now
- allow separation between -config/-make/-install stages
- update for cmake 2.6
This commit is contained in:
Mark Olesen
2008-12-13 17:55:07 +01:00
parent 4c6a7ca707
commit aa522c93f1
4 changed files with 289 additions and 319 deletions

View File

@ -45,7 +45,7 @@ WITH_MPI=OFF
MPI_MAX_PROCS=32 MPI_MAX_PROCS=32
# Python support: # Python support:
# note: script will try to determine python library. # note: script will try to determine the appropriate python library.
# If it fails, specify the path using the PYTHON_LIBRARY variable # If it fails, specify the path using the PYTHON_LIBRARY variable
WITH_PYTHON=OFF WITH_PYTHON=OFF
PYTHON_LIBRARY="" PYTHON_LIBRARY=""
@ -60,8 +60,8 @@ WITH_MESA=OFF
Script=${0##*/} Script=${0##*/}
usage() { usage() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE cat<<USAGE
usage: ${0##*/} [OPTION] usage: ${0##*/} [OPTION]
options: options:
@ -72,6 +72,11 @@ options:
-verbose verbose cmake output -verbose verbose cmake output
-help -help
For finer control, the build stages can be selected (mutually exclusive)
-config
-make
-install
Build and install $PARAVIEW_SRC Build and install $PARAVIEW_SRC
- run from folder above the ParaView source folder or place the - run from folder above the ParaView source folder or place the
ParaView source under \$WM_THIRD_PARTY_DIR ParaView source under \$WM_THIRD_PARTY_DIR
@ -86,50 +91,77 @@ case "$Script" in *-mpi*) WITH_MPI=ON;; esac
case "$Script" in *-python*) WITH_PYTHON=ON;; esac case "$Script" in *-python*) WITH_PYTHON=ON;; esac
case "$Script" in *-mesa*) WITH_MESA=ON;; esac case "$Script" in *-mesa*) WITH_MESA=ON;; esac
runCONFIG=true
runMAKE=true
runINSTALL=true
# parse options # parse options
while [ "$#" -gt 0 ] while [ "$#" -gt 0 ]
do do
case "$1" in case "$1" in
-h | -help) -h | -help)
usage usage
;; ;;
-fast) -config) # stage 1: config only
CMAKE_SKIP=YES runCONFIG=true
shift runMAKE=false
;; runINSTALL=false
-mpi) shift
WITH_MPI=ON ;;
shift -make) # stage 2: make only
;; runCONFIG=false
-python) runMAKE=true
WITH_PYTHON=ON runINSTALL=false
shift shift
;; ;;
-mesa) -install) # stage 3: install only
WITH_MESA=ON runCONFIG=false
shift runMAKE=false
;; runINSTALL=true
-verbose) shift
VERBOSE=ON ;;
shift -fast) # shortcut for rebuild
;; runCONFIG=false
*) runMAKE=true
usage "unknown option/argument: '$*'" runINSTALL=true
;; shift
esac ;;
-mpi)
WITH_MPI=ON
shift
;;
-python)
WITH_PYTHON=ON
shift
;;
-mesa)
WITH_MESA=ON
shift
;;
-verbose)
VERBOSE=ON
shift
;;
*)
usage "unknown option/argument: '$*'"
;;
esac
done done
# Set configure options # Set configure options
#~~~~~~~~~~~~~~~~~~~~~~ #~~~~~~~~~~~~~~~~~~~~~~
addVerbosity # set CMake verbosity addVerbosity
addMpiSupport # set MPI-specific options addMpiSupport # set MPI-specific options
addPythonSupport # set Python-specific options addPythonSupport # set Python-specific options
addMesaSupport # set MESA-specific options addMesaSupport # set MESA-specific options
getPaths # discover where things are or should be put
# Build and install # Build and install
# ~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~
buildParaView [ $runCONFIG = true ] && configParaView
installParaView [ $runMAKE = true ] && makeParaView
[ $runINSTALL = true ] && installParaView
echo "done" echo "done"

View File

@ -1,75 +0,0 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 1991-2008 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 2 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, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# Script
# buildParaView3.2.1
#
# Description
# Build and install ParaView
# - run from folder above ParaView source folder or place the
# ParaView source under $WM_PROJECT_INST_DIR
#
#------------------------------------------------------------------------------
. $WM_PROJECT_DIR/bin/tools/buildParaViewFunctions
PARAVIEW_SRC="ParaView3.2.1"
PARAVIEW_MAJOR_VERSION="3.2"
# User options:
# ~~~~~~~~~~~~~
WITH_MPI=ON
MPI_MAX_PROCS=32
WITH_PYTHON=ON
PYTHON_LIBRARY=""
WITH__MESA=OFF
#
# No further editing below this line
#------------------------------------------------------------------------------
# shortcut for repeated builds - use with caution
if [ "$1" = "-fast" ]
then
CMAKE_SKIP=YES
elif [ "$#" -gt 0 ]
then
echo "$0: only supports a -fast option"
exit 1
fi
# Set configure options
#~~~~~~~~~~~~~~~~~~~~~~
addVerbosity # set cmake verbosity
addMpiSupport # set MPI-specific options
addPythonSupport # set Python-specific options
addMesaSupport # set MESA-specific options
buildParaView
installParaView
echo "done"
#------------------------------------------------------------------------------

View File

@ -35,200 +35,209 @@
addCMakeVariable() addCMakeVariable()
{ {
while [ -n "$1" ] while [ -n "$1" ]
do do
CMAKE_VARIABLES="$CMAKE_VARIABLES -D$1" CMAKE_VARIABLES="$CMAKE_VARIABLES -D$1"
shift shift
done done
} }
addVerbosity() addVerbosity()
{ {
[ "$VERBOSE" = ON ] && addCMakeVariable CMAKE_VERBOSE_MAKEFILE=TRUE [ "$VERBOSE" = ON ] && addCMakeVariable CMAKE_VERBOSE_MAKEFILE=TRUE
} }
addMpiSupport() addMpiSupport()
{ {
[ "$WITH_MPI" = ON ] || return [ "$WITH_MPI" = ON ] || return
OBJ_ADD="$OBJ_ADD-mpi" OBJ_ADD="$OBJ_ADD-mpi"
addCMakeVariable PARAVIEW_USE_MPI=ON addCMakeVariable PARAVIEW_USE_MPI=ON VTK_USE_MPI=ON
addCMakeVariable VTK_USE_MPI=ON addCMakeVariable MPI_INCLUDE_PATH=$MPI_ARCH_PATH/include
addCMakeVariable MPI_INCLUDE_PATH=$MPI_ARCH_PATH/include addCMakeVariable MPI_LIBRARY=$MPI_ARCH_PATH/lib/libmpi.so
addCMakeVariable MPI_LIBRARY=$MPI_ARCH_PATH/lib/libmpi.so addCMakeVariable VTK_MPIRUN_EXE=$MPI_ARCH_PATH/bin/mpirun
addCMakeVariable VTK_MPIRUN_EXE=$MPI_ARCH_PATH/bin/mpirun addCMakeVariable VTK_MPI_MAX_NUMPROCS=$MPI_MAX_PROCS
addCMakeVariable VTK_MPI_MAX_NUMPROCS=$MPI_MAX_PROCS
} }
addPythonSupport() addPythonSupport()
{ {
[ "$WITH_PYTHON" = ON ] || return [ "$WITH_PYTHON" = ON ] || return
OBJ_ADD="$OBJ_ADD-py" OBJ_ADD="$OBJ_ADD-py"
if pythonBin=$(which python 2>/dev/null) if pythonBin=$(which python 2>/dev/null)
then then
if [ -n "$PYTHON_LIBRARY" ] if [ -n "$PYTHON_LIBRARY" ]
then then
# check $PYTHON_LIBRARY if it has been set # check $PYTHON_LIBRARY if it has been set
if [ ! -e "$PYTHON_LIBRARY" ] if [ ! -e "$PYTHON_LIBRARY" ]
then then
echo "*** Error: libpython not found at location specified " \ echo "*** Error: libpython not found at location specified " \
"by PYTHON_LIBRARY=$PYTHON_LIBRARY" "by PYTHON_LIBRARY=$PYTHON_LIBRARY"
fi fi
else else
# Try to get $PYTHON_LIBRARY from dynamically linked binary # Try to get $PYTHON_LIBRARY from dynamically linked binary
PYTHON_LIBRARY=$(ldd $pythonBin | \ PYTHON_LIBRARY=$(ldd $pythonBin | \
sed -ne '/libpython/s/.* => \(.*\) (.*/\1/p') sed -ne '/libpython/s/.* => \(.*\) (.*/\1/p')
if [ ! -e "$PYTHON_LIBRARY" ] if [ ! -e "$PYTHON_LIBRARY" ]
then then
echo "*** Error: Unable to determine path to python library." echo "*** Error: Unable to determine path to python library."
fi fi
fi fi
[ -e "$PYTHON_LIBRARY" ] || { [ -e "$PYTHON_LIBRARY" ] || {
echo " Please set the variable PYTHON_LIBRARY to the full" echo " Please set the variable PYTHON_LIBRARY to the full"
echo " path to (and including) libpython, or deactivate" echo " path to (and including) libpython, or deactivate"
echo " python support by setting WITH_PYTHON=OFF" echo " python support by setting WITH_PYTHON=OFF"
exit 1 exit 1
} }
pythonMajor=$(echo $PYTHON_LIBRARY | sed 's/.*libpython\(.*\)\.so.*/\1/') pythonMajor=$(echo $PYTHON_LIBRARY | sed 's/.*libpython\(.*\)\.so.*/\1/')
pythonInclude=/usr/include/python$pythonMajor pythonInclude=/usr/include/python$pythonMajor
[ -e "$PYTHON_LIBRARY" ] || { [ -e "$PYTHON_LIBRARY" ] || {
echo " Please set the variable PYTHON_LIBRARY to the full" echo " Please set the variable PYTHON_LIBRARY to the full"
echo " path to (and including) libpython, or deactivate" echo " path to (and including) libpython, or deactivate"
echo " python support by setting WITH_PYTHON=OFF" echo " python support by setting WITH_PYTHON=OFF"
exit 1 exit 1
} }
# note - we could also allow for a PYTHON_INCLUDE variable ... # note - we could also allow for a PYTHON_INCLUDE variable ...
[ -e "$pythonInclude" ] || { [ -e "$pythonInclude" ] || {
echo " No python include headers found" echo " No python include headers found"
echo " Please install python headers or deactivate " echo " Please install python headers or deactivate "
echo " python support by setting WITH_PYTHON=OFF" echo " python support by setting WITH_PYTHON=OFF"
exit 1 exit 1
} }
addCMakeVariable PARAVIEW_ENABLE_PYTHON=ON addCMakeVariable PARAVIEW_ENABLE_PYTHON=ON
addCMakeVariable PYTHON_INCLUDE_PATH=$pythonInclude addCMakeVariable PYTHON_INCLUDE_PATH=$pythonInclude
addCMakeVariable PYTHON_LIBRARY=$PYTHON_LIBRARY addCMakeVariable PYTHON_LIBRARY=$PYTHON_LIBRARY
echo "----" echo "----"
echo "Python information:" echo "Python information:"
echo " executable : $pythonBin" echo " executable : $pythonBin"
echo " version : $pythonMajor" echo " version : $pythonMajor"
echo " include path : $pythonInclude" echo " include path : $pythonInclude"
echo " library : $PYTHON_LIBRARY" echo " library : $PYTHON_LIBRARY"
unset pythonBin pythonInclude pythonMajor unset pythonBin pythonInclude pythonMajor
else else
echo "*** Error: python not installed" echo "*** Error: python not installed"
echo "*** Deactivate python support by setting WITH_PYTHON=OFF" echo "*** Deactivate python support by setting WITH_PYTHON=OFF"
exit 1 exit 1
fi fi
} }
addMesaSupport() addMesaSupport()
{ {
[ "$WITH_MESA" = ON ] || return [ "$WITH_MESA" = ON ] || return
MESA_INCLUDE_DIR=/usr/include/GL MESA_INCLUDE_DIR=/usr/include/GL
MESA_LIBRARY=/usr/lib$WM_COMPILER_LIB_ARCH/libOSMesa.so MESA_LIBRARY=/usr/lib$WM_COMPILER_LIB_ARCH/libOSMesa.so
if [ -d "$MESA_INCLUDE_DIR" -a -f "$MESA_LIBRARY" ] if [ -d "$MESA_INCLUDE_DIR" -a -f "$MESA_LIBRARY" ]
then then
OBJ_ADD="$OBJ_ADD-mesa" OBJ_ADD="$OBJ_ADD-mesa"
addCMakeVariable VTK_OPENGL_HAS_OSMESA=ON addCMakeVariable VTK_OPENGL_HAS_OSMESA=ON
addCMakeVariable OSMESA_INCLUDE_DIR=$MESA_INCLUDE_DIR addCMakeVariable OSMESA_INCLUDE_DIR=$MESA_INCLUDE_DIR
addCMakeVariable OSMESA_LIBRARY=$MESA_LIBRARY addCMakeVariable OSMESA_LIBRARY=$MESA_LIBRARY
else else
echo "*** Error: no MESA information found" echo "*** Error: no MESA information found"
exit 1 exit 1
fi fi
} }
buildParaView() #
# discover where things are or should be put
#
getPaths()
{ {
# set paraview environment # set paraview environment
for i in $PWD $WM_THIRD_PARTY_DIR for i in $PWD $WM_THIRD_PARTY_DIR
do do
ParaView_INST_DIR=$i/$PARAVIEW_SRC ParaView_INST_DIR=$i/$PARAVIEW_SRC
[ -d $ParaView_INST_DIR ] && break [ -d $ParaView_INST_DIR ] && break
done done
if [ ! -d "$ParaView_INST_DIR" ] if [ ! -d "$ParaView_INST_DIR" ]
then then
# last chance: maybe already in the paraview directory # last chance: maybe already in the paraview directory
[ "${PWD##*/}" = $PARAVIEW_SRC ] && ParaView_INST_DIR=$PWD [ "${PWD##*/}" = $PARAVIEW_SRC ] && ParaView_INST_DIR=$PWD
[ -d "$ParaView_INST_DIR" ] || { [ -d "$ParaView_INST_DIR" ] || {
echo "did not find $PARAVIEW_SRC in these directories:" echo "did not find $PARAVIEW_SRC in these directories:"
echo " PWD=$PWD" echo " PWD=$PWD"
echo " WM_THIRD_PARTY_DIR=$WM_THIRD_PARTY_DIR" echo " WM_THIRD_PARTY_DIR=$WM_THIRD_PARTY_DIR"
echo "abort build" echo "abort build"
exit 1 exit 1
} }
fi fi
# ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER$OBJ_ADD
ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER
echo "ParaView_DIR=$ParaView_DIR"
}
# ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER$OBJ_ADD # configure via cmake, but don't actually build anything
ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_ARCH$WM_COMPILER configParaView()
{
# remove any existing build folder and recreate
rm -rf $ParaView_DIR
mkdir -p $ParaView_DIR
cd $ParaView_DIR
# shortcut for repeated builds - use with caution echo "----"
if [ "$CMAKE_SKIP" = YES ] echo "Configuring $PARAVIEW_SRC"
then echo " MPI support : $WITH_MPI"
echo " Python support : $WITH_PYTHON"
echo " MESA support : $WITH_MESA"
echo " Source : $ParaView_INST_DIR"
echo " Target : $ParaView_DIR"
echo "----"
echo
echo cmake \
-DCMAKE_INSTALL_PREFIX:PATH=$ParaView_DIR \
$CMAKE_VARIABLES \
$ParaView_INST_DIR
echo
echo "----"
echo
# change to build/install folder # run cmake to create Makefiles
cd $ParaView_DIR || exit 1 cmake \
-DCMAKE_INSTALL_PREFIX:PATH=$ParaView_DIR \
$CMAKE_VARIABLES \
$ParaView_INST_DIR
else }
# remove any existing build folder and recreate makeParaView()
rm -rf $ParaView_DIR {
mkdir -p $ParaView_DIR # change to build/install folder
cd $ParaView_DIR cd $ParaView_DIR || exit 1
echo " Starting make"
echo "----" if [ -r /proc/cpuinfo ]
echo "Building $PARAVIEW_SRC" then
echo " MPI support : $WITH_MPI" WM_NCOMPPROCS=$(egrep "^processor" /proc/cpuinfo | wc -l)
echo " Python support : $WITH_PYTHON" [ $WM_NCOMPPROCS -le 8 ] || WM_NCOMPPROCS=8
echo " MESA support : $WITH_MESA"
echo " Source : $ParaView_INST_DIR"
echo " Target : $ParaView_DIR"
echo "----"
# make paraview make -j $WM_NCOMPPROCS
cmake \ else
-DCMAKE_INSTALL_PREFIX=$PARAVIEW_APP_DIR \ make
$CMAKE_VARIABLES \ fi
$ParaView_INST_DIR make install
fi echo " Done make"
# change to build folder
echo " Starting make"
if [ -r /proc/cpuinfo ]
then
WM_NCOMPPROCS=$(egrep "^processor" /proc/cpuinfo | wc -l)
if [ $WM_NCOMPPROCS -gt 8 ]
then
WM_NCOMPPROCS=8
fi
make -j $WM_NCOMPPROCS
else
make
fi
} }
@ -236,76 +245,76 @@ buildParaView()
# Note: use loop with grep to avoid touching too many files # Note: use loop with grep to avoid touching too many files
fixCMakeHardLinks() fixCMakeHardLinks()
{ {
fileSpec=$1 fileSpec=$1
string=$2 string=$2
envName=$3 envName=$3
echo -n " for \$$envName " echo -n " for \$$envName "
for i in $(find . -type f -iname "$fileSpec") for i in $(find . -type f -iname "$fileSpec")
do do
if grep -q "$string" $i if grep -q "$string" $i
then then
echo -n "#" echo -n "#"
sed -i "s,$string,\$ENV{$envName},g" $i sed -i "s,$string,\$ENV{$envName},g" $i
fi fi
done done
echo echo
} }
installParaView() installParaView()
{ {
if [ ! -e "$ParaView_DIR/bin/paraview" ] [ -e "$ParaView_DIR/bin/paraview" ] || {
then echo " Cannot install - no paraview binary found"
echo " Cannot install - no paraview binary found" return
return }
fi
echo " Build complete"
cd $ParaView_DIR # change to build/install folder
cd $ParaView_DIR || exit 1
echo " Replacing path hard links" echo " Installing ParaView"
echo " Replacing path hard links"
# Replace local ParaView_INST_DIR path with ParaView_INST_DIR # Replace local ParaView_INST_DIR path with ParaView_INST_DIR
# environment variable # environment variable
fixCMakeHardLinks '*.cmake' "$ParaView_INST_DIR" ParaView_INST_DIR fixCMakeHardLinks '*.cmake' "$ParaView_INST_DIR" ParaView_INST_DIR
# Replace local MPI_ARCH_PATH path with MPI_ARCH_PATH # Replace local MPI_ARCH_PATH path with MPI_ARCH_PATH
# environment variable # environment variable
if [ "$WITH_MPI" = ON ] if [ "$WITH_MPI" = ON ]
then then
fixCMakeHardLinks '*.cmake' "$MPI_ARCH_PATH" MPI_ARCH_PATH fixCMakeHardLinks '*.cmake' "$MPI_ARCH_PATH" MPI_ARCH_PATH
fi fi
# Replace local CMAKE_HOME path with CMAKE_HOME # Replace local CMAKE_HOME path with CMAKE_HOME
# environment variable # environment variable
if [ -r "$CMAKE_HOME" ] if [ -r "$CMAKE_HOME" ]
then then
fixCMakeHardLinks '*cmake*' "$CMAKE_HOME" CMAKE_HOME fixCMakeHardLinks '*cmake*' "$CMAKE_HOME" CMAKE_HOME
fi fi
# Replace local WM_COMPILER_DIR path with WM_COMPILER_DIR # Replace local WM_COMPILER_DIR path with WM_COMPILER_DIR
# environment variable # environment variable
fixCMakeHardLinks '*cmake*' "$WM_COMPILER_DIR" WM_COMPILER_DIR fixCMakeHardLinks '*cmake*' "$WM_COMPILER_DIR" WM_COMPILER_DIR
# create a softlink to the $ParaView_DIR/bin folder # create a softlink to the $ParaView_DIR/bin folder
# - workaround for chosen install location # - workaround for chosen install location
echo " Creating lib/paraview-$PARAVIEW_MAJOR_VERSION soft link to 'bin'" echo " Creating lib/paraview-$PARAVIEW_MAJOR_VERSION soft link to 'bin'"
rm -rf lib/paraview-$PARAVIEW_MAJOR_VERSION rm -rf lib/paraview-$PARAVIEW_MAJOR_VERSION
[ -d lib ] || mkdir lib [ -d lib ] || mkdir lib
( cd lib && ln -s ../bin paraview-$PARAVIEW_MAJOR_VERSION ) ( cd lib && ln -s ../bin paraview-$PARAVIEW_MAJOR_VERSION )
# info on symlinks to screen # info on symlinks to screen
echo "" echo ""
echo " ---" echo " ---"
echo " Installation complete" echo " Installation complete"
echo " Set environment variables:" echo " Set environment variables:"
echo " - ParaView_INST_DIR to $ParaView_INST_DIR" echo " - ParaView_INST_DIR to $ParaView_INST_DIR"
echo " - ParaView_DIR to $ParaView_DIR" echo " - ParaView_DIR to $ParaView_DIR"
echo " - PV_PLUGIN_PATH to $FOAM_LIBBIN" echo " - PV_PLUGIN_PATH to $FOAM_LIBBIN"
echo " Add $ParaView_DIR/bin to PATH" echo " Add $ParaView_DIR/bin to PATH"
# echo " Add $ParaView_INST_DIR/lib to LD_LIBRARY_PATH" # echo " Add $ParaView_INST_DIR/lib to LD_LIBRARY_PATH"
echo " ---" echo " ---"
} }
@ -317,7 +326,6 @@ unset WITH_MESA
unset WITH_PYTHON unset WITH_PYTHON
unset PYTHON_LIBRARY unset PYTHON_LIBRARY
unset CMAKE_VARIABLES unset CMAKE_VARIABLES
unset CMAKE_SKIP
unset OBJ_ADD unset OBJ_ADD
# start with these general settings # start with these general settings

View File

@ -31,14 +31,19 @@
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
export CMAKE_HOME=$WM_THIRD_PARTY_DIR/cmake-2.4.6/platforms/$WM_ARCH unset CMAKE_HOME
for cmake in cmake-2.6.2 cmake-2.4.6
do
cmake=$WM_THIRD_PARTY_DIR/$cmake/platforms/$WM_ARCH
if [ -r $CMAKE_HOME ] if [ -r $cmake ]
then then
export PATH=$CMAKE_HOME/bin:$PATH export CMAKE_HOME=$cmake
else export PATH=$CMAKE_HOME/bin:$PATH
unset CMAKE_HOME break
fi fi
done
unset cmake
export ParaView_VERSION="3.3-cvs" export ParaView_VERSION="3.3-cvs"