cmGlobalVisualStudioGenerator.h 4.8 KB

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