MCPcopy Create free account
hub / github.com/Kitware/CMake / IsIPOEnabled

Method IsIPOEnabled

Source/cmGeneratorTarget.cxx:787–862  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

785}
786
787bool cmGeneratorTarget::IsIPOEnabled(std::string const& lang,
788 std::string const& config) const
789{
790 cmValue feature = this->GetFeature("INTERPROCEDURAL_OPTIMIZATION", config);
791
792 if (!feature.IsOn()) {
793 // 'INTERPROCEDURAL_OPTIMIZATION' is off, no need to check policies
794 return false;
795 }
796
797 if (lang != "C" && lang != "CXX" && lang != "CUDA" && lang != "Fortran") {
798 // We do not define IPO behavior for other languages.
799 return false;
800 }
801
802 if (lang == "CUDA") {
803 // CUDA IPO requires both CUDA_ARCHITECTURES and CUDA_SEPARABLE_COMPILATION
804 if (cmIsOff(this->GetSafeProperty("CUDA_ARCHITECTURES")) ||
805 cmIsOff(this->GetSafeProperty("CUDA_SEPARABLE_COMPILATION"))) {
806 return false;
807 }
808 }
809
810 cmPolicies::PolicyStatus cmp0069 = this->GetPolicyStatusCMP0069();
811
812 if (cmp0069 == cmPolicies::OLD || cmp0069 == cmPolicies::WARN) {
813 if (this->Makefile->IsOn(
814 cmStrCat("_CMAKE_", lang, "_IPO_LEGACY_BEHAVIOR"))) {
815 return true;
816 }
817 if (this->PolicyReportedCMP0069) {
818 // problem is already reported, no need to issue a message
819 return false;
820 }
821 bool const in_try_compile =
822 this->LocalGenerator->GetCMakeInstance()->GetIsInTryCompile();
823 if (cmp0069 == cmPolicies::WARN && !in_try_compile) {
824 std::ostringstream w;
825 w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0069) << "\n";
826 w << "INTERPROCEDURAL_OPTIMIZATION property will be ignored for target "
827 << "'" << this->GetName() << "'.";
828 this->LocalGenerator->GetCMakeInstance()->IssueMessage(
829 MessageType::AUTHOR_WARNING, w.str(), this->GetBacktrace());
830
831 this->PolicyReportedCMP0069 = true;
832 }
833 return false;
834 }
835
836 // Note: check consistency with messages from CheckIPOSupported
837 char const* message = nullptr;
838 if (!this->Makefile->IsOn("_CMAKE_" + lang + "_IPO_SUPPORTED_BY_CMAKE")) {
839 message = "CMake doesn't support IPO for current compiler";
840 } else if (!this->Makefile->IsOn("_CMAKE_" + lang +
841 "_IPO_MAY_BE_SUPPORTED_BY_COMPILER")) {
842 message = "Compiler doesn't support IPO";
843 } else if (!this->GlobalGenerator->IsIPOSupported()) {
844 message = "CMake doesn't support IPO for current generator";

Callers 12

CreateBuildSettingsMethod · 0.80
GetDeviceLinkFlagsMethod · 0.80
GetTargetCompileFlagsMethod · 0.80
AppendIPOLinkerFlagsMethod · 0.80
WriteConfigurationMethod · 0.80
ComputeClOptionsMethod · 0.80
DumpLinkMethod · 0.80
DumpArchiveMethod · 0.80

Calls 11

GetFeatureMethod · 0.95
GetBacktraceMethod · 0.95
cmIsOffFunction · 0.85
GetIsInTryCompileMethod · 0.80
strMethod · 0.80
cmStrCatFunction · 0.70
IsOnMethod · 0.45
GetCMakeInstanceMethod · 0.45
GetNameMethod · 0.45
IssueMessageMethod · 0.45
IsIPOSupportedMethod · 0.45

Tested by

no test coverage detected