cmGlobalVisualStudio7Generator.h 6.8 KB

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