Imported Upstream version 2.8.9
[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 bool ComputeTargetDepends();
88   class VSDependSet: public std::set<cmStdString> {};
89   class VSDependMap: public std::map<cmTarget*, VSDependSet> {};
90   VSDependMap VSTargetDepends;
91   void ComputeVSTargetDepends(cmTarget&);
92
93   bool CheckTargetLinks(cmTarget& target, const char* name);
94   std::string GetUtilityForTarget(cmTarget& target, const char*);
95   virtual std::string WriteUtilityDepend(cmTarget*) = 0;
96   std::string GetUtilityDepend(cmTarget* target);
97   typedef std::map<cmTarget*, cmStdString> UtilityDependsMap;
98   UtilityDependsMap UtilityDepends;
99 private:
100   void ComputeTargetObjects(cmGeneratorTarget* gt) const;
101
102   void FollowLinkDepends(cmTarget* target, std::set<cmTarget*>& linked);
103
104   class TargetSetMap: public std::map<cmTarget*, TargetSet> {};
105   TargetSetMap TargetLinkClosure;
106   void FillLinkClosure(cmTarget* target, TargetSet& linked);
107   TargetSet const& GetTargetLinkClosure(cmTarget* target);
108 };
109
110 class cmGlobalVisualStudioGenerator::OrderedTargetDependSet:
111   public std::multiset<cmTargetDepend,
112                        cmGlobalVisualStudioGenerator::TargetCompare>
113 {
114 public:
115   typedef cmGlobalGenerator::TargetDependSet TargetDependSet;
116   typedef cmGlobalVisualStudioGenerator::TargetSet TargetSet;
117   OrderedTargetDependSet(TargetDependSet const&);
118   OrderedTargetDependSet(TargetSet const&);
119 };
120
121 #endif