cmLocalVisualStudio7Generator.h 6.0 KB

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