cmGlobalVisualStudio7Generator.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file LICENSE.rst or https://cmake.org/licensing for details. */
  3. #pragma once
  4. #include <iosfwd>
  5. #include <map>
  6. #include <memory>
  7. #include <set>
  8. #include <string>
  9. #include <utility>
  10. #include <vector>
  11. #include <cm/optional>
  12. #include <cm3p/json/value.h>
  13. #include "cmGlobalVisualStudioGenerator.h"
  14. #include "cmValue.h"
  15. class cmGeneratorTarget;
  16. struct cmIDEFlagTable;
  17. class cmLocalGenerator;
  18. class cmMakefile;
  19. class cmake;
  20. template <typename T>
  21. class BT;
  22. struct cmVisualStudioFolder
  23. {
  24. std::set<std::string> Projects;
  25. std::set<std::string> SolutionItems;
  26. };
  27. /** \class cmGlobalVisualStudio7Generator
  28. * \brief Write a Unix makefiles.
  29. *
  30. * cmGlobalVisualStudio7Generator manages UNIX build process for a tree
  31. */
  32. class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator
  33. {
  34. public:
  35. ~cmGlobalVisualStudio7Generator() override;
  36. //! Create a local generator appropriate to this Global Generator
  37. std::unique_ptr<cmLocalGenerator> CreateLocalGenerator(
  38. cmMakefile* mf) override;
  39. #if !defined(CMAKE_BOOTSTRAP)
  40. Json::Value GetJson() const override;
  41. #endif
  42. bool SetSystemName(std::string const& s, cmMakefile* mf) override;
  43. /**
  44. * Utilized by the generator factory to determine if this generator
  45. * supports toolsets.
  46. */
  47. static bool SupportsToolset() { return false; }
  48. /**
  49. * Utilized by the generator factory to determine if this generator
  50. * supports platforms.
  51. */
  52. static bool SupportsPlatform() { return false; }
  53. /**
  54. * Try to determine system information such as shared library
  55. * extension, pthreads, byte order etc.
  56. */
  57. void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*,
  58. bool optional) override;
  59. /**
  60. * Try running cmake and building a file. This is used for dynamically
  61. * loaded commands, not as part of the usual build process.
  62. */
  63. std::vector<GeneratedMakeCommand> GenerateBuildCommand(
  64. std::string const& makeProgram, std::string const& projectName,
  65. std::string const& projectDir, std::vector<std::string> const& targetNames,
  66. std::string const& config, int jobs, bool verbose,
  67. cmBuildOptions buildOptions = cmBuildOptions(),
  68. std::vector<std::string> const& makeOptions =
  69. std::vector<std::string>()) override;
  70. /** Append the subdirectory for the given configuration. */
  71. void AppendDirectoryForConfig(std::string const& prefix,
  72. std::string const& config,
  73. std::string const& suffix,
  74. std::string& dir) override;
  75. //! What is the configurations directory variable called?
  76. char const* GetCMakeCFGIntDir() const override
  77. {
  78. return "$(ConfigurationName)";
  79. }
  80. /** Return true if the target project file should have the option
  81. LinkLibraryDependencies and link to .sln dependencies. */
  82. virtual bool NeedLinkLibraryDependencies(cmGeneratorTarget*)
  83. {
  84. return false;
  85. }
  86. std::string const& GetIntelProjectVersion();
  87. virtual cm::optional<std::string> GetPlatformToolsetFortran() const
  88. {
  89. return cm::nullopt;
  90. }
  91. bool FindMakeProgram(cmMakefile* mf) override;
  92. /** Is the Microsoft Assembler enabled? */
  93. bool IsMarmasmEnabled() const { return this->MarmasmEnabled; }
  94. bool IsMasmEnabled() const { return this->MasmEnabled; }
  95. bool IsNasmEnabled() const { return this->NasmEnabled; }
  96. // Encoding for Visual Studio files
  97. virtual std::string Encoding();
  98. cmIDEFlagTable const* ExtraFlagTable;
  99. virtual bool SupportsCxxModuleDyndep() const { return false; }
  100. protected:
  101. cmGlobalVisualStudio7Generator(cmake* cm);
  102. void Generate() override;
  103. struct VSFolders
  104. {
  105. std::map<std::string, cmVisualStudioFolder> Folders;
  106. cmVisualStudioFolder* Create(std::string const& path);
  107. };
  108. std::string const& GetDevEnvCommand();
  109. virtual std::string FindDevEnvCommand();
  110. static char const* ExternalProjectType(std::string const& location);
  111. virtual void OutputSLNFile(cmLocalGenerator* root,
  112. std::vector<cmLocalGenerator*>& generators);
  113. virtual void WriteSLNFile(
  114. std::ostream& fout, cmLocalGenerator* root,
  115. OrderedTargetDependSet const& orderedProjectTargets,
  116. VSFolders const& vsFolders) const = 0;
  117. virtual void WriteProject(std::ostream& fout, std::string const& name,
  118. std::string const& path,
  119. cmGeneratorTarget const* t) const = 0;
  120. virtual void WriteProjectDepends(std::ostream& fout, std::string const& name,
  121. std::string const& path,
  122. cmGeneratorTarget const* t) const = 0;
  123. virtual void WriteProjectConfigurations(
  124. std::ostream& fout, std::string const& name,
  125. cmGeneratorTarget const& target, std::vector<std::string> const& configs,
  126. std::set<std::string> const& configsPartOfDefaultBuild,
  127. std::string const& platformMapping = "") const = 0;
  128. virtual void WriteSLNGlobalSections(std::ostream& fout,
  129. cmLocalGenerator* root) const;
  130. virtual void WriteSLNFooter(std::ostream& fout) const;
  131. VSFolders CreateSolutionFolders(
  132. OrderedTargetDependSet const& orderedProjectTargets);
  133. virtual void WriteTargetsToSolution(
  134. std::ostream& fout, cmLocalGenerator* root,
  135. OrderedTargetDependSet const& projectTargets) const;
  136. virtual void WriteTargetConfigurations(
  137. std::ostream& fout, std::vector<std::string> const& configs,
  138. OrderedTargetDependSet const& projectTargets) const;
  139. virtual void WriteExternalProject(
  140. std::ostream& fout, std::string const& name, std::string const& path,
  141. cmValue typeGuid,
  142. std::set<BT<std::pair<std::string, bool>>> const& dependencies) const = 0;
  143. virtual void WriteFolders(std::ostream& fout,
  144. VSFolders const& vsFolders) const;
  145. virtual void WriteFoldersContent(std::ostream& fout,
  146. VSFolders const& vsFolders) const;
  147. virtual void AddSolutionItems(cmLocalGenerator* root,
  148. VSFolders& vsFolders) = 0;
  149. virtual void WriteFolderSolutionItems(
  150. std::ostream& fout, cmVisualStudioFolder const& folder) const = 0;
  151. bool MarmasmEnabled;
  152. bool MasmEnabled;
  153. bool NasmEnabled;
  154. private:
  155. std::string IntelProjectVersion;
  156. std::string DevEnvCommand;
  157. bool DevEnvCommandInitialized;
  158. std::string GetVSMakeProgram() override { return this->GetDevEnvCommand(); }
  159. };
  160. #define CMAKE_CHECK_BUILD_SYSTEM_TARGET "ZERO_CHECK"