From e3d971dd1d82b01336994ee4b81945ba781d0ee6 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Thu, 12 Dec 2019 14:02:39 +0100
Subject: [PATCH] CONFIG: prefer use of ParaView_MESA_DIR in
 runTimePostProcessing

- when using VTK from ParaView sources it can better to tag them as
  such, but simultaneously not mask the ParaView with hardware
  rendering.

  The additional ParaView_MESA_DIR variable allows this.
  The balance of library and path setup is unaffected by this.

STYLE: cleanup of Allwclean, Allwmake

CONFIG: remove local version of cmakeVersionedInstall
---
 src/catalyst/Allwmake               | 31 -----------------------------
 src/paraview-plugins/Allwclean      |  2 +-
 src/paraview-plugins/Allwmake       |  2 +-
 src/runTimePostProcessing/Allwclean |  7 ++++---
 src/runTimePostProcessing/Allwmake  | 13 ++++++++----
 5 files changed, 15 insertions(+), 40 deletions(-)

diff --git a/src/catalyst/Allwmake b/src/catalyst/Allwmake
index 896e5fd..ae7502b 100755
--- a/src/catalyst/Allwmake
+++ b/src/catalyst/Allwmake
@@ -3,37 +3,6 @@ cd "${0%/*}" || exit                                # Run from this directory
 . ${WM_PROJECT_DIR:?}/wmake/scripts/cmakeFunctions  # The cmake functions
 #------------------------------------------------------------------------------
 
-# CMake into objectsDir with external dependency
-#
-# 1 - depend
-# 2 - sourceDir
-# 3... optional cmake defines
-#
-# Available directly in OpenFOAM-1812 but left here for a while
-# to ensure we can build with slightly older versions too (2018-11-29)
-#
-unset -f cmakeVersionedInstall 2>/dev/null
-cmakeVersionedInstall()
-{
-    local depend="$1"
-    local sourceDir="$2"
-    shift 2
-    local objectsDir sentinel
-
-    # Where generated files are stored
-    objectsDir=$(findObjectDir "$sourceDir") || exit 1 # Fatal
-
-    # Version changed
-    sentinel=$(sameDependency "$depend" "$sourceDir") || \
-        rm -rf "$objectsDir" > /dev/null 2>&1
-
-    mkdir -p "$objectsDir" \
-    && (cd "$objectsDir" && _cmake "$@" "$sourceDir" && make install) \
-    && echo "$depend" >| "${sentinel:-/dev/null}"
-}
-
-#------------------------------------------------------------------------------
-
 # Installation prefix: user/group/other or custom
 case "$1" in
     -prefix=u) prefix="${FOAM_USER_LIBBIN%/*}" ;; # user
diff --git a/src/paraview-plugins/Allwclean b/src/paraview-plugins/Allwclean
index 405031c..1644b25 100755
--- a/src/paraview-plugins/Allwclean
+++ b/src/paraview-plugins/Allwclean
@@ -1,5 +1,5 @@
 #!/bin/sh
-cd ${0%/*} || exit 1                                # Run from this directory
+cd "${0%/*}" || exit                                # Run from this directory
 . ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions  # Require wmake functions
 . ${WM_PROJECT_DIR:?}/wmake/scripts/paraviewFunctions # For API info
 # -----------------------------------------------------------------------------
diff --git a/src/paraview-plugins/Allwmake b/src/paraview-plugins/Allwmake
index c81120f..6dbaa02 100755
--- a/src/paraview-plugins/Allwmake
+++ b/src/paraview-plugins/Allwmake
@@ -1,5 +1,5 @@
 #!/bin/sh
-cd ${0%/*} || exit 1                                # Run from this directory
+cd "${0%/*}" || exit                                # Run from this directory
 export WM_CONTINUE_ON_ERROR=true                    # Optional unit
 . ${WM_PROJECT_DIR:?}/wmake/scripts/AllwmakeParseArguments
 . ${WM_PROJECT_DIR:?}/wmake/scripts/paraviewFunctions # CMake, PV functions
diff --git a/src/runTimePostProcessing/Allwclean b/src/runTimePostProcessing/Allwclean
index 140edc4..af1168f 100755
--- a/src/runTimePostProcessing/Allwclean
+++ b/src/runTimePostProcessing/Allwclean
@@ -1,11 +1,12 @@
 #!/bin/sh
-cd ${0%/*} || exit 1                            # Run from this directory
-. $WM_PROJECT_DIR/wmake/scripts/wmakeFunctions  # Source wmake functions
+cd "${0%/*}" || exit                                # Run from this directory
+. ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions  # Require wmake functions
+#------------------------------------------------------------------------------
 
 # This cleanup handles both cmake runTimePostProcessing and the dummy version
 
 # Cleanup library files with .so version endings
-rm -f $FOAM_LIBBIN/librunTimePostProcessing* 2>/dev/null
+rm -f $FOAM_LIBBIN/librunTimePostProcessing*
 
 # Cleanup generated files - remove entire top-level
 removeObjectDir "$PWD"
diff --git a/src/runTimePostProcessing/Allwmake b/src/runTimePostProcessing/Allwmake
index 94766cb..b4451ae 100755
--- a/src/runTimePostProcessing/Allwmake
+++ b/src/runTimePostProcessing/Allwmake
@@ -1,7 +1,6 @@
 #!/bin/sh
-cd ${0%/*} || exit 1                            # Run from this directory
-. $WM_PROJECT_DIR/wmake/scripts/cmakeFunctions  # The CMake functions
-
+cd "${0%/*}" || exit                                # Run from this directory
+. ${WM_PROJECT_DIR:?}/wmake/scripts/cmakeFunctions  # Require cmake functions
 # -----------------------------------------------------------------------------
 
 echo "======================================================================"
@@ -9,6 +8,12 @@ echo "${PWD##*/} : $PWD"
 
 unset depend runTimePostProDebug
 
+# If available, prefer use of ParaView MESA
+if [ -d "$ParaView_MESA_DIR" ]
+then
+    export ParaView_DIR="$ParaView_MESA_DIR"
+fi
+
 if [ -d "$VTK_DIR" ]
 then
     depend="VTK_DIR=$VTK_DIR"
@@ -28,7 +33,7 @@ then
     depend=ignore
 elif [ -n "$depend" ]
 then
-    if command -v cmake > /dev/null 2>&1
+    if command -v cmake >/dev/null
     then
         cmakeVersioned "$depend" $PWD || {
             echo
-- 
GitLab