Merge remote-tracking branch 'origin/master' into develop

This commit is contained in:
Mark Olesen
2020-05-06 10:13:56 +02:00
13 changed files with 496 additions and 116 deletions

View File

@ -1,2 +1,2 @@
api=2003 api=2003
patch=200417 patch=200506

View File

@ -107,6 +107,7 @@ Components specified by absolute path
-adios-path DIR Path for 'ADIOS2_ARCH_PATH' (overrides -adios) -adios-path DIR Path for 'ADIOS2_ARCH_PATH' (overrides -adios)
-boost-path DIR Path for 'BOOST_ARCH_PATH' (overrides -boost) -boost-path DIR Path for 'BOOST_ARCH_PATH' (overrides -boost)
-cgal-path DIR Path for 'CGAL_ARCH_PATH' (overrides -cgal) -cgal-path DIR Path for 'CGAL_ARCH_PATH' (overrides -cgal)
-cmake-path DIR Path for 'CMAKE_ARCH_PATH' (overrides -cmake)
-fftw-path DIR Path for 'FFTW_ARCH_PATH' (overrides -fftw) -fftw-path DIR Path for 'FFTW_ARCH_PATH' (overrides -fftw)
-kahip-path DIR Path for 'KAHIP_ARCH_PATH' (overrides -kahip) -kahip-path DIR Path for 'KAHIP_ARCH_PATH' (overrides -kahip)
-metis-path DIR Path for 'METIS_ARCH_PATH' (overrides -metis) -metis-path DIR Path for 'METIS_ARCH_PATH' (overrides -metis)
@ -662,8 +663,15 @@ CONFIG_CSH
-cmake) -cmake)
# Replace cmake_version=... # Replace cmake_version=...
optionValue=$(getOptionValue "$@") optionValue=$(getOptionValue "$@")
replaceEtc config.sh/paraview cmake_version "$optionValue" replaceEtc config.sh/cmake cmake_version "$optionValue"
replaceEtc config.csh/paraview cmake_version "$optionValue" adjusted=true
shift
;;
-cmake-path)
# Replace CMAKE_ARCH_PATH=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/cmake CMAKE_ARCH_PATH "$optionValue"
adjusted=true adjusted=true
shift shift
;; ;;

View File

