From be17d1454467ae43985f4b2ee5dec30cb22314a2 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Tue, 7 Jan 2014 09:50:36 -0800 Subject: [PATCH] Simplify compile tests. --- CMakeLists.txt | 6 ------ test/CMakeLists.txt | 7 +++++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 908c9390..f225d926 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,12 +28,6 @@ add_subdirectory(doc) enable_testing() -# Remove the CMake cache in the test directory so that CMake -# performed full configuration. Otherwise compile-test will -# just used cached information. -add_test(prepare-test ${CMAKE_COMMAND} - -E remove ${CMAKE_CURRENT_BINARY_DIR}/test/CMakeCache.txt) - add_test(compile-test ${CMAKE_CTEST_COMMAND} --build-and-test "${CMAKE_CURRENT_SOURCE_DIR}/test" diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index be713bca..8d9ef092 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -10,10 +10,13 @@ function (expect_compile_error code) ${code} } " compiles) - if (compiles) + set (does_compile ${compiles}) + # Unset the CMake cache variable compiles. Otherwise the compile test will + # just used cached information next time it runs. + unset(compiles CACHE) + if (does_compile) error("No compile error for: ${code}") endif () - unset(compiles CACHE) endfunction () # Writing a wide character to a character stream Writer is forbidden.