Przeglądaj źródła

CMake: Provide language level compile features lists

Now CMake stores what compile features are associated with each
language level and exposes them as global properties.
Robert Maynard 6 lat temu
rodzic
commit
616282a5ce
2 zmienionych plików z 56 dodań i 22 usunięć
  1. 19 0
      Source/cmState.cxx
  2. 37 22
      Source/cmake.h

+ 19 - 0
Source/cmState.cxx

@@ -556,9 +556,28 @@ const char* cmState::GetGlobalProperty(const std::string& prop)
   if (prop == "CMAKE_C_KNOWN_FEATURES") {
     return &FOR_EACH_C_FEATURE(STRING_LIST_ELEMENT)[1];
   }
+  if (prop == "CMAKE_C90_KNOWN_FEATURES") {
+    return &FOR_EACH_C90_FEATURE(STRING_LIST_ELEMENT)[1];
+  }
+  if (prop == "CMAKE_C99_KNOWN_FEATURES") {
+    return &FOR_EACH_C99_FEATURE(STRING_LIST_ELEMENT)[1];
+  }
+  if (prop == "CMAKE_C11_KNOWN_FEATURES") {
+    return &FOR_EACH_C11_FEATURE(STRING_LIST_ELEMENT)[1];
+  }
   if (prop == "CMAKE_CXX_KNOWN_FEATURES") {
     return &FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT)[1];
   }
+  if (prop == "CMAKE_CXX98_KNOWN_FEATURES") {
+    return &FOR_EACH_CXX98_FEATURE(STRING_LIST_ELEMENT)[1];
+  }
+  if (prop == "CMAKE_CXX11_KNOWN_FEATURES") {
+    return &FOR_EACH_CXX11_FEATURE(STRING_LIST_ELEMENT)[1];
+  }
+  if (prop == "CMAKE_CXX14_KNOWN_FEATURES") {
+    return &FOR_EACH_CXX14_FEATURE(STRING_LIST_ELEMENT)[1];
+  }
+
 #undef STRING_LIST_ELEMENT
   return this->GlobalProperties.GetPropertyValue(prop);
 }

+ 37 - 22
Source/cmake.h

@@ -562,40 +562,38 @@ private:
       "not errors."                                                           \
   }
 
+#define FOR_EACH_C90_FEATURE(F) F(c_function_prototypes)
+
+#define FOR_EACH_C99_FEATURE(F)                                               \
+  F(c_restrict)                                                               \
+  F(c_variadic_macros)
+
+#define FOR_EACH_C11_FEATURE(F) F(c_static_assert)
+
 #define FOR_EACH_C_FEATURE(F)                                                 \
   F(c_std_90)                                                                 \
   F(c_std_99)                                                                 \
   F(c_std_11)                                                                 \
-  F(c_function_prototypes)                                                    \
-  F(c_restrict)                                                               \
-  F(c_static_assert)                                                          \
-  F(c_variadic_macros)
+  FOR_EACH_C90_FEATURE(F)                                                     \
+  FOR_EACH_C99_FEATURE(F)                                                     \
+  FOR_EACH_C11_FEATURE(F)
 
-#define FOR_EACH_CXX_FEATURE(F)                                               \
-  F(cxx_std_98)                                                               \
-  F(cxx_std_11)                                                               \
-  F(cxx_std_14)                                                               \
-  F(cxx_std_17)                                                               \
-  F(cxx_std_20)                                                               \
-  F(cxx_aggregate_default_initializers)                                       \
+#define FOR_EACH_CXX98_FEATURE(F) F(cxx_template_template_parameters)
+
+#define FOR_EACH_CXX11_FEATURE(F)                                             \
   F(cxx_alias_templates)                                                      \
   F(cxx_alignas)                                                              \
   F(cxx_alignof)                                                              \
   F(cxx_attributes)                                                           \
-  F(cxx_attribute_deprecated)                                                 \
   F(cxx_auto_type)                                                            \
-  F(cxx_binary_literals)                                                      \
   F(cxx_constexpr)                                                            \
-  F(cxx_contextual_conversions)                                               \
   F(cxx_decltype)                                                             \
-  F(cxx_decltype_auto)                                                        \
   F(cxx_decltype_incomplete_return_types)                                     \
   F(cxx_default_function_template_args)                                       \
   F(cxx_defaulted_functions)                                                  \
   F(cxx_defaulted_move_initializers)                                          \
   F(cxx_delegating_constructors)                                              \
   F(cxx_deleted_functions)                                                    \
-  F(cxx_digit_separators)                                                     \
   F(cxx_enum_forward_declarations)                                            \
   F(cxx_explicit_conversions)                                                 \
   F(cxx_extended_friend_declarations)                                         \
@@ -603,11 +601,9 @@ private:
   F(cxx_final)                                                                \
   F(cxx_func_identifier)                                                      \
   F(cxx_generalized_initializers)                                             \
-  F(cxx_generic_lambdas)                                                      \
   F(cxx_inheriting_constructors)                                              \
   F(cxx_inline_namespaces)                                                    \
   F(cxx_lambdas)                                                              \
-  F(cxx_lambda_init_captures)                                                 \
   F(cxx_local_type_template_args)                                             \
   F(cxx_long_long_type)                                                       \
   F(cxx_noexcept)                                                             \
@@ -617,22 +613,41 @@ private:
   F(cxx_range_for)                                                            \
   F(cxx_raw_string_literals)                                                  \
   F(cxx_reference_qualified_functions)                                        \
-  F(cxx_relaxed_constexpr)                                                    \
-  F(cxx_return_type_deduction)                                                \
   F(cxx_right_angle_brackets)                                                 \
   F(cxx_rvalue_references)                                                    \
   F(cxx_sizeof_member)                                                        \
   F(cxx_static_assert)                                                        \
   F(cxx_strong_enums)                                                         \
-  F(cxx_template_template_parameters)                                         \
   F(cxx_thread_local)                                                         \
   F(cxx_trailing_return_types)                                                \
   F(cxx_unicode_literals)                                                     \
   F(cxx_uniform_initialization)                                               \
   F(cxx_unrestricted_unions)                                                  \
   F(cxx_user_literals)                                                        \
-  F(cxx_variable_templates)                                                   \
   F(cxx_variadic_macros)                                                      \
   F(cxx_variadic_templates)
 
+#define FOR_EACH_CXX14_FEATURE(F)                                             \
+  F(cxx_aggregate_default_initializers)                                       \
+  F(cxx_attribute_deprecated)                                                 \
+  F(cxx_binary_literals)                                                      \
+  F(cxx_contextual_conversions)                                               \
+  F(cxx_decltype_auto)                                                        \
+  F(cxx_digit_separators)                                                     \
+  F(cxx_generic_lambdas)                                                      \
+  F(cxx_lambda_init_captures)                                                 \
+  F(cxx_relaxed_constexpr)                                                    \
+  F(cxx_return_type_deduction)                                                \
+  F(cxx_variable_templates)
+
+#define FOR_EACH_CXX_FEATURE(F)                                               \
+  F(cxx_std_98)                                                               \
+  F(cxx_std_11)                                                               \
+  F(cxx_std_14)                                                               \
+  F(cxx_std_17)                                                               \
+  F(cxx_std_20)                                                               \
+  FOR_EACH_CXX98_FEATURE(F)                                                   \
+  FOR_EACH_CXX11_FEATURE(F)                                                   \
+  FOR_EACH_CXX14_FEATURE(F)
+
 #endif