cebf7d7414b06b557975de0e9bd682e80830d8e2
[platform/upstream/cmake.git] / Source / cmGlobalVisualStudioGenerator.h
1 /*============================================================================
2   CMake - Cross Platform Makefile Generator
3   Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
4
5   Distributed under the OSI-approved BSD License (the "License");
6   see accompanying file Copyright.txt for details.
7
8   This software is distributed WITHOUT ANY WARRANTY; without even the
9   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10   See the License for more information.
11 ============================================================================*/
12 #ifndef cmGlobalVisualStudioGenerator_h
13 #define cmGlobalVisualStudioGenerator_h
14
15 #include "cmGlobalGenerator.h"
16
17 /** \class cmGlobalVisualStudioGenerator
18  * \brief Base class for global Visual Studio generators.
19  *
20  * cmGlobalVisualStudioGenerator provides functionality common to all
21  * global Visual Studio generators.
22  */
23 class cmGlobalVisualStudioGenerator : public cmGlobalGenerator
24 {
25 public:
26   cmGlobalVisualStudioGenerator();
27   virtual ~cmGlobalVisualStudioGenerator();
28
29   /**
30    * Basic generate implementation for all VS generators.
31    */
32   virtual void Generate();
33
34   /**
35    * Configure CMake's Visual Studio macros file into the user's Visual
36    * Studio macros directory.
37    */
38   virtual void ConfigureCMakeVisualStudioMacros();
39
40   /**
41    * Where does this version of Visual Studio look for macros for the
42    * current user? Returns the empty string if this version of Visual
43    * Studio does not implement support for VB macros.
44    */
45   virtual std::string GetUserMacrosDirectory();
46
47   /**
48    * What is the reg key path to "vsmacros" for this version of Visual
49    * Studio?
50    */
51   virtual std::string GetUserMacrosRegKeyBase();
52
53   enum MacroName {MacroReload, MacroStop};
54
55   /**
56    * Call the ReloadProjects macro if necessary based on
57    * GetFilesReplacedDuringGenerate results.
58    */
59   virtual void CallVisualStudioMacro(MacroName m,
60                                      const char* vsSolutionFile = 0);
61
62   // return true if target is fortran only
63   bool TargetIsFortranOnly(cmTarget& t);
64
65   /** Get the top-level registry key for this VS version.  */
66   std::string GetRegistryBase();
67
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
72   class TargetSet: public std::set<cmTarget*> {};
73   struct TargetCompare
74   {
75     bool operator()(cmTarget const* l, cmTarget const* r) const;
76   };
77   class OrderedTargetDependSet;
78
79 protected:
80   // Does this VS version link targets to each other if there are
81   // dependencies in the SLN file?  This was done for VS versions
82   // below 8.
83   virtual bool VSLinksDependencies() const { return true; }
84
85   virtual const char* GetIDEVersion() = 0;
86
87   virtual void AddPlatformDefinitions(cmMakefile* mf);
88
89   virtual bool ComputeTargetDepends();
90   class VSDependSet: public std::set<cmStdString> {};
91   class VSDependMap: public std::map<cmTarget*, VSDependSet> {};
92   VSDependMap VSTargetDepends;
93   void ComputeVSTargetDepends(cmTarget&);
94
95   bool CheckTargetLinks(cmTarget& target, const char* name);
96   std::string GetUtilityForTarget(cmTarget& target, const char*);
97   virtual std::string WriteUtilityDepend(cmTarget*) = 0;
98   std::string GetUtilityDepend(cmTarget* target);
99   typedef std::map<cmTarget*, cmStdString> UtilityDependsMap;
100   UtilityDependsMap UtilityDepends;
101   const char* ArchitectureId;
102
103 private:
104   void ComputeTargetObjects(cmGeneratorTarget* gt) const;
105
106   void FollowLinkDepends(cmTarget* target, std::set<cmTarget*>& linked);
107
108   class TargetSetMap: public std::map<cmTarget*, TargetSet> {};
109   TargetSetMap TargetLinkClosure;
110   void FillLinkClosure(cmTarget* target, TargetSet& linked);
111   TargetSet const& GetTargetLinkClosure(cmTarget* target);
112 };
113
114 class cmGlobalVisualStudioGenerator::OrderedTargetDependSet:
115   public std::multiset<cmTargetDepend,
116                        cmGlobalVisualStudioGenerator::TargetCompare>
117 {
118 public:
119   typedef cmGlobalGenerator::TargetDependSet TargetDependSet;
120   typedef cmGlobalVisualStudioGenerator::TargetSet TargetSet;
121   OrderedTargetDependSet(TargetDependSet const&);
122   OrderedTargetDependSet(TargetSet const&);
123 };
124
125 #endif