diff options
author | Brad King <brad.king@kitware.com> | 2017-06-14 14:12:48 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-06-14 14:36:57 (GMT) |
commit | ba247ccabab05c0aad4fe7f56dd020bfa8ff4583 (patch) | |
tree | 259898e83b41d70b454287d01e88923ecb1bbd4e /Source/cmGeneratorTarget.cxx | |
parent | d025faf436c86ee9cc033fbb324a9bc2c18757fa (diff) | |
download | CMake-ba247ccabab05c0aad4fe7f56dd020bfa8ff4583.zip CMake-ba247ccabab05c0aad4fe7f56dd020bfa8ff4583.tar.gz CMake-ba247ccabab05c0aad4fe7f56dd020bfa8ff4583.tar.bz2 |
IPO: Consider support for each language separately
We only define `INTERPROCEDURAL_OPTIMIZATION` behavior for C, CXX, and
Fortran languages. Do not try to enable support for other languages.
Furthermore, each language builds with a different compiler, so check
for support by CMake and the compiler for each language independently.
Fixes: #16944
Diffstat (limited to 'Source/cmGeneratorTarget.cxx')
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c79e113..b93442d 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -469,7 +469,8 @@ const char* cmGeneratorTarget::GetFeature(const std::string& feature, return this->LocalGenerator->GetFeature(feature, config); } -bool cmGeneratorTarget::IsIPOEnabled(const std::string& config) const +bool cmGeneratorTarget::IsIPOEnabled(std::string const& lang, + std::string const& config) const { const char* feature = "INTERPROCEDURAL_OPTIMIZATION"; const bool result = cmSystemTools::IsOn(this->GetFeature(feature, config)); @@ -479,10 +480,15 @@ bool cmGeneratorTarget::IsIPOEnabled(const std::string& config) const return false; } + if (lang != "C" && lang != "CXX" && lang != "Fortran") { + // We do not define IPO behavior for other languages. + return false; + } + cmPolicies::PolicyStatus cmp0069 = this->GetPolicyStatusCMP0069(); if (cmp0069 == cmPolicies::OLD || cmp0069 == cmPolicies::WARN) { - if (this->Makefile->IsOn("_CMAKE_IPO_LEGACY_BEHAVIOR")) { + if (this->Makefile->IsOn("_CMAKE_" + lang + "_IPO_LEGACY_BEHAVIOR")) { return true; } if (this->PolicyReportedCMP0069) { @@ -506,10 +512,10 @@ bool cmGeneratorTarget::IsIPOEnabled(const std::string& config) const // Note: check consistency with messages from CheckIPOSupported const char* message = CM_NULLPTR; - if (!this->Makefile->IsOn("_CMAKE_IPO_SUPPORTED_BY_CMAKE")) { + if (!this->Makefile->IsOn("_CMAKE_" + lang + "_IPO_SUPPORTED_BY_CMAKE")) { message = "CMake doesn't support IPO for current compiler"; - } else if (!this->Makefile->IsOn( - "_CMAKE_IPO_MAY_BE_SUPPORTED_BY_COMPILER")) { + } else if (!this->Makefile->IsOn("_CMAKE_" + lang + + "_IPO_MAY_BE_SUPPORTED_BY_COMPILER")) { message = "Compiler doesn't support IPO"; } else if (!this->GlobalGenerator->IsIPOSupported()) { message = "CMake doesn't support IPO for current generator"; @@ -2417,9 +2423,10 @@ void cmGeneratorTarget::GetAppleArchs(const std::string& config, //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetFeatureSpecificLinkRuleVariable( - std::string const& var, std::string const& config) const + std::string const& var, std::string const& lang, + std::string const& config) const { - if (this->IsIPOEnabled(config)) { + if (this->IsIPOEnabled(lang, config)) { std::string varIPO = var + "_IPO"; if (this->Makefile->IsDefinitionSet(varIPO)) { return varIPO; @@ -2436,7 +2443,7 @@ std::string cmGeneratorTarget::GetCreateRuleVariable( switch (this->GetType()) { case cmStateEnums::STATIC_LIBRARY: { std::string var = "CMAKE_" + lang + "_CREATE_STATIC_LIBRARY"; - return this->GetFeatureSpecificLinkRuleVariable(var, config); + return this->GetFeatureSpecificLinkRuleVariable(var, lang, config); } case cmStateEnums::SHARED_LIBRARY: return "CMAKE_" + lang + "_CREATE_SHARED_LIBRARY"; |