cmLocalVisualStudio7Generator.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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 cmLocalVisualStudio7Generator
  23. * \brief Write Visual Studio .NET project files.
  24. *
  25. * cmLocalVisualStudio7Generator produces a Visual Studio .NET project
  26. * file for each target in its directory.
  27. */
  28. class cmLocalVisualStudio7Generator : public cmLocalVisualStudioGenerator
  29. {
  30. public:
  31. ///! Set cache only and recurse to false by default.
  32. cmLocalVisualStudio7Generator();
  33. virtual ~cmLocalVisualStudio7Generator();
  34. virtual void AddHelperCommands();
  35. /**
  36. * Generate the makefile for this directory.
  37. */
  38. virtual void Generate();
  39. enum BuildType {STATIC_LIBRARY, DLL, EXECUTABLE, WIN32_EXECUTABLE, UTILITY};
  40. /**
  41. * Specify the type of the build: static, dll, or executable.
  42. */
  43. void SetBuildType(BuildType,const char *name);
  44. void SetVersion71() {this->Version = 71;}
  45. void SetVersion8() {this->Version = 8;}
  46. void SetPlatformName(const char* n) { this->PlatformName = n;}
  47. virtual void ConfigureFinalPass();
  48. void GetTargetObjectFileDirectories(cmTarget* target,
  49. std::vector<std::string>&
  50. dirs);
  51. void SetExtraFlagTable(cmVS7FlagTable const* table)
  52. { this->ExtraFlagTable = table; }
  53. private:
  54. typedef cmLocalVisualStudio7GeneratorOptions Options;
  55. void ReadAndStoreExternalGUID(const char* name,
  56. const char* path);
  57. std::string GetBuildTypeLinkerFlags(std::string rootLinkerFlags,
  58. const char* configName);
  59. void FixGlobalTargets();
  60. void OutputVCProjFile();
  61. void WriteVCProjHeader(std::ostream& fout, const char *libName,
  62. cmTarget &tgt, std::vector<cmSourceGroup> &sgs);
  63. void WriteVCProjFooter(std::ostream& fout);
  64. void CreateSingleVCProj(const char *lname, cmTarget &tgt);
  65. void WriteVCProjFile(std::ostream& fout, const char *libName,
  66. cmTarget &tgt);
  67. void AddVCProjBuildRule(cmTarget& tgt);
  68. void WriteConfigurations(std::ostream& fout,
  69. const char *libName, cmTarget &tgt);
  70. void WriteConfiguration(std::ostream& fout,
  71. const char* configName,
  72. const char* libName, cmTarget &tgt);
  73. std::string EscapeForXML(const char* s);
  74. std::string ConvertToXMLOutputPath(const char* path);
  75. std::string ConvertToXMLOutputPathSingle(const char* path);
  76. void OutputTargetRules(std::ostream& fout, const char* configName,
  77. cmTarget &target, const char *libName);
  78. void OutputBuildTool(std::ostream& fout, const char* configName,
  79. cmTarget& t);
  80. void OutputLibraries(std::ostream& fout,
  81. std::vector<cmStdString> const& libs);
  82. void OutputLibraryDirectories(std::ostream& fout,
  83. std::vector<cmStdString> const& dirs);
  84. void OutputModuleDefinitionFile(std::ostream& fout, cmTarget &target);
  85. void WriteProjectStart(std::ostream& fout, const char *libName,
  86. cmTarget &tgt, std::vector<cmSourceGroup> &sgs);
  87. void WriteVCProjBeginGroup(std::ostream& fout,
  88. const char* group,
  89. const char* filter);
  90. void WriteVCProjEndGroup(std::ostream& fout);
  91. void WriteCustomRule(std::ostream& fout,
  92. const char* source,
  93. const cmCustomCommand& command,
  94. const char* extraFlags);
  95. void WriteTargetVersionAttribute(std::ostream& fout, cmTarget& target);
  96. void WriteGroup(const cmSourceGroup *sg,
  97. cmTarget target, std::ostream &fout,
  98. const char *libName, std::vector<std::string> *configs);
  99. virtual std::string GetTargetDirectory(cmTarget const&) const;
  100. cmVS7FlagTable const* ExtraFlagTable;
  101. std::string ModuleDefinitionFile;
  102. int Version;
  103. std::string PlatformName; // Win32 or x64
  104. };
  105. // This is a table mapping XML tag IDE names to command line options
  106. struct cmVS7FlagTable
  107. {
  108. const char* IDEName; // name used in the IDE xml file
  109. const char* commandFlag; // command line flag
  110. const char* comment; // comment
  111. const char* value; // string value
  112. unsigned int special; // flags for special handling requests
  113. enum
  114. {
  115. UserValue = (1<<0), // flag contains a user-specified value
  116. UserIgnored = (1<<1), // ignore any user value
  117. UserRequired = (1<<2), // match only when user value is non-empty
  118. Continue = (1<<3), // continue looking for matching entries
  119. UserValueIgnored = UserValue | UserIgnored,
  120. UserValueRequired = UserValue | UserRequired
  121. };
  122. };
  123. #endif