cmLocalVisualStudio7Generator.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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 "cmConfigure.h" // IWYU pragma: keep
  5. #include <iosfwd>
  6. #include <memory>
  7. #include <string>
  8. #include <vector>
  9. #include "cmLocalVisualStudioGenerator.h"
  10. #include "cmVisualStudioGeneratorOptions.h"
  11. class cmCustomCommand;
  12. class cmGeneratorTarget;
  13. class cmGlobalGenerator;
  14. class cmLocalVisualStudio7GeneratorFCInfo;
  15. class cmLocalVisualStudio7GeneratorInternals;
  16. class cmMakefile;
  17. class cmSourceFile;
  18. class cmSourceGroup;
  19. class cmVS7GeneratorOptions : public cmVisualStudioGeneratorOptions
  20. {
  21. public:
  22. cmVS7GeneratorOptions(cmLocalVisualStudioGenerator* lg, Tool tool,
  23. cmVS7FlagTable const* table = nullptr,
  24. cmVS7FlagTable const* extraTable = nullptr)
  25. : cmVisualStudioGeneratorOptions(lg, tool, table, extraTable)
  26. {
  27. }
  28. void OutputFlag(std::ostream& fout, int indent, const std::string& tag,
  29. const std::string& content) override;
  30. };
  31. /** \class cmLocalVisualStudio7Generator
  32. * \brief Write Visual Studio .NET project files.
  33. *
  34. * cmLocalVisualStudio7Generator produces a Visual Studio .NET project
  35. * file for each target in its directory.
  36. */
  37. class cmLocalVisualStudio7Generator : public cmLocalVisualStudioGenerator
  38. {
  39. public:
  40. //! Set cache only and recurse to false by default.
  41. cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, cmMakefile* mf);
  42. virtual ~cmLocalVisualStudio7Generator();
  43. cmLocalVisualStudio7Generator(const cmLocalVisualStudio7Generator&) = delete;
  44. const cmLocalVisualStudio7Generator& operator=(
  45. const cmLocalVisualStudio7Generator&) = delete;
  46. void AddHelperCommands() override;
  47. /**
  48. * Generate the makefile for this directory.
  49. */
  50. void Generate() override;
  51. enum BuildType
  52. {
  53. STATIC_LIBRARY,
  54. DLL,
  55. EXECUTABLE,
  56. WIN32_EXECUTABLE,
  57. UTILITY
  58. };
  59. /**
  60. * Specify the type of the build: static, dll, or executable.
  61. */
  62. void SetBuildType(BuildType, const std::string& name);
  63. std::string GetTargetDirectory(
  64. cmGeneratorTarget const* target) const override;
  65. cmSourceFile* CreateVCProjBuildRule();
  66. void WriteStampFiles();
  67. std::string ComputeLongestObjectDirectory(
  68. cmGeneratorTarget const*) const override;
  69. virtual void ReadAndStoreExternalGUID(const std::string& name,
  70. const char* path);
  71. std::set<cmSourceFile const*>& GetSourcesVisited(
  72. cmGeneratorTarget const* target)
  73. {
  74. return this->SourcesVisited[target];
  75. };
  76. protected:
  77. virtual void GenerateTarget(cmGeneratorTarget* target);
  78. private:
  79. using Options = cmVS7GeneratorOptions;
  80. using FCInfo = cmLocalVisualStudio7GeneratorFCInfo;
  81. std::string GetBuildTypeLinkerFlags(std::string rootLinkerFlags,
  82. const std::string& configName);
  83. void FixGlobalTargets();
  84. void WriteVCProjHeader(std::ostream& fout, const std::string& libName,
  85. cmGeneratorTarget* tgt,
  86. std::vector<cmSourceGroup>& sgs);
  87. void WriteVCProjFooter(std::ostream& fout, cmGeneratorTarget* target);
  88. void WriteVCProjFile(std::ostream& fout, const std::string& libName,
  89. cmGeneratorTarget* tgt);
  90. void WriteConfigurations(std::ostream& fout,
  91. std::vector<std::string> const& configs,
  92. const std::string& libName, cmGeneratorTarget* tgt);
  93. void WriteConfiguration(std::ostream& fout, const std::string& configName,
  94. const std::string& libName, cmGeneratorTarget* tgt);
  95. std::string EscapeForXML(const std::string& s);
  96. std::string ConvertToXMLOutputPath(const std::string& path);
  97. std::string ConvertToXMLOutputPathSingle(const std::string& path);
  98. void OutputTargetRules(std::ostream& fout, const std::string& configName,
  99. cmGeneratorTarget* target,
  100. const std::string& libName);
  101. void OutputBuildTool(std::ostream& fout, const std::string& configName,
  102. cmGeneratorTarget* t, const Options& targetOptions);
  103. void OutputDeploymentDebuggerTool(std::ostream& fout,
  104. std::string const& config,
  105. cmGeneratorTarget* target);
  106. void OutputLibraryDirectories(std::ostream& fout,
  107. std::vector<std::string> const& dirs);
  108. void WriteProjectSCC(std::ostream& fout, cmGeneratorTarget* target);
  109. void WriteProjectStart(std::ostream& fout, const std::string& libName,
  110. cmGeneratorTarget* tgt,
  111. std::vector<cmSourceGroup>& sgs);
  112. void WriteProjectStartFortran(std::ostream& fout, const std::string& libName,
  113. cmGeneratorTarget* tgt);
  114. void WriteVCProjBeginGroup(std::ostream& fout, const char* group,
  115. const char* filter);
  116. void WriteVCProjEndGroup(std::ostream& fout);
  117. void WriteCustomRule(std::ostream& fout,
  118. std::vector<std::string> const& configs,
  119. const char* source, const cmCustomCommand& command,
  120. FCInfo& fcinfo);
  121. void WriteTargetVersionAttribute(std::ostream& fout, cmGeneratorTarget* gt);
  122. class AllConfigSources;
  123. bool WriteGroup(const cmSourceGroup* sg, cmGeneratorTarget* target,
  124. std::ostream& fout, const std::string& libName,
  125. std::vector<std::string> const& configs,
  126. AllConfigSources const& sources);
  127. friend class cmLocalVisualStudio7GeneratorFCInfo;
  128. friend class cmLocalVisualStudio7GeneratorInternals;
  129. class EventWriter;
  130. friend class EventWriter;
  131. bool FortranProject;
  132. bool WindowsCEProject;
  133. std::unique_ptr<cmLocalVisualStudio7GeneratorInternals> Internal;
  134. std::map<cmGeneratorTarget const*, std::set<cmSourceFile const*>>
  135. SourcesVisited;
  136. };