1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
13 #include <cm3p/json/value.h>
15 #include "cmGlobalVisualStudioGenerator.h"
18 class cmGeneratorTarget;
19 struct cmIDEFlagTable;
20 class cmLocalGenerator;
26 /** \class cmGlobalVisualStudio7Generator
27 * \brief Write a Unix makefiles.
29 * cmGlobalVisualStudio7Generator manages UNIX build process for a tree
31 class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator
34 ~cmGlobalVisualStudio7Generator();
36 //! Create a local generator appropriate to this Global Generator
37 std::unique_ptr<cmLocalGenerator> CreateLocalGenerator(
38 cmMakefile* mf) override;
40 #if !defined(CMAKE_BOOTSTRAP)
41 Json::Value GetJson() const override;
44 bool SetSystemName(std::string const& s, cmMakefile* mf) override;
47 * Utilized by the generator factory to determine if this generator
50 static bool SupportsToolset() { return false; }
53 * Utilized by the generator factory to determine if this generator
56 static bool SupportsPlatform() { return false; }
59 * Try to determine system information such as shared library
60 * extension, pthreads, byte order etc.
62 void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*,
63 bool optional) override;
66 * Try running cmake and building a file. This is used for dynamically
67 * loaded commands, not as part of the usual build process.
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;
78 * Generate the DSW workspace file.
80 virtual void OutputSLNFile();
82 //! Lookup a stored GUID or compute one deterministically.
83 std::string GetGUID(std::string const& name);
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;
91 //! What is the configurations directory variable called?
92 const char* GetCMakeCFGIntDir() const override
94 return "$(ConfigurationName)";
97 /** Return true if the target project file should have the option
98 LinkLibraryDependencies and link to .sln dependencies. */
99 virtual bool NeedLinkLibraryDependencies(cmGeneratorTarget*)
104 const std::string& GetIntelProjectVersion();
106 bool FindMakeProgram(cmMakefile* mf) override;
108 /** Is the Microsoft Assembler enabled? */
109 bool IsMasmEnabled() const { return this->MasmEnabled; }
110 bool IsNasmEnabled() const { return this->NasmEnabled; }
112 // Encoding for Visual Studio files
113 virtual std::string Encoding();
115 cmIDEFlagTable const* ExtraFlagTable;
118 cmGlobalVisualStudio7Generator(cmake* cm,
119 std::string const& platformInGeneratorName);
121 void Generate() override;
123 std::string const& GetDevEnvCommand();
124 virtual std::string FindDevEnvCommand();
126 static const char* ExternalProjectType(const std::string& location);
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;
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);
155 virtual void WriteExternalProject(
156 std::ostream& fout, const std::string& name, const std::string& path,
158 const std::set<BT<std::pair<std::string, bool>>>& dependencies) = 0;
160 std::string ConvertToSolutionPath(const std::string& path);
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;
170 virtual void WriteFolders(std::ostream& fout);
171 virtual void WriteFoldersContent(std::ostream& fout);
172 std::map<std::string, std::set<std::string>> VisualStudioFolders;
174 // Set during OutputSLNFile with the name of the current project.
175 // There is one SLN file per project.
176 std::string CurrentProject;
181 std::string IntelProjectVersion;
182 std::string DevEnvCommand;
183 bool DevEnvCommandInitialized;
184 std::string GetVSMakeProgram() override { return this->GetDevEnvCommand(); }
187 #define CMAKE_CHECK_BUILD_SYSTEM_TARGET "ZERO_CHECK"