@ -78,7 +78,6 @@ example,
ParaView_VERSION=5.6.0 ParaView_VERSION=5.6.0
ParaView_QT=qt-system ParaView_QT=qt-system
cmake_version=cmake-system
# END OF (NORMAL) USER EDITABLE PART # END OF (NORMAL) USER EDITABLE PART
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -16,13 +16,12 @@
# - sourced by OpenFOAM-*/etc/cshrc or via foamPV alias # - sourced by OpenFOAM-*/etc/cshrc or via foamPV alias
# #
# Description # Description
# Setup for PARAVIEW (partially cmake, qt too) # Setup for PARAVIEW (partially QT too)
# #
# To disable use of the PV_PLUGIN_PATH: # To disable use of the PV_PLUGIN_PATH:
# ParaView_VERSION=none # ParaView_VERSION=none
# #
# For system-wide installations: # For system-wide installations:
# cmake_version=cmake-system
# ParaView_QT=qt-system # ParaView_QT=qt-system
# ParaView_VERSION=system [EXPERIMENTAL] # ParaView_VERSION=system [EXPERIMENTAL]
# #
@ -52,7 +51,6 @@
set ParaView_VERSION=5.6.3 set ParaView_VERSION=5.6.3
set ParaView_QT=qt-system set ParaView_QT=qt-system
set cmake_version=cmake-system
# END OF (NORMAL) USER EDITABLE PART # END OF (NORMAL) USER EDITABLE PART
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
@ -65,13 +63,12 @@ if (! $?WM_COMPILER_LIB_ARCH ) setenv WM_COMPILER_LIB_ARCH
set archDir="$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER" set archDir="$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER"
# Clean path and library path # Clean path and 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=PATH "$ParaView_DIR $archDir/ParaView- $archDir/qt-"`
eval `$WM_PROJECT_DIR/bin/foamCleanPath -csh-env=LD_LIBRARY_PATH "$ParaView_DIR $archDir/ParaView- $archDir/qt-"` eval `$WM_PROJECT_DIR/bin/foamCleanPath -csh-env=LD_LIBRARY_PATH "$ParaView_DIR $archDir/ParaView- $archDir/qt-"`
# Evaluate command-line parameters for ParaView and cmake # Evaluate command-line parameters for ParaView
while ( $#argv > 0 ) while ( $#argv > 0 )
switch ($argv[1]) switch ($argv[1])
case cmake*=*:
case ParaView*=*: case ParaView*=*:
# name=value -> set name=value # name=value -> set name=value
eval "set $argv[1]" eval "set $argv[1]"
@ -80,13 +77,6 @@ while ( $#argv > 0 )
shift shift
end end
# 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
if ($?ParaView_VERSION) then if ($?ParaView_VERSION) then
switch ("$ParaView_VERSION") switch ("$ParaView_VERSION")
case "": case "":
@ -211,7 +201,6 @@ endif
unsetenv ParaView_VERSION ParaView_QT unsetenv ParaView_VERSION ParaView_QT
unset archDir libDir unset archDir libDir
unset cmake cmake_version
unset pv_api pvLibDir pvPython qtDir unset pv_api pvLibDir pvPython qtDir
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

35
etc/config.sh/cmake Normal file
View File

@ -0,0 +1,35 @@
#----------------------------------*-sh-*--------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# File
# etc/config.sh/cmake
# - possibly sourced during make process only.
#
# Description
# CMAKE location (ThirdParty or otherwise) when not found via the PATH
# Does not affect the PATH, that is left for the caller
#
# For system-wide installations:
# cmake_version=cmake-system
# define CMAKE_ARCH_PATH
#
# Note
# No csh version. This file is only used during make processes.
#
#------------------------------------------------------------------------------
# USER EDITABLE PART: Changes made here may be lost with the next upgrade
cmake_version=cmake-system
export CMAKE_ARCH_PATH="$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$cmake_version"
# END OF (NORMAL) USER EDITABLE PART
#------------------------------------------------------------------------------

View File

@ -16,7 +16,7 @@
# - sourced by OpenFOAM-*/etc/bashrc or via foamPV alias # - sourced by OpenFOAM-*/etc/bashrc or via foamPV alias
# #
# Description # Description
# Setup for PARAVIEW (partially cmake, qt too) # Setup for PARAVIEW (partially QT too)
# #
# To disable use of the PV_PLUGIN_PATH: # To disable use of the PV_PLUGIN_PATH:
# ParaView_VERSION=none # ParaView_VERSION=none
@ -55,7 +55,6 @@
ParaView_VERSION=5.6.3 ParaView_VERSION=5.6.3
ParaView_QT=qt-system ParaView_QT=qt-system
cmake_version=cmake-system
# END OF (NORMAL) USER EDITABLE PART # END OF (NORMAL) USER EDITABLE PART
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
@ -67,31 +66,23 @@ archDir="$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER"
# Clean path and library path # Clean path and library path
eval \ eval \
"$($WM_PROJECT_DIR/bin/foamCleanPath -sh-env=PATH \ "$($WM_PROJECT_DIR/bin/foamCleanPath -sh-env=PATH \
$ParaView_DIR $archDir/ParaView- $archDir/qt- $archDir/cmake-)" $ParaView_DIR $archDir/ParaView- $archDir/qt-)"
eval \ eval \
"$($WM_PROJECT_DIR/bin/foamCleanPath -sh-env=LD_LIBRARY_PATH \ "$($WM_PROJECT_DIR/bin/foamCleanPath -sh-env=LD_LIBRARY_PATH \
$ParaView_DIR $archDir/ParaView- $archDir/qt-)" $ParaView_DIR $archDir/ParaView- $archDir/qt-)"
# Evaluate command-line parameters for ParaView and cmake # Evaluate command-line parameters for ParaView
for i for i
do do
case "$i" in case "$i" in
(cmake*=* | ParaView*=*) (ParaView*=*)
# name=value -> export name=value # name=value -> export name=value
eval "export $i" eval "export $i"
;; ;;
esac esac
done done
# ThirdParty cmake
cmake="$archDir/$cmake_version"
if [ -r "$cmake/bin/cmake" ]
then
# _foamAddPath not available when foamPV function is used
PATH="$cmake/bin:$PATH"
fi
case "$ParaView_VERSION" in case "$ParaView_VERSION" in
('') ('')
# empty - do nothing # empty - do nothing
@ -206,7 +197,6 @@ then
fi fi
unset archDir libDir unset archDir libDir
unset cmake cmake_version
unset pv_api pvLibDir pvPython qtDir unset pv_api pvLibDir pvPython qtDir
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -63,7 +63,12 @@ options:
Open an interactive bash session with an OpenFOAM environment, Open an interactive bash session with an OpenFOAM environment,
or run an OpenFOAM application (with arguments) after first sourcing or run an OpenFOAM application (with arguments) after first sourcing
the OpenFOAM etc/bashrc file from the project directory: the OpenFOAM etc/bashrc file from the project directory:
($projectDir) (${projectDir:-???})
For a persistent OpenFOAM environment, the following can be added to your
~/.bashrc file:
source ${projectDir:-???}/etc/bashrc
For more information: www.openfoam.com For more information: www.openfoam.com
@ -91,8 +96,9 @@ getApiInfo()
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# No inheritance of FOAM_SETTINGS # - No inheritance of FOAM_SETTINGS
unset FOAM_SETTINGS # - No default verbosity (only as command-line option)
unset FOAM_CONFIG_ETC FOAM_SETTINGS FOAM_VERBOSE
unset _foamEtcDir _foamSettings _foamScriptCommand unset _foamEtcDir _foamSettings _foamScriptCommand
unset optTestTut unset optTestTut
@ -221,8 +227,6 @@ if [ -n "$_foamEtcDir" ] && [ -d "$_foamEtcDir" ]
then then
# Additional etc directory # Additional etc directory
export FOAM_CONFIG_ETC="$_foamEtcDir" export FOAM_CONFIG_ETC="$_foamEtcDir"
else
unset FOAM_CONFIG_ETC
fi fi
if [ -n "$interactive" ] if [ -n "$interactive" ]

View File

@ -6,11 +6,10 @@
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation # Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2019 OpenCFD Ltd. # Copyright (C) 2019-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# License # License
# This file is part of OpenFOAM, licensed under GNU General Public License # This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
# <http://www.gnu.org/licenses/>.
# #
# File # File
# wmake/makefiles/general # wmake/makefiles/general
@ -67,6 +66,14 @@ EXE_LIBS =
LIB_LIBS = LIB_LIBS =
# These variables are used for some builds - provide fallback values
ifeq (,$(FOAM_SOLVERS))
FOAM_SOLVERS = $(WM_PROJECT_DIR)/applications/solvers
endif
ifeq (,$(FOAM_UTILITIES))
FOAM_UTILITIES = $(WM_PROJECT_DIR)/applications/utilities
endif
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Declare default name of libraries and executables # Declare default name of libraries and executables
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -16,7 +16,16 @@
# Description # Description
# Helper functions for CMake # Helper functions for CMake
# #
# Environment
# Consider CMAKE_INSTALL_PREFIX as a reserved name, although it is not
# set/unset here.
#
# Files
# Uses etc/config.sh/cmake (if it exists) for the
# CMAKE_ARCH_PATH that may specify a possible cmake/bin directory.
#
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
. ${WM_PROJECT_DIR:?}/wmake/scripts/have_cmake
. ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions # Require wmake functions . ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions # Require wmake functions
# Export compiler information for cmake # Export compiler information for cmake
@ -29,64 +38,92 @@ export CXXFLAGS="$(wmake -show-cxxflags)"
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# #
# Check sentinel file(s) to handle paraview / vtk version changes # Save build/configure parameter information (dependency) into sentinel file
# #
sameDependency() # 1 - sentinelFile
{ # 2... build/configure parameters
local depend="$1"
local sourceDir="$2"
local objectsDir sentinel prev
# Where generated files are stored
objectsDir=$(findObjectDir "$sourceDir") || exit 1 # Fatal
sentinel="$objectsDir/ThirdParty"
echo "$sentinel"
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
}
#
# Save dependency information into sentinel file
# #
storeDependency() storeDependency()
{ {
local depend="$1" local sentinel="$1"
local sentinel="$2" local depend
shift
if [ -n "$sentinel" ] if [ -n "$sentinel" ]
then then
mkdir -p "$(dirname "$sentinel")" mkdir -p "$(dirname "$sentinel")"
echo "$depend" >| "$sentinel"
echo '# Build/configure parameters' >| "$sentinel"
for depend
do
echo "-- $depend"
done >> "$sentinel"
fi fi
return 0 return 0
} }
# CMake with output suppressed according to WM_QUIET #
_cmake() # Check sentinel file(s) to handle changed build/configure parameters
# such as paraview / vtk version changes
#
# 1 - sourceDir
# 2... build/configure parameters
#
sameDependency()
{ {
echo "cmake..." local sourceDir="$1"
shift
local depend objectsDir
local compare=0
# Where generated files are stored
objectsDir=$(findObjectDir "$sourceDir") || exit 1 # Fatal
local sentinel="$objectsDir/ThirdParty"
if [ -f "$sentinel" ]
then
# Create an .update version
storeDependency "${sentinel}.update" $@
cmp "${sentinel}" "${sentinel}.update" >/dev/null 2>&1
compare=$?
if [ "$compare" -ne 0 ]
then
echo "build/configure parameters changed between builds" 1>&2
fi
else
# No sentinel file: First time, or failed compilation?
if [ -f "$objectsDir/CMakeCache.txt" ]
then
echo "previous build was incomplete" 1>&2
compare=1
fi
fi
echo "$sentinel"
return "$compare"
}
# Resolve the location of cmake (if needed) and call with output
# suppressed according to WM_QUIET
call_cmake()
{
if have_cmake
then
if [ -n "$WM_QUIET" ] if [ -n "$WM_QUIET" ]
then then
cmake -DCMAKE_RULE_MESSAGES=OFF $@ >/dev/null echo "cmake..."
"$CMAKE_EXE" -DCMAKE_RULE_MESSAGES=OFF $@ >/dev/null
else else
cmake $@ echo "cmake $@"
"$CMAKE_EXE" $@
fi
else
return 1
fi fi
} }
@ -109,12 +146,13 @@ cmakeVersioned()
objectsDir=$(findObjectDir "$sourceDir") || exit 1 # Fatal objectsDir=$(findObjectDir "$sourceDir") || exit 1 # Fatal
# Version changed # Version changed
sentinel=$(sameDependency "$depend" "$sourceDir") || \ sentinel=$(sameDependency "$sourceDir" "$depend" $@) || \
rm -rf "$objectsDir" 2>/dev/null rm -rf "$objectsDir" 2>/dev/null
mkdir -p "$objectsDir" \ mkdir -p "$objectsDir" \
&& (cd "$objectsDir" && _cmake "$@" "$sourceDir" && make) \ && ( cd "$objectsDir" && call_cmake "$@" "$sourceDir" && \
&& storeDependency "$depend" "$sentinel" make "-j${WM_NCOMPPROCS:-1}" ) \
&& storeDependency "$sentinel" "$depend" $@
} }
@ -135,12 +173,13 @@ cmakeVersionedInstall()
objectsDir=$(findObjectDir "$sourceDir") || exit 1 # Fatal objectsDir=$(findObjectDir "$sourceDir") || exit 1 # Fatal
# Version changed # Version changed
sentinel=$(sameDependency "$depend" "$sourceDir") || \ sentinel=$(sameDependency "$sourceDir" "$depend" $@) || \
rm -rf "$objectsDir" 2>/dev/null rm -rf "$objectsDir" 2>/dev/null
mkdir -p "$objectsDir" \ mkdir -p "$objectsDir" \
&& (cd "$objectsDir" && _cmake "$@" "$sourceDir" && make install) \ && ( cd "$objectsDir" && call_cmake "$@" "$sourceDir" && \
&& storeDependency "$depend" "$sentinel" make "-j${WM_NCOMPPROCS:-1}" install ) \
&& storeDependency "$sentinel" "$depend" $@
} }
@ -162,12 +201,12 @@ wmakeVersioned()
objectsDir=$(findObjectDir "$sourceDir") || exit 1 # Fatal objectsDir=$(findObjectDir "$sourceDir") || exit 1 # Fatal
# Version changed # Version changed
sentinel=$(sameDependency "$depend" "$sourceDir") || \ sentinel=$(sameDependency "$sourceDir" "$depend" $@) || \
rm -rf "$objectsDir" 2>/dev/null rm -rf "$objectsDir" 2>/dev/null
mkdir -p "$objectsDir" \ mkdir -p "$objectsDir" \
&& wmake "$@" \ && wmake "$@" \
&& storeDependency "$depend" "$sentinel" && storeDependency "$sentinel" "$depend" $@
} }

