Tests: Make CompileFeature tests use highest standard known.
Remove the use of check_cxx_source_compiles which is now just getting in the way. Blacklist the cxx_alignof feature in the test with GNU 4.7. The test file compiles, but it is documented as available first in GNU 4.8.
This commit is contained in:
parent
3547a00d77
commit
f5bf9d4311
|
@ -8,6 +8,8 @@ set(_cmake_feature_test_cxx_decltype_incomplete_return_types "${GNU481_CXX11}")
|
||||||
set(_cmake_feature_test_cxx_reference_qualified_functions "${GNU481_CXX11}")
|
set(_cmake_feature_test_cxx_reference_qualified_functions "${GNU481_CXX11}")
|
||||||
set(GNU48_CXX11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L")
|
set(GNU48_CXX11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L")
|
||||||
set(_cmake_feature_test_cxx_alignas "${GNU48_CXX11}")
|
set(_cmake_feature_test_cxx_alignas "${GNU48_CXX11}")
|
||||||
|
# The alignof feature works with GNU 4.7 and -std=c++11, but it is documented
|
||||||
|
# as available with GNU 4.8, so treat that as true.
|
||||||
set(_cmake_feature_test_cxx_alignof "${GNU48_CXX11}")
|
set(_cmake_feature_test_cxx_alignof "${GNU48_CXX11}")
|
||||||
set(_cmake_feature_test_cxx_attributes "${GNU48_CXX11}")
|
set(_cmake_feature_test_cxx_attributes "${GNU48_CXX11}")
|
||||||
set(_cmake_feature_test_cxx_inheriting_constructors "${GNU48_CXX11}")
|
set(_cmake_feature_test_cxx_inheriting_constructors "${GNU48_CXX11}")
|
||||||
|
|
|
@ -27,13 +27,29 @@ foreach(feature ${cxx_features})
|
||||||
run_test(${feature} CXX)
|
run_test(${feature} CXX)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
if (CMAKE_CXX_COMPILER_ID STREQUAL GNU
|
||||||
|
AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
|
||||||
|
list(REMOVE_ITEM CXX_non_features
|
||||||
|
cxx_alignof
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (CMAKE_CXX_COMPILE_FEATURES)
|
if (CMAKE_CXX_COMPILE_FEATURES)
|
||||||
include(CheckCXXSourceCompiles)
|
|
||||||
foreach(feature ${CXX_non_features})
|
foreach(feature ${CXX_non_features})
|
||||||
check_cxx_source_compiles("#include \"${CMAKE_CURRENT_SOURCE_DIR}/${feature}.cpp\"\nint main() { return 0; }\n" ${feature}_works)
|
message("Testing feature : ${feature}")
|
||||||
|
try_compile(${feature}_works
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/${feature}_test"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/feature_test.cpp"
|
||||||
|
COMPILE_DEFINITIONS "-DTEST=${CMAKE_CURRENT_SOURCE_DIR}/${feature}.cpp"
|
||||||
|
CMAKE_FLAGS "-DCMAKE_CXX_STANDARD=11"
|
||||||
|
OUTPUT_VARIABLE OUTPUT
|
||||||
|
)
|
||||||
if (${feature}_works)
|
if (${feature}_works)
|
||||||
message(SEND_ERROR
|
message(SEND_ERROR
|
||||||
"Feature ${feature} expected not to work for ${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION}. Update the supported features or blacklist it.")
|
"Feature ${feature} expected not to work for ${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION}.
|
||||||
|
Update the supported features or blacklist it.\n${OUTPUT}")
|
||||||
|
else()
|
||||||
|
message("Testing feature : ${feature} -- Fails, as expected.")
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
|
||||||
|
#define STRINGIFY_IMPL(X) #X
|
||||||
|
#define STRINGIFY(X) STRINGIFY_IMPL(X)
|
||||||
|
|
||||||
|
#include STRINGIFY(TEST)
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue