cmLocalVisualStudio7Generator.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #ifndef cmLocalVisualStudio7Generator_h
  4. #define cmLocalVisualStudio7Generator_h
  5. #include "cmConfigure.h" // IWYU pragma: keep
  6. #include <iosfwd>
  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 char* 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. void AddHelperCommands() override;
  44. /**
  45. * Generate the makefile for this directory.
  46. */
  47. void Generate() override;
  48. enum BuildType
  49. {
  50. STATIC_LIBRARY,
  51. DLL,
  52. EXECUTABLE,
  53. WIN32_EXECUTABLE,
  54. UTILITY
  55. };
  56. /**
  57. * Specify the type of the build: static, dll, or executable.
  58. */
  59. void SetBuildType(BuildType, const std::string& name);
  60. std::string GetTargetDirectory(
  61. cmGeneratorTarget const* target) const override;
  62. cmSourceFile* CreateVCProjBuildRule();
  63. void WriteStampFiles();
  64. std::string ComputeLongestObjectDirectory(
  65. cmGeneratorTarget const*) const override;
  66. virtual void ReadAndStoreExternalGUID(const std::string& name,
  67. const char* path);
  68. protected:
  69. void CreateSingleVCProj(const std::string& lname, cmGeneratorTarget* tgt);
  70. private:
  71. using Options = cmVS7GeneratorOptions;
  72. using FCInfo = cmLocalVisualStudio7GeneratorFCInfo;
  73. std::string GetBuildTypeLinkerFlags(std::string rootLinkerFlags,
  74. const std::string& configName);
  75. void FixGlobalTargets();
  76. void WriteProjectFiles();
  77. void WriteVCProjHeader(std::ostream& fout, const std::string& libName,
  78. cmGeneratorTarget* tgt,
  79. std::vector<cmSourceGroup>& sgs);
  80. void WriteVCProjFooter(std::ostream& fout, cmGeneratorTarget* target);
  81. void WriteVCProjFile(std::ostream& fout, const std::string& libName,
  82. cmGeneratorTarget* tgt);
  83. void WriteConfigurations(std::ostream& fout,
  84. std::vector<std::string> const& configs,
  85. const std::string& libName, cmGeneratorTarget* tgt);
  86. void WriteConfiguration(std::ostream& fout, const std::string& configName,
  87. const std::string& libName, cmGeneratorTarget* tgt);
  88. std::string EscapeForXML(const std::string& s);
  89. std::string ConvertToXMLOutputPath(const char* path);
  90. std::string ConvertToXMLOutputPathSingle(const char* path);
  91. void OutputTargetRules(std::ostream& fout, const std::string& configName,
  92. cmGeneratorTarget* target,
  93. const std::string& libName);
  94. void OutputBuildTool(std::ostream& fout, const std::string& configName,
  95. cmGeneratorTarget* t, const Options& targetOptions);
  96. void OutputDeploymentDebuggerTool(std::ostream& fout,
  97. std::string const& config,
  98. cmGeneratorTarget* target);
  99. void OutputLibraryDirectories(std::ostream& fout,
  100. std::vector<std::string> const& dirs);
  101. void WriteProjectSCC(std::ostream& fout, cmGeneratorTarget* target);
  102. void WriteProjectStart(std::ostream& fout, const std::string& libName,
  103. cmGeneratorTarget* tgt,
  104. std::vector<cmSourceGroup>& sgs);
  105. void WriteProjectStartFortran(std::ostream& fout, const std::string& libName,
  106. cmGeneratorTarget* tgt);
  107. void WriteVCProjBeginGroup(std::ostream& fout, const char* group,
  108. const char* filter);
  109. void WriteVCProjEndGroup(std::ostream& fout);
  110. void WriteCustomRule(std::ostream& fout,
  111. std::vector<std::string> const& configs,
  112. const char* source, const cmCustomCommand& command,
  113. FCInfo& fcinfo);
  114. void WriteTargetVersionAttribute(std::ostream& fout, cmGeneratorTarget* gt);
  115. class AllConfigSources;
  116. bool WriteGroup(const cmSourceGroup* sg, cmGeneratorTarget* target,
  117. std::ostream& fout, const std::string& libName,
  118. std::vector<std::string> const& configs,
  119. AllConfigSources const& sources);
  120. friend class cmLocalVisualStudio7GeneratorFCInfo;
  121. friend class cmLocalVisualStudio7GeneratorInternals;
  122. class EventWriter;
  123. friend class EventWriter;
  124. bool FortranProject;
  125. bool WindowsCEProject;
  126. cmLocalVisualStudio7GeneratorInternals* Internal;
  127. };
  128. #endif