diff options
author | Brad King <brad.king@kitware.com> | 2016-11-30 20:25:01 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-12-02 16:22:46 (GMT) |
commit | ae1a6815b6e2c0a45df51e994b75f9005e1794fe (patch) | |
tree | c8ccf890ced342e9287c8115ac525d062cb6ce0b /Source | |
parent | 684e4d205d64ff8b98c00a1d6a358bffbf509c62 (diff) | |
download | CMake-ae1a6815b6e2c0a45df51e994b75f9005e1794fe.zip CMake-ae1a6815b6e2c0a45df51e994b75f9005e1794fe.tar.gz CMake-ae1a6815b6e2c0a45df51e994b75f9005e1794fe.tar.bz2 |
Features: Add infrastructure for C++ 17 language standard
Issue: #16468
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmLocalGenerator.cxx | 1 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 33 | ||||
-rw-r--r-- | Source/cmMakefile.h | 3 | ||||
-rw-r--r-- | Source/cmake.h | 1 |
4 files changed, 30 insertions, 8 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 46e49dc..ead1e72 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1470,6 +1470,7 @@ void cmLocalGenerator::AddCompilerRequirementFlag( static std::map<std::string, std::vector<std::string> > langStdMap; if (langStdMap.empty()) { // Maintain sorted order, most recent first. + langStdMap["CXX"].push_back("17"); 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 fecc983..ed0f73b 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4064,7 +4064,7 @@ static const char* const CXX_FEATURES[] = { CM_NULLPTR FOR_EACH_CXX_FEATURE( #undef FEATURE_STRING static const char* const C_STANDARDS[] = { "90", "99", "11" }; -static const char* const CXX_STANDARDS[] = { "98", "11", "14" }; +static const char* const CXX_STANDARDS[] = { "98", "11", "14", "17" }; bool cmMakefile::AddRequiredTargetFeature(cmTarget* target, const std::string& feature, @@ -4297,7 +4297,9 @@ bool cmMakefile::HaveCxxStandardAvailable(cmTarget const* target, bool needCxx98 = false; bool needCxx11 = false; bool needCxx14 = false; - this->CheckNeededCxxLanguage(feature, needCxx98, needCxx11, needCxx14); + bool needCxx17 = false; + this->CheckNeededCxxLanguage(feature, needCxx98, needCxx11, needCxx14, + needCxx17); const char* existingCxxStandard = target->GetProperty("CXX_STANDARD"); if (!existingCxxStandard) { @@ -4336,7 +4338,7 @@ bool cmMakefile::HaveCxxStandardAvailable(cmTarget const* target, void cmMakefile::CheckNeededCxxLanguage(const std::string& feature, bool& needCxx98, bool& needCxx11, - bool& needCxx14) const + bool& needCxx14, bool& needCxx17) const { if (const char* propCxx98 = this->GetDefinition("CMAKE_CXX98_COMPILE_FEATURES")) { @@ -4356,6 +4358,12 @@ void cmMakefile::CheckNeededCxxLanguage(const std::string& feature, cmSystemTools::ExpandListArgument(propCxx14, props); needCxx14 = std::find(props.begin(), props.end(), feature) != props.end(); } + if (const char* propCxx17 = + this->GetDefinition("CMAKE_CXX17_COMPILE_FEATURES")) { + std::vector<std::string> props; + cmSystemTools::ExpandListArgument(propCxx17, props); + needCxx17 = std::find(props.begin(), props.end(), feature) != props.end(); + } } bool cmMakefile::AddRequiredTargetCxxFeature(cmTarget* target, @@ -4365,8 +4373,10 @@ bool cmMakefile::AddRequiredTargetCxxFeature(cmTarget* target, bool needCxx98 = false; bool needCxx11 = false; bool needCxx14 = false; + bool needCxx17 = false; - this->CheckNeededCxxLanguage(feature, needCxx98, needCxx11, needCxx14); + this->CheckNeededCxxLanguage(feature, needCxx98, needCxx11, needCxx14, + needCxx17); const char* existingCxxStandard = target->GetProperty("CXX_STANDARD"); if (existingCxxStandard) { @@ -4393,11 +4403,17 @@ bool cmMakefile::AddRequiredTargetCxxFeature(cmTarget* target, bool setCxx98 = needCxx98 && !existingCxxStandard; bool setCxx11 = needCxx11 && !existingCxxStandard; bool setCxx14 = needCxx14 && !existingCxxStandard; + bool setCxx17 = needCxx17 && !existingCxxStandard; - if (needCxx14 && existingCxxStandard && + if (needCxx17 && existingCxxStandard && existingCxxIt < std::find_if(cmArrayBegin(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS), - cmStrCmp("14"))) { + cmStrCmp("17"))) { + setCxx17 = true; + } else 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), @@ -4411,7 +4427,10 @@ bool cmMakefile::AddRequiredTargetCxxFeature(cmTarget* target, setCxx98 = true; } - if (setCxx14) { + if (setCxx17) { + target->SetProperty("CXX_STANDARD", "17"); + target->SetProperty("CUDA_STANDARD", "17"); + } else if (setCxx14) { target->SetProperty("CXX_STANDARD", "14"); target->SetProperty("CUDA_STANDARD", "14"); } else if (setCxx11) { diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 859b3c8..3484e5a 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -905,7 +905,8 @@ private: void CheckNeededCLanguage(const std::string& feature, bool& needC90, bool& needC99, bool& needC11) const; void CheckNeededCxxLanguage(const std::string& feature, bool& needCxx98, - bool& needCxx11, bool& needCxx14) const; + bool& needCxx11, bool& needCxx14, + bool& needCxx17) const; bool HaveCStandardAvailable(cmTarget const* target, const std::string& feature) const; diff --git a/Source/cmake.h b/Source/cmake.h index 0f1891d..5347745 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -549,6 +549,7 @@ private: F(cxx_std_98) \ F(cxx_std_11) \ F(cxx_std_14) \ + F(cxx_std_17) \ F(cxx_aggregate_default_initializers) \ F(cxx_alias_templates) \ F(cxx_alignas) \ |