mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add versioning for VTK library to runTimePostProcessing (issue #370)
Eg,
librunTimePostProcessing.so
librunTimePostProcessing.so.7 -> librunTimePostProcessing.so.7.1.0
librunTimePostProcessing.so.7.1.0
- centralize handling of paraview/vtk versioning into wmake/cmakeFunctions
This commit is contained in:
@ -7,84 +7,8 @@ export WM_CONTINUE_ON_ERROR=true
|
|||||||
# Parse arguments for library compilation
|
# Parse arguments for library compilation
|
||||||
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
|
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
|
||||||
|
|
||||||
# Source the wmake functions
|
# Source CMake functions
|
||||||
. $WM_PROJECT_DIR/wmake/scripts/wmakeFunctions
|
. $WM_PROJECT_DIR/wmake/scripts/cmakeFunctions
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#
|
|
||||||
# There are several prerequisites for building plugins
|
|
||||||
#
|
|
||||||
#set -x
|
|
||||||
canBuildPlugin()
|
|
||||||
{
|
|
||||||
[ -d "$ParaView_DIR" -a -r "$ParaView_DIR" ] || {
|
|
||||||
echo "==> cannot build ParaView plugins without paraview directory"
|
|
||||||
echo " ParaView_DIR=$ParaView_DIR"
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
[ -n "$PV_PLUGIN_PATH" ] || {
|
|
||||||
echo "==> ${PWD##*/} : invalid PV_PLUGIN_PATH for building ParaView plugins"
|
|
||||||
echo " PV_PLUGIN_PATH=${PV_PLUGIN_PATH:-unset}"
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
type cmake > /dev/null 2>&1 || {
|
|
||||||
echo "==> cannot build ParaView plugins without cmake"
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0 # success
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Check sentinel file(s) to handle paraview version changes
|
|
||||||
#
|
|
||||||
versionOk()
|
|
||||||
{
|
|
||||||
findObjectDir "$1" # Where generated files are stored
|
|
||||||
local sentinel="$objectsDir/ThirdParty"
|
|
||||||
|
|
||||||
echo $sentinel
|
|
||||||
|
|
||||||
local prev
|
|
||||||
if read -r prev 2>/dev/null < $sentinel
|
|
||||||
then
|
|
||||||
case "$prev" in
|
|
||||||
("ParaView_DIR=$ParaView_DIR")
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
(*)
|
|
||||||
echo "ParaView_DIR changed between builds" 1>&2
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
elif [ -f "$objectsDir/CMakeCache.txt" ]
|
|
||||||
then
|
|
||||||
echo "previous build was incomplete" 1>&2
|
|
||||||
return 1
|
|
||||||
else
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Build library - use sentinel file(s) to handle paraview version changes
|
|
||||||
#
|
|
||||||
wmakeLibPv()
|
|
||||||
{
|
|
||||||
for libName
|
|
||||||
do
|
|
||||||
sentinel=$(versionOk $libName) || wclean $libName # version changed
|
|
||||||
wmake $targetType $libName && {
|
|
||||||
echo "ParaView_DIR=$ParaView_DIR" > $sentinel
|
|
||||||
}
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@ -4,94 +4,8 @@ cd ${0%/*} || exit 1 # Run from this directory
|
|||||||
# Parse arguments for library compilation
|
# Parse arguments for library compilation
|
||||||
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
|
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
|
||||||
|
|
||||||
# Source the wmake functions
|
# Source CMake functions
|
||||||
. $WM_PROJECT_DIR/wmake/scripts/wmakeFunctions
|
. $WM_PROJECT_DIR/wmake/scripts/cmakeFunctions
|
||||||
|
|
||||||
# Ensure CMake gets the correct C/C++ compilers
|
|
||||||
[ -n "$WM_CC" ] && export CC="$WM_CC"
|
|
||||||
[ -n "$WM_CXX" ] && export CXX="$WM_CXX"
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#
|
|
||||||
# Check sentinel file(s) to handle paraview version changes
|
|
||||||
#
|
|
||||||
versionOk()
|
|
||||||
{
|
|
||||||
findObjectDir "$1" # Where generated files are stored
|
|
||||||
local sentinel="$objectsDir/ThirdParty"
|
|
||||||
|
|
||||||
echo $sentinel
|
|
||||||
|
|
||||||
local prev
|
|
||||||
if read -r prev 2>/dev/null < $sentinel
|
|
||||||
then
|
|
||||||
case "$prev" in
|
|
||||||
("ParaView_DIR=$ParaView_DIR")
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
(*)
|
|
||||||
echo "ParaView_DIR changed between builds" 1>&2
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
elif [ -f "$objectsDir/CMakeCache.txt" ]
|
|
||||||
then
|
|
||||||
echo "previous build was incomplete" 1>&2
|
|
||||||
return 1
|
|
||||||
else
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# CMake into objectsDir,
|
|
||||||
# with an additional attempt if (possibly incorrect) CMakeCache.txt existed
|
|
||||||
doCmake()
|
|
||||||
{
|
|
||||||
local sourceDir="$1"
|
|
||||||
findObjectDir $sourceDir # Where are generated files stored?
|
|
||||||
|
|
||||||
# version changed
|
|
||||||
sentinel=$(versionOk $sourceDir) || rm -rf "$objectsDir" > /dev/null 2>&1
|
|
||||||
|
|
||||||
test -f "$objectsDir/CMakeCache.txt"
|
|
||||||
retry=$? # CMakeCache.txt exists, but sources may have moved
|
|
||||||
|
|
||||||
mkdir -p $objectsDir && \
|
|
||||||
(
|
|
||||||
cd $objectsDir || exit 1
|
|
||||||
|
|
||||||
cmake $sourceDir || {
|
|
||||||
if [ $retry -eq 0 ]
|
|
||||||
then
|
|
||||||
echo "Removing CMakeCache.txt and attempt again"
|
|
||||||
rm -f CMakeCache.txt
|
|
||||||
cmake $sourceDir
|
|
||||||
else
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
} && make && {
|
|
||||||
echo "ParaView_DIR=$ParaView_DIR" > $sentinel
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Build library - use sentinel file(s) to handle paraview version changes
|
|
||||||
#
|
|
||||||
wmakeLibPv()
|
|
||||||
{
|
|
||||||
for libName
|
|
||||||
do
|
|
||||||
sentinel=$(versionOk $libName) || wclean $libName # version changed
|
|
||||||
wmake $targetType $libName && {
|
|
||||||
echo "ParaView_DIR=$ParaView_DIR" > $sentinel
|
|
||||||
}
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -101,7 +15,7 @@ then
|
|||||||
|
|
||||||
if [ "$targetType" != objects ]
|
if [ "$targetType" != objects ]
|
||||||
then
|
then
|
||||||
doCmake $PWD/PVFoamReader || {
|
cmakePv $PWD/PVFoamReader || {
|
||||||
echo
|
echo
|
||||||
echo " WARNING: incomplete build of ParaView OpenFOAM plugin"
|
echo " WARNING: incomplete build of ParaView OpenFOAM plugin"
|
||||||
echo
|
echo
|
||||||
|
|||||||
@ -4,94 +4,8 @@ cd ${0%/*} || exit 1 # Run from this directory
|
|||||||
# Parse arguments for library compilation
|
# Parse arguments for library compilation
|
||||||
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
|
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
|
||||||
|
|
||||||
# Source the wmake functions
|
# Source CMake functions
|
||||||
. $WM_PROJECT_DIR/wmake/scripts/wmakeFunctions
|
. $WM_PROJECT_DIR/wmake/scripts/cmakeFunctions
|
||||||
|
|
||||||
# Ensure CMake gets the correct C/C++ compilers
|
|
||||||
[ -n "$WM_CC" ] && export CC="$WM_CC"
|
|
||||||
[ -n "$WM_CXX" ] && export CXX="$WM_CXX"
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#
|
|
||||||
# Check sentinel file(s) to handle paraview version changes
|
|
||||||
#
|
|
||||||
versionOk()
|
|
||||||
{
|
|
||||||
findObjectDir "$1" # Where generated files are stored
|
|
||||||
local sentinel="$objectsDir/ThirdParty"
|
|
||||||
|
|
||||||
echo $sentinel
|
|
||||||
|
|
||||||
local prev
|
|
||||||
if read -r prev 2>/dev/null < $sentinel
|
|
||||||
then
|
|
||||||
case "$prev" in
|
|
||||||
("ParaView_DIR=$ParaView_DIR")
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
(*)
|
|
||||||
echo "ParaView_DIR changed between builds" 1>&2
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
elif [ -f "$objectsDir/CMakeCache.txt" ]
|
|
||||||
then
|
|
||||||
echo "previous build was incomplete" 1>&2
|
|
||||||
return 1
|
|
||||||
else
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# CMake into objectsDir,
|
|
||||||
# with an additional attempt if (possibly incorrect) CMakeCache.txt existed
|
|
||||||
doCmake()
|
|
||||||
{
|
|
||||||
local sourceDir="$1"
|
|
||||||
findObjectDir $sourceDir # Where are generated files stored?
|
|
||||||
|
|
||||||
# version changed
|
|
||||||
sentinel=$(versionOk $sourceDir) || rm -rf "$objectsDir" > /dev/null 2>&1
|
|
||||||
|
|
||||||
test -f "$objectsDir/CMakeCache.txt"
|
|
||||||
retry=$? # CMakeCache.txt exists, but sources may have moved
|
|
||||||
|
|
||||||
mkdir -p $objectsDir && \
|
|
||||||
(
|
|
||||||
cd $objectsDir || exit 1
|
|
||||||
|
|
||||||
cmake $sourceDir || {
|
|
||||||
if [ $retry -eq 0 ]
|
|
||||||
then
|
|
||||||
echo "Removing CMakeCache.txt and attempt again"
|
|
||||||
rm -f CMakeCache.txt
|
|
||||||
cmake $sourceDir
|
|
||||||
else
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
} && make && {
|
|
||||||
echo "ParaView_DIR=$ParaView_DIR" > $sentinel
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Build library - use sentinel file(s) to handle paraview version changes
|
|
||||||
#
|
|
||||||
wmakeLibPv()
|
|
||||||
{
|
|
||||||
for libName
|
|
||||||
do
|
|
||||||
sentinel=$(versionOk $libName) || wclean $libName # version changed
|
|
||||||
wmake $targetType $libName && {
|
|
||||||
echo "ParaView_DIR=$ParaView_DIR" > $sentinel
|
|
||||||
}
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -101,7 +15,7 @@ then
|
|||||||
|
|
||||||
if [ "$targetType" != objects ]
|
if [ "$targetType" != objects ]
|
||||||
then
|
then
|
||||||
doCmake $PWD/PVblockMeshReader || {
|
cmakePv $PWD/PVblockMeshReader || {
|
||||||
echo
|
echo
|
||||||
echo " WARNING: incomplete build of ParaView BlockMesh plugin"
|
echo " WARNING: incomplete build of ParaView BlockMesh plugin"
|
||||||
echo
|
echo
|
||||||
|
|||||||
@ -1,87 +1,8 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
cd ${0%/*} || exit 1 # Run from this directory
|
cd ${0%/*} || exit 1 # Run from this directory
|
||||||
|
|
||||||
# Source the wmake functions
|
# Source CMake functions
|
||||||
. $WM_PROJECT_DIR/wmake/scripts/wmakeFunctions
|
. $WM_PROJECT_DIR/wmake/scripts/cmakeFunctions
|
||||||
|
|
||||||
# Ensure CMake gets the correct C/C++ compilers
|
|
||||||
[ -n "$WM_CC" ] && export CC="$WM_CC"
|
|
||||||
[ -n "$WM_CXX" ] && export CXX="$WM_CXX"
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#
|
|
||||||
# Check sentinel file(s) to handle vtk/paraview version changes
|
|
||||||
#
|
|
||||||
versionOk()
|
|
||||||
{
|
|
||||||
findObjectDir "$1" # Where generated files are stored
|
|
||||||
local sentinel="$objectsDir/ThirdParty"
|
|
||||||
|
|
||||||
echo $sentinel
|
|
||||||
|
|
||||||
local prev
|
|
||||||
if read -r prev 2>/dev/null < $sentinel
|
|
||||||
then
|
|
||||||
case "$prev" in
|
|
||||||
("ParaView_DIR=$ParaView_DIR" | "VTK_DIR=$VTK_DIR")
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
(*)
|
|
||||||
echo "ParaView_DIR or VTK_DIR changed between builds" 1>&2
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
elif [ -f "$objectsDir/CMakeCache.txt" ]
|
|
||||||
then
|
|
||||||
echo "previous build was incomplete" 1>&2
|
|
||||||
return 1
|
|
||||||
else
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# CMake into objectsDir,
|
|
||||||
# with an additional attempt if (possibly incorrect) CMakeCache.txt existed
|
|
||||||
doCmake()
|
|
||||||
{
|
|
||||||
local sourceDir="$1"
|
|
||||||
findObjectDir $sourceDir # Where are generated files stored?
|
|
||||||
|
|
||||||
# version changed
|
|
||||||
sentinel=$(versionOk $sourceDir) || rm -rf "$objectsDir" > /dev/null 2>&1
|
|
||||||
|
|
||||||
test -f "$objectsDir/CMakeCache.txt"
|
|
||||||
retry=$? # CMakeCache.txt exists, but sources may have moved
|
|
||||||
|
|
||||||
mkdir -p $objectsDir && \
|
|
||||||
(
|
|
||||||
cd $objectsDir || exit 1
|
|
||||||
|
|
||||||
cmake $sourceDir || {
|
|
||||||
if [ $retry -eq 0 ]
|
|
||||||
then
|
|
||||||
echo "Removing CMakeCache.txt and attempt again"
|
|
||||||
rm -f CMakeCache.txt
|
|
||||||
cmake $sourceDir
|
|
||||||
else
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
} && make && {
|
|
||||||
if [ -d "$VTK_DIR" ]
|
|
||||||
then
|
|
||||||
echo "VTK_DIR=$VTK_DIR"
|
|
||||||
elif [ -d "$ParaView_DIR" ]
|
|
||||||
then
|
|
||||||
echo "ParaView_DIR=$ParaView_DIR"
|
|
||||||
else
|
|
||||||
echo unknown
|
|
||||||
fi > $sentinel
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -89,13 +10,22 @@ echo "======================================================================"
|
|||||||
echo "${PWD##*/} : $PWD"
|
echo "${PWD##*/} : $PWD"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
if [ -d "$VTK_DIR" -o -d "$ParaView_DIR" ]
|
unset depend
|
||||||
|
if [ -d "$VTK_DIR" ]
|
||||||
|
then
|
||||||
|
depend="VTK_DIR=$VTK_DIR"
|
||||||
|
elif [ -d "$ParaView_DIR" ]
|
||||||
|
then
|
||||||
|
depend="ParaView_DIR=$ParaView_DIR"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$depend" ]
|
||||||
then
|
then
|
||||||
if [ "$targetType" != objects ]
|
if [ "$targetType" != objects ]
|
||||||
then
|
then
|
||||||
if type cmake > /dev/null 2>&1
|
if type cmake > /dev/null 2>&1
|
||||||
then
|
then
|
||||||
doCmake $PWD || {
|
cmakeVersioned "$depend" $PWD || {
|
||||||
echo
|
echo
|
||||||
echo " WARNING: incomplete build of VTK-based post-processing"
|
echo " WARNING: incomplete build of VTK-based post-processing"
|
||||||
echo
|
echo
|
||||||
|
|||||||
@ -32,13 +32,13 @@ add_definitions(
|
|||||||
set(CMAKE_BUILD_TYPE Release)
|
set(CMAKE_BUILD_TYPE Release)
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG
|
set(CMAKE_CXX_FLAGS_DEBUG
|
||||||
"-g -O0 -std=c++0x -Wall -Wextra -Wno-unused-parameter -Wnon-virtual-dtor -Wno-overloaded-virtual"
|
"-g -O0 -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wnon-virtual-dtor -Wno-overloaded-virtual"
|
||||||
)
|
)
|
||||||
set(CMAKE_C_FLAGS_DEBUG "-g -O0 -std=c++0x")
|
set(CMAKE_C_FLAGS_DEBUG "-g -O0 -std=c++11")
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE
|
set(CMAKE_CXX_FLAGS_RELEASE
|
||||||
"-O3 -std=c++0x -Wall -Wextra -Wno-unused-parameter -Wnon-virtual-dtor -Wno-overloaded-virtual")
|
"-O3 -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wnon-virtual-dtor -Wno-overloaded-virtual")
|
||||||
set(CMAKE_C_FLAGS_RELEASE "-O3 -std=c++0x")
|
set(CMAKE_C_FLAGS_RELEASE "-O3 -std=c++11")
|
||||||
|
|
||||||
# Set output library destination to plugin directory
|
# Set output library destination to plugin directory
|
||||||
set(LIBRARY_OUTPUT_PATH $ENV{FOAM_LIBBIN}
|
set(LIBRARY_OUTPUT_PATH $ENV{FOAM_LIBBIN}
|
||||||
@ -46,6 +46,12 @@ set(LIBRARY_OUTPUT_PATH $ENV{FOAM_LIBBIN}
|
|||||||
""
|
""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
## Record VTK version for general bookkeeping
|
||||||
|
# file(WRITE
|
||||||
|
# ${CMAKE_BINARY_DIR}/version
|
||||||
|
# "VTK_VERSION=${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}.${VTK_BUILD_VERSION}\n"
|
||||||
|
# )
|
||||||
|
|
||||||
file(GLOB SOURCE_FILES
|
file(GLOB SOURCE_FILES
|
||||||
fieldVisualisationBase.C
|
fieldVisualisationBase.C
|
||||||
functionObjectBase.C
|
functionObjectBase.C
|
||||||
@ -75,11 +81,17 @@ add_library(
|
|||||||
${SOURCE_FILES}
|
${SOURCE_FILES}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set_target_properties(
|
||||||
|
runTimePostProcessing
|
||||||
|
PROPERTIES
|
||||||
|
VERSION ${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}.${VTK_BUILD_VERSION}
|
||||||
|
SOVERSION ${VTK_MAJOR_VERSION}
|
||||||
|
)
|
||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
runTimePostProcessing
|
runTimePostProcessing
|
||||||
${VTK_LIBRARIES}
|
${VTK_LIBRARIES}
|
||||||
${OPENFOAM_LIBRARIES}
|
${OPENFOAM_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
|
|||||||
163
wmake/scripts/cmakeFunctions
Normal file
163
wmake/scripts/cmakeFunctions
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
#----------------------------------*-sh-*--------------------------------------
|
||||||
|
# ========= |
|
||||||
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
# \\ / O peration |
|
||||||
|
# \\ / A nd | Copyright (C) 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/>.
|
||||||
|
#
|
||||||
|
# Script
|
||||||
|
# cmakeFunctions
|
||||||
|
#
|
||||||
|
# Description
|
||||||
|
# Helper functions for CMake
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Source the wmake functions
|
||||||
|
. $WM_PROJECT_DIR/wmake/scripts/wmakeFunctions
|
||||||
|
|
||||||
|
# Ensure CMake gets the correct C/C++ compilers
|
||||||
|
[ -n "$WM_CC" ] && export CC="$WM_CC"
|
||||||
|
[ -n "$WM_CXX" ] && export CXX="$WM_CXX"
|
||||||
|
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#
|
||||||
|
# Check sentinel file(s) to handle paraview / vtk version changes
|
||||||
|
#
|
||||||
|
sameDependency()
|
||||||
|
{
|
||||||
|
local depend="$1"
|
||||||
|
findObjectDir "$2" # Where generated files are stored
|
||||||
|
local sentinel="$objectsDir/ThirdParty"
|
||||||
|
|
||||||
|
echo $sentinel
|
||||||
|
|
||||||
|
local prev
|
||||||
|
if read -r prev 2>/dev/null < $sentinel
|
||||||
|
then
|
||||||
|
if [ "$prev" = "$depend" ]
|
||||||
|
then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
echo "${depend%=*} changed between builds" 1>&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
elif [ -f "$objectsDir/CMakeCache.txt" ]
|
||||||
|
then
|
||||||
|
echo "previous build was incomplete" 1>&2
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# CMake into objectsDir with external dependency
|
||||||
|
cmakeVersioned()
|
||||||
|
{
|
||||||
|
local depend="$1"
|
||||||
|
local sourceDir="$2"
|
||||||
|
findObjectDir $sourceDir # Where are generated files stored?
|
||||||
|
|
||||||
|
local sentinel
|
||||||
|
|
||||||
|
# version changed
|
||||||
|
sentinel=$(sameDependency "$depend" "$sourceDir") \
|
||||||
|
|| rm -rf "$objectsDir" > /dev/null 2>&1
|
||||||
|
|
||||||
|
test -f "$objectsDir/CMakeCache.txt"
|
||||||
|
retry=$? # Additional attempt if sources moved
|
||||||
|
|
||||||
|
mkdir -p $objectsDir && \
|
||||||
|
(
|
||||||
|
cd $objectsDir || exit 1
|
||||||
|
|
||||||
|
cmake $sourceDir || {
|
||||||
|
if [ $retry -eq 0 ]
|
||||||
|
then
|
||||||
|
echo "Removing CMakeCache.txt and attempt again" 1>&2
|
||||||
|
rm -f CMakeCache.txt
|
||||||
|
cmake $sourceDir
|
||||||
|
else
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
} && make && { echo "$depend" > $sentinel; }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# CMake into objectsDir with VTK_DIR dependency
|
||||||
|
cmakeVtk()
|
||||||
|
{
|
||||||
|
cmakeVersioned "VTK_DIR=$VTK_DIR" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# CMake into objectsDir with ParaView_DIR dependency
|
||||||
|
cmakePv()
|
||||||
|
{
|
||||||
|
cmakeVersioned "ParaView_DIR=$ParaView_DIR" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Build library - use sentinel file(s) to handle paraview version changes
|
||||||
|
#
|
||||||
|
wmakeLibPv()
|
||||||
|
{
|
||||||
|
local depend="ParaView_DIR=$ParaView_DIR"
|
||||||
|
local sentinel
|
||||||
|
|
||||||
|
for libName
|
||||||
|
do
|
||||||
|
# version changed
|
||||||
|
sentinel=$(sameDependency "$depend" $libName) || wclean $libName
|
||||||
|
wmake $targetType $libName && { echo "$depend" > $sentinel; }
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# There are several prerequisites for building plugins
|
||||||
|
#
|
||||||
|
canBuildPlugin()
|
||||||
|
{
|
||||||
|
[ -d "$ParaView_DIR" -a -r "$ParaView_DIR" ] || {
|
||||||
|
echo "==> cannot build ParaView plugins without paraview directory"
|
||||||
|
echo " ParaView_DIR=$ParaView_DIR"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
[ -n "$PV_PLUGIN_PATH" ] || {
|
||||||
|
echo "==> ${PWD##*/} : invalid PV_PLUGIN_PATH for building ParaView plugins"
|
||||||
|
echo " PV_PLUGIN_PATH=${PV_PLUGIN_PATH:-unset}"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
type cmake > /dev/null 2>&1 || {
|
||||||
|
echo "==> cannot build ParaView plugins without cmake"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0 # success
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
5
wmake/scripts/wmakeFunctions
Executable file → Normal file
5
wmake/scripts/wmakeFunctions
Executable file → Normal file
@ -1,11 +1,10 @@
|
|||||||
#!/bin/sh
|
#----------------------------------*-sh-*--------------------------------------
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# ========= |
|
# ========= |
|
||||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
# \\ / O peration |
|
# \\ / O peration |
|
||||||
# \\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation
|
# \\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation
|
||||||
# \\/ M anipulation |
|
# \\/ M anipulation |
|
||||||
#-------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# License
|
# License
|
||||||
# This file is part of OpenFOAM.
|
# This file is part of OpenFOAM.
|
||||||
#
|
#
|
||||||
|
|||||||
Reference in New Issue
Block a user