diff options
author | Brad King <brad.king@kitware.com> | 2017-06-27 13:20:28 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2017-06-27 13:20:32 (GMT) |
commit | 43c3afa74538fd7b78bcf534bfb3fa93c3c1f191 (patch) | |
tree | 941dae7b8042b688dde062d8c6e9e858ca2d2538 /Source/cmMakefile.cxx | |
parent | dc11a20d7b308f15cc0080f6c14ea06d96dbc2c7 (diff) | |
parent | e03a1b3b6185e36a5905db3d2551c9575fb074aa (diff) | |
download | CMake-43c3afa74538fd7b78bcf534bfb3fa93c3c1f191.zip CMake-43c3afa74538fd7b78bcf534bfb3fa93c3c1f191.tar.gz CMake-43c3afa74538fd7b78bcf534bfb3fa93c3c1f191.tar.bz2 |
Merge topic 'fix-crash-on-non-enabled-language-features'
e03a1b3b target_compile_features: Do not crash on non-enabled language
86990427 Tests: Enable languages explicitly in RunCMake.target_compile_features
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1010
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r-- | Source/cmMakefile.cxx | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 2a93966..4a0cab3 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4191,6 +4191,23 @@ bool cmMakefile::CompileFeatureKnown(cmTarget const* target, const char* cmMakefile::CompileFeaturesAvailable(const std::string& lang, std::string* error) const { + if (!this->GlobalGenerator->GetLanguageEnabled(lang)) { + std::ostringstream e; + if (error) { + e << "cannot"; + } else { + e << "Cannot"; + } + e << " use features from non-enabled language " << lang; + if (error) { + *error = e.str(); + } else { + this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, e.str(), + this->Backtrace); + } + return CM_NULLPTR; + } + const char* featuresKnown = this->GetDefinition("CMAKE_" + lang + "_COMPILE_FEATURES"); @@ -4202,9 +4219,9 @@ const char* cmMakefile::CompileFeaturesAvailable(const std::string& lang, e << "No"; } e << " known features for " << lang << " compiler\n\"" - << this->GetDefinition("CMAKE_" + lang + "_COMPILER_ID") + << this->GetSafeDefinition("CMAKE_" + lang + "_COMPILER_ID") << "\"\nversion " - << this->GetDefinition("CMAKE_" + lang + "_COMPILER_VERSION") << "."; + << this->GetSafeDefinition("CMAKE_" + lang + "_COMPILER_VERSION") << "."; if (error) { *error = e.str(); } else { |