ENH: support alternative build-root location (#2286)

- specify any of these

    ./Allwmake -build-root=...
    wmake -build-root=...
    FOAM_BUILDROOT=... wmake

  these specify an alternative root where build artifacts are to land.
  Currently only used as an alternative for the 'build/' hierarchy
  since the 'platforms/' target normally includes inputs as well.

  Possible use:
  ```
  (
      export WM_MPLIB="%{foam_mplib}"
      export FOAM_MPI="%{foam_mpi}"
      export MPI_ARCH_PATH="%{mpi_prefix}"

      export FOAM_BUILDROOT=/tmp/mpibuild
      export FOAM_MPI_LIBBIN="$FOAM_BUILDROOT/platforms/$WM_OPTIONS/lib/$FOAM_MPI"

      src/Pstream/Allwmake-mpi
   )
   ```
This commit is contained in:
Mark Olesen
2021-12-02 15:59:42 +01:00
parent 27e57c29f7
commit 8624d65c5a
3 changed files with 32 additions and 6 deletions

View File

@ -214,7 +214,7 @@ cdSource()
# - the objectsDir
#
# Global variables used:
# - WM_PROJECT_DIR, WM_OPTIONS
# - FOAM_BUILDROOT, WM_PROJECT_DIR, WM_OPTIONS
findObjectDir()
{
local project="$(expandPath "$WM_PROJECT_DIR")"
@ -225,8 +225,13 @@ findObjectDir()
relativeDir="${absdir#${project}/}"
if [ "$relativeDir" != "$absdir" ]
then
[ -w "$WM_PROJECT_DIR" ] && \
if [ -n "$FOAM_BUILDROOT" ] && [ -w "$FOAM_BUILDROOT" ]
then
objectsDir="${FOAM_BUILDROOT}/build/${WM_OPTIONS}/${relativeDir}"
elif [ -w "$WM_PROJECT_DIR" ]
then
objectsDir="${WM_PROJECT_DIR}/build/${WM_OPTIONS}/${relativeDir}"
fi
fi
# Default (local) build directory