From 47fd10c9944d29f6cd8bd24b78b594165762a8d9 Mon Sep 17 00:00:00 2001
From: Ger van Diepen <diepen@astron.nl>
Date: Fri, 6 Nov 2009 15:14:20 +0000
Subject: [PATCH] bug 1389: Set TESTING OFF unless -test or -check is given

---
 CMake/makeCMakeCache      | 30 ++++++++++++++++--------------
 autoconf_share/dorubbuild | 11 ++++++-----
 2 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/CMake/makeCMakeCache b/CMake/makeCMakeCache
index ddda38c67d6..5d4d9388415 100755
--- a/CMake/makeCMakeCache
+++ b/CMake/makeCMakeCache
@@ -28,14 +28,14 @@
 # Run as:   makeCMakeCache sourceroot lofarconf_file outfile
 # E.g.      makeCMakeCache ~/LOFAR ~/LOFAR/lofarconf.in.private CMakeCache
 
-if test $# != 3; then
-  echo "Run as:   makeCMakeCache sourceroot lofarconf_file outfile"
+if test $# != 4; then
+  echo "Run as:   makeCMakeCache sourceroot lofarconf_file buildtest outfile"
   exit 1
 fi
 
 # Create output file.
-rm -f $3
-touch $3
+rm -f $4
+touch $4
 
 # Find the packages to be built.
 pkgs=
@@ -64,20 +64,22 @@ do
           break
         fi
       done
-      echo "//Build package $pkg?" >> $3
-      echo "BUILD_$pkg:BOOL=$opt" >> $3
-      echo "" >> $3
+      echo "//Build package $pkg?" >> $4
+      echo "BUILD_$pkg:BOOL=$opt" >> $4
+      echo "" >> $4
     fi
   fi
 done
 
-# By default do not build test programs.  
-#echo "//Build the testing tree." >> $3
-#echo "BUILD_TESTING:BOOL=OFF" >> $3
-#echo "" >> $3
+# Optionally build test programs.
+btest=ON
+test $3 = 1  ||  btest=OFF
+echo "//Build the testing tree?" >> $4
+echo "BUILD_TESTING:BOOL=$btest" >> $4
+echo "" >> $4
 # LOFAR needs to be built.
-echo "//Build packageLOFAR?." >> $3
-echo "BUILD_LOFAR:BOOL=ON" >> $3
-echo "" >> $3
+echo "//Build packageLOFAR?." >> $4
+echo "BUILD_LOFAR:BOOL=ON" >> $4
+echo "" >> $4
 
 exit 0
diff --git a/autoconf_share/dorubbuild b/autoconf_share/dorubbuild
index 57cca30babf..c0fc4049384 100755
--- a/autoconf_share/dorubbuild
+++ b/autoconf_share/dorubbuild
@@ -127,6 +127,7 @@ confcmd=
 premake=
 mainmake=date
 postmake=
+cmaketest=0
 # If -k, continue in case of failure, so use ; to separate commands.
 ksep="&&"
 [ $kopt = 1 ] && ksep=";"
@@ -136,13 +137,13 @@ fi
 if [ $buildmake = 1 ]; then
   mainmake="date $ksep make $kstr $jobsopt "
   if [ $bldtest = 1 ]; then
-    if [ $cmake = 1 ]; then
-      postmake="$ksep make test"
-    else
+    cmaketest=1
+    if [ $cmake = 0 ]; then
       postmake="$ksep (if [ -d test ]; then cd test $ksep make test; fi;)"
     fi
   fi
   if [ $check = 1 ]; then
+    cmaketest=1
     if [ "$checktool" = "" ]; then
       postmake="$postmake $ksep make $kstr check"
     else
@@ -180,8 +181,8 @@ if [ $cmake = 1 ]; then
   mkdir -p build/$variant >> $logfile 2>&1  ||  exit 1
   cd build/$variant >> $logfile 2>&1  ||  exit 1
   echo ":::::: BUILDING VARIANT $variant " >> $srcdir/$logfile
-  echo "$srcdir/CMake/makeCMakeCache $srcdir $srcdir/lofarconf.in.private CMakeCache.txt && cmake -DCMAKE_MODULE_PATH:PATH=$srcdir/CMake $srcdir && $premake $mainmake $postmake" >> $srcdir/$logfile
-  eval "($srcdir/CMake/makeCMakeCache $srcdir $srcdir/lofarconf.in.private CMakeCache.txt && cmake -DCMAKE_MODULE_PATH:PATH=$srcdir/CMake $srcdir && $premake $mainmake $postmake)" >> $srcdir/$logfile 2>&1
+  echo "$srcdir/CMake/makeCMakeCache $srcdir $srcdir/lofarconf.in.private $cmaketest CMakeCache.txt && cmake -DCMAKE_MODULE_PATH:PATH=$srcdir/CMake $srcdir && $premake $mainmake $postmake" >> $srcdir/$logfile
+  eval "($srcdir/CMake/makeCMakeCache $srcdir $srcdir/lofarconf.in.private $cmaketest CMakeCache.txt && cmake -DCMAKE_MODULE_PATH:PATH=$srcdir/CMake $srcdir && $premake $mainmake $postmake)" >> $srcdir/$logfile 2>&1
   status=$?
   echo ":::::: FINISHED BUILDING VARIANT $variant" >> $srcdir/$logfile
 else
-- 
GitLab