122
wmake/scripts/have_cmake Normal file
View File

@ -0,0 +1,122 @@
#----------------------------------*-sh-*--------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# have_cmake
#
# Description
# Locate CMAKE executable
#
# Files
# Uses etc/config.sh/cmake (if it exists) for the
# CMAKE_ARCH_PATH that may specify a possible cmake/bin directory.
#
# Functions provided
# have_cmake, no_cmake, echo_cmake
#
# Variables set on success
# HAVE_CMAKE
# CMAKE_EXE
#
# When properly resolved, CMAKE_EXE will be an absolute path to the
# cmake executable. On failure it will point to 'false'
#
#------------------------------------------------------------------------------
# Reset variables
no_cmake()
{
unset HAVE_CMAKE CMAKE_EXE
}
# Report
echo_cmake()
{
echo cmake="${CMAKE_EXE:-false}"
echo version="$("${CMAKE_EXE:-false}" --version | sed -ne '1s/^.*version *//p')"
}
#
# Try to locate cmake according to values specified in <etc/config.sh/cmake>
# or just use what is found on the path.
#
# On success: return the resolved value as output.
# On failure: set executable as "false" and return with 1
#
have_cmake()
{
# Treat previous queries as "sticky"
if [ -n "$CMAKE_EXE" ]
then
test "$CMAKE_EXE" != "false"
return $?
fi
local config="config.sh/cmake"
unset CMAKE_ARCH_PATH
local settings candidate foundExe
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config" 2>/dev/null)"
then
. "$settings"
if [ -d "$CMAKE_ARCH_PATH" ]
then
candidate="$CMAKE_ARCH_PATH"/bin/cmake
if [ -f "$candidate" ] && [ -x "$candidate" ]
then
foundExe="$candidate"
fi
fi
fi
if [ -z "$foundExe" ]
then
# Default: resolve from PATH
if candidate="$(command -v cmake 2>/dev/null)"
then
foundExe="$candidate"
fi
fi
if [ -n "$foundExe" ]
then
# OK
export HAVE_CMAKE=true
export CMAKE_EXE="$foundExe"
else
# Failure
export CMAKE_EXE="false" # Avoid repeated calls?
return 2
fi
}
# Reset variables
no_cmake
# Test/query
case "$1" in
-test)
have_cmake
echo_cmake
;;
-query)
## query_cmake
;;
esac
#------------------------------------------------------------------------------

