Files
ThirdParty-common/makeAdios2
Mark Olesen 1fdacf14dd ENH: separate basic CMakeFunctions from ParaViewFunctions
- allows more reuse of functionality
2023-12-12 19:34:33 +01:00

233 lines
6.5 KiB
Bash
Executable File

#!/bin/sh
#------------------------------------------------------------------------------
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2023 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# makeAdios2
#
# Description
# Build script for ADIOS2
#
# ----------------------------------------------
# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
#------------------------------------------------------------------------------
# Dynamic library ending (default is .so)
[ "$(uname -s)" = Darwin ] && EXT_SO=.dylib || EXT_SO=.so
# Short-circuit test for an installation
if [ "$1" = "-test" ]
then
[ "$#" -eq 2 ] || { echo "${0##*/} -test : needs 1 argument"; exit 1; }
dir="${2%/}" # <- *_ARCH_PATH
[ -d "$dir/include" ] || exit 2
package="adios2"
libName="libadios2"
libName2="libadios2_cxx11_mpi"
for lib in \
"$dir/lib/$libName$EXT_SO" \
"$dir/lib$WM_COMPILER_LIB_ARCH/$libName$EXT_SO" \
"$dir/lib/$libName2$EXT_SO" \
"$dir/lib$WM_COMPILER_LIB_ARCH/$libName2$EXT_SO" \
;
do
if [ -r "$lib" ]
then
echo " $package include: $dir/include"
echo " $package library: ${lib%/*}"
exit 0
fi
done
exit 2
fi
#------------------------------------------------------------------------------
if : # Run from third-party directory
then
cd "${0%/*}" || exit
wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
echo " Check your OpenFOAM environment and installation"
exit 1
}
fi
. "${WM_THIRD_PARTY_DIR:?}"/etc/tools/ThirdPartyFunctions
. "${WM_THIRD_PARTY_DIR:?}"/etc/tools/CMakeFunctions
#------------------------------------------------------------------------------
# Obtain version from OpenFOAM etc/config.sh file:
_foamConfig adios2
PACKAGE="${adios2_version:-none}"
# Hint for cmake findMPI
if [ -d "$MPI_ARCH_PATH" ]
then
export MPI_HOME="$MPI_ARCH_PATH"
fi
#------------------------------------------------------------------------------
printVersions() { listPackageVersions adios; exit 0; }
printHelp() {
cat<<USAGE
Usage: ${0##*/} [OPTION] [adios-VERSION]
options:
-force Force compilation, even if include/library already exists
-gcc Force use of gcc/g++
-cmake PATH With cmake from the given path
-mpi-home PATH With hint for MPI_HOME
-DNAME=VALUE add cmake variable
-list List available unpacked source versions
-help Display usage help
* Build ADIOS2
${PACKAGE:-[unspecified]}
USAGE
showDownloadHint adios2
exit 0 # Clean exit
}
#------------------------------------------------------------------------------
exportCompiler minimal # Minimal compiler info for CMake/configure
unset optForce
# Parse options
while [ "$#" -gt 0 ]
do
case "$1" in
'') ;; # Ignore empty
-h | -help*) printHelp;;
-list) printVersions;;
-gcc) useGcc ;;
-force) optForce=true ;;
-cmake)
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
CMAKE_PATH="${2%%/}"
shift
;;
-mpi-home) # mpi with hint
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
export MPI_HOME="${2%%/}"
case "${MPI_HOME:-none}" in (false|none) unset MPI_HOME;; esac
shift
;;
adios/* | sources/ADIOS* | sources/adios* | \
ADIOS2-[0-9]* | ADIOS2-git* | ADIOS-[0-9]* | ADIOS-git* | \
adios2-[0-9]* | adios2-git* | adios-[0-9]* | adios-git*)
PACKAGE="${1%%/}"
;;
-D[A-Z]*=* | [A-Z]*=*) # cmake variables
addCMakeVariable "$1"
;;
*)
die "unknown option/argument: '$1'"
;;
esac
shift
done
if [ -z "$PACKAGE" ]
then
die "The ADIOS package/version not specified"
elif _foamIsNone "$PACKAGE" || _foamIsSystem "$PACKAGE"
then
echo "Using none/system (skip ThirdParty build of ADIOS)"
exit 0
fi
# Known build issues for mingw (various things)
case "$WM_COMPILER" in
(Mingw*)
if [ "$optForce" = true ]
then
echo "Warning: adios2 - known compilation issues with $WM_COMPILER"
else
echo "Skipping adios2 - known compilation issues with $WM_COMPILER"
exit 0
fi
;;
esac
#------------------------------------------------------------------------------
#
# Build ADIOS
# *PACKAGE : name-version of the package
# *SOURCE : location of original sources
# *PREFIX : installation directory
PKG_SOURCE="$(findSourceDir "$PACKAGE")"
PACKAGE="$(basename "$PACKAGE")"
PKG_PREFIX="$installBASE/$PACKAGE"
export GIT_DIR="$PKG_SOURCE/.git"
: "${FOAM_MPI:=dummy}"
echo
echo ========================================
echo "Build adios library $PACKAGE for $FOAM_MPI"
echo
# Needs future adjustment
# - for mpi-specific library locations
if [ -z "$optForce" ] \
&& [ -f "$PKG_PREFIX/include/adios2.h" ] \
&& {
[ -r "$PKG_PREFIX/lib/libadios2$EXT_SO" ] \
|| [ -r "$PKG_PREFIX/lib$WM_COMPILER_LIB_ARCH/libadios2$EXT_SO" ]
}
then
echo " ADIOS2 already built : $PKG_PREFIX"
else
# CMake options often lag the configure ones
echo "Starting build: $PACKAGE (using cmake)"
echo
(
PKG_BUILD="$buildBASE/$PACKAGE"
cd "$PKG_SOURCE" || exit
applyPatch "$PACKAGE" "$PKG_SOURCE"
# Remove any existing build folder and recreate
rm -rf "$PKG_PREFIX"
rm -rf "$PKG_BUILD"
mkdir -p "$PKG_BUILD"
# May not work properly with FOAM_MPI = dummy
if [ "$FOAM_MPI" != dummy ]
then
CC=mpicc
CXX=mpicxx
fi
cmake=$(findCMake)
# Installs into lib64/
cd "$PKG_BUILD" && set -x && \
${cmake:?} \
-DCMAKE_INSTALL_PREFIX="$PKG_PREFIX" \
-DCMAKE_BUILD_TYPE=Release \
-DADIOS2_USE_Fortran=FALSE \
-DADIOS2_BUILD_EXAMPLES=FALSE \
${WM_QUIET:+-DCMAKE_RULE_MESSAGES=OFF} \
"$PKG_SOURCE" \
&& make -j $WM_NCOMPPROCS all \
&& make install \
&& echo "Built: $PACKAGE"
) || {
echo "Error building: $PACKAGE"
exit 1
}
fi
# -----------------------------------------------------------------------------