Merge topic 'minor-cleanups'
bc9a8bba
Makefile: Undef FEATURE_STRING iteration define after use.eb638c75
Tests: Make CompileFeatures feature list lang-specific.e2f09aff
CMakeConfigurableFile: Remove excess newline.5109b042
Features: Fix GNU 4.8.1 version test.6a9fdbeb
Test: Parameterize the language in the CompileFeature test.f5bf9d43
Tests: Make CompileFeature tests use highest standard known.
This commit is contained in:
commit
f20bb8f003
|
@ -1,2 +1 @@
|
|||
@CMAKE_CONFIGURABLE_FILE_CONTENT@
|
||||
|
||||
|
|
|
@ -3,11 +3,13 @@
|
|||
|
||||
set(_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 407")
|
||||
# Introduced in GCC 4.8.1
|
||||
set(GNU481_CXX11 "((__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __GNUC_PATCHLEVEL__ >= 1) && __cplusplus >= 201103L")
|
||||
set(GNU481_CXX11 "((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40801) && __cplusplus >= 201103L")
|
||||
set(_cmake_feature_test_cxx_decltype_incomplete_return_types "${GNU481_CXX11}")
|
||||
set(_cmake_feature_test_cxx_reference_qualified_functions "${GNU481_CXX11}")
|
||||
set(GNU48_CXX11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L")
|
||||
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_attributes "${GNU48_CXX11}")
|
||||
set(_cmake_feature_test_cxx_inheriting_constructors "${GNU48_CXX11}")
|
||||
|
|
|
@ -4978,6 +4978,7 @@ static const char * const CXX_FEATURES[] = {
|
|||
0
|
||||
FOR_EACH_CXX_FEATURE(FEATURE_STRING)
|
||||
};
|
||||
#undef FEATURE_STRING
|
||||
|
||||
static const char * const CXX_STANDARDS[] = {
|
||||
"98"
|
||||
|
|
|
@ -27,17 +27,37 @@ foreach(feature ${cxx_features})
|
|||
run_test(${feature} CXX)
|
||||
endforeach()
|
||||
|
||||
if (CMAKE_CXX_COMPILE_FEATURES)
|
||||
include(CheckCXXSourceCompiles)
|
||||
foreach(feature ${CXX_non_features})
|
||||
check_cxx_source_compiles("#include \"${CMAKE_CURRENT_SOURCE_DIR}/${feature}.cpp\"\nint main() { return 0; }\n" ${feature}_works)
|
||||
if (${feature}_works)
|
||||
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.")
|
||||
endif()
|
||||
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()
|
||||
|
||||
set(CXX_ext cpp)
|
||||
set(CXX_standard_flag 11)
|
||||
foreach(lang CXX)
|
||||
if (CMAKE_${lang}_COMPILE_FEATURES)
|
||||
foreach(feature ${${lang}_non_features})
|
||||
message("Testing feature : ${feature}")
|
||||
try_compile(${feature}_works
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${feature}_test"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/feature_test.${${lang}_ext}"
|
||||
COMPILE_DEFINITIONS "-DTEST=${CMAKE_CURRENT_SOURCE_DIR}/${feature}.${${lang}_ext}"
|
||||
CMAKE_FLAGS "-DCMAKE_${lang}_STANDARD=${${lang}_standard_flag}"
|
||||
OUTPUT_VARIABLE OUTPUT
|
||||
)
|
||||
if (${feature}_works)
|
||||
message(SEND_ERROR
|
||||
"Feature ${feature} expected not to work for ${lang} ${CMAKE_${lang}_COMPILER_ID}-${CMAKE_${lang}_COMPILER_VERSION}.
|
||||
Update the supported features or blacklist it.\n${OUTPUT}")
|
||||
else()
|
||||
message("Testing feature : ${feature} -- Fails, as expected.")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
add_executable(CompileFeatures main.cpp)
|
||||
set_property(TARGET CompileFeatures
|
||||
PROPERTY COMPILE_FEATURES "cxx_auto_type"
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
#define STRINGIFY_IMPL(X) #X
|
||||
#define STRINGIFY(X) STRINGIFY_IMPL(X)
|
||||
|
||||
#include STRINGIFY(TEST)
|
||||
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
|
@ -10,11 +10,11 @@ run_cmake(NotAFeature_OriginDebug_target_compile_features)
|
|||
|
||||
run_cmake(generate_feature_list)
|
||||
file(READ
|
||||
"${RunCMake_BINARY_DIR}/generate_feature_list-build/features.txt"
|
||||
FEATURES
|
||||
"${RunCMake_BINARY_DIR}/generate_feature_list-build/cxx_features.txt"
|
||||
CXX_FEATURES
|
||||
)
|
||||
|
||||
if (NOT FEATURES)
|
||||
if (NOT CXX_FEATURES)
|
||||
run_cmake(NoSupportedCxxFeatures)
|
||||
run_cmake(NoSupportedCxxFeaturesGenex)
|
||||
endif()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/features.txt"
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cxx_features.txt"
|
||||
"${CMAKE_CXX_COMPILE_FEATURES}"
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue