cmGlobalVisualStudioGenerator.h 5.7 KB

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