From 131d446183d5f4f6ec7ebb7648cbcc163b20781f Mon Sep 17 00:00:00 2001 From: Dean Moldovan Date: Wed, 4 May 2016 00:33:29 +0200 Subject: [PATCH] Fix compile tests not clearing the cache after an error The cache bug meant that a failed test would appear forever broken, even if the proper fix was applied. --- test/compile-test/CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/compile-test/CMakeLists.txt b/test/compile-test/CMakeLists.txt index 35a2d296..68cfe0c8 100644 --- a/test/compile-test/CMakeLists.txt +++ b/test/compile-test/CMakeLists.txt @@ -20,22 +20,28 @@ function (expect_compile code) generate_source(source "${code}") check_cxx_source_compiles("${source}" compiles) if (NOT compiles) - message(FATAL_ERROR "Compile error for: ${code}") + set(error_msg "Compile error for: ${code}") endif () # Unset the CMake cache variable compiles. Otherwise the compile test will # just use cached information next time it runs. unset(compiles CACHE) + if (error_msg) + message(FATAL_ERROR ${error_msg}) + endif () endfunction () function (expect_compile_error code) generate_source(source "${code}") check_cxx_source_compiles("${source}" compiles) if (compiles) - message(FATAL_ERROR "No compile error for: ${code}") + set(error_msg "No compile error for: ${code}") endif () # Unset the CMake cache variable compiles. Otherwise the compile test will # just use cached information next time it runs. unset(compiles CACHE) + if (error_msg) + message(FATAL_ERROR ${error_msg}) + endif () endfunction () # check if the source file skeleton compiles