forked from fmtlib/fmt
updated compile-test and include a working test
This makes sure that the test does not break due to other reasons.
This commit is contained in:
@ -5,23 +5,41 @@ cmake_minimum_required(VERSION 2.8)
|
|||||||
include(CheckCXXSourceCompiles)
|
include(CheckCXXSourceCompiles)
|
||||||
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/../..)
|
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/../..)
|
||||||
|
|
||||||
function (expect_compile_error code)
|
function (generate_source result fragment)
|
||||||
check_cxx_source_compiles("
|
set(${result} "
|
||||||
#include \"format.cc\"
|
#define FMT_HEADER_ONLY 1
|
||||||
#include \"posix.h\"
|
#include \"cppformat/format.h\"
|
||||||
int main() {
|
int main() {
|
||||||
${code}
|
${fragment}
|
||||||
}
|
}
|
||||||
" compiles)
|
" PARENT_SCOPE)
|
||||||
set (does_compile ${compiles})
|
endfunction ()
|
||||||
|
|
||||||
|
function (expect_compile code)
|
||||||
|
generate_source(source "${code}")
|
||||||
|
check_cxx_source_compiles("${source}" compiles)
|
||||||
|
if (NOT compiles)
|
||||||
|
message(FATAL_ERROR "Compile error for: ${code}")
|
||||||
|
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 (does_compile)
|
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}")
|
message(FATAL_ERROR "No compile error for: ${code}")
|
||||||
endif ()
|
endif ()
|
||||||
|
# Unset the CMake cache variable compiles. Otherwise the compile test will
|
||||||
|
# just use cached information next time it runs.
|
||||||
|
unset(compiles CACHE)
|
||||||
endfunction ()
|
endfunction ()
|
||||||
|
|
||||||
|
# check if the source file skeleton compiles
|
||||||
|
expect_compile("")
|
||||||
|
|
||||||
# MakeArg doesn't accept [const] volatile char *.
|
# MakeArg doesn't accept [const] volatile char *.
|
||||||
expect_compile_error("volatile char s[] = \"test\"; (fmt::internal::MakeArg<char>)(s);")
|
expect_compile_error("volatile char s[] = \"test\"; (fmt::internal::MakeArg<char>)(s);")
|
||||||
expect_compile_error("const volatile char s[] = \"test\"; (fmt::internal::MakeArg<char>)(s);")
|
expect_compile_error("const volatile char s[] = \"test\"; (fmt::internal::MakeArg<char>)(s);")
|
||||||
|
Reference in New Issue
Block a user