resolve cyclic dependency with zstd
[platform/upstream/cmake.git] / Source / cmLocalVisualStudio7Generator.h
1 /* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2    file Copyright.txt or https://cmake.org/licensing for details.  */
3 #pragma once
4
5 #include "cmConfigure.h" // IWYU pragma: keep
6
7 #include <iosfwd>
8 #include <map>
9 #include <memory>
10 #include <set>
11 #include <string>
12 #include <vector>
13
14 #include "cmLocalVisualStudioGenerator.h"
15 #include "cmVisualStudioGeneratorOptions.h"
16
17 class cmCustomCommand;
18 class cmGeneratorTarget;
19 class cmGlobalGenerator;
20 class cmLocalVisualStudio7GeneratorFCInfo;
21 class cmLocalVisualStudio7GeneratorInternals;
22 class cmMakefile;
23 class cmSourceFile;
24 class cmSourceGroup;
25
26 class cmVS7GeneratorOptions : public cmVisualStudioGeneratorOptions
27 {
28 public:
29   cmVS7GeneratorOptions(cmLocalVisualStudioGenerator* lg, Tool tool,
30                         cmVS7FlagTable const* table = nullptr,
31                         cmVS7FlagTable const* extraTable = nullptr)
32     : cmVisualStudioGeneratorOptions(lg, tool, table, extraTable)
33   {
34   }
35   void OutputFlag(std::ostream& fout, int indent, const std::string& tag,
36                   const std::string& content) override;
37 };
38
39 /** \class cmLocalVisualStudio7Generator
40  * \brief Write Visual Studio .NET project files.
41  *
42  * cmLocalVisualStudio7Generator produces a Visual Studio .NET project
43  * file for each target in its directory.
44  */
45 class cmLocalVisualStudio7Generator : public cmLocalVisualStudioGenerator
46 {
47 public:
48   //! Set cache only and recurse to false by default.
49   cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, cmMakefile* mf);
50
51   virtual ~cmLocalVisualStudio7Generator();
52
53   cmLocalVisualStudio7Generator(const cmLocalVisualStudio7Generator&) = delete;
54   const cmLocalVisualStudio7Generator& operator=(
55     const cmLocalVisualStudio7Generator&) = delete;
56
57   void AddHelperCommands() override;
58
59   /**
60    * Generate the makefile for this directory.
61    */
62   void Generate() override;
63
64   enum BuildType
65   {
66     STATIC_LIBRARY,
67     DLL,
68     EXECUTABLE,
69     WIN32_EXECUTABLE,
70     UTILITY
71   };
72
73   /**
74    * Specify the type of the build: static, dll, or executable.
75    */
76   void SetBuildType(BuildType, const std::string& name);
77
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;
84
85   virtual void ReadAndStoreExternalGUID(const std::string& name,
86                                         const char* path);
87
88   std::set<cmSourceFile const*>& GetSourcesVisited(
89     cmGeneratorTarget const* target)
90   {
91     return this->SourcesVisited[target];
92   };
93
94 protected:
95   virtual void GenerateTarget(cmGeneratorTarget* target);
96
97 private:
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,
134                              const char* filter);
135   void WriteVCProjEndGroup(std::ostream& fout);
136
137   void WriteCustomRule(std::ostream& fout,
138                        std::vector<std::string> const& configs,
139                        const char* source, const cmCustomCommand& command,
140                        FCInfo& fcinfo);
141   void WriteTargetVersionAttribute(std::ostream& fout, cmGeneratorTarget* gt);
142
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);
148
149   friend class cmLocalVisualStudio7GeneratorFCInfo;
150   friend class cmLocalVisualStudio7GeneratorInternals;
151
152   class EventWriter;
153
154   friend class EventWriter;
155
156   bool FortranProject;
157   bool WindowsCEProject;
158   std::unique_ptr<cmLocalVisualStudio7GeneratorInternals> Internal;
159
160   std::map<cmGeneratorTarget const*, std::set<cmSourceFile const*>>
161     SourcesVisited;
162 };