cmGlobalVisualStudioGenerator.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. VS7 = 70,
  26. VS71 = 71,
  27. VS8 = 80,
  28. VS9 = 90,
  29. VS10 = 100,
  30. VS11 = 110,
  31. VS12 = 120,
  32. /* VS13 = 130 was skipped */
  33. VS14 = 140
  34. };
  35. cmGlobalVisualStudioGenerator(cmake* cm);
  36. virtual ~cmGlobalVisualStudioGenerator();
  37. VSVersion GetVersion() const;
  38. void SetVersion(VSVersion v);
  39. /**
  40. * Configure CMake's Visual Studio macros file into the user's Visual
  41. * Studio macros directory.
  42. */
  43. virtual void ConfigureCMakeVisualStudioMacros();
  44. /**
  45. * Where does this version of Visual Studio look for macros for the
  46. * current user? Returns the empty string if this version of Visual
  47. * Studio does not implement support for VB macros.
  48. */
  49. virtual std::string GetUserMacrosDirectory();
  50. /**
  51. * What is the reg key path to "vsmacros" for this version of Visual
  52. * Studio?
  53. */
  54. virtual std::string GetUserMacrosRegKeyBase();
  55. enum MacroName {MacroReload, MacroStop};
  56. /**
  57. * Call the ReloadProjects macro if necessary based on
  58. * GetFilesReplacedDuringGenerate results.
  59. */
  60. void CallVisualStudioMacro(MacroName m,
  61. const char* vsSolutionFile = 0);
  62. // return true if target is fortran only
  63. bool TargetIsFortranOnly(const cmGeneratorTarget *gt);
  64. /** Get the top-level registry key for this VS version. */
  65. std::string GetRegistryBase();
  66. /** Get the top-level registry key for the given VS version. */
  67. static std::string GetRegistryBase(const char* version);
  68. /** Return true if the generated build tree may contain multiple builds.
  69. i.e. "Can I build Debug and Release in the same tree?" */
  70. virtual bool IsMultiConfig() { return true; }
  71. /** Return true if building for Windows CE */
  72. virtual bool TargetsWindowsCE() const { return false; }
  73. class TargetSet: public std::set<cmGeneratorTarget const*> {};
  74. class TargetCompare
  75. {
  76. std::string First;
  77. public:
  78. TargetCompare(std::string const& first): First(first) {}
  79. bool operator()(cmGeneratorTarget const* l,
  80. cmGeneratorTarget const* r) const;
  81. };
  82. class OrderedTargetDependSet;
  83. virtual void FindMakeProgram(cmMakefile*);
  84. virtual std::string ExpandCFGIntDir(const std::string& str,
  85. const std::string& config) const;
  86. void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
  87. void AddSymbolExportCommand(
  88. cmGeneratorTarget*, std::vector<cmCustomCommand>& commands,
  89. std::string const& configName);
  90. protected:
  91. virtual void AddExtraIDETargets();
  92. // Does this VS version link targets to each other if there are
  93. // dependencies in the SLN file? This was done for VS versions
  94. // below 8.
  95. virtual bool VSLinksDependencies() const { return true; }
  96. virtual const char* GetIDEVersion() = 0;
  97. virtual bool ComputeTargetDepends();
  98. class VSDependSet: public std::set<std::string> {};
  99. class VSDependMap: public std::map<cmGeneratorTarget const*, VSDependSet> {};
  100. VSDependMap VSTargetDepends;
  101. void ComputeVSTargetDepends(cmGeneratorTarget *);
  102. bool CheckTargetLinks(cmGeneratorTarget& target, const std::string& name);
  103. std::string GetUtilityForTarget(cmGeneratorTarget& target,
  104. const std::string&);
  105. virtual std::string WriteUtilityDepend(cmGeneratorTarget const*) = 0;
  106. std::string GetUtilityDepend(const cmGeneratorTarget *target);
  107. typedef std::map<cmGeneratorTarget const*, std::string> UtilityDependsMap;
  108. UtilityDependsMap UtilityDepends;
  109. protected:
  110. VSVersion Version;
  111. private:
  112. virtual std::string GetVSMakeProgram() = 0;
  113. void PrintCompilerAdvice(std::ostream&, std::string const&,
  114. const char*) const {}
  115. void FollowLinkDepends(cmGeneratorTarget const* target,
  116. std::set<cmGeneratorTarget const*>& linked);
  117. class TargetSetMap: public std::map<cmGeneratorTarget*, TargetSet> {};
  118. TargetSetMap TargetLinkClosure;
  119. void FillLinkClosure(const cmGeneratorTarget *target,
  120. TargetSet& linked);
  121. TargetSet const& GetTargetLinkClosure(cmGeneratorTarget* target);
  122. };
  123. class cmGlobalVisualStudioGenerator::OrderedTargetDependSet:
  124. public std::multiset<cmTargetDepend,
  125. cmGlobalVisualStudioGenerator::TargetCompare>
  126. {
  127. typedef std::multiset<cmTargetDepend,
  128. cmGlobalVisualStudioGenerator::TargetCompare>
  129. derived;
  130. public:
  131. typedef cmGlobalGenerator::TargetDependSet TargetDependSet;
  132. typedef cmGlobalVisualStudioGenerator::TargetSet TargetSet;
  133. OrderedTargetDependSet(TargetDependSet const&, std::string const& first);
  134. OrderedTargetDependSet(TargetSet const&, std::string const& first);
  135. };
  136. #endif