cmGlobalVisualStudio7Generator.h 6.6 KB

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