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

Method WriteCustomRule

Source/cmLocalVisualStudio7Generator.cxx:1814–1893  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1812}
1813
1814void cmLocalVisualStudio7Generator::WriteCustomRule(
1815 std::ostream& fout, std::vector<std::string> const& configs,
1816 char const* source, cmCustomCommand const& command, FCInfo& fcinfo)
1817{
1818 cmGlobalVisualStudio7Generator* gg =
1819 static_cast<cmGlobalVisualStudio7Generator*>(this->GlobalGenerator);
1820
1821 // Write the rule for each configuration.
1822 char const* compileTool = "VCCLCompilerTool";
1823 if (this->FortranProject) {
1824 compileTool = "VFCLCompilerTool";
1825 }
1826 char const* customTool = "VCCustomBuildTool";
1827 if (this->FortranProject) {
1828 customTool = "VFCustomBuildTool";
1829 }
1830 for (std::string const& config : configs) {
1831 cmCustomCommandGenerator ccg(command, config, this);
1832 cmLVS7GFileConfig const& fc = fcinfo.FileConfigMap[config];
1833 fout << "\t\t\t\t<FileConfiguration\n"
1834 "\t\t\t\t\tName=\""
1835 << config << '|' << gg->GetPlatformName() << "\">\n";
1836 if (!fc.CompileFlags.empty()) {
1837 fout << "\t\t\t\t\t<Tool\n"
1838 "\t\t\t\t\tName=\""
1839 << compileTool
1840 << "\"\n"
1841 "\t\t\t\t\tAdditionalOptions=\""
1842 << this->EscapeForXML(fc.CompileFlags) << "\"/>\n";
1843 }
1844
1845 std::string comment = this->ConstructComment(ccg);
1846 std::string script = this->ConstructScript(ccg);
1847 if (this->FortranProject) {
1848 cmSystemTools::ReplaceString(script, "$(Configuration)", config);
1849 }
1850 script += this->FinishConstructScript(VsProjectType::vcxproj);
1851 /* clang-format off */
1852 fout << "\t\t\t\t\t<Tool\n"
1853 "\t\t\t\t\tName=\"" << customTool << "\"\n"
1854 << "\t\t\t\t\tDescription=\""
1855 << this->EscapeForXML(comment) << "\"\n"
1856 "\t\t\t\t\tCommandLine=\""
1857 << this->EscapeForXML(script) << "\"\n"
1858 "\t\t\t\t\tAdditionalDependencies=\"";
1859 /* clang-format on */
1860 if (ccg.GetDepends().empty()) {
1861 // There are no real dependencies. Produce an artificial one to
1862 // make sure the rule runs reliably.
1863 if (!cmSystemTools::FileExists(source)) {
1864 cmsys::ofstream depout(source);
1865 depout << "Artificial dependency for a custom command.\n";
1866 }
1867 fout << this->ConvertToXMLOutputPath(source);
1868 } else {
1869 // Write out the dependencies for the rule.
1870 for (std::string const& d : ccg.GetDepends()) {
1871 // Get the real name of the dependency in case it is a CMake target.

Callers 1

WriteGroupMethod · 0.95

Calls 10

EscapeForXMLMethod · 0.95
ConstructCommentMethod · 0.80
FinishConstructScriptMethod · 0.80
GetDependsMethod · 0.80
GetRealDependencyMethod · 0.80
FileExistsFunction · 0.50
emptyMethod · 0.45
ConstructScriptMethod · 0.45

Tested by

no test coverage detected