mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: improve cmake/ParaView config handling
- improve handling of changes in ParaView/VTK or cmake parameters (#1693) * adjust internals to support recording of an unlimited number of configuration parameters and use file `cmp` instead of trying to check strings ourselves. ENH: new wmake/scripts/wmake.cmake-args handler - additional handling of -prefix=... as CMAKE_INSTALL_PREFIX export. - in some contexts, can use instead of AllwmakeParseArguments
This commit is contained in:
@ -16,7 +16,16 @@
|
||||
# Description
|
||||
# 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
|
||||
|
||||
# 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()
|
||||
{
|
||||
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
|
||||
# 1 - sentinelFile
|
||||
# 2... build/configure parameters
|
||||
#
|
||||
storeDependency()
|
||||
{
|
||||
local depend="$1"
|
||||
local sentinel="$2"
|
||||
local sentinel="$1"
|
||||
local depend
|
||||
shift
|
||||
|
||||
if [ -n "$sentinel" ]
|
||||
then
|
||||
mkdir -p "$(dirname "$sentinel")"
|
||||
echo "$depend" >| "$sentinel"
|
||||
|
||||
echo '# Build/configure parameters' >| "$sentinel"
|
||||
|
||||
for depend
|
||||
do
|
||||
echo "-- $depend"
|
||||
done >> "$sentinel"
|
||||
fi
|
||||
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..."
|
||||
if [ -n "$WM_QUIET" ]
|
||||
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
|
||||
cmake -DCMAKE_RULE_MESSAGES=OFF $@ >/dev/null
|
||||
# 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
|
||||
cmake $@
|
||||
# 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" ]
|
||||
then
|
||||
echo "cmake..."
|
||||
"$CMAKE_EXE" -DCMAKE_RULE_MESSAGES=OFF $@ >/dev/null
|
||||
else
|
||||
echo "cmake $@"
|
||||
"$CMAKE_EXE" $@
|
||||
fi
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
@ -109,12 +146,13 @@ cmakeVersioned()
|
||||
objectsDir=$(findObjectDir "$sourceDir") || exit 1 # Fatal
|
||||
|
||||
# Version changed
|
||||
sentinel=$(sameDependency "$depend" "$sourceDir") || \
|
||||
sentinel=$(sameDependency "$sourceDir" "$depend" $@) || \
|
||||
rm -rf "$objectsDir" 2>/dev/null
|
||||
|
||||
mkdir -p "$objectsDir" \
|
||||
&& (cd "$objectsDir" && _cmake "$@" "$sourceDir" && make) \
|
||||
&& storeDependency "$depend" "$sentinel"
|
||||
&& ( cd "$objectsDir" && call_cmake "$@" "$sourceDir" && \
|
||||
make "-j${WM_NCOMPPROCS:-1}" ) \
|
||||
&& storeDependency "$sentinel" "$depend" $@
|
||||
}
|
||||
|
||||
|
||||
@ -135,12 +173,13 @@ cmakeVersionedInstall()
|
||||
objectsDir=$(findObjectDir "$sourceDir") || exit 1 # Fatal
|
||||
|
||||
# Version changed
|
||||
sentinel=$(sameDependency "$depend" "$sourceDir") || \
|
||||
sentinel=$(sameDependency "$sourceDir" "$depend" $@) || \
|
||||
rm -rf "$objectsDir" 2>/dev/null
|
||||
|
||||
mkdir -p "$objectsDir" \
|
||||
&& (cd "$objectsDir" && _cmake "$@" "$sourceDir" && make install) \
|
||||
&& storeDependency "$depend" "$sentinel"
|
||||
&& ( cd "$objectsDir" && call_cmake "$@" "$sourceDir" && \
|
||||
make "-j${WM_NCOMPPROCS:-1}" install ) \
|
||||
&& storeDependency "$sentinel" "$depend" $@
|
||||
}
|
||||
|
||||
|
||||
@ -162,12 +201,12 @@ wmakeVersioned()
|
||||
objectsDir=$(findObjectDir "$sourceDir") || exit 1 # Fatal
|
||||
|
||||
# Version changed
|
||||
sentinel=$(sameDependency "$depend" "$sourceDir") || \
|
||||
sentinel=$(sameDependency "$sourceDir" "$depend" $@) || \
|
||||
rm -rf "$objectsDir" 2>/dev/null
|
||||
|
||||
mkdir -p "$objectsDir" \
|
||||
&& wmake "$@" \
|
||||
&& storeDependency "$depend" "$sentinel"
|
||||
&& storeDependency "$sentinel" "$depend" $@
|
||||
}
|
||||
|
||||
|
||||
|
||||
122
wmake/scripts/have_cmake
Normal file
122
wmake/scripts/have_cmake
Normal 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
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@ -18,8 +18,8 @@
|
||||
# Setup of variables for creating ParaView plugins
|
||||
#
|
||||
# Requires
|
||||
# ParaView_DIR (unless system)
|
||||
# PV_PLUGIN_PATH
|
||||
# ParaView_DIR (unless system)
|
||||
# PV_PLUGIN_PATH (or rely on automatic mechanism)
|
||||
#
|
||||
# Provides Functions
|
||||
# get_pvplugin_api, have_pvplugin_support, no_paraview, echo_paraview
|
||||
@ -85,22 +85,59 @@ cmakePvInstall()
|
||||
cmakeVersionedInstall "ParaView_DIR=$ParaView_DIR" "$@"
|
||||
}
|
||||
|
||||
#
|
||||
|
||||
# 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()
|
||||
{
|
||||
local depend="ParaView_DIR=$ParaView_DIR"
|
||||
local sentinel libName
|
||||
local libName="$1"
|
||||
shift 1
|
||||
local sentinel
|
||||
|
||||
for libName
|
||||
do
|
||||
sentinel=$(sameDependency "$depend" "$libName") || \
|
||||
wclean $libName
|
||||
sentinel=$(sameDependency "$libName" "$depend" $@) || \
|
||||
wclean "$libName"
|
||||
|
||||
wmake $targetType $libName \
|
||||
&& storeDependency "$depend" "$sentinel"
|
||||
done
|
||||
wmake $targetType "$libName" \
|
||||
&& storeDependency "$sentinel" "$depend" $@
|
||||
}
|
||||
|
||||
# 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="${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
|
||||
pv_api=$(echo "$targetDir" | \
|
||||
sed -ne 's@^.*/@@;s/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/p')
|
||||
pv_api=$(get_pvapi "$targetDir")
|
||||
|
||||
[ -n "$pv_api" ] || return 1
|
||||
|
||||
@ -147,7 +183,7 @@ get_pvplugin_api()
|
||||
have_pvplugin_support()
|
||||
{
|
||||
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
|
||||
command -v cmake >/dev/null || {
|
||||
@ -162,12 +198,13 @@ have_pvplugin_support()
|
||||
fi
|
||||
unset FOAM_PV_PLUGIN_LIBBIN PARAVIEW_API
|
||||
|
||||
if [ -z "$targetDir" ] || [ -z "$pv_api" ]
|
||||
then
|
||||
echo "$warn (could not determine target or major.minor version)"
|
||||
echo " PV_PLUGIN_PATH=${PV_PLUGIN_PATH:-???}"
|
||||
return 1
|
||||
fi
|
||||
# Probably not needed...
|
||||
# if [ -z "$targetDir" ] || [ -z "$pv_api" ]
|
||||
# then
|
||||
# echo "$warn (could not determine target or major.minor version)"
|
||||
# echo " PV_PLUGIN_PATH=${PV_PLUGIN_PATH:-???}"
|
||||
# return 1
|
||||
# fi
|
||||
|
||||
# Include/library names
|
||||
local header="pqServerManagerModel.h"
|
||||
@ -176,6 +213,21 @@ have_pvplugin_support()
|
||||
then
|
||||
# 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 \
|
||||
"$ParaView_DIR/include/paraview-$pv_api/$header" \
|
||||
"$ParaView_DIR/include/paraview/$header"
|
||||
@ -184,11 +236,14 @@ have_pvplugin_support()
|
||||
else
|
||||
# No ParaView_DIR defined
|
||||
# - 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)"
|
||||
binDir="${binDir%/*}" # Eg, /usr/bin/paraview -> /usr/bin
|
||||
installDir="${binDir%/*}" # Eg, /usr/bin -> /usr
|
||||
pv_executable="$(command -v paraview 2>/dev/null)" || {
|
||||
echo "$warn (no paraview found?)"
|
||||
return 2
|
||||
}
|
||||
binDir="${pv_executable%/*}" # Eg, /usr/bin/paraview -> /usr/bin
|
||||
installDir="${binDir%/*}" # Eg, /usr/bin -> /usr
|
||||
|
||||
case "$installDir" in
|
||||
(/*) # An absolute path
|
||||
@ -196,6 +251,17 @@ have_pvplugin_support()
|
||||
;;
|
||||
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 \
|
||||
"$(paraview-config --include 2>/dev/null |sed -ne 's/^ *-I//p')/$header"\
|
||||
"${includeDir:+$includeDir/paraview-$pv_api/$header}" \
|
||||
@ -218,8 +284,9 @@ have_pvplugin_support()
|
||||
# ----------------------------------
|
||||
|
||||
# OK
|
||||
# Use FOAM_LIBBIN/paraview-maj.min as default
|
||||
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_INC_DIR="${header%/*}" # Basename
|
||||
|
||||
|
||||
120
wmake/scripts/wmake.cmake-args
Normal file
120
wmake/scripts/wmake.cmake-args
Normal 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
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
Reference in New Issue
Block a user