From aa16fa547acc236477381e6ac873cde051f1943f Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Fri, 4 Nov 2016 12:05:35 +0100
Subject: [PATCH] COMP: Newer CGAL versions break current CGAL wmake rules
 (issue #288)

On 64-bit systems, the system installations of boost, cgal are under
lib64/. The behaviour for a ThirdParty build is mostly lib/ but this
can also be changing.

    Boost 1_62_0 and older build into 'lib/'.
    CGAL-4.9 builds into 'lib64/', older versions into 'lib/'.

Future-proof things by using lib$WM_COMPILER_LIB_ARCH for boost and
cgal build rules, and forcing these as build targets in the ThirdParty
makeCGAL as well.

--
STYLE: check for boost/version.hpp, CGAL/version.h instead their directories
---
 applications/utilities/mesh/generation/foamyMesh/Allwmake     | 4 ++--
 .../utilities/mesh/manipulation/renumberMesh/Allwmake         | 2 +-
 .../utilities/surface/surfaceBooleanFeatures/Allwmake         | 4 ++--
 .../surfaceBooleanFeatures/PolyhedronReader/Make/options      | 3 +--
 etc/config.csh/CGAL                                           | 4 ++--
 etc/config.sh/CGAL                                            | 4 ++--
 src/renumber/Allwmake                                         | 4 ++--
 src/renumber/SloanRenumber/Make/options                       | 2 +-
 wmake/rules/General/CGAL                                      | 4 ++--
 9 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/applications/utilities/mesh/generation/foamyMesh/Allwmake b/applications/utilities/mesh/generation/foamyMesh/Allwmake
index 4090d594e4..85f046473c 100755
--- a/applications/utilities/mesh/generation/foamyMesh/Allwmake
+++ b/applications/utilities/mesh/generation/foamyMesh/Allwmake
@@ -4,8 +4,8 @@ cd ${0%/*} || exit 1    # Run from this directory
 # Parse arguments for library compilation
 . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
 
-if [ -d "$CGAL_ARCH_PATH/include/CGAL" ] || \
-   [ "${CGAL_ARCH_PATH##*-}" = system -a -d /usr/include/CGAL ]
+if [ -f "$CGAL_ARCH_PATH/include/CGAL/version.h" ] || \
+   [ "${CGAL_ARCH_PATH##*-}" = system -a -f /usr/include/CGAL/version.h ]
 then
     set -x
 
diff --git a/applications/utilities/mesh/manipulation/renumberMesh/Allwmake b/applications/utilities/mesh/manipulation/renumberMesh/Allwmake
index 3acf4a1da7..fae482e08b 100755
--- a/applications/utilities/mesh/manipulation/renumberMesh/Allwmake
+++ b/applications/utilities/mesh/manipulation/renumberMesh/Allwmake
@@ -3,7 +3,6 @@ cd ${0%/*} || exit 1    # Run from this directory
 
 # Parse arguments for compilation (at least for error catching)
 . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
-set -x
 
 export COMPILE_FLAGS=''
 export LINK_FLAGS=''
@@ -21,6 +20,7 @@ then
     export LINK_FLAGS="${LINK_FLAGS} -lzoltanRenumber -L${ZOLTAN_ARCH_PATH}/lib -lzoltan"
 fi
 
+set -x
 wmake $targetType
 
 #------------------------------------------------------------------------------
diff --git a/applications/utilities/surface/surfaceBooleanFeatures/Allwmake b/applications/utilities/surface/surfaceBooleanFeatures/Allwmake
index 98d3d2035c..660a2e59b5 100755
--- a/applications/utilities/surface/surfaceBooleanFeatures/Allwmake
+++ b/applications/utilities/surface/surfaceBooleanFeatures/Allwmake
@@ -4,8 +4,8 @@ set -x
 
 unset COMPILE_FLAGS LINK_FLAGS
 
-if [ -d "$CGAL_ARCH_PATH/include/CGAL" ] || \
-   [ "${CGAL_ARCH_PATH##*-}" = system -a -d /usr/include/CGAL ]
+if [ -f "$CGAL_ARCH_PATH/include/CGAL/version.h" ] || \
+   [ "${CGAL_ARCH_PATH##*-}" = system -a -f /usr/include/CGAL/version.h ]
 then
     wmake PolyhedronReader
     export COMPILE_FLAGS='-IPolyhedronReader'
diff --git a/applications/utilities/surface/surfaceBooleanFeatures/PolyhedronReader/Make/options b/applications/utilities/surface/surfaceBooleanFeatures/PolyhedronReader/Make/options
index 6603adda0f..424f89a8ab 100644
--- a/applications/utilities/surface/surfaceBooleanFeatures/PolyhedronReader/Make/options
+++ b/applications/utilities/surface/surfaceBooleanFeatures/PolyhedronReader/Make/options
@@ -1,7 +1,6 @@
 EXE_NDEBUG = -DNDEBUG
 /* EXE_NDEBUG = -g -O0 -DFULLDEBUG */
 
-
 c++CGALWARN = -Wno-old-style-cast
 
 /*-- Define CGAL_INEXACT to use inexact CGAL constructions */
@@ -21,5 +20,5 @@ EXE_INC = \
     -I/usr/include/Qt
 
 LIB_LIBS = \
-    -L${CGAL_ARCH_PATH}/lib \
+    -L$(CGAL_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \
     -ltriSurface
diff --git a/etc/config.csh/CGAL b/etc/config.csh/CGAL
index 2fd06120eb..84bc71bda6 100644
--- a/etc/config.csh/CGAL
+++ b/etc/config.csh/CGAL
@@ -68,12 +68,12 @@ endif
 
 set ending="${BOOST_ARCH_PATH:t}"
 if ( "$ending" != "boost-none" && "$ending" != "boost-system" ) then
-    _foamAddLib $BOOST_ARCH_PATH/lib
+    _foamAddLib $BOOST_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH
 endif
 
 set ending="${CGAL_ARCH_PATH:t}"
 if ( "$ending" != "cgal-none" && "$ending" != "cgal-system" ) then
-    _foamAddLib $CGAL_ARCH_PATH/lib
+    _foamAddLib $CGAL_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH
 endif
 
 unset boost_version cgal_version ending
diff --git a/etc/config.sh/CGAL b/etc/config.sh/CGAL
index e23164d2c9..044327109f 100644
--- a/etc/config.sh/CGAL
+++ b/etc/config.sh/CGAL
@@ -72,13 +72,13 @@ then
     ending="${BOOST_ARCH_PATH##*-}"
     if [ "$ending" != none -a "$ending" != system ]
     then
-        _foamAddLib $BOOST_ARCH_PATH/lib
+        _foamAddLib $BOOST_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH
     fi
 
     ending="${CGAL_ARCH_PATH##*-}"
     if [ "$ending" != none -a "$ending" != system ]
     then
-        _foamAddLib $CGAL_ARCH_PATH/lib
+        _foamAddLib $CGAL_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH
     fi
 
     unset boost_version cgal_version ending
diff --git a/src/renumber/Allwmake b/src/renumber/Allwmake
index 14191c9526..66d9bfd536 100755
--- a/src/renumber/Allwmake
+++ b/src/renumber/Allwmake
@@ -20,8 +20,8 @@ set -x
 
 wmake $targetType renumberMethods
 
-if [ -d "$BOOST_ARCH_PATH/include/boost" ] || \
-   [ "${BOOST_ARCH_PATH##*-}" = system -a -d /usr/include/boost ]
+if [ -f "$BOOST_ARCH_PATH/include/boost/version.hpp" ] || \
+   [ "${BOOST_ARCH_PATH##*-}" = system -a -f /usr/include/boost/version.hpp ]
 then
     wmake $targetType SloanRenumber
 else
diff --git a/src/renumber/SloanRenumber/Make/options b/src/renumber/SloanRenumber/Make/options
index cf6e548615..2c8f956a61 100644
--- a/src/renumber/SloanRenumber/Make/options
+++ b/src/renumber/SloanRenumber/Make/options
@@ -5,7 +5,7 @@ EXE_INC = \
     -I$(LIB_SRC)/renumber/renumberMethods/lnInclude
 
 LIB_LIBS = \
-    -L$(BOOST_ARCH_PATH)/lib -lboost_system \
+    -L$(BOOST_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) -lboost_system \
     -lmeshTools \
     -ldecompositionMethods \
     -lrenumberMethods
diff --git a/wmake/rules/General/CGAL b/wmake/rules/General/CGAL
index fd1965e656..83e8b1df1e 100644
--- a/wmake/rules/General/CGAL
+++ b/wmake/rules/General/CGAL
@@ -8,6 +8,6 @@ CGAL_INC = \
 CGAL_LIBS = \
     -L$(MPFR_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \
     -L$(GMP_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \
-    -L$(BOOST_ARCH_PATH)/lib \
-    -L$(CGAL_ARCH_PATH)/lib \
+    -L$(BOOST_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \
+    -L$(CGAL_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \
     -lCGAL
-- 
GitLab