Merge topic 'GNU-4.4-compile-features'

004e1540 Features: Record for GNU 4.4.
2a5ca650 Features: Wrap failure-test in UNIX condition.
1ae2c6b2 Features: Blacklist cxx_constexpr test for GNU 4.5.
c66e3317 Features: Use a more-common feature in cycle-test.
c43a6dc5 Features: Update comment in test to match the code.
78259135 Features: Test presence of cxx_auto_type with genex.
7b9fc88b Features: Remove outdated comment.
This commit is contained in:
Brad King 2015-01-19 13:55:31 -05:00 committed by CMake Topic Stage
commit 813ace90e4
9 changed files with 38 additions and 38 deletions

View File

@ -1,5 +1,5 @@
GNU-4.6-compile-features GNU-4.4-compile-features
------------------------ ------------------------
* The :manual:`Compile Features <cmake-compile-features(7)>` functionality * The :manual:`Compile Features <cmake-compile-features(7)>` functionality
is now aware of features supported by GNU 4.6 compilers. is now aware of features supported by GNU 4.4 to 4.6 compilers.

View File

@ -1,5 +1,5 @@
set(_cmake_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 406") set(_cmake_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 404")
# GNU 4.7 correctly sets __STDC_VERSION__ to 201112L, but GNU 4.6 sets it # GNU 4.7 correctly sets __STDC_VERSION__ to 201112L, but GNU 4.6 sets it
# to 201000L. As the former is strictly greater than the latter, test only # to 201000L. As the former is strictly greater than the latter, test only
@ -9,7 +9,7 @@ set(_cmake_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 406")
set(GNU46_C11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201000L") set(GNU46_C11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201000L")
set(_cmake_feature_test_c_static_assert "${GNU46_C11}") set(_cmake_feature_test_c_static_assert "${GNU46_C11}")
# Since 4.4 at least: # Since 4.4 at least:
set(GNU44_C99 "${_cmake_oldestSupported} && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L") set(GNU44_C99 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L")
set(_cmake_feature_test_c_restrict "${GNU44_C99}") set(_cmake_feature_test_c_restrict "${GNU44_C99}")
set(_cmake_feature_test_c_variadic_macros "${GNU44_C99}") set(_cmake_feature_test_c_variadic_macros "${GNU44_C99}")

View File

@ -1,7 +1,7 @@
include(Compiler/GNU) include(Compiler/GNU)
__compiler_gnu(C) __compiler_gnu(C)
if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6) if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4)
set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90") set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90")
set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90")
@ -12,7 +12,7 @@ endif()
if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7) if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7)
set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11")
set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11")
elseif (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6) elseif (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4)
set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c1x") set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c1x")
set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu1x") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu1x")
endif() endif()
@ -29,7 +29,7 @@ macro(cmake_record_c_compile_features)
endmacro() endmacro()
set(_result 0) set(_result 0)
if (UNIX AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6) if (UNIX AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4)
_get_gcc_features(${CMAKE_C11_STANDARD_COMPILE_OPTION} CMAKE_C11_COMPILE_FEATURES) _get_gcc_features(${CMAKE_C11_STANDARD_COMPILE_OPTION} CMAKE_C11_COMPILE_FEATURES)
if (_result EQUAL 0) if (_result EQUAL 0)
_get_gcc_features(${CMAKE_C99_STANDARD_COMPILE_OPTION} CMAKE_C99_COMPILE_FEATURES) _get_gcc_features(${CMAKE_C99_STANDARD_COMPILE_OPTION} CMAKE_C99_COMPILE_FEATURES)

View File

