mirror of
https://develop.openfoam.com/Development/ThirdParty-common.git
synced 2025-12-08 06:57:50 +00:00
ENH: use OpenFOAM etc/config.sh/cmake (if it exists) for finding cmake
This commit is contained in:
@ -23,6 +23,10 @@
|
|||||||
# Compiler and flags are managed via the 'wmake -show-c, -show-cflags, ..'
|
# Compiler and flags are managed via the 'wmake -show-c, -show-cflags, ..'
|
||||||
# but also with WM_CC, WM_CFLAGS,... env variables
|
# but also with WM_CC, WM_CFLAGS,... env variables
|
||||||
#
|
#
|
||||||
|
# Files
|
||||||
|
# Uses OpenFOAM/etc/config.sh/cmake (if it exists) for the
|
||||||
|
# CMAKE_ARCH_PATH that may specify a possible cmake/bin directory.
|
||||||
|
#
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
# The normal locations for source, build and installation (prefix-dir)
|
# The normal locations for source, build and installation (prefix-dir)
|
||||||
@ -456,6 +460,7 @@ _foamIsSystem()
|
|||||||
unset CMAKE_PATH # clear when first loaded
|
unset CMAKE_PATH # clear when first loaded
|
||||||
findCMake()
|
findCMake()
|
||||||
{
|
{
|
||||||
|
local config="config.sh/cmake"
|
||||||
local candidate foundExe
|
local candidate foundExe
|
||||||
|
|
||||||
if [ -n "$CMAKE_PATH" ]
|
if [ -n "$CMAKE_PATH" ]
|
||||||
@ -464,13 +469,13 @@ findCMake()
|
|||||||
if [ -d "$CMAKE_PATH" ]
|
if [ -d "$CMAKE_PATH" ]
|
||||||
then
|
then
|
||||||
for candidate in \
|
for candidate in \
|
||||||
$CMAKE_PATH/cmake \
|
"$CMAKE_PATH"/cmake \
|
||||||
$CMAKE_PATH/bin/cmake \
|
"$CMAKE_PATH"/bin/cmake \
|
||||||
;
|
;
|
||||||
do
|
do
|
||||||
if [ -f "$candidate" -a -x "$candidate" ]
|
if [ -f "$candidate" ] && [ -x "$candidate" ]
|
||||||
then
|
then
|
||||||
foundExe=$candidate
|
foundExe="$candidate"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -480,14 +485,14 @@ findCMake()
|
|||||||
if [ -z "$foundExe" ]
|
if [ -z "$foundExe" ]
|
||||||
then
|
then
|
||||||
for candidate in \
|
for candidate in \
|
||||||
$CMAKE_PATH \
|
"$CMAKE_PATH" \
|
||||||
$installBASE/$CMAKE_PATH/bin/cmake \
|
"$installBASE/$CMAKE_PATH"/bin/cmake \
|
||||||
$installBASE/cmake-$CMAKE_PATH/bin/cmake \
|
"$installBASE/cmake-$CMAKE_PATH"/bin/cmake \
|
||||||
;
|
;
|
||||||
do
|
do
|
||||||
if [ -f "$candidate" -a -x "$candidate" ]
|
if [ -f "$candidate" ] && [ -x "$candidate" ]
|
||||||
then
|
then
|
||||||
foundExe=$candidate
|
foundExe="$candidate"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -501,26 +506,45 @@ findCMake()
|
|||||||
foundExe="$(cd ${foundExe%/cmake} 2>/dev/null && pwd)/cmake"
|
foundExe="$(cd ${foundExe%/cmake} 2>/dev/null && pwd)/cmake"
|
||||||
fi
|
fi
|
||||||
echo "Using cmake=$foundExe" 1>&2
|
echo "Using cmake=$foundExe" 1>&2
|
||||||
echo $foundExe
|
echo "$foundExe"
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
cat << NOT_FOUND 1>&2
|
cat << NOT_FOUND 1>&2
|
||||||
'cmake' not found under specified CMAKE_PATH
|
'cmake' not found under specified CMAKE_PATH
|
||||||
CMAKE_PATH=$CMAKE_PATH
|
CMAKE_PATH=$CMAKE_PATH
|
||||||
reverting to using command from path
|
reverting to using command from $config or from PATH
|
||||||
NOT_FOUND
|
NOT_FOUND
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
unset cmake_version CMAKE_ARCH_PATH
|
||||||
|
if candidate="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config" 2>/dev/null)"
|
||||||
|
then
|
||||||
|
. "$candidate"
|
||||||
|
|
||||||
|
for candidate in \
|
||||||
|
"$CMAKE_ARCH_PATH"/bin/cmake \
|
||||||
|
"$installBASE/$cmake_version"/bin/cmake \
|
||||||
|
;
|
||||||
|
do
|
||||||
|
if [ -f "$candidate" ] && [ -x "$candidate" ]
|
||||||
|
then
|
||||||
|
echo "Using cmake=$candidate" 1>&2
|
||||||
|
echo "$candidate"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
# Default to use the path, try resolving (so we know what we are using).
|
# Default to use the path, try resolving (so we know what we are using).
|
||||||
for candidate in cmake
|
for candidate in cmake
|
||||||
do
|
do
|
||||||
foundExe=$(command -v $candidate 2>/dev/null) && break
|
foundExe="$(command -v "$candidate" 2>/dev/null)" && break
|
||||||
done
|
done
|
||||||
: ${foundExe:=false}
|
: "${foundExe:=false}"
|
||||||
|
|
||||||
echo "Using cmake=$foundExe" 1>&2
|
echo "Using cmake=$foundExe" 1>&2
|
||||||
echo $foundExe
|
echo "$foundExe"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -541,13 +565,13 @@ findQMake()
|
|||||||
if [ -d "$QMAKE_PATH" ]
|
if [ -d "$QMAKE_PATH" ]
|
||||||
then
|
then
|
||||||
for candidate in \
|
for candidate in \
|
||||||
$QMAKE_PATH/qmake \
|
"$QMAKE_PATH"/qmake \
|
||||||
$QMAKE_PATH/bin/qmake \
|
"$QMAKE_PATH"/bin/qmake \
|
||||||
;
|
;
|
||||||
do
|
do
|
||||||
if [ -f "$candidate" -a -x "$candidate" ]
|
if [ -f "$candidate" ] && [ -x "$candidate" ]
|
||||||
then
|
then
|
||||||
foundExe=$candidate
|
foundExe="$candidate"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -557,14 +581,14 @@ findQMake()
|
|||||||
if [ -z "$foundExe" ]
|
if [ -z "$foundExe" ]
|
||||||
then
|
then
|
||||||
for candidate in \
|
for candidate in \
|
||||||
$QMAKE_PATH \
|
"$QMAKE_PATH" \
|
||||||
$installBASE/$QMAKE_PATH/bin/qmake \
|
"$installBASE/$QMAKE_PATH"/bin/qmake \
|
||||||
$installBASE/qt-$QMAKE_PATH/bin/qmake \
|
"$installBASE/qt-$QMAKE_PATH"/bin/qmake \
|
||||||
;
|
;
|
||||||
do
|
do
|
||||||
if [ -f "$candidate" -a -x "$candidate" ]
|
if [ -f "$candidate" ] && [ -x "$candidate" ]
|
||||||
then
|
then
|
||||||
foundExe=$candidate
|
foundExe="$candidate"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -578,13 +602,13 @@ findQMake()
|
|||||||
foundExe="$(cd ${foundExe%/qmake} 2>/dev/null && pwd)/qmake"
|
foundExe="$(cd ${foundExe%/qmake} 2>/dev/null && pwd)/qmake"
|
||||||
fi
|
fi
|
||||||
echo "Using qmake=$foundExe" 1>&2
|
echo "Using qmake=$foundExe" 1>&2
|
||||||
echo $foundExe
|
echo "$foundExe"
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
cat << NOT_FOUND 1>&2
|
cat << NOT_FOUND 1>&2
|
||||||
'qmake' not found under specified QMAKE_PATH
|
'qmake' not found under specified QMAKE_PATH
|
||||||
QMAKE_PATH=$QMAKE_PATH
|
QMAKE_PATH=$QMAKE_PATH
|
||||||
reverting to using command from path
|
reverting to using command from PATH
|
||||||
NOT_FOUND
|
NOT_FOUND
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -593,9 +617,9 @@ NOT_FOUND
|
|||||||
# Some systems have qmake-qt5 as well as qmake
|
# Some systems have qmake-qt5 as well as qmake
|
||||||
for candidate in qmake-qt5 qmake
|
for candidate in qmake-qt5 qmake
|
||||||
do
|
do
|
||||||
foundExe=$(command -v $candidate 2>/dev/null) && break
|
foundExe="$(command -v "$candidate" 2>/dev/null)" && break
|
||||||
done
|
done
|
||||||
: ${foundExe:=false}
|
: "${foundExe:=false}"
|
||||||
|
|
||||||
echo "Using qmake=$foundExe" 1>&2
|
echo "Using qmake=$foundExe" 1>&2
|
||||||
echo $foundExe
|
echo $foundExe
|
||||||
@ -609,7 +633,7 @@ pkgconfigNewPrefix()
|
|||||||
{
|
{
|
||||||
local dir="${1%%/}"
|
local dir="${1%%/}"
|
||||||
|
|
||||||
if [ -n "$dir" -a -d "$dir" ]
|
if [ -n "$dir" ] && [ -d "$dir" ]
|
||||||
then
|
then
|
||||||
# Require absolute path, but use logical (not physical) location
|
# Require absolute path, but use logical (not physical) location
|
||||||
[ "${dir}" != "${dir#/}" ] || dir=$(cd $dir 2>/dev/null && /bin/pwd -L)
|
[ "${dir}" != "${dir#/}" ] || dir=$(cd $dir 2>/dev/null && /bin/pwd -L)
|
||||||
@ -657,7 +681,7 @@ pkgconfigAdjust()
|
|||||||
{
|
{
|
||||||
local dir="${1%%/}"
|
local dir="${1%%/}"
|
||||||
|
|
||||||
if [ -n "$dir" -a -d "$dir" ]
|
if [ -n "$dir" ] && [ -d "$dir" ]
|
||||||
then
|
then
|
||||||
# Require absolute path, but use logical (not physical) location
|
# Require absolute path, but use logical (not physical) location
|
||||||
[ "${dir}" != "${dir#/}" ] || dir=$(cd $dir 2>/dev/null && /bin/pwd -L)
|
[ "${dir}" != "${dir#/}" ] || dir=$(cd $dir 2>/dev/null && /bin/pwd -L)
|
||||||
|
|||||||
Reference in New Issue
Block a user