View File

@ -19,7 +19,7 @@
# #
# Requires # Requires
# ParaView_DIR (unless system) # ParaView_DIR (unless system)
# PV_PLUGIN_PATH # PV_PLUGIN_PATH (or rely on automatic mechanism)
# #
# Provides Functions # Provides Functions
# get_pvplugin_api, have_pvplugin_support, no_paraview, echo_paraview # get_pvplugin_api, have_pvplugin_support, no_paraview, echo_paraview
@ -85,22 +85,59 @@ cmakePvInstall()
cmakeVersionedInstall "ParaView_DIR=$ParaView_DIR" "$@" cmakeVersionedInstall "ParaView_DIR=$ParaView_DIR" "$@"
} }
#
# Build library - use sentinel file(s) to handle paraview version changes # Build library - use sentinel file(s) to handle paraview version changes
# Some difficulty handling different installation options as well
# as wmake options, so only handle build/configure information for now
# #
# 1 - libName
# 2... build/configure information
#
# Similar to wmakeVersioned
wmakeLibPv() wmakeLibPv()
{ {
local depend="ParaView_DIR=$ParaView_DIR" local depend="ParaView_DIR=$ParaView_DIR"
local sentinel libName local libName="$1"
shift 1
local sentinel
for libName sentinel=$(sameDependency "$libName" "$depend" $@) || \
do wclean "$libName"
sentinel=$(sameDependency "$depend" "$libName") || \
wclean $libName
wmake $targetType $libName \ wmake $targetType "$libName" \
&& storeDependency "$depend" "$sentinel" && storeDependency "$sentinel" "$depend" $@
done }
# Get ParaView API from given path.
# Eg, "/path/paraview-dir/paraview-5.6" -> "5.6"
#
# Or the output from `paraview --version`
# Eg, "paraview version 5.6.3" -> "5.6"
#
# 1 - the input path ending with paraview-x.y, or paraview --version information
#
# On success, return 0 and echo value
#
get_pvapi()
{
local pv_api
# Extract paraview major+minor version from the directory name
# From /path/paraview-5.6 -> 5.6
pv_api=$(echo "${1:-none}" | \
sed -ne 's@^.*/@@;s@^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$@\1@p')
if [ -z "$pv_api" ]
then
# Extract paraview major+minor version from "paraview --version" information
pv_api=$(echo "${1:-none}" | \
sed -ne 's@^.*version *\([0-9][0-9]*\.[0-9][0-9]*\).*$@\1@p')
fi
[ -n "$pv_api" ] || return 1
# OK
echo "$pv_api"
} }
@ -122,10 +159,9 @@ get_pvplugin_api()
targetDir="${PV_PLUGIN_PATH##;}" targetDir="${PV_PLUGIN_PATH##;}"
targetDir="${targetDir%%;*}" targetDir="${targetDir%%;*}"
# Extract paraview major+minor version from the directory name # Extract paraview major+minor version from directory name
# From /path/paraview-5.6 -> 5.6 # From /path/paraview-5.6 -> 5.6
pv_api=$(echo "$targetDir" | \ pv_api=$(get_pvapi "$targetDir")
sed -ne 's@^.*/@@;s/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/p')
[ -n "$pv_api" ] || return 1 [ -n "$pv_api" ] || return 1
@ -147,7 +183,7 @@ get_pvplugin_api()
have_pvplugin_support() have_pvplugin_support()
{ {
local warn="==> skip paraview-plugin" local warn="==> skip paraview-plugin"
local settings pv_api installDir binDir includeDir targetDir local settings pv_api pv_executable installDir binDir includeDir targetDir
# Trivial check # Trivial check
command -v cmake >/dev/null || { command -v cmake >/dev/null || {
@ -162,12 +198,13 @@ have_pvplugin_support()
fi fi
unset FOAM_PV_PLUGIN_LIBBIN PARAVIEW_API unset FOAM_PV_PLUGIN_LIBBIN PARAVIEW_API
if [ -z "$targetDir" ] || [ -z "$pv_api" ] # Probably not needed...
then # if [ -z "$targetDir" ] || [ -z "$pv_api" ]
echo "$warn (could not determine target or major.minor version)" # then
echo " PV_PLUGIN_PATH=${PV_PLUGIN_PATH:-???}" # echo "$warn (could not determine target or major.minor version)"
return 1 # echo " PV_PLUGIN_PATH=${PV_PLUGIN_PATH:-???}"
fi # return 1
# fi
# Include/library names # Include/library names
local header="pqServerManagerModel.h" local header="pqServerManagerModel.h"
@ -176,6 +213,21 @@ have_pvplugin_support()
then then
# ParaView_DIR defined. Look for include/ # ParaView_DIR defined. Look for include/
# Unless already known, get API value from include directory name
if [ -z "$pv_api" ]
then
for settings in $(find "$ParaView_DIR"/include -maxdepth 1 -name 'paraview-*' -type d)
do
pv_api=$(get_pvapi "$settings") && break
done
if [ -z "$pv_api" ]
then
echo "$warn (could not determine paraview major.minor version)"
return 1
fi
fi
header=$(findFirstFile \ header=$(findFirstFile \
"$ParaView_DIR/include/paraview-$pv_api/$header" \ "$ParaView_DIR/include/paraview-$pv_api/$header" \
"$ParaView_DIR/include/paraview/$header" "$ParaView_DIR/include/paraview/$header"
@ -184,10 +236,13 @@ have_pvplugin_support()
else else
# No ParaView_DIR defined # No ParaView_DIR defined
# - use location of 'paraview' to guess an equivalent ParaView_DIR # - use location of 'paraview' to guess an equivalent ParaView_DIR
# - assume we can use paraview-config # - assume paraview-config works, but might be removed too!
binDir="$(command -v paraview 2>/dev/null)" pv_executable="$(command -v paraview 2>/dev/null)" || {
binDir="${binDir%/*}" # Eg, /usr/bin/paraview -> /usr/bin echo "$warn (no paraview found?)"
return 2
}
binDir="${pv_executable%/*}" # Eg, /usr/bin/paraview -> /usr/bin
installDir="${binDir%/*}" # Eg, /usr/bin -> /usr installDir="${binDir%/*}" # Eg, /usr/bin -> /usr
case "$installDir" in case "$installDir" in
@ -196,6 +251,17 @@ have_pvplugin_support()
;; ;;
esac esac
# Unless already known, get API value from `paraview --version` information
if [ -z "$pv_api" ]
then
pv_api=$(get_pvapi "$("$pv_executable" --version)")
if [ -z "$pv_api" ]
then
echo "$warn (could not determine paraview major.minor version)"
return 1
fi
fi
header=$(findFirstFile \ header=$(findFirstFile \
"$(paraview-config --include 2>/dev/null |sed -ne 's/^ *-I//p')/$header"\ "$(paraview-config --include 2>/dev/null |sed -ne 's/^ *-I//p')/$header"\
"${includeDir:+$includeDir/paraview-$pv_api/$header}" \ "${includeDir:+$includeDir/paraview-$pv_api/$header}" \
@ -218,8 +284,9 @@ have_pvplugin_support()
# ---------------------------------- # ----------------------------------
# OK # OK
# Use FOAM_LIBBIN/paraview-maj.min as default
export HAVE_PVPLUGIN_SUPPORT=true export HAVE_PVPLUGIN_SUPPORT=true
export FOAM_PV_PLUGIN_LIBBIN="$targetDir" export FOAM_PV_PLUGIN_LIBBIN="${targetDir:-$FOAM_LIBBIN/paraview-$pv_api}"
export PARAVIEW_API="$pv_api" export PARAVIEW_API="$pv_api"
export PARAVIEW_INC_DIR="${header%/*}" # Basename export PARAVIEW_INC_DIR="${header%/*}" # Basename

View File

@ -0,0 +1,120 @@
#----------------------------------*-sh-*--------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# File
# wmake/scripts/wmake.cmake-args
#
# Description
# Special-purpose argument parser (eg, for Allwmake scripts)
# that handles -prefix=... and some other simpler tasks
#
# Usage
# # Parse the arguments by sourcing this script
# . ${WM_PROJECT_DIR:?}/wmake/scripts/wmake.cmake-args
#
# Options
# -prefix=...
# Exports CMAKE_INSTALL_PREFIX value.
# Handles u(ser), g(roup), o(ther) short-cuts (see foamEtcFile),
# absolute or relative paths
#
# -j | -jN | -j N
# Compile using all or specified N cores/hyperthreads
#
#------------------------------------------------------------------------------
# NB: nArgs to track the current processing position to avoid wraparound
# when checking for optional parameters (eg, the -j processing)
nArgs="$#"
for arg in "$@"
do
shift; nArgs="$((nArgs - 1))" # Drop argument
case "$arg" in
# Install prefix: user
-prefix=u | -prefix=user)
export CMAKE_INSTALL_PREFIX="${FOAM_USER_LIBBIN%/*}"
echo "Install prefix = user ($CMAKE_INSTALL_PREFIX)" 1>&2
continue # Handled argument
;;
# Install prefix: group
-prefix=g | -prefix=group)
export CMAKE_INSTALL_PREFIX="${FOAM_SITE_LIBBIN%/*}"
echo "Install prefix = group ($CMAKE_INSTALL_PREFIX)" 1>&2
continue # Handled argument
;;
# Install prefix: other/openfoam
-prefix=o | -prefix=other | -prefix=openfoam)
export CMAKE_INSTALL_PREFIX="${FOAM_LIBBIN%/*}"
echo "Install prefix = openfoam ($CMAKE_INSTALL_PREFIX)" 1>&2
continue # Handled argument
;;
# Install prefix: custom
-prefix=*)
export CMAKE_INSTALL_PREFIX="${arg#*=}"
: "${CMAKE_INSTALL_PREFIX:=/usr/local}" # Default as per autoconf
# Require as absolute path
[ "${CMAKE_INSTALL_PREFIX#/}" != "${CMAKE_INSTALL_PREFIX}" ] || \
CMAKE_INSTALL_PREFIX="${PWD}/${CMAKE_INSTALL_PREFIX}"
echo "Install prefix = $CMAKE_INSTALL_PREFIX" 1>&2
continue # Handled argument
;;
# Parallel compilation (all or specified number of cores)
-j)
export WM_NCOMPPROCS=0
if [ "$nArgs" -gt 0 ]
then
case "$1" in
[0-9]*)
if WM_NCOMPPROCS="$(expr 0 + "$1" 2>/dev/null)"
then
shift; nArgs="$((nArgs - 1))" # Drop argument
fi
;;
esac
fi
if [ "${WM_NCOMPPROCS:=0}" -le 0 ]
then
WM_NCOMPPROCS=$(getconf _NPROCESSORS_ONLN 2>/dev/null) || \
WM_NCOMPPROCS=1
fi
echo "Compiling enabled on $WM_NCOMPPROCS cores" 1>&2
continue # Handled argument
;;
# Parallel compilation (specified number of cores)
-j[0-9]*)
export WM_NCOMPPROCS="${arg#-j}"
if [ "${WM_NCOMPPROCS:=0}" -le 0 ]
then
WM_NCOMPPROCS=$(getconf _NPROCESSORS_ONLN 2>/dev/null) || \
WM_NCOMPPROCS=1
fi
echo "Compiling enabled on $WM_NCOMPPROCS cores" 1>&2
continue # Handled argument
;;
esac
set -- "$@" "$arg" # Reinsert unhandled argument
done
#------------------------------------------------------------------------------