From 834c221936d9c460b44e3a65b6fedfb3193f491b Mon Sep 17 00:00:00 2001
From: Samuel Martin <s.martin49@gmail.com>
Date: Sat, 11 Jan 2014 21:33:12 +0100
Subject: [PATCH 2/6] cmake: make test build sensitive to BUILD_TESTING

This patch prevent from wasting time building the tests if it's our
wish.

The test build takes a significant amount of time, and the binaries
are not installed.

Signed-off-by: Samuel Martin <s.martin49@gmail.com>
---
 BLAS/TESTING/CMakeLists.txt | 3 +++
 CMakeLists.txt              | 9 ++++++---
 TESTING/CMakeLists.txt      | 4 ++++
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/BLAS/TESTING/CMakeLists.txt b/BLAS/TESTING/CMakeLists.txt
index ec2c587..e7dc0b7 100644
--- a/BLAS/TESTING/CMakeLists.txt
+++ b/BLAS/TESTING/CMakeLists.txt
@@ -25,6 +25,9 @@
 #       make single FRC=FRC
 #
 #######################################################################
+if(NOT BUILD_TESTING)
+  return()
+endif()
 
 macro(add_blas_test name src)
   get_filename_component(baseNAME ${src} NAME_WE)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 320ccc6..0a362c0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,5 @@
 cmake_minimum_required(VERSION 2.6)
 project(CLAPACK C)
-enable_testing()
 include(CTest)
 
 if(WIN32 AND NOT CYGWIN)
@@ -11,7 +10,9 @@ else()
   set(SECOND_SRC  ${CLAPACK_SOURCE_DIR}/INSTALL/second.c)
   set(DSECOND_SRC  ${CLAPACK_SOURCE_DIR}/INSTALL/dsecnd.c)
 endif()
-enable_testing()
+if(NOT BUILD_TESTING)
+  enable_testing()
+endif()
 option(USE_BLAS_WRAP "pre-pend f2c_ to each function in blas" OFF)
 if(NOT USE_BLAS_WRAP)
 # _zrotg_ seems to be missing in the wrap header
@@ -21,7 +22,9 @@ include_directories(${CLAPACK_SOURCE_DIR}/INCLUDE)
 add_subdirectory(F2CLIBS)
 add_subdirectory(BLAS)
 add_subdirectory(SRC)
-add_subdirectory(TESTING)
+if(NOT BUILD_TESTING)
+  add_subdirectory(TESTING)
+endif()
 set(CLAPACK_VERSION 3.2.1)
 set(CPACK_PACKAGE_VERSION_MAJOR 3)
 set(CPACK_PACKAGE_VERSION_MINOR 2)
diff --git a/TESTING/CMakeLists.txt b/TESTING/CMakeLists.txt
index d59359d..f6b083a 100644
--- a/TESTING/CMakeLists.txt
+++ b/TESTING/CMakeLists.txt
@@ -1,3 +1,7 @@
+if(NOT BUILD_TESTING)
+  return()
+endif()
+
 if(MSVC_VERSION)
 #  string(REPLACE "/STACK:10000000" "/STACK:900000000000000000"
 #    CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
-- 
1.8.5.3

