mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-30 18:29:37 -06:00
IPO: INTERPROCEDURAL_OPTIMIZATION (LTCG) for Visual Studio
Add IPO support for Visual Studio (which is referred to by VS as "Link Time Code Generation" and "Whole Program Optimization"), for VS version >= 10. This allows CMake/VS users to enable IPO by setting property `INTERPROCEDURAL_OPTIMIZATION`. Fixes: #16748
This commit is contained in:
6
Help/release/dev/vs-ipo.rst
Normal file
6
Help/release/dev/vs-ipo.rst
Normal file
@@ -0,0 +1,6 @@
|
||||
vs-ipo
|
||||
------
|
||||
|
||||
* The :ref:`Visual Studio Generators` for VS 2010 and above learned to
|
||||
support the :prop_tgt:`INTERPROCEDURAL_OPTIMIZATION` target property
|
||||
and supporting :module:`CheckIPOSupported` module.
|
||||
@@ -226,7 +226,7 @@ function(check_ipo_supported)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(CMAKE_GENERATOR MATCHES "^Visual Studio ")
|
||||
if(CMAKE_GENERATOR MATCHES "^Visual Studio 9 ")
|
||||
_ipo_not_supported("CMake doesn't support IPO for current generator")
|
||||
return()
|
||||
endif()
|
||||
|
||||
@@ -111,6 +111,8 @@ public:
|
||||
|
||||
bool FindMakeProgram(cmMakefile* mf) override;
|
||||
|
||||
bool IsIPOSupported() const override { return true; }
|
||||
|
||||
static std::string GetInstalledNsightTegraVersion();
|
||||
|
||||
cmIDEFlagTable const* GetClFlagTable() const;
|
||||
|
||||
@@ -1122,6 +1122,9 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValues(
|
||||
this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_EXTENSIONS")) {
|
||||
e1.Element("WindowsAppContainer", "true");
|
||||
}
|
||||
if (this->IPOEnabledConfigurations.count(config) > 0) {
|
||||
e1.Element("WholeProgramOptimization", "true");
|
||||
}
|
||||
}
|
||||
|
||||
void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged(
|
||||
@@ -2485,8 +2488,10 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
|
||||
clOptions.AddFlag("CompileAs", "CompileAsCpp");
|
||||
}
|
||||
|
||||
// Check IPO related warning/error.
|
||||
this->GeneratorTarget->IsIPOEnabled(linkLanguage, configName);
|
||||
// Put the IPO enabled configurations into a set.
|
||||
if (this->GeneratorTarget->IsIPOEnabled(linkLanguage, configName)) {
|
||||
this->IPOEnabledConfigurations.insert(configName);
|
||||
}
|
||||
|
||||
// Get preprocessor definitions for this directory.
|
||||
std::string defineFlags = this->Makefile->GetDefineFlags();
|
||||
|
||||
@@ -204,6 +204,7 @@ private:
|
||||
bool NsightTegra;
|
||||
unsigned int NsightTegraVersion[4];
|
||||
bool TargetCompileAsWinRT;
|
||||
std::set<std::string> IPOEnabledConfigurations;
|
||||
cmGlobalVisualStudio10Generator* const GlobalGenerator;
|
||||
cmLocalVisualStudio10Generator* const LocalGenerator;
|
||||
std::set<std::string> CSharpCustomCommandNames;
|
||||
|
||||
@@ -5,6 +5,6 @@ run_cmake(CMP0069-NEW-cmake)
|
||||
run_cmake(CMP0069-NEW-compiler)
|
||||
run_cmake(CMP0069-WARN)
|
||||
|
||||
if(RunCMake_GENERATOR MATCHES "^Visual Studio ")
|
||||
if(RunCMake_GENERATOR MATCHES "^Visual Studio 9 ")
|
||||
run_cmake(CMP0069-NEW-generator)
|
||||
endif()
|
||||
|
||||
@@ -8,6 +8,6 @@ run_cmake(not-supported-by-compiler)
|
||||
run_cmake(save-to-result)
|
||||
run_cmake(cmp0069-is-old)
|
||||
|
||||
if(RunCMake_GENERATOR MATCHES "^Visual Studio ")
|
||||
if(RunCMake_GENERATOR MATCHES "^Visual Studio 9 ")
|
||||
run_cmake(not-supported-by-generator)
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user