1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
5 #include "cmConfigure.h" // IWYU pragma: keep
14 #include "cmLocalVisualStudioGenerator.h"
15 #include "cmVisualStudioGeneratorOptions.h"
17 class cmCustomCommand;
18 class cmGeneratorTarget;
19 class cmGlobalGenerator;
20 class cmLocalVisualStudio7GeneratorFCInfo;
21 class cmLocalVisualStudio7GeneratorInternals;
26 class cmVS7GeneratorOptions : public cmVisualStudioGeneratorOptions
29 cmVS7GeneratorOptions(cmLocalVisualStudioGenerator* lg, Tool tool,
30 cmVS7FlagTable const* table = nullptr,
31 cmVS7FlagTable const* extraTable = nullptr)
32 : cmVisualStudioGeneratorOptions(lg, tool, table, extraTable)
35 void OutputFlag(std::ostream& fout, int indent, const std::string& tag,
36 const std::string& content) override;
39 /** \class cmLocalVisualStudio7Generator
40 * \brief Write Visual Studio .NET project files.
42 * cmLocalVisualStudio7Generator produces a Visual Studio .NET project
43 * file for each target in its directory.
45 class cmLocalVisualStudio7Generator : public cmLocalVisualStudioGenerator
48 //! Set cache only and recurse to false by default.
49 cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, cmMakefile* mf);
51 virtual ~cmLocalVisualStudio7Generator();
53 cmLocalVisualStudio7Generator(const cmLocalVisualStudio7Generator&) = delete;
54 const cmLocalVisualStudio7Generator& operator=(
55 const cmLocalVisualStudio7Generator&) = delete;
57 void AddHelperCommands() override;
60 * Generate the makefile for this directory.
62 void Generate() override;
74 * Specify the type of the build: static, dll, or executable.
76 void SetBuildType(BuildType, const std::string& name);
78 std::string GetTargetDirectory(
79 cmGeneratorTarget const* target) const override;
80 cmSourceFile* CreateVCProjBuildRule();
81 void WriteStampFiles();
82 std::string ComputeLongestObjectDirectory(
83 cmGeneratorTarget const*) const override;
85 virtual void ReadAndStoreExternalGUID(const std::string& name,
88 std::set<cmSourceFile const*>& GetSourcesVisited(
89 cmGeneratorTarget const* target)
91 return this->SourcesVisited[target];
95 virtual void GenerateTarget(cmGeneratorTarget* target);
98 using Options = cmVS7GeneratorOptions;
99 using FCInfo = cmLocalVisualStudio7GeneratorFCInfo;
100 std::string GetBuildTypeLinkerFlags(std::string rootLinkerFlags,
101 const std::string& configName);
102 void FixGlobalTargets();
103 void WriteVCProjHeader(std::ostream& fout, const std::string& libName,
104 cmGeneratorTarget* tgt,
105 std::vector<cmSourceGroup>& sgs);
106 void WriteVCProjFooter(std::ostream& fout, cmGeneratorTarget* target);
107 void WriteVCProjFile(std::ostream& fout, const std::string& libName,
108 cmGeneratorTarget* tgt);
109 void WriteConfigurations(std::ostream& fout,
110 std::vector<std::string> const& configs,
111 const std::string& libName, cmGeneratorTarget* tgt);
112 void WriteConfiguration(std::ostream& fout, const std::string& configName,
113 const std::string& libName, cmGeneratorTarget* tgt);
114 std::string EscapeForXML(const std::string& s);
115 std::string ConvertToXMLOutputPath(const std::string& path);
116 std::string ConvertToXMLOutputPathSingle(const std::string& path);
117 void OutputTargetRules(std::ostream& fout, const std::string& configName,
118 cmGeneratorTarget* target,
119 const std::string& libName);
120 void OutputBuildTool(std::ostream& fout, const std::string& configName,
121 cmGeneratorTarget* t, const Options& targetOptions);
122 void OutputDeploymentDebuggerTool(std::ostream& fout,
123 std::string const& config,
124 cmGeneratorTarget* target);
125 void OutputLibraryDirectories(std::ostream& fout,
126 std::vector<std::string> const& dirs);
127 void WriteProjectSCC(std::ostream& fout, cmGeneratorTarget* target);
128 void WriteProjectStart(std::ostream& fout, const std::string& libName,
129 cmGeneratorTarget* tgt,
130 std::vector<cmSourceGroup>& sgs);
131 void WriteProjectStartFortran(std::ostream& fout, const std::string& libName,
132 cmGeneratorTarget* tgt);
133 void WriteVCProjBeginGroup(std::ostream& fout, const char* group,
135 void WriteVCProjEndGroup(std::ostream& fout);
137 void WriteCustomRule(std::ostream& fout,
138 std::vector<std::string> const& configs,
139 const char* source, const cmCustomCommand& command,
141 void WriteTargetVersionAttribute(std::ostream& fout, cmGeneratorTarget* gt);
143 class AllConfigSources;
144 bool WriteGroup(const cmSourceGroup* sg, cmGeneratorTarget* target,
145 std::ostream& fout, const std::string& libName,
146 std::vector<std::string> const& configs,
147 AllConfigSources const& sources);
149 friend class cmLocalVisualStudio7GeneratorFCInfo;
150 friend class cmLocalVisualStudio7GeneratorInternals;
154 friend class EventWriter;
157 bool WindowsCEProject;
158 std::unique_ptr<cmLocalVisualStudio7GeneratorInternals> Internal;
160 std::map<cmGeneratorTarget const*, std::set<cmSourceFile const*>>