1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmFindPackageCommand.h,v $
6 Date: $Date: 2009-01-22 18:18:39 $
7 Version: $Revision: 1.28 $
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 AddPrefixesBuilds();
94 void AddPrefixesCMakeSystemVariable();
95 void AddPrefixesUserGuess();
96 void AddPrefixesUserHints();
97 void ComputeFinalPrefixes();
98 bool SearchDirectory(std::string
const& dir
);
99 bool CheckDirectory(std::string
const& dir
);
100 bool FindConfigFile(std::string
const& dir
, std::string
& file
);
101 bool CheckVersion(std::string
const& config_file
);
102 bool CheckVersionFile(std::string
const& version_file
);
103 bool SearchPrefix(std::string
const& prefix
);
104 bool SearchFrameworkPrefix(std::string
const& prefix_in
);
105 bool SearchAppBundlePrefix(std::string
const& prefix_in
);
107 friend class cmFindPackageFileList
;
109 struct OriginalDef
{ bool exists
; std::string value
; };
110 std::map
<cmStdString
, OriginalDef
> OriginalDefs
;
112 std::string CommandDocumentation
;
114 cmStdString Variable
;
116 unsigned int VersionMajor
;
117 unsigned int VersionMinor
;
118 unsigned int VersionPatch
;
119 unsigned int VersionTweak
;
120 unsigned int VersionCount
;
122 cmStdString FileFound
;
123 cmStdString VersionFound
;
124 unsigned int VersionFoundMajor
;
125 unsigned int VersionFoundMinor
;
126 unsigned int VersionFoundPatch
;
127 unsigned int VersionFoundTweak
;
128 unsigned int VersionFoundCount
;
131 bool Compatibility_1_6
;
137 std::vector
<std::string
> Names
;
138 std::vector
<std::string
> Configs
;