cmLocalVisualStudio7Generator.h 5.6 KB

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