cmGlobalVisualStudio7Generator.h 6.5 KB

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