cmGlobalVisualStudioGenerator.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef cmGlobalVisualStudioGenerator_h
  11. #define cmGlobalVisualStudioGenerator_h
  12. #include "cmGlobalGenerator.h"
  13. /** \class cmGlobalVisualStudioGenerator
  14. * \brief Base class for global Visual Studio generators.
  15. *
  16. * cmGlobalVisualStudioGenerator provides functionality common to all
  17. * global Visual Studio generators.
  18. */
  19. class cmGlobalVisualStudioGenerator : public cmGlobalGenerator
  20. {
  21. public:
  22. /** Known versions of Visual Studio. */
  23. enum VSVersion
  24. {
  25. VS6 = 60,
  26. VS7 = 70,
  27. VS71 = 71,
  28. VS8 = 80,
  29. VS9 = 90,
  30. VS10 = 100,
  31. VS11 = 110,
  32. VS12 = 120,
  33. /* VS13 = 130 was skipped */
  34. VS14 = 140
  35. };
  36. cmGlobalVisualStudioGenerator(cmake* cm);
  37. virtual ~cmGlobalVisualStudioGenerator();
  38. VSVersion GetVersion() const;
  39. void SetVersion(VSVersion v);
  40. /**
  41. * Configure CMake's Visual Studio macros file into the user's Visual
  42. * Studio macros directory.
  43. */
  44. virtual void ConfigureCMakeVisualStudioMacros();
  45. /**
  46. * Where does this version of Visual Studio look for macros for the
  47. * current user? Returns the empty string if this version of Visual
  48. * Studio does not implement support for VB macros.
  49. */
  50. virtual std::string GetUserMacrosDirectory();
  51. /**
  52. * What is the reg key path to "vsmacros" for this version of Visual
  53. * Studio?
  54. */
  55. virtual std::string GetUserMacrosRegKeyBase();
  56. enum MacroName {MacroReload, MacroStop};
  57. /**
  58. * Call the ReloadProjects macro if necessary based on
  59. * GetFilesReplacedDuringGenerate results.
  60. */
  61. void CallVisualStudioMacro(MacroName m,
  62. const char* vsSolutionFile = 0);
  63. // return true if target is fortran only
  64. bool TargetIsFortranOnly(cmTarget const& t);
  65. /** Get the top-level registry key for this VS version. */
  66. std::string GetRegistryBase();
  67. /** Get the top-level registry key for the given VS version. */
  68. static std::string GetRegistryBase(const char* version);
  69. /** Return true if the generated build tree may contain multiple builds.
  70. i.e. "Can I build Debug and Release in the same tree?" */
  71. virtual bool IsMultiConfig() { return true; }
  72. /** Return true if building for Windows CE */
  73. virtual bool TargetsWindowsCE() const { return false; }
  74. class TargetSet: public std::set<cmTarget const*> {};
  75. struct TargetCompare
  76. {
  77. bool operator()(cmGeneratorTarget const* l,
  78. cmGeneratorTarget const* r) const;
  79. };
  80. class OrderedTargetDependSet;
  81. virtual void FindMakeProgram(cmMakefile*);
  82. virtual std::string ExpandCFGIntDir(const std::string& str,
  83. const std::string& config) const;
  84. void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
  85. void AddSymbolExportCommand(
  86. cmGeneratorTarget*, std::vector<cmCustomCommand>& commands,
  87. std::string const& configName);
  88. protected:
  89. virtual void Generate();
  90. // Does this VS version link targets to each other if there are
  91. // dependencies in the SLN file? This was done for VS versions
  92. // below 8.
  93. virtual bool VSLinksDependencies() const { return true; }
  94. virtual const char* GetIDEVersion() = 0;
  95. virtual bool ComputeTargetDepends();
  96. class VSDependSet: public std::set<std::string> {};
  97. class VSDependMap: public std::map<cmTarget const*, VSDependSet> {};
  98. VSDependMap VSTargetDepends;
  99. void ComputeVSTargetDepends(cmTarget&);
  100. bool CheckTargetLinks(cmTarget& target, const std::string& name);
  101. std::string GetUtilityForTarget(cmTarget& target, const std::string&);
  102. virtual std::string WriteUtilityDepend(cmTarget const*) = 0;
  103. std::string GetUtilityDepend(cmTarget const* target);
  104. typedef std::map<cmTarget const*, std::string> UtilityDependsMap;
  105. UtilityDependsMap UtilityDepends;
  106. protected:
  107. VSVersion Version;
  108. private:
  109. virtual std::string GetVSMakeProgram() = 0;
  110. void PrintCompilerAdvice(std::ostream&, std::string const&,
  111. const char*) const {}
  112. void FollowLinkDepends(cmTarget const* target,
  113. std::set<cmTarget const*>& linked);
  114. class TargetSetMap: public std::map<cmTarget*, TargetSet> {};
  115. TargetSetMap TargetLinkClosure;
  116. void FillLinkClosure(cmTarget const* target, TargetSet& linked);
  117. TargetSet const& GetTargetLinkClosure(cmTarget* target);
  118. };
  119. class cmGlobalVisualStudioGenerator::OrderedTargetDependSet:
  120. public std::multiset<cmTargetDepend,
  121. cmGlobalVisualStudioGenerator::TargetCompare>
  122. {
  123. public:
  124. typedef cmGlobalGenerator::TargetDependSet TargetDependSet;
  125. typedef cmGlobalVisualStudioGenerator::TargetSet TargetSet;
  126. OrderedTargetDependSet(TargetDependSet const&);
  127. OrderedTargetDependSet(TargetSet const&);
  128. };
  129. #endif