cmLocalVisualStudio7Generator.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. bool IsVFProj() const override { return this->FortranProject; }
  79. protected:
  80. virtual void GenerateTarget(cmGeneratorTarget* target);
  81. private:
  82. using Options = cmVS7GeneratorOptions;
  83. using FCInfo = cmLocalVisualStudio7GeneratorFCInfo;
  84. std::string GetBuildTypeLinkerFlags(std::string const& rootLinkerFlags,
  85. const std::string& configName);
  86. void FixGlobalTargets();
  87. void WriteVCProjHeader(std::ostream& fout, const std::string& libName,
  88. cmGeneratorTarget* tgt,
  89. std::vector<cmSourceGroup>& sgs);
  90. void WriteVCProjFooter(std::ostream& fout, cmGeneratorTarget* target);
  91. void WriteVCProjFile(std::ostream& fout, const std::string& libName,
  92. cmGeneratorTarget* tgt);
  93. void WriteConfigurations(std::ostream& fout,
  94. std::vector<std::string> const& configs,
  95. const std::string& libName, cmGeneratorTarget* tgt);
  96. void WriteConfiguration(std::ostream& fout, const std::string& configName,
  97. const std::string& libName, cmGeneratorTarget* tgt);
  98. std::string EscapeForXML(const std::string& s);
  99. std::string ConvertToXMLOutputPath(const std::string& path);
  100. std::string ConvertToXMLOutputPathSingle(const std::string& path);
  101. void OutputTargetRules(std::ostream& fout, const std::string& configName,
  102. cmGeneratorTarget* target,
  103. const std::string& libName);
  104. void OutputBuildTool(std::ostream& fout, const std::string& configName,
  105. cmGeneratorTarget* t, const Options& targetOptions);
  106. void OutputDeploymentDebuggerTool(std::ostream& fout,
  107. std::string const& config,
  108. cmGeneratorTarget* target);
  109. void OutputLibraryDirectories(std::ostream& fout,
  110. std::vector<std::string> const& dirs);
  111. void WriteProjectSCC(std::ostream& fout, cmGeneratorTarget* target);
  112. void WriteProjectStart(std::ostream& fout, const std::string& libName,
  113. cmGeneratorTarget* tgt,
  114. std::vector<cmSourceGroup>& sgs);
  115. void WriteProjectStartFortran(std::ostream& fout, const std::string& libName,
  116. cmGeneratorTarget* tgt);
  117. void WriteVCProjBeginGroup(std::ostream& fout, const char* group,
  118. const char* filter);
  119. void WriteVCProjEndGroup(std::ostream& fout);
  120. void WriteCustomRule(std::ostream& fout,
  121. std::vector<std::string> const& configs,
  122. const char* source, const cmCustomCommand& command,
  123. FCInfo& fcinfo);
  124. void WriteTargetVersionAttribute(std::ostream& fout, cmGeneratorTarget* gt);
  125. class AllConfigSources;
  126. bool WriteGroup(const cmSourceGroup* sg, cmGeneratorTarget* target,
  127. std::ostream& fout, const std::string& libName,
  128. std::vector<std::string> const& configs,
  129. AllConfigSources const& sources);
  130. friend class cmLocalVisualStudio7GeneratorFCInfo;
  131. friend class cmLocalVisualStudio7GeneratorInternals;
  132. class EventWriter;
  133. friend class EventWriter;
  134. bool FortranProject = false;
  135. bool WindowsCEProject = false;
  136. std::unique_ptr<cmLocalVisualStudio7GeneratorInternals> Internal;
  137. std::map<cmGeneratorTarget const*, std::set<cmSourceFile const*>>
  138. SourcesVisited;
  139. };