1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmFindPackageCommand.h,v $
6 Date: $Date: 2009-09-01 18:04:27 $
7 Version: $Revision: 1.29 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #ifndef cmFindPackageCommand_h
18 #define cmFindPackageCommand_h
20 #include "cmFindCommon.h"
22 class cmFindPackageFileList
;
24 /** \class cmFindPackageCommand
25 * \brief Load settings from an external project.
27 * cmFindPackageCommand
29 class cmFindPackageCommand
: public cmFindCommon
32 cmFindPackageCommand();
35 * This is a virtual constructor for the command.
37 virtual cmCommand
* Clone()
39 return new cmFindPackageCommand
;
43 * This is called when the command is first encountered in
44 * the CMakeLists.txt file.
46 virtual bool InitialPass(std::vector
<std::string
> const& args
,
47 cmExecutionStatus
&status
);
50 * This determines if the command is invoked when in script mode.
52 virtual bool IsScriptable() { return true; }
55 * The name of the command as specified in CMakeList.txt.
57 virtual const char* GetName() { return "find_package";}
60 * Succinct documentation.
62 virtual const char* GetTerseDocumentation()
64 return "Load settings for an external project.";
70 virtual const char* GetFullDocumentation();
72 cmTypeMacro(cmFindPackageCommand
, cmFindCommon
);
74 void AppendSuccessInformation();
75 void AppendToProperty(const char* propertyName
);
76 void SetModuleVariables(const std::string
& components
);
77 bool FindModule(bool& found
);
78 void AddFindDefinition(const char* var
, const char* val
);
79 void RestoreFindDefinitions();
80 bool HandlePackageMode();
82 bool FindPrefixedConfig();
83 bool FindFrameworkConfig();
84 bool FindAppBundleConfig();
85 enum PolicyScopeRule
{ NoPolicyScope
, DoPolicyScope
};
86 bool ReadListFile(const char* f
, PolicyScopeRule psr
);
87 void StoreVersionFound();
89 void ComputePrefixes();
90 void AddPrefixesCMakeEnvironment();
91 void AddPrefixesCMakeVariable();
92 void AddPrefixesSystemEnvironment();
93 void AddPrefixesRegistry();
94 void AddPrefixesBuilds();
95 void AddPrefixesCMakeSystemVariable();
96 void AddPrefixesUserGuess();
97 void AddPrefixesUserHints();
98 void ComputeFinalPrefixes();
99 void LoadPackageRegistryDir(std::string
const& dir
);
100 void LoadPackageRegistryWin();
101 bool CheckPackageRegistryEntry(std::istream
& is
);
102 bool SearchDirectory(std::string
const& dir
);
103 bool CheckDirectory(std::string
const& dir
);
104 bool FindConfigFile(std::string
const& dir
, std::string
& file
);
105 bool CheckVersion(std::string
const& config_file
);
106 bool CheckVersionFile(std::string
const& version_file
);
107 bool SearchPrefix(std::string
const& prefix
);
108 bool SearchFrameworkPrefix(std::string
const& prefix_in
);
109 bool SearchAppBundlePrefix(std::string
const& prefix_in
);
111 friend class cmFindPackageFileList
;
113 struct OriginalDef
{ bool exists
; std::string value
; };
114 std::map
<cmStdString
, OriginalDef
> OriginalDefs
;
116 std::string CommandDocumentation
;
118 cmStdString Variable
;
120 unsigned int VersionMajor
;
121 unsigned int VersionMinor
;
122 unsigned int VersionPatch
;
123 unsigned int VersionTweak
;
124 unsigned int VersionCount
;
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
;
135 bool Compatibility_1_6
;
142 std::vector
<std::string
> Names
;
143 std::vector
<std::string
> Configs
;