cmGlobalVisualStudioGenerator.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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
  56. {
  57. MacroReload,
  58. MacroStop
  59. };
  60. /**
  61. * Call the ReloadProjects macro if necessary based on
  62. * GetFilesReplacedDuringGenerate results.
  63. */
  64. void CallVisualStudioMacro(MacroName m, const char* vsSolutionFile = 0);
  65. // return true if target is fortran only
  66. bool TargetIsFortranOnly(const cmGeneratorTarget* gt);
  67. /** Get the top-level registry key for this VS version. */
  68. std::string GetRegistryBase();
  69. /** Get the top-level registry key for the given VS version. */
  70. static std::string GetRegistryBase(const char* version);
  71. /** Return true if the generated build tree may contain multiple builds.
  72. i.e. "Can I build Debug and Release in the same tree?" */
  73. virtual bool IsMultiConfig() const { return true; }
  74. /** Return true if building for Windows CE */
  75. virtual bool TargetsWindowsCE() const { return false; }
  76. class TargetSet : public std::set<cmGeneratorTarget const*>
  77. {
  78. };
  79. class TargetCompare
  80. {
  81. std::string First;
  82. public:
  83. TargetCompare(std::string const& first)
  84. : First(first)
  85. {
  86. }
  87. bool operator()(cmGeneratorTarget const* l,
  88. cmGeneratorTarget const* r) const;
  89. };
  90. class OrderedTargetDependSet;
  91. virtual void FindMakeProgram(cmMakefile*);
  92. virtual std::string ExpandCFGIntDir(const std::string& str,
  93. const std::string& config) const;
  94. void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
  95. std::string GetStartupProjectName(cmLocalGenerator const* root) const;
  96. void AddSymbolExportCommand(cmGeneratorTarget*,
  97. std::vector<cmCustomCommand>& commands,
  98. std::string const& configName);
  99. protected:
  100. virtual void AddExtraIDETargets();
  101. // Does this VS version link targets to each other if there are
  102. // dependencies in the SLN file? This was done for VS versions
  103. // below 8.
  104. virtual bool VSLinksDependencies() const { return true; }
  105. virtual const char* GetIDEVersion() = 0;
  106. virtual bool ComputeTargetDepends();
  107. class VSDependSet : public std::set<std::string>
  108. {
  109. };
  110. class VSDependMap : public std::map<cmGeneratorTarget const*, VSDependSet>
  111. {
  112. };
  113. VSDependMap VSTargetDepends;
  114. void ComputeVSTargetDepends(cmGeneratorTarget*);
  115. bool CheckTargetLinks(cmGeneratorTarget& target, const std::string& name);
  116. std::string GetUtilityForTarget(cmGeneratorTarget& target,
  117. const std::string&);
  118. virtual std::string WriteUtilityDepend(cmGeneratorTarget const*) = 0;
  119. std::string GetUtilityDepend(const cmGeneratorTarget* target);
  120. typedef std::map<cmGeneratorTarget const*, std::string> UtilityDependsMap;
  121. UtilityDependsMap UtilityDepends;
  122. protected:
  123. VSVersion Version;
  124. private:
  125. virtual std::string GetVSMakeProgram() = 0;
  126. void PrintCompilerAdvice(std::ostream&, std::string const&,
  127. const char*) const
  128. {
  129. }
  130. void FollowLinkDepends(cmGeneratorTarget const* target,
  131. std::set<cmGeneratorTarget const*>& linked);
  132. class TargetSetMap : public std::map<cmGeneratorTarget*, TargetSet>
  133. {
  134. };
  135. TargetSetMap TargetLinkClosure;
  136. void FillLinkClosure(const cmGeneratorTarget* target, TargetSet& linked);
  137. TargetSet const& GetTargetLinkClosure(cmGeneratorTarget* target);
  138. };
  139. class cmGlobalVisualStudioGenerator::OrderedTargetDependSet
  140. : public std::multiset<cmTargetDepend,
  141. cmGlobalVisualStudioGenerator::TargetCompare>
  142. {
  143. typedef std::multiset<cmTargetDepend,
  144. cmGlobalVisualStudioGenerator::TargetCompare>
  145. derived;
  146. public:
  147. typedef cmGlobalGenerator::TargetDependSet TargetDependSet;
  148. typedef cmGlobalVisualStudioGenerator::TargetSet TargetSet;
  149. OrderedTargetDependSet(TargetDependSet const&, std::string const& first);
  150. OrderedTargetDependSet(TargetSet const&, std::string const& first);
  151. };
  152. #endif