1
2# Reference: http://gcc.gnu.org/projects/cxx0x.html
3# http://gcc.gnu.org/projects/cxx1y.html
4
5set(_cmake_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 404")
6
7set(GNU50_CXX14 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 500 && __cplusplus >= 201402L")
8set(_cmake_feature_test_cxx_variable_templates "${GNU50_CXX14}")
9set(_cmake_feature_test_cxx_relaxed_constexpr "${GNU50_CXX14}")
10set(_cmake_feature_test_cxx_aggregate_default_initializers "${GNU50_CXX14}")
11
12# GNU 4.9 in c++14 mode sets __cplusplus to 201300L, so don't test for the
13# correct value of it below.
14# https://patchwork.ozlabs.org/patch/382470/
15set(GNU49_CXX14 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L")
16set(_cmake_feature_test_cxx_contextual_conversions "${GNU49_CXX14}")
17set(_cmake_feature_test_cxx_attribute_deprecated "${GNU49_CXX14}")
18set(_cmake_feature_test_cxx_decltype_auto "${GNU49_CXX14}")
19set(_cmake_feature_test_cxx_digit_separators "${GNU49_CXX14}")
20set(_cmake_feature_test_cxx_generic_lambdas "${GNU49_CXX14}")
21# GNU 4.3 supports binary literals as an extension, but may warn about
22# use of extensions prior to GNU 4.9
23# http://stackoverflow.com/questions/16334024/difference-between-gcc-binary-literals-and-c14-ones
24set(_cmake_feature_test_cxx_binary_literals "${GNU49_CXX14}")
25# The features below are documented as available in GNU 4.8 (by implementing an
26# earlier draft of the standard paper), but that version of the compiler
27# does not set __cplusplus to a value greater than 201103L until GNU 4.9:
28# http://gcc.gnu.org/onlinedocs/gcc-4.8.2/cpp/Standard-Predefined-Macros.html#Standard-Predefined-Macros
29# http://gcc.gnu.org/onlinedocs/gcc-4.9.0/cpp/Standard-Predefined-Macros.html#Standard-Predefined-Macros
30# So, CMake only reports availability for it with GNU 4.9 or later.
31set(_cmake_feature_test_cxx_return_type_deduction "${GNU49_CXX14}")
32set(_cmake_feature_test_cxx_lambda_init_captures "${GNU49_CXX14}")
33
34# Introduced in GCC 4.8.1
35set(GNU481_CXX11 "((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40801) && __cplusplus >= 201103L")
36set(_cmake_feature_test_cxx_decltype_incomplete_return_types "${GNU481_CXX11}")
37set(_cmake_feature_test_cxx_reference_qualified_functions "${GNU481_CXX11}")
38set(GNU48_CXX11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L")
39set(_cmake_feature_test_cxx_alignas "${GNU48_CXX11}")
40# The alignof feature works with GNU 4.7 and -std=c++11, but it is documented
41# as available with GNU 4.8, so treat that as true.
42set(_cmake_feature_test_cxx_alignof "${GNU48_CXX11}")
43set(_cmake_feature_test_cxx_attributes "${GNU48_CXX11}")
44set(_cmake_feature_test_cxx_inheriting_constructors "${GNU48_CXX11}")
45set(_cmake_feature_test_cxx_thread_local "${GNU48_CXX11}")
46set(GNU47_CXX11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && __cplusplus >= 201103L")
47set(_cmake_feature_test_cxx_alias_templates "${GNU47_CXX11}")
48set(_cmake_feature_test_cxx_delegating_constructors "${GNU47_CXX11}")
49set(_cmake_feature_test_cxx_extended_friend_declarations "${GNU47_CXX11}")
50set(_cmake_feature_test_cxx_final "${GNU47_CXX11}")
51set(_cmake_feature_test_cxx_nonstatic_member_init "${GNU47_CXX11}")
52set(_cmake_feature_test_cxx_override "${GNU47_CXX11}")
53set(_cmake_feature_test_cxx_user_literals "${GNU47_CXX11}")
54# NOTE: C++11 was ratified in September 2011. GNU 4.7 is the first minor
55# release following that (March 2012), and the first minor release to
56# support -std=c++11. Prior to that, support for C++11 features is technically
57# experiemental and possibly incomplete (see for example the note below about
58# cxx_variadic_template_template_parameters)
59# GNU does not define __cplusplus correctly before version 4.7.
60# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=1773
61# __GXX_EXPERIMENTAL_CXX0X__ is defined in prior versions, but may not be
62# defined in the future.
63set(GNU_CXX0X_DEFINED "(__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__))")
64set(GNU46_CXX11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && ${GNU_CXX0X_DEFINED}")
65set(_cmake_feature_test_cxx_constexpr "${GNU46_CXX11}")
66set(_cmake_feature_test_cxx_defaulted_move_initializers "${GNU46_CXX11}")
67set(_cmake_feature_test_cxx_enum_forward_declarations "${GNU46_CXX11}")
68set(_cmake_feature_test_cxx_noexcept "${GNU46_CXX11}")
69set(_cmake_feature_test_cxx_nullptr "${GNU46_CXX11}")
70set(_cmake_feature_test_cxx_range_for "${GNU46_CXX11}")
71set(_cmake_feature_test_cxx_unrestricted_unions "${GNU46_CXX11}")
72set(GNU45_CXX11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 405 && ${GNU_CXX0X_DEFINED}")
73set(_cmake_feature_test_cxx_explicit_conversions "${GNU45_CXX11}")
74set(_cmake_feature_test_cxx_lambdas "${GNU45_CXX11}")
75set(_cmake_feature_test_cxx_local_type_template_args "${GNU45_CXX11}")
76set(_cmake_feature_test_cxx_raw_string_literals "${GNU45_CXX11}")
77set(GNU44_CXX11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && ${GNU_CXX0X_DEFINED}")
78set(_cmake_feature_test_cxx_auto_type "${GNU44_CXX11}")
79set(_cmake_feature_test_cxx_defaulted_functions "${GNU44_CXX11}")
80set(_cmake_feature_test_cxx_deleted_functions "${GNU44_CXX11}")
81set(_cmake_feature_test_cxx_generalized_initializers "${GNU44_CXX11}")
82set(_cmake_feature_test_cxx_inline_namespaces "${GNU44_CXX11}")
83set(_cmake_feature_test_cxx_sizeof_member "${GNU44_CXX11}")
84set(_cmake_feature_test_cxx_strong_enums "${GNU44_CXX11}")
85set(_cmake_feature_test_cxx_trailing_return_types "${GNU44_CXX11}")
86set(_cmake_feature_test_cxx_unicode_literals "${GNU44_CXX11}")
87set(_cmake_feature_test_cxx_uniform_initialization "${GNU44_CXX11}")
88set(_cmake_feature_test_cxx_variadic_templates "${GNU44_CXX11}")
89# TODO: If features are ever recorded for GNU 4.3, there should possibly
90# be a new feature added like cxx_variadic_template_template_parameters,
91# which is implemented by GNU 4.4, but not 4.3. cxx_variadic_templates is
92# actually implemented by GNU 4.3, but variadic template template parameters
93# 'completes' it, so that is the version we record as having the variadic
94# templates capability in CMake. See
95# http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2555.pdf
96# TODO: Should be supported by GNU 4.3
97set(GNU43_CXX11 "${_cmake_oldestSupported} && ${GNU_CXX0X_DEFINED}")
98set(_cmake_feature_test_cxx_decltype "${GNU43_CXX11}")
99set(_cmake_feature_test_cxx_default_function_template_args "${GNU43_CXX11}")
100set(_cmake_feature_test_cxx_long_long_type "${GNU43_CXX11}")
101set(_cmake_feature_test_cxx_right_angle_brackets "${GNU43_CXX11}")
102set(_cmake_feature_test_cxx_rvalue_references "${GNU43_CXX11}")
103set(_cmake_feature_test_cxx_static_assert "${GNU43_CXX11}")
104# TODO: Should be supported since GNU 3.4?
105set(_cmake_feature_test_cxx_extern_templates "${_cmake_oldestSupported} && ${GNU_CXX0X_DEFINED}")
106# TODO: Should be supported forever?
107set(_cmake_feature_test_cxx_func_identifier "${_cmake_oldestSupported} && ${GNU_CXX0X_DEFINED}")
108set(_cmake_feature_test_cxx_variadic_macros "${_cmake_oldestSupported} && ${GNU_CXX0X_DEFINED}")
109set(_cmake_feature_test_cxx_template_template_parameters "${_cmake_oldestSupported} && __cplusplus")
110