cmGlobalVisualStudio7Generator.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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();
  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, bool fast, int jobs, bool verbose,
  61. std::vector<std::string> const& makeOptions =
  62. std::vector<std::string>()) override;
  63. /**
  64. * Generate the DSW workspace file.
  65. */
  66. virtual void OutputSLNFile();
  67. //! Lookup a stored GUID or compute one deterministically.
  68. std::string GetGUID(std::string const& name);
  69. /** Append the subdirectory for the given configuration. */
  70. void AppendDirectoryForConfig(const std::string& prefix,
  71. const std::string& config,
  72. const std::string& suffix,
  73. std::string& dir) override;
  74. //! What is the configurations directory variable called?
  75. const char* GetCMakeCFGIntDir() const override
  76. {
  77. return "$(ConfigurationName)";
  78. }
  79. /** Return true if the target project file should have the option
  80. LinkLibraryDependencies and link to .sln dependencies. */
  81. virtual bool NeedLinkLibraryDependencies(cmGeneratorTarget*)
  82. {
  83. return false;
  84. }
  85. const std::string& GetIntelProjectVersion();
  86. bool FindMakeProgram(cmMakefile* mf) override;
  87. /** Is the Microsoft Assembler enabled? */
  88. bool IsMasmEnabled() const { return this->MasmEnabled; }
  89. bool IsNasmEnabled() const { return this->NasmEnabled; }
  90. // Encoding for Visual Studio files
  91. virtual std::string Encoding();
  92. cmIDEFlagTable const* ExtraFlagTable;
  93. protected:
  94. cmGlobalVisualStudio7Generator(cmake* cm,
  95. std::string const& platformInGeneratorName);
  96. void Generate() override;
  97. std::string const& GetDevEnvCommand();
  98. virtual std::string FindDevEnvCommand();
  99. static const char* ExternalProjectType(const std::string& location);
  100. virtual void OutputSLNFile(cmLocalGenerator* root,
  101. std::vector<cmLocalGenerator*>& generators);
  102. virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root,
  103. std::vector<cmLocalGenerator*>& generators) = 0;
  104. virtual void WriteProject(std::ostream& fout, const std::string& name,
  105. const std::string& path,
  106. const cmGeneratorTarget* t) = 0;
  107. virtual void WriteProjectDepends(std::ostream& fout, const std::string& name,
  108. const std::string& path,
  109. cmGeneratorTarget const* t) = 0;
  110. virtual void WriteProjectConfigurations(
  111. std::ostream& fout, const std::string& name,
  112. cmGeneratorTarget const& target, std::vector<std::string> const& configs,
  113. const std::set<std::string>& configsPartOfDefaultBuild,
  114. const std::string& platformMapping = "") = 0;
  115. virtual void WriteSLNGlobalSections(std::ostream& fout,
  116. cmLocalGenerator* root);
  117. virtual void WriteSLNFooter(std::ostream& fout);
  118. std::string WriteUtilityDepend(const cmGeneratorTarget* target) override;
  119. virtual void WriteTargetsToSolution(
  120. std::ostream& fout, cmLocalGenerator* root,
  121. OrderedTargetDependSet const& projectTargets);
  122. virtual void WriteTargetDepends(
  123. std::ostream& fout, OrderedTargetDependSet const& projectTargets);
  124. virtual void WriteTargetConfigurations(
  125. std::ostream& fout, std::vector<std::string> const& configs,
  126. OrderedTargetDependSet const& projectTargets);
  127. virtual void WriteExternalProject(
  128. std::ostream& fout, const std::string& name, const std::string& path,
  129. cmValue typeGuid,
  130. const std::set<BT<std::pair<std::string, bool>>>& dependencies) = 0;
  131. std::string ConvertToSolutionPath(const std::string& path);
  132. std::set<std::string> IsPartOfDefaultBuild(
  133. std::vector<std::string> const& configs,
  134. OrderedTargetDependSet const& projectTargets,
  135. cmGeneratorTarget const* target);
  136. bool IsDependedOn(OrderedTargetDependSet const& projectTargets,
  137. cmGeneratorTarget const* target);
  138. std::map<std::string, std::string> GUIDMap;
  139. virtual void WriteFolders(std::ostream& fout);
  140. virtual void WriteFoldersContent(std::ostream& fout);
  141. std::map<std::string, std::set<std::string>> VisualStudioFolders;
  142. // Set during OutputSLNFile with the name of the current project.
  143. // There is one SLN file per project.
  144. std::string CurrentProject;
  145. bool MasmEnabled;
  146. bool NasmEnabled;
  147. private:
  148. std::string IntelProjectVersion;
  149. std::string DevEnvCommand;
  150. bool DevEnvCommandInitialized;
  151. std::string GetVSMakeProgram() override { return this->GetDevEnvCommand(); }
  152. };
  153. #define CMAKE_CHECK_BUILD_SYSTEM_TARGET "ZERO_CHECK"