cmLocalVisualStudio7Generator.h 5.9 KB

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