diff options
author | Stephen Kelly <steveire@gmail.com> | 2014-05-05 22:21:14 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2014-05-22 16:01:23 (GMT) |
commit | dd043c3f21fbfab17d7f400bd2bc9f927215b18e (patch) | |
tree | 73f942d1294819f457309e1ccb507a057901a180 /Source | |
parent | 3ea9bde8450a28b58730230e9e73e4b8d439f701 (diff) | |
download | CMake-dd043c3f21fbfab17d7f400bd2bc9f927215b18e.zip CMake-dd043c3f21fbfab17d7f400bd2bc9f927215b18e.tar.gz CMake-dd043c3f21fbfab17d7f400bd2bc9f927215b18e.tar.bz2 |
Features: Add support for C++14 features.
Record the features implemented by GNU 4.9 and Clang 3.4.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmLocalGenerator.cxx | 1 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 33 | ||||
-rw-r--r-- | Source/cmMakefile.h | 2 | ||||
-rw-r--r-- | Source/cmake.h | 11 |
4 files changed, 41 insertions, 6 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index e80b8ee..f83981e 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2222,6 +2222,7 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget* target, if (langStdMap.empty()) { // Maintain sorted order, most recent first. + langStdMap["CXX"].push_back("14"); langStdMap["CXX"].push_back("11"); langStdMap["CXX"].push_back("98"); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 9f33b92..9e72fb8 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4992,6 +4992,7 @@ static const char * const C_STANDARDS[] = { static const char * const CXX_STANDARDS[] = { "98" , "11" + , "14" }; //---------------------------------------------------------------------------- @@ -5214,7 +5215,8 @@ bool cmMakefile::HaveCxxFeatureAvailable(cmTarget const* target, { bool needCxx98 = false; bool needCxx11 = false; - this->CheckNeededCxxLanguage(feature, needCxx98, needCxx11); + bool needCxx14 = false; + this->CheckNeededCxxLanguage(feature, needCxx98, needCxx11, needCxx14); const char *existingCxxStandard = target->GetProperty("CXX_STANDARD"); if (!existingCxxStandard) @@ -5257,7 +5259,8 @@ bool cmMakefile::HaveCxxFeatureAvailable(cmTarget const* target, //---------------------------------------------------------------------------- void cmMakefile::CheckNeededCxxLanguage(const std::string& feature, bool& needCxx98, - bool& needCxx11) const + bool& needCxx11, + bool& needCxx14) const { if (const char *propCxx98 = this->GetDefinition("CMAKE_CXX98_COMPILE_FEATURES")) @@ -5273,6 +5276,13 @@ void cmMakefile::CheckNeededCxxLanguage(const std::string& feature, cmSystemTools::ExpandListArgument(propCxx11, props); needCxx11 = std::find(props.begin(), props.end(), feature) != props.end(); } + if (const char *propCxx14 = + this->GetDefinition("CMAKE_CXX14_COMPILE_FEATURES")) + { + std::vector<std::string> props; + cmSystemTools::ExpandListArgument(propCxx14, props); + needCxx14 = std::find(props.begin(), props.end(), feature) != props.end(); + } } //---------------------------------------------------------------------------- @@ -5282,8 +5292,9 @@ AddRequiredTargetCxxFeature(cmTarget *target, { bool needCxx98 = false; bool needCxx11 = false; + bool needCxx14 = false; - this->CheckNeededCxxLanguage(feature, needCxx98, needCxx11); + this->CheckNeededCxxLanguage(feature, needCxx98, needCxx11, needCxx14); const char *existingCxxStandard = target->GetProperty("CXX_STANDARD"); if (existingCxxStandard) @@ -5306,8 +5317,16 @@ AddRequiredTargetCxxFeature(cmTarget *target, bool setCxx98 = needCxx98 && !existingCxxStandard; bool setCxx11 = needCxx11 && !existingCxxStandard; + bool setCxx14 = needCxx14 && !existingCxxStandard; - if (needCxx11 && existingCxxStandard && existingCxxIt < + if (needCxx14 && existingCxxStandard && existingCxxIt < + std::find_if(cmArrayBegin(CXX_STANDARDS), + cmArrayEnd(CXX_STANDARDS), + cmStrCmp("14"))) + { + setCxx14 = true; + } + else if (needCxx11 && existingCxxStandard && existingCxxIt < std::find_if(cmArrayBegin(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS), cmStrCmp("11"))) @@ -5322,7 +5341,11 @@ AddRequiredTargetCxxFeature(cmTarget *target, setCxx98 = true; } - if (setCxx11) + if (setCxx14) + { + target->SetProperty("CXX_STANDARD", "14"); + } + else if (setCxx11) { target->SetProperty("CXX_STANDARD", "11"); } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 11904a6..6a72663 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -1121,7 +1121,7 @@ private: void CheckNeededCLanguage(const std::string& feature, bool& needC90, bool& needC99, bool& needC11) const; void CheckNeededCxxLanguage(const std::string& feature, bool& needCxx98, - bool& needCxx11) const; + bool& needCxx11, bool& needCxx14) const; bool HaveCFeatureAvailable(cmTarget const* target, const std::string& feature) const; diff --git a/Source/cmake.h b/Source/cmake.h index 33a5d78..3992a9e 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -465,19 +465,25 @@ private: F(c_variadic_macros) #define FOR_EACH_CXX_FEATURE(F) \ + F(cxx_aggregate_default_initializers) \ 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) \ @@ -485,9 +491,11 @@ 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) \ @@ -497,6 +505,8 @@ 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) \ @@ -509,6 +519,7 @@ private: F(cxx_uniform_initialization) \ F(cxx_unrestricted_unions) \ F(cxx_user_literals) \ + F(cxx_variable_templates) \ F(cxx_variadic_macros) \ F(cxx_variadic_templates) |