Skip to content

Commit eb6fac4

Browse files
authored
Merge pull request #284 from jcfr/tweak-handling-build-testing-option
Tweak handling of BUILD_TESTING option
2 parents 7851b18 + 24f47c0 commit eb6fac4

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

CMakeLists.txt

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
2424
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo" "Coverage")
2525
endif()
2626

27+
# Coverage
28+
set(_is_coverage_build 0)
2729
set(_msg "Checking if build type is 'Coverage'")
2830
message(STATUS "${_msg}")
2931
if(NOT CMAKE_CONFIGURATION_TYPES)
@@ -108,16 +110,8 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL "Compaq")
108110
endif()
109111
endif()
110112

111-
# Get Python
112-
message(STATUS "Looking for Python greater than 2.6 - ${PYTHONINTERP_FOUND}")
113-
find_package(PythonInterp 2.7) # lapack_testing.py uses features from python 2.7 and greater
114-
if(PYTHONINTERP_FOUND)
115-
message(STATUS "Using Python version ${PYTHON_VERSION_STRING}")
116-
else()
117-
message(STATUS "No suitable Python version found, so skipping summary tests.")
118-
endif()
119-
# --------------------------------------------------
120113

114+
# --------------------------------------------------
121115
set(LAPACK_INSTALL_EXPORT_NAME lapack-targets)
122116

123117
macro(lapack_install_library lib)
@@ -133,12 +127,22 @@ set(PKG_CONFIG_DIR ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
133127

134128
# --------------------------------------------------
135129
# Testing
136-
option(BUILD_TESTING "Build tests" OFF)
137-
enable_testing()
130+
option(BUILD_TESTING "Build tests" ${_is_coverage_build})
138131
include(CTest)
139-
enable_testing()
140132
message(STATUS "Build tests: ${BUILD_TESTING}")
141133

134+
# lapack_testing.py uses features from python 2.7 and greater
135+
if(BUILD_TESTING)
136+
set(_msg "Looking for Python >= 2.7 needed for summary tests")
137+
message(STATUS "${_msg}")
138+
find_package(PythonInterp 2.7 QUIET)
139+
if(PYTHONINTERP_FOUND)
140+
message(STATUS "${_msg} - found (${PYTHON_VERSION_STRING})")
141+
else()
142+
message(STATUS "${_msg} - not found (skipping summary tests)")
143+
endif()
144+
endif()
145+
142146
# --------------------------------------------------
143147
# Organize output files. On Windows this also keeps .dll files next
144148
# to the .exe files that need them, making tests easy to run.

0 commit comments

Comments
 (0)