Features: Record for GNU 4.7.
Update the CompileFeatures test to verify that unsupported features do not work.
This commit is contained in:
parent
c010e7cc80
commit
9cbc63e40c
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
# Reference: http://gcc.gnu.org/projects/cxx0x.html
|
# Reference: http://gcc.gnu.org/projects/cxx0x.html
|
||||||
|
|
||||||
set(_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 408")
|
set(_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 407")
|
||||||
# Introduced in GCC 4.8.1
|
# Introduced in GCC 4.8.1
|
||||||
set(GNU481_CXX11 "((__GNUC__ * 100 + __GNUC_MINOR__) > 408 || __GNUC_PATCHLEVEL__ >= 1) && __cplusplus >= 201103L")
|
set(GNU481_CXX11 "((__GNUC__ * 100 + __GNUC_MINOR__) > 408 || __GNUC_PATCHLEVEL__ >= 1) && __cplusplus >= 201103L")
|
||||||
set(_cmake_feature_test_cxx_decltype_incomplete_return_types "${GNU481_CXX11}")
|
set(_cmake_feature_test_cxx_decltype_incomplete_return_types "${GNU481_CXX11}")
|
||||||
|
@ -12,8 +12,7 @@ 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}")
|
||||||
set(_cmake_feature_test_cxx_thread_local "${GNU48_CXX11}")
|
set(_cmake_feature_test_cxx_thread_local "${GNU48_CXX11}")
|
||||||
# TODO: Should be supported by GNU 4.7
|
set(GNU47_CXX11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && __cplusplus >= 201103L")
|
||||||
set(GNU47_CXX11 "${_oldestSupported} && __cplusplus >= 201103L")
|
|
||||||
set(_cmake_feature_test_cxx_alias_templates "${GNU47_CXX11}")
|
set(_cmake_feature_test_cxx_alias_templates "${GNU47_CXX11}")
|
||||||
set(_cmake_feature_test_cxx_delegating_constructors "${GNU47_CXX11}")
|
set(_cmake_feature_test_cxx_delegating_constructors "${GNU47_CXX11}")
|
||||||
set(_cmake_feature_test_cxx_extended_friend_declarations "${GNU47_CXX11}")
|
set(_cmake_feature_test_cxx_extended_friend_declarations "${GNU47_CXX11}")
|
||||||
|
|
|
@ -32,7 +32,7 @@ macro(cmake_record_cxx_compile_features)
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
if (UNIX AND NOT APPLE AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
|
if (UNIX AND NOT APPLE AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
|
||||||
_get_gcc_features(c++11 CMAKE_CXX11_COMPILE_FEATURES)
|
_get_gcc_features(c++11 CMAKE_CXX11_COMPILE_FEATURES)
|
||||||
_get_gcc_features(c++98 CMAKE_CXX98_COMPILE_FEATURES)
|
_get_gcc_features(c++98 CMAKE_CXX98_COMPILE_FEATURES)
|
||||||
else()
|
else()
|
||||||
|
|
|
@ -11,22 +11,33 @@ if (NOT CMAKE_CXX_COMPILE_FEATURES)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
macro(run_test feature)
|
macro(run_test feature lang)
|
||||||
if (";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ${feature})
|
if (";${CMAKE_${lang}_COMPILE_FEATURES};" MATCHES ${feature})
|
||||||
add_library(test_${feature} OBJECT ${feature}.cpp)
|
add_library(test_${feature} OBJECT ${feature})
|
||||||
set_property(TARGET test_${feature}
|
set_property(TARGET test_${feature}
|
||||||
PROPERTY COMPILE_FEATURES "${feature}"
|
PROPERTY COMPILE_FEATURES "${feature}"
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
message("Not supported: ${feature}")
|
list(APPEND ${lang}_non_features ${feature})
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
get_property(features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES)
|
get_property(cxx_features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES)
|
||||||
foreach(feature ${features})
|
foreach(feature ${cxx_features})
|
||||||
run_test(${feature})
|
run_test(${feature} CXX)
|
||||||
endforeach()
|
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()
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(CompileFeatures main.cpp)
|
add_executable(CompileFeatures main.cpp)
|
||||||
set_property(TARGET CompileFeatures
|
set_property(TARGET CompileFeatures
|
||||||
PROPERTY COMPILE_FEATURES "cxx_auto_type"
|
PROPERTY COMPILE_FEATURES "cxx_auto_type"
|
||||||
|
|
Loading…
Reference in New Issue