From 475220cfae58c9304f5b1f26fa897539fae11ddd Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Mon, 22 Jan 2018 11:29:06 +0100
Subject: [PATCH] COMP: unset ParaView_DIR from PATH, LD_LIBRARY_PATH when
 building

- potential symbol conflicts and build errors if building from the git
  version since it uses the last major number (eg, 5.4) but may have a
  layout similar to the next release (eg, 5.5) and thus different
  sizes for classes etc.
---
 etc/tools/ThirdPartyFunctions | 26 ++++++++++++++++----------
 makeParaView                  | 10 +++++++++-
 2 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/etc/tools/ThirdPartyFunctions b/etc/tools/ThirdPartyFunctions
index 1fa756c..c023b3c 100644
--- a/etc/tools/ThirdPartyFunctions
+++ b/etc/tools/ThirdPartyFunctions
@@ -118,18 +118,24 @@ requireWMakeToolchain()
 #------------------------------------------------------------------------------
 # Some functions as per OpenFOAM etc/config.sh/functions
 
-unset -f _foamAddLib _foamAddMan _foamAddPath   # Get settings only
-unset -f _foamEtc
+unset -f _foamAddLib _foamAddLibAuto _foamAddMan _foamAddPath # Get settings only
+unset -f _foamClean _foamEtc
+
+if [ -x "$WM_PROJECT_DIR/bin/foamCleanPath" ]
+then
+    # Cleaning environment variables
+    _foamClean()
+    {
+         local var=$1
+         shift
+         eval $($WM_PROJECT_DIR/bin/foamCleanPath -sh-env=$var "$@")
+    }
+else
+    _foamClean() { echo "No foamCleanPath" 1>&2; }
+fi
 
 # Source an etc file
-_foamEtc()
-{
-    local file
-    if [ $# -gt 0 ] && file=$($WM_PROJECT_DIR/bin/foamEtcFile "$@")
-    then
-        . $file
-    fi
-}
+_foamEtc() { eval "$($WM_PROJECT_DIR/bin/foamEtcFile -sh $@)"; }
 
 #------------------------------------------------------------------------------
 
diff --git a/makeParaView b/makeParaView
index c72fad0..fdec7db 100755
--- a/makeParaView
+++ b/makeParaView
@@ -37,7 +37,15 @@ cd ${0%/*} && wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
 unset ParaView_VERSION                                   # Purge current values
 
 # ParaView_VERSION from etc/config.sh file:
-_foamEtc config.sh/paraview
+_foamEtc -config paraview
+
+# Avoid any potential conflicts (especially if building from git)
+if [ -d "$ParaView_DIR" ]
+then
+    _foamClean PATH "$ParaView_DIR"
+    _foamClean LD_LIBRARY_PATH "$ParaView_DIR"
+fi
+unset ParaView_DIR ParaView_INCLUDE_DIR PV_PLUGIN_PATH
 
 ParaView_VERSION="${ParaView_VERSION##*-}"               # Without prefix
 
-- 
GitLab