Imported Upstream version 2.8.9
[platform/upstream/cmake.git] / Source / cmFindPackageCommand.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 cmFindPackageCommand_h
13 #define cmFindPackageCommand_h
14
15 #include "cmFindCommon.h"
16
17 class cmFindPackageFileList;
18
19 /** \class cmFindPackageCommand
20  * \brief Load settings from an external project.
21  *
22  * cmFindPackageCommand
23  */
24 class cmFindPackageCommand : public cmFindCommon
25 {
26 public:
27   cmFindPackageCommand();
28
29   /**
30    * This is a virtual constructor for the command.
31    */
32   virtual cmCommand* Clone()
33     {
34     return new cmFindPackageCommand;
35     }
36
37   /**
38    * This is called when the command is first encountered in
39    * the CMakeLists.txt file.
40    */
41   virtual bool InitialPass(std::vector<std::string> const& args,
42                            cmExecutionStatus &status);
43
44   /**
45    * This determines if the command is invoked when in script mode.
46    */
47   virtual bool IsScriptable() const { return true; }
48
49   /**
50    * The name of the command as specified in CMakeList.txt.
51    */
52   virtual const char* GetName() const { return "find_package";}
53
54   /**
55    * Succinct documentation.
56    */
57   virtual const char* GetTerseDocumentation() const
58     {
59     return "Load settings for an external project.";
60     }
61
62   /**
63    * More documentation.
64    */
65   virtual const char* GetFullDocumentation() const;
66
67   cmTypeMacro(cmFindPackageCommand, cmFindCommon);
68 protected:
69   virtual void GenerateDocumentation();
70 private:
71   void AppendSuccessInformation();
72   void AppendToFoundProperty(bool found);
73   void SetModuleVariables(const std::string& components);
74   bool FindModule(bool& found);
75   void AddFindDefinition(const char* var, const char* val);
76   void RestoreFindDefinitions();
77   bool HandlePackageMode();
78   bool FindConfig();
79   bool FindPrefixedConfig();
80   bool FindFrameworkConfig();
81   bool FindAppBundleConfig();
82   enum PolicyScopeRule { NoPolicyScope, DoPolicyScope };
83   bool ReadListFile(const char* f, PolicyScopeRule psr);
84   void StoreVersionFound();
85
86   void ComputePrefixes();
87   void AddPrefixesCMakeEnvironment();
88   void AddPrefixesCMakeVariable();
89   void AddPrefixesSystemEnvironment();
90   void AddPrefixesUserRegistry();
91   void AddPrefixesSystemRegistry();
92   void AddPrefixesBuilds();
93   void AddPrefixesCMakeSystemVariable();
94   void AddPrefixesUserGuess();
95   void AddPrefixesUserHints();
96   void LoadPackageRegistryDir(std::string const& dir);
97   void LoadPackageRegistryWinUser();
98   void LoadPackageRegistryWinSystem();
99   void LoadPackageRegistryWin(bool user, unsigned int view);
100   bool CheckPackageRegistryEntry(std::istream& is);
101   bool SearchDirectory(std::string const& dir);
102   bool CheckDirectory(std::string const& dir);
103   bool FindConfigFile(std::string const& dir, std::string& file);
104   bool CheckVersion(std::string const& config_file);
105   bool CheckVersionFile(std::string const& version_file,
106                         std::string& result_version);
107   bool SearchPrefix(std::string const& prefix);
108   bool SearchFrameworkPrefix(std::string const& prefix_in);
109   bool SearchAppBundlePrefix(std::string const& prefix_in);
110
111   friend class cmFindPackageFileList;
112
113   struct OriginalDef { bool exists; std::string value; };
114   std::map<cmStdString, OriginalDef> OriginalDefs;
115
116   std::string CommandDocumentation;
117   cmStdString Name;
118   cmStdString Variable;
119   cmStdString Version;
120   unsigned int VersionMajor;
121   unsigned int VersionMinor;
122   unsigned int VersionPatch;
123   unsigned int VersionTweak;
124   unsigned int VersionCount;
125   bool VersionExact;
126   cmStdString FileFound;
127   cmStdString VersionFound;
128   unsigned int VersionFoundMajor;
129   unsigned int VersionFoundMinor;
130   unsigned int VersionFoundPatch;
131   unsigned int VersionFoundTweak;
132   unsigned int VersionFoundCount;
133   unsigned int RequiredCMakeVersion;
134   bool Quiet;
135   bool Required;
136   bool Compatibility_1_6;
137   bool UseConfigFiles;
138   bool UseFindModules;
139   bool NoUserRegistry;
140   bool NoSystemRegistry;
141   bool NoBuilds;
142   bool DebugMode;
143   bool UseLib64Paths;
144   bool PolicyScope;
145   std::string LibraryArchitecture;
146   std::vector<std::string> Names;
147   std::vector<std::string> Configs;
148   std::set<std::string> IgnoredPaths;
149
150   struct ConfigFileInfo { std::string filename; std::string version; };
151   std::vector<ConfigFileInfo> ConsideredConfigs;
152 };
153
154 #endif