Imported Upstream version 2.8.12.2
[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   /** Get the top-level registry key for the given VS version.  */
69   static std::string GetRegistryBase(const char* version);
70
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() { return true; }
74
75   /** Return true if building for Windows CE */
76   virtual bool TargetsWindowsCE() const { return false; }
77
78   class TargetSet: public std::set<cmTarget*> {};
79   struct TargetCompare
80   {
81     bool operator()(cmTarget const* l, cmTarget const* r) const;
82   };
83   class OrderedTargetDependSet;
84
85 protected:
86   // Does this VS version link targets to each other if there are
87   // dependencies in the SLN file?  This was done for VS versions
88   // below 8.
89   virtual bool VSLinksDependencies() const { return true; }
90
91   virtual const char* GetIDEVersion() = 0;
92
93   virtual void AddPlatformDefinitions(cmMakefile* mf);
94
95   virtual bool ComputeTargetDepends();
96   class VSDependSet: public std::set<cmStdString> {};
97   class VSDependMap: public std::map<cmTarget*, VSDependSet> {};
98   VSDependMap VSTargetDepends;
99   void ComputeVSTargetDepends(cmTarget&);
100
101   bool CheckTargetLinks(cmTarget& target, const char* name);
102   std::string GetUtilityForTarget(cmTarget& target, const char*);
103   virtual std::string WriteUtilityDepend(cmTarget*) = 0;
104   std::string GetUtilityDepend(cmTarget* target);
105   typedef std::map<cmTarget*, cmStdString> UtilityDependsMap;
106   UtilityDependsMap UtilityDepends;
107   const char* AdditionalPlatformDefinition;
108
109 private:
110   void ComputeTargetObjects(cmGeneratorTarget* gt) const;
111
112   void FollowLinkDepends(cmTarget* target, std::set<cmTarget*>& linked);
113
114   class TargetSetMap: public std::map<cmTarget*, TargetSet> {};
115   TargetSetMap TargetLinkClosure;
116   void FillLinkClosure(cmTarget* target, TargetSet& linked);
117   TargetSet const& GetTargetLinkClosure(cmTarget* target);
118 };
119
120 class cmGlobalVisualStudioGenerator::OrderedTargetDependSet:
121   public std::multiset<cmTargetDepend,
122                        cmGlobalVisualStudioGenerator::TargetCompare>
123 {
124 public:
125   typedef cmGlobalGenerator::TargetDependSet TargetDependSet;
126   typedef cmGlobalVisualStudioGenerator::TargetSet TargetSet;
127   OrderedTargetDependSet(TargetDependSet const&);
128   OrderedTargetDependSet(TargetSet const&);
129 };
130
131 #endif