@ -2,7 +2,7 @@
# Reference: http://gcc.gnu.org/projects/cxx0x.html # Reference: http://gcc.gnu.org/projects/cxx0x.html
# http://gcc.gnu.org/projects/cxx1y.html # http://gcc.gnu.org/projects/cxx1y.html
set(_cmake_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 406") set(_cmake_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 404")
set(GNU50_CXX14 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 500 && __cplusplus >= 201402L") set(GNU50_CXX14 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 500 && __cplusplus >= 201402L")
set(_cmake_feature_test_cxx_variable_templates "${GNU50_CXX14}") set(_cmake_feature_test_cxx_variable_templates "${GNU50_CXX14}")
@ -59,7 +59,6 @@ set(_cmake_feature_test_cxx_user_literals "${GNU47_CXX11}")
# __GXX_EXPERIMENTAL_CXX0X__ is defined in prior versions, but may not be # __GXX_EXPERIMENTAL_CXX0X__ is defined in prior versions, but may not be
# defined in the future. # defined in the future.
set(GNU_CXX0X_DEFINED "(__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))") set(GNU_CXX0X_DEFINED "(__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))")
# TODO: Should be supported by GNU 4.6
set(GNU46_CXX11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && ${GNU_CXX0X_DEFINED}") set(GNU46_CXX11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && ${GNU_CXX0X_DEFINED}")
set(_cmake_feature_test_cxx_constexpr "${GNU46_CXX11}") set(_cmake_feature_test_cxx_constexpr "${GNU46_CXX11}")
set(_cmake_feature_test_cxx_defaulted_move_initializers "${GNU46_CXX11}") set(_cmake_feature_test_cxx_defaulted_move_initializers "${GNU46_CXX11}")
@ -68,14 +67,12 @@ set(_cmake_feature_test_cxx_noexcept "${GNU46_CXX11}")
set(_cmake_feature_test_cxx_nullptr "${GNU46_CXX11}") set(_cmake_feature_test_cxx_nullptr "${GNU46_CXX11}")
set(_cmake_feature_test_cxx_range_for "${GNU46_CXX11}") set(_cmake_feature_test_cxx_range_for "${GNU46_CXX11}")
set(_cmake_feature_test_cxx_unrestricted_unions "${GNU46_CXX11}") set(_cmake_feature_test_cxx_unrestricted_unions "${GNU46_CXX11}")
# TODO: Should be supported by GNU 4.5 set(GNU45_CXX11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 405 && ${GNU_CXX0X_DEFINED}")
set(GNU45_CXX11 "${_cmake_oldestSupported} && ${GNU_CXX0X_DEFINED}")
set(_cmake_feature_test_cxx_explicit_conversions "${GNU45_CXX11}") set(_cmake_feature_test_cxx_explicit_conversions "${GNU45_CXX11}")
set(_cmake_feature_test_cxx_lambdas "${GNU45_CXX11}") set(_cmake_feature_test_cxx_lambdas "${GNU45_CXX11}")
set(_cmake_feature_test_cxx_local_type_template_args "${GNU45_CXX11}") set(_cmake_feature_test_cxx_local_type_template_args "${GNU45_CXX11}")
set(_cmake_feature_test_cxx_raw_string_literals "${GNU45_CXX11}") set(_cmake_feature_test_cxx_raw_string_literals "${GNU45_CXX11}")
# TODO: Should be supported by GNU 4.4 set(GNU44_CXX11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && ${GNU_CXX0X_DEFINED}")
set(GNU44_CXX11 "${_cmake_oldestSupported} && ${GNU_CXX0X_DEFINED}")
set(_cmake_feature_test_cxx_auto_type "${GNU44_CXX11}") set(_cmake_feature_test_cxx_auto_type "${GNU44_CXX11}")
set(_cmake_feature_test_cxx_defaulted_functions "${GNU44_CXX11}") set(_cmake_feature_test_cxx_defaulted_functions "${GNU44_CXX11}")
set(_cmake_feature_test_cxx_deleted_functions "${GNU44_CXX11}") set(_cmake_feature_test_cxx_deleted_functions "${GNU44_CXX11}")

View File

@ -11,7 +11,7 @@ else()
endif() endif()
endif() endif()
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6) if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4)
# Supported since 4.3 # Supported since 4.3
set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98") set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98")
set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98") set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98")
@ -20,7 +20,7 @@ endif()
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7) if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11")
set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11") set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11")
elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6) elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4)
# 4.3 supports 0x variants # 4.3 supports 0x variants
set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++0x") set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++0x")
set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++0x") set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++0x")
@ -45,7 +45,7 @@ macro(cmake_record_cxx_compile_features)
if (UNIX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) if (UNIX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
_get_gcc_features(${CMAKE_CXX14_STANDARD_COMPILE_OPTION} CMAKE_CXX14_COMPILE_FEATURES) _get_gcc_features(${CMAKE_CXX14_STANDARD_COMPILE_OPTION} CMAKE_CXX14_COMPILE_FEATURES)
endif() endif()
if (UNIX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6) if (UNIX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4)
if (_result EQUAL 0) if (_result EQUAL 0)
_get_gcc_features(${CMAKE_CXX11_STANDARD_COMPILE_OPTION} CMAKE_CXX11_COMPILE_FEATURES) _get_gcc_features(${CMAKE_CXX11_STANDARD_COMPILE_OPTION} CMAKE_CXX11_COMPILE_FEATURES)
endif() endif()

View File

@ -62,6 +62,14 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL SunPro)
) )
endif() endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6)
# The cxx_constexpr feature happens to work (for *this* testcase) with
# GNU 4.5, but it is first documented as available with GNU 4.6.
list(REMOVE_ITEM CXX_non_features
cxx_constexpr
)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
# The cxx_alignof feature happens to work (for *this* testcase) with # The cxx_alignof feature happens to work (for *this* testcase) with
@ -212,7 +220,7 @@ if (CMAKE_CXX_COMPILE_FEATURES)
set_property(TARGET CompileFeaturesGenex PROPERTY CXX_STANDARD 11) set_property(TARGET CompileFeaturesGenex PROPERTY CXX_STANDARD 11)
target_compile_definitions(CompileFeaturesGenex PRIVATE target_compile_definitions(CompileFeaturesGenex PRIVATE
HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override> HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override>
HAVE_NULLPTR=$<COMPILE_FEATURES:cxx_nullptr> HAVE_AUTO_TYPE=$<COMPILE_FEATURES:cxx_auto_type>
HAVE_INHERITING_CONSTRUCTORS=$<COMPILE_FEATURES:cxx_inheriting_constructors> HAVE_INHERITING_CONSTRUCTORS=$<COMPILE_FEATURES:cxx_inheriting_constructors>
HAVE_FINAL=$<COMPILE_FEATURES:cxx_final> HAVE_FINAL=$<COMPILE_FEATURES:cxx_final>
HAVE_INHERITING_CONSTRUCTORS_AND_FINAL=$<COMPILE_FEATURES:cxx_inheriting_constructors,cxx_final> HAVE_INHERITING_CONSTRUCTORS_AND_FINAL=$<COMPILE_FEATURES:cxx_inheriting_constructors,cxx_final>
@ -222,7 +230,7 @@ if (CMAKE_CXX_COMPILE_FEATURES)
target_compile_features(CompileFeaturesGenex2 PRIVATE cxx_static_assert) target_compile_features(CompileFeaturesGenex2 PRIVATE cxx_static_assert)
target_compile_definitions(CompileFeaturesGenex2 PRIVATE target_compile_definitions(CompileFeaturesGenex2 PRIVATE
HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override> HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override>
HAVE_NULLPTR=$<COMPILE_FEATURES:cxx_nullptr> HAVE_AUTO_TYPE=$<COMPILE_FEATURES:cxx_auto_type>
HAVE_INHERITING_CONSTRUCTORS=$<COMPILE_FEATURES:cxx_inheriting_constructors> HAVE_INHERITING_CONSTRUCTORS=$<COMPILE_FEATURES:cxx_inheriting_constructors>
HAVE_FINAL=$<COMPILE_FEATURES:cxx_final> HAVE_FINAL=$<COMPILE_FEATURES:cxx_final>
HAVE_INHERITING_CONSTRUCTORS_AND_FINAL=$<COMPILE_FEATURES:cxx_inheriting_constructors,cxx_final> HAVE_INHERITING_CONSTRUCTORS_AND_FINAL=$<COMPILE_FEATURES:cxx_inheriting_constructors,cxx_final>
@ -234,7 +242,7 @@ if (CMAKE_CXX_COMPILE_FEATURES)
target_link_libraries(CompileFeaturesGenex3 PRIVATE static_assert_iface) target_link_libraries(CompileFeaturesGenex3 PRIVATE static_assert_iface)
target_compile_definitions(CompileFeaturesGenex3 PRIVATE target_compile_definitions(CompileFeaturesGenex3 PRIVATE
HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override> HAVE_OVERRIDE_CONTROL=$<COMPILE_FEATURES:cxx_final,cxx_override>
HAVE_NULLPTR=$<COMPILE_FEATURES:cxx_nullptr> HAVE_AUTO_TYPE=$<COMPILE_FEATURES:cxx_auto_type>
HAVE_INHERITING_CONSTRUCTORS=$<COMPILE_FEATURES:cxx_inheriting_constructors> HAVE_INHERITING_CONSTRUCTORS=$<COMPILE_FEATURES:cxx_inheriting_constructors>
HAVE_FINAL=$<COMPILE_FEATURES:cxx_final> HAVE_FINAL=$<COMPILE_FEATURES:cxx_final>
HAVE_INHERITING_CONSTRUCTORS_AND_FINAL=$<COMPILE_FEATURES:cxx_inheriting_constructors,cxx_final> HAVE_INHERITING_CONSTRUCTORS_AND_FINAL=$<COMPILE_FEATURES:cxx_inheriting_constructors,cxx_final>

View File

@ -17,9 +17,9 @@ struct B final : A
#endif #endif
#if !HAVE_NULLPTR #if !HAVE_AUTO_TYPE
#error "Expect nullptr feature" # error Expect cxx_auto_type support
#else #endif
#if !HAVE_INHERITING_CONSTRUCTORS #if !HAVE_INHERITING_CONSTRUCTORS
# if EXPECT_INHERITING_CONSTRUCTORS # if EXPECT_INHERITING_CONSTRUCTORS
@ -51,13 +51,6 @@ struct B final : A
# endif # endif
#endif #endif
const char* getString()
{
return nullptr;
}
#endif
int main() int main()
{ {

View File

@ -25,12 +25,14 @@ if (NOT CMAKE_CXX_COMPILE_FEATURES AND NOT CMAKE_C_COMPILE_FEATURES)
) )
add_executable(WriteCompilerDetectionHeader "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp") add_executable(WriteCompilerDetectionHeader "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp")
include(CheckCXXSourceCompiles) if(UNIX OR NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
check_cxx_source_compiles("#include \"${CMAKE_CURRENT_BINARY_DIR}/test_compiler_detection.h\"\nint main() { return 0; }\n" include(CheckCXXSourceCompiles)
file_include_works check_cxx_source_compiles("#include \"${CMAKE_CURRENT_BINARY_DIR}/test_compiler_detection.h\"\nint main() { return 0; }\n"
) file_include_works
if (file_include_works) )
message(SEND_ERROR "Inclusion of ${CMAKE_CURRENT_BINARY_DIR}/test_compiler_detection.h was expected to cause an error, but did not.") if (file_include_works)
message(SEND_ERROR "Inclusion of ${CMAKE_CURRENT_BINARY_DIR}/test_compiler_detection.h was expected to cause an error, but did not.")
endif()
endif() endif()
return() return()
endif() endif()

View File

@ -6,10 +6,10 @@ add_library(empty3 INTERFACE)
target_compile_features(empty3 INTERFACE cxx_static_assert) target_compile_features(empty3 INTERFACE cxx_static_assert)
target_link_libraries(empty1 target_link_libraries(empty1
# When starting, $<COMPILE_FEATURES:cxx_nullptr> is '0', so 'freeze' the # When starting, $<COMPILE_FEATURES:cxx_auto_type> is '0', so 'freeze' the
# CXX_STANDARD at 98 during computation. # CXX_STANDARD at 98 during computation.
$<$<COMPILE_FEATURES:cxx_nullptr>:empty2> $<$<COMPILE_FEATURES:cxx_auto_type>:empty2>
# This would add cxx_constexpr, but that would require CXX_STANDARD = 11, # This would add cxx_static_assert, but that would require CXX_STANDARD = 11,
# which is not allowed after freeze. Report an error. # which is not allowed after freeze. Report an error.
empty3 empty3
) )