From 6abfb84808aebe62e586032feb9b8712a8bb0f6e Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Tue, 7 Jan 2014 08:43:53 -0800 Subject: [PATCH] Simplify compile error tests. --- test/CMakeLists.txt | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 125555ee..358a2b8f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -3,11 +3,17 @@ include(CheckCXXSourceCompiles) set(CMAKE_REQUIRED_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/..) -# Writing a wide character to a character stream Writer is forbidden. -check_cxx_source_compiles(" +function (expect_compile_error code) + check_cxx_source_compiles(" #include \"format.cc\" - int main() { fmt::Writer() << L'a'; } - " WRITE_WCHAR_COMPILES) -if (WRITE_WCHAR_COMPILES) - error("No compile error for: fmt::Writer() << L'a'") -endif () + int main() { + ${code} + } + " compiles) + if (compiles) + error("No compile error for: ${code}") + endif () +endfunction () + +# Writing a wide character to a character stream Writer is forbidden. +expect_compile_error("fmt::Writer() << L'a';")