cmLocalVisualStudio7Generator.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #ifndef cmLocalVisualStudio7Generator_h
  14. #define cmLocalVisualStudio7Generator_h
  15. #include "cmLocalVisualStudioGenerator.h"
  16. class cmTarget;
  17. class cmSourceFile;
  18. class cmCustomCommand;
  19. class cmSourceGroup;
  20. struct cmVS7FlagTable;
  21. class cmLocalVisualStudio7GeneratorOptions;
  22. class cmLocalVisualStudio7GeneratorFCInfo;
  23. class cmLocalVisualStudio7GeneratorInternals;
  24. /** \class cmLocalVisualStudio7Generator
  25. * \brief Write Visual Studio .NET project files.
  26. *
  27. * cmLocalVisualStudio7Generator produces a Visual Studio .NET project
  28. * file for each target in its directory.
  29. */
  30. class cmLocalVisualStudio7Generator : public cmLocalVisualStudioGenerator
  31. {
  32. public:
  33. ///! Set cache only and recurse to false by default.
  34. cmLocalVisualStudio7Generator();
  35. virtual ~cmLocalVisualStudio7Generator();
  36. virtual void AddHelperCommands();
  37. /**
  38. * Generate the makefile for this directory.
  39. */
  40. virtual void Generate();
  41. enum BuildType {STATIC_LIBRARY, DLL, EXECUTABLE, WIN32_EXECUTABLE, UTILITY};
  42. /**
  43. * Specify the type of the build: static, dll, or executable.
  44. */
  45. void SetBuildType(BuildType,const char *name);
  46. void SetVersion71() {this->Version = 71;}
  47. void SetVersion8() {this->Version = 8;}
  48. void SetVersion9() {this->Version = 9;}
  49. void SetPlatformName(const char* n) { this->PlatformName = n;}
  50. virtual void ConfigureFinalPass();
  51. void GetTargetObjectFileDirectories(cmTarget* target,
  52. std::vector<std::string>&
  53. dirs);
  54. void SetExtraFlagTable(cmVS7FlagTable const* table)
  55. { this->ExtraFlagTable = table; }
  56. private:
  57. typedef cmLocalVisualStudio7GeneratorOptions Options;
  58. typedef cmLocalVisualStudio7GeneratorFCInfo FCInfo;
  59. void ReadAndStoreExternalGUID(const char* name,
  60. const char* path);
  61. std::string GetBuildTypeLinkerFlags(std::string rootLinkerFlags,
  62. const char* configName);
  63. void FixGlobalTargets();
  64. void WriteProjectFiles();
  65. void WriteStampFiles();
  66. void WriteVCProjHeader(std::ostream& fout, const char *libName,
  67. cmTarget &tgt, std::vector<cmSourceGroup> &sgs);
  68. void WriteVCProjFooter(std::ostream& fout);
  69. void CreateSingleVCProj(const char *lname, cmTarget &tgt);
  70. void WriteVCProjFile(std::ostream& fout, const char *libName,
  71. cmTarget &tgt);
  72. cmSourceFile* CreateVCProjBuildRule();
  73. void WriteConfigurations(std::ostream& fout,
  74. const char *libName, cmTarget &tgt);
  75. void WriteConfiguration(std::ostream& fout,
  76. const char* configName,
  77. const char* libName, cmTarget &tgt);
  78. std::string EscapeForXML(const char* s);
  79. std::string ConvertToXMLOutputPath(const char* path);
  80. std::string ConvertToXMLOutputPathSingle(const char* path);
  81. void OutputTargetRules(std::ostream& fout, const char* configName,
  82. cmTarget &target, const char *libName);
  83. void OutputBuildTool(std::ostream& fout, const char* configName,
  84. cmTarget& t);
  85. void OutputLibraryDirectories(std::ostream& fout,
  86. std::vector<std::string> const& dirs);
  87. void OutputModuleDefinitionFile(std::ostream& fout, cmTarget &target);
  88. void WriteProjectStart(std::ostream& fout, const char *libName,
  89. cmTarget &tgt, std::vector<cmSourceGroup> &sgs);
  90. void WriteVCProjBeginGroup(std::ostream& fout,
  91. const char* group,
  92. const char* filter);
  93. void WriteVCProjEndGroup(std::ostream& fout);
  94. void WriteCustomRule(std::ostream& fout,
  95. const char* source,
  96. const cmCustomCommand& command,
  97. FCInfo& fcinfo);
  98. void WriteTargetVersionAttribute(std::ostream& fout, cmTarget& target);
  99. void WriteGroup(const cmSourceGroup *sg,
  100. cmTarget target, std::ostream &fout,
  101. const char *libName, std::vector<std::string> *configs);
  102. virtual std::string GetTargetDirectory(cmTarget const&) const;
  103. friend class cmLocalVisualStudio7GeneratorFCInfo;
  104. friend class cmLocalVisualStudio7GeneratorInternals;
  105. cmVS7FlagTable const* ExtraFlagTable;
  106. std::string ModuleDefinitionFile;
  107. int Version;
  108. std::string PlatformName; // Win32 or x64
  109. cmLocalVisualStudio7GeneratorInternals* Internal;
  110. };
  111. // This is a table mapping XML tag IDE names to command line options
  112. struct cmVS7FlagTable
  113. {
  114. const char* IDEName; // name used in the IDE xml file
  115. const char* commandFlag; // command line flag
  116. const char* comment; // comment
  117. const char* value; // string value
  118. unsigned int special; // flags for special handling requests
  119. enum
  120. {
  121. UserValue = (1<<0), // flag contains a user-specified value
  122. UserIgnored = (1<<1), // ignore any user value
  123. UserRequired = (1<<2), // match only when user value is non-empty
  124. Continue = (1<<3), // continue looking for matching entries
  125. SemicolonAppendable = (1<<4), // a flag that if specified multiple times
  126. // should have its value appended to the
  127. // old value with semicolons (e.g.
  128. // /NODEFAULTLIB: =>
  129. // IgnoreDefaultLibraryNames)
  130. UserValueIgnored = UserValue | UserIgnored,
  131. UserValueRequired = UserValue | UserRequired
  132. };
  133. };
  134. #endif