mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
ENH: Major improvements to the FIND_PACKAGE command. See bug #3659.
- Use CMAKE_PREFIX_PATH and CMAKE_SYSTEM_PREFIX_PATH among other means
to locate package configuration files.
- Create cmFindCommon as base for cmFindBase and cmFindPackageCommand
- Move common functionality up to cmFindCommon
- Improve documentation of FIND_* commands.
- Fix FIND_* commands to not add framework/app paths in wrong place.
This commit is contained in:
@@ -17,16 +17,20 @@
|
||||
#ifndef cmFindPackageCommand_h
|
||||
#define cmFindPackageCommand_h
|
||||
|
||||
#include "cmCommand.h"
|
||||
#include "cmFindCommon.h"
|
||||
|
||||
class cmFindPackageFileList;
|
||||
|
||||
/** \class cmFindPackageCommand
|
||||
* \brief Load settings from an external project.
|
||||
*
|
||||
* cmFindPackageCommand
|
||||
*/
|
||||
class cmFindPackageCommand : public cmCommand
|
||||
class cmFindPackageCommand : public cmFindCommon
|
||||
{
|
||||
public:
|
||||
cmFindPackageCommand();
|
||||
|
||||
/**
|
||||
* This is a virtual constructor for the command.
|
||||
*/
|
||||
@@ -62,51 +66,45 @@ public:
|
||||
/**
|
||||
* More documentation.
|
||||
*/
|
||||
virtual const char* GetFullDocumentation()
|
||||
{
|
||||
return
|
||||
" find_package(<name> [major.minor] [QUIET] [NO_MODULE]\n"
|
||||
" [[REQUIRED|COMPONENTS] [components...]])\n"
|
||||
"Finds and loads settings from an external project. <name>_FOUND will "
|
||||
"be set to indicate whether the package was found. Settings that "
|
||||
"can be used when <name>_FOUND is true are package-specific. The "
|
||||
"package is found through several steps. "
|
||||
"Directories listed in CMAKE_MODULE_PATH are searched for files called "
|
||||
"\"Find<name>.cmake\". If such a file is found, it is read and "
|
||||
"processed by CMake, and is responsible for finding the package. "
|
||||
"This first step may be skipped by using the NO_MODULE option. "
|
||||
"If no such file is found, it is expected that the package is another "
|
||||
"project built by CMake that has a \"<name>Config.cmake\" file. "
|
||||
"A cache entry called <name>_DIR is created and is expected to be set "
|
||||
"to the directory containing this file. If the file is found, it is "
|
||||
"read and processed by CMake to load the settings of the package. If "
|
||||
"<name>_DIR has not been set during a configure step, the command "
|
||||
"will generate an error describing the problem unless the QUIET "
|
||||
"argument is specified. If <name>_DIR has been set to a directory "
|
||||
"not containing a \"<name>Config.cmake\" file, an error is always "
|
||||
"generated. If REQUIRED is specified and the package is not found, "
|
||||
"a FATAL_ERROR is generated and the configure step stops executing. "
|
||||
"A package-specific list of components may be listed after the "
|
||||
"REQUIRED option, or after the COMPONENTS option if no REQUIRED "
|
||||
"option is given.";
|
||||
}
|
||||
virtual const char* GetFullDocumentation();
|
||||
|
||||
cmTypeMacro(cmFindPackageCommand, cmCommand);
|
||||
cmTypeMacro(cmFindPackageCommand, cmFindCommon);
|
||||
private:
|
||||
void AppendSuccessInformation(bool quiet);
|
||||
void AppendSuccessInformation();
|
||||
void AppendToProperty(const char* propertyName);
|
||||
bool FindModule(bool& found, bool quiet, bool required);
|
||||
bool FindConfig();
|
||||
std::string SearchForConfig() const;
|
||||
bool FindModule(bool& found);
|
||||
bool HandlePackageMode();
|
||||
void FindConfig();
|
||||
bool FindPrefixedConfig();
|
||||
bool FindFrameworkConfig();
|
||||
bool FindAppBundleConfig();
|
||||
bool ReadListFile(const char* f);
|
||||
|
||||
void AddUserPath(std::string const& p);
|
||||
void ComputePrefixes();
|
||||
bool SearchDirectory(std::string const& dir);
|
||||
bool CheckDirectory(std::string const& dir);
|
||||
bool FindConfigFile(std::string const& dir, std::string& file);
|
||||
bool SearchPrefix(std::string const& prefix);
|
||||
bool SearchFrameworkPrefix(std::string const& prefix_in);
|
||||
bool SearchAppBundlePrefix(std::string const& prefix_in);
|
||||
|
||||
friend class cmFindPackageFileList;
|
||||
|
||||
std::string CommandDocumentation;
|
||||
cmStdString Name;
|
||||
cmStdString Variable;
|
||||
cmStdString Config;
|
||||
std::vector<cmStdString> Builds;
|
||||
std::vector<cmStdString> Prefixes;
|
||||
std::vector<cmStdString> Relatives;
|
||||
cmStdString FileFound;
|
||||
bool Quiet;
|
||||
bool Required;
|
||||
bool Compatibility_1_6;
|
||||
bool NoModule;
|
||||
bool NoBuilds;
|
||||
bool DebugMode;
|
||||
std::vector<std::string> Names;
|
||||
std::vector<std::string> Configs;
|
||||
std::vector<std::string> Prefixes;
|
||||
std::vector<std::string> UserPaths;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user