a55cf45c8bf50aa034f238cef9e1ed1b81938887
[platform/upstream/cmake.git] / Source / cmGlobalVisualStudio7Generator.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 <iosfwd>
6 #include <map>
7 #include <memory>
8 #include <set>
9 #include <string>
10 #include <utility>
11 #include <vector>
12
13 #include <cm3p/json/value.h>
14
15 #include "cmGlobalVisualStudioGenerator.h"
16 #include "cmValue.h"
17
18 class cmGeneratorTarget;
19 struct cmIDEFlagTable;
20 class cmLocalGenerator;
21 class cmMakefile;
22 class cmake;
23 template <typename T>
24 class BT;
25
26 /** \class cmGlobalVisualStudio7Generator
27  * \brief Write a Unix makefiles.
28  *
29  * cmGlobalVisualStudio7Generator manages UNIX build process for a tree
30  */
31 class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator
32 {
33 public:
34   ~cmGlobalVisualStudio7Generator();
35
36   //! Create a local generator appropriate to this Global Generator
37   std::unique_ptr<cmLocalGenerator> CreateLocalGenerator(
38     cmMakefile* mf) override;
39
40 #if !defined(CMAKE_BOOTSTRAP)
41   Json::Value GetJson() const override;
42 #endif
43
44   bool SetSystemName(std::string const& s, cmMakefile* mf) override;
45
46   /**
47    * Utilized by the generator factory to determine if this generator
48    * supports toolsets.
49    */
50   static bool SupportsToolset() { return false; }
51
52   /**
53    * Utilized by the generator factory to determine if this generator
54    * supports platforms.
55    */
56   static bool SupportsPlatform() { return false; }
57
58   /**
59    * Try to determine system information such as shared library
60    * extension, pthreads, byte order etc.
61    */
62   void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*,
63                       bool optional) override;
64
65   /**
66    * Try running cmake and building a file. This is used for dynamically
67    * loaded commands, not as part of the usual build process.
68    */
69   std::vector<GeneratedMakeCommand> GenerateBuildCommand(
70     const std::string& makeProgram, const std::string& projectName,
71     const std::string& projectDir, std::vector<std::string> const& targetNames,
72     const std::string& config, int jobs, bool verbose,
73     const cmBuildOptions& buildOptions = cmBuildOptions(),
74     std::vector<std::string> const& makeOptions =
75       std::vector<std::string>()) override;
76
77   /**
78    * Generate the DSW workspace file.
79    */
80   virtual void OutputSLNFile();
81
82   //! Lookup a stored GUID or compute one deterministically.
83   std::string GetGUID(std::string const& name);
84
85   /** Append the subdirectory for the given configuration.  */
86   void AppendDirectoryForConfig(const std::string& prefix,
87                                 const std::string& config,
88                                 const std::string& suffix,
89                                 std::string& dir) override;
90
91   //! What is the configurations directory variable called?
92   const char* GetCMakeCFGIntDir() const override
93   {
94     return "$(ConfigurationName)";
95   }
96
97   /** Return true if the target project file should have the option
98       LinkLibraryDependencies and link to .sln dependencies. */
99   virtual bool NeedLinkLibraryDependencies(cmGeneratorTarget*)
100   {
101     return false;
102   }
103
104   const std::string& GetIntelProjectVersion();
105
106   bool FindMakeProgram(cmMakefile* mf) override;
107
108   /** Is the Microsoft Assembler enabled?  */
109   bool IsMasmEnabled() const { return this->MasmEnabled; }
110   bool IsNasmEnabled() const { return this->NasmEnabled; }
111
112   // Encoding for Visual Studio files
113   virtual std::string Encoding();
114
115   cmIDEFlagTable const* ExtraFlagTable;
116
117 protected:
118   cmGlobalVisualStudio7Generator(cmake* cm,
119                                  std::string const& platformInGeneratorName);
120
121   void Generate() override;
122
123   std::string const& GetDevEnvCommand();
124   virtual std::string FindDevEnvCommand();
125
126   static const char* ExternalProjectType(const std::string& location);
127
128   virtual void OutputSLNFile(cmLocalGenerator* root,
129                              std::vector<cmLocalGenerator*>& generators);
130   virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root,
131                             std::vector<cmLocalGenerator*>& generators) = 0;
132   virtual void WriteProject(std::ostream& fout, const std::string& name,
133                             const std::string& path,
134                             const cmGeneratorTarget* t) = 0;
135   virtual void WriteProjectDepends(std::ostream& fout, const std::string& name,
136                                    const std::string& path,
137                                    cmGeneratorTarget const* t) = 0;
138   virtual void WriteProjectConfigurations(
139     std::ostream& fout, const std::string& name,
140     cmGeneratorTarget const& target, std::vector<std::string> const& configs,
141     const std::set<std::string>& configsPartOfDefaultBuild,
142     const std::string& platformMapping = "") = 0;
143   virtual void WriteSLNGlobalSections(std::ostream& fout,
144                                       cmLocalGenerator* root);
145   virtual void WriteSLNFooter(std::ostream& fout);
146   std::string WriteUtilityDepend(const cmGeneratorTarget* target) override;
147
148   virtual void WriteTargetsToSolution(
149     std::ostream& fout, cmLocalGenerator* root,
150     OrderedTargetDependSet const& projectTargets);
151   virtual void WriteTargetConfigurations(
152     std::ostream& fout, std::vector<std::string> const& configs,
153     OrderedTargetDependSet const& projectTargets);
154
155   virtual void WriteExternalProject(
156     std::ostream& fout, const std::string& name, const std::string& path,
157     cmValue typeGuid,
158     const std::set<BT<std::pair<std::string, bool>>>& dependencies) = 0;
159
160   std::string ConvertToSolutionPath(const std::string& path);
161
162   std::set<std::string> IsPartOfDefaultBuild(
163     std::vector<std::string> const& configs,
164     OrderedTargetDependSet const& projectTargets,
165     cmGeneratorTarget const* target);
166   bool IsDependedOn(OrderedTargetDependSet const& projectTargets,
167                     cmGeneratorTarget const* target);
168   std::map<std::string, std::string> GUIDMap;
169
170   virtual void WriteFolders(std::ostream& fout);
171   virtual void WriteFoldersContent(std::ostream& fout);
172   std::map<std::string, std::set<std::string>> VisualStudioFolders;
173
174   // Set during OutputSLNFile with the name of the current project.
175   // There is one SLN file per project.
176   std::string CurrentProject;
177   bool MasmEnabled;
178   bool NasmEnabled;
179
180 private:
181   std::string IntelProjectVersion;
182   std::string DevEnvCommand;
183   bool DevEnvCommandInitialized;
184   std::string GetVSMakeProgram() override { return this->GetDevEnvCommand(); }
185 };
186
187 #define CMAKE_CHECK_BUILD_SYSTEM_TARGET "ZERO_CHECK"