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.
This commit is contained in:
Dean Moldovan 2016-05-04 00:33:29 +02:00
parent 4042198262
commit 131d446183

View File

@ -20,22 +20,28 @@ function (expect_compile code)
generate_source(source "${code}") generate_source(source "${code}")
check_cxx_source_compiles("${source}" compiles) check_cxx_source_compiles("${source}" compiles)
if (NOT compiles) if (NOT compiles)
message(FATAL_ERROR "Compile error for: ${code}") set(error_msg "Compile error for: ${code}")
endif () endif ()
# Unset the CMake cache variable compiles. Otherwise the compile test will # Unset the CMake cache variable compiles. Otherwise the compile test will
# just use cached information next time it runs. # just use cached information next time it runs.
unset(compiles CACHE) unset(compiles CACHE)
if (error_msg)
message(FATAL_ERROR ${error_msg})
endif ()
endfunction () endfunction ()
function (expect_compile_error code) function (expect_compile_error code)
generate_source(source "${code}") generate_source(source "${code}")
check_cxx_source_compiles("${source}" compiles) check_cxx_source_compiles("${source}" compiles)
if (compiles) if (compiles)
message(FATAL_ERROR "No compile error for: ${code}") set(error_msg "No compile error for: ${code}")
endif () endif ()
# Unset the CMake cache variable compiles. Otherwise the compile test will # Unset the CMake cache variable compiles. Otherwise the compile test will
# just use cached information next time it runs. # just use cached information next time it runs.
unset(compiles CACHE) unset(compiles CACHE)
if (error_msg)
message(FATAL_ERROR ${error_msg})
endif ()
endfunction () endfunction ()
# check if the source file skeleton compiles # check if the source file skeleton compiles