2016-09-27 19:01:08 +00:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2003-01-21 22:15:22 +00:00
|
|
|
#ifndef cmFindPackageCommand_h
|
|
|
|
#define cmFindPackageCommand_h
|
|
|
|
|
2017-08-25 18:39:02 +00:00
|
|
|
#include "cmConfigure.h" // IWYU pragma: keep
|
2017-04-11 19:42:35 +00:00
|
|
|
|
2017-04-11 20:00:21 +00:00
|
|
|
#include "cm_kwiml.h"
|
2016-10-25 18:35:04 +00:00
|
|
|
#include <map>
|
|
|
|
#include <set>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2008-01-17 14:02:31 +00:00
|
|
|
#include "cmFindCommon.h"
|
|
|
|
|
2016-10-25 18:35:04 +00:00
|
|
|
class cmCommand;
|
|
|
|
class cmExecutionStatus;
|
|
|
|
class cmSearchPath;
|
2003-01-21 22:15:22 +00:00
|
|
|
|
|
|
|
/** \class cmFindPackageCommand
|
|
|
|
* \brief Load settings from an external project.
|
|
|
|
*
|
|
|
|
* cmFindPackageCommand
|
|
|
|
*/
|
2008-01-17 14:02:31 +00:00
|
|
|
class cmFindPackageCommand : public cmFindCommon
|
2003-01-21 22:15:22 +00:00
|
|
|
{
|
|
|
|
public:
|
2016-09-08 18:26:59 +00:00
|
|
|
/*! A sorting order strategy to be applied to recovered package folders (see
|
|
|
|
* FIND_PACKAGE_SORT_ORDER)*/
|
|
|
|
enum /*class*/ SortOrderType
|
|
|
|
{
|
|
|
|
None,
|
|
|
|
Name_order,
|
|
|
|
Natural
|
|
|
|
};
|
|
|
|
/*! A sorting direction to be applied to recovered package folders (see
|
|
|
|
* FIND_PACKAGE_SORT_DIRECTION)*/
|
|
|
|
enum /*class*/ SortDirectionType
|
|
|
|
{
|
|
|
|
Asc,
|
|
|
|
Dec
|
|
|
|
};
|
|
|
|
|
|
|
|
/*! sorts a given list of string based on the input sort parameters */
|
|
|
|
static void Sort(std::vector<std::string>::iterator begin,
|
|
|
|
std::vector<std::string>::iterator end, SortOrderType order,
|
|
|
|
SortDirectionType dir);
|
|
|
|
|
2008-01-17 14:02:31 +00:00
|
|
|
cmFindPackageCommand();
|
|
|
|
|
2003-01-21 22:15:22 +00:00
|
|
|
/**
|
|
|
|
* This is a virtual constructor for the command.
|
|
|
|
*/
|
2017-09-15 13:56:26 +00:00
|
|
|
cmCommand* Clone() override { return new cmFindPackageCommand; }
|
2003-01-21 22:15:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This is called when the command is first encountered in
|
|
|
|
* the CMakeLists.txt file.
|
|
|
|
*/
|
2016-06-27 19:25:27 +00:00
|
|
|
bool InitialPass(std::vector<std::string> const& args,
|
2017-09-15 13:56:26 +00:00
|
|
|
cmExecutionStatus& status) override;
|
2003-01-21 22:15:22 +00:00
|
|
|
|
|
|
|
private:
|
2014-10-17 17:07:26 +00:00
|
|
|
class PathLabel : public cmFindCommon::PathLabel
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
PathLabel();
|
2016-05-16 14:34:04 +00:00
|
|
|
|
2014-10-17 17:07:26 +00:00
|
|
|
public:
|
2016-05-16 14:34:04 +00:00
|
|
|
PathLabel(const std::string& label)
|
|
|
|
: cmFindCommon::PathLabel(label)
|
|
|
|
{
|
|
|
|
}
|
2014-10-17 17:07:26 +00:00
|
|
|
static PathLabel UserRegistry;
|
|
|
|
static PathLabel Builds;
|
|
|
|
static PathLabel SystemRegistry;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Add additional search path labels and groups not present in the
|
|
|
|
// parent class
|
|
|
|
void AppendSearchPathGroups();
|
|
|
|
|
2008-01-17 14:02:31 +00:00
|
|
|
void AppendSuccessInformation();
|
2012-05-06 14:32:10 +00:00
|
|
|
void AppendToFoundProperty(bool found);
|
2008-09-07 10:52:06 +00:00
|
|
|
void SetModuleVariables(const std::string& components);
|
2008-01-17 14:02:31 +00:00
|
|
|
bool FindModule(bool& found);
|
2014-02-04 21:06:56 +00:00
|
|
|
void AddFindDefinition(const std::string& var, const char* val);
|
2008-12-09 15:08:54 +00:00
|
|
|
void RestoreFindDefinitions();
|
2008-01-17 14:02:31 +00:00
|
|
|
bool HandlePackageMode();
|
2009-10-07 18:37:30 +00:00
|
|
|
bool FindConfig();
|
2008-01-17 14:02:31 +00:00
|
|
|
bool FindPrefixedConfig();
|
|
|
|
bool FindFrameworkConfig();
|
|
|
|
bool FindAppBundleConfig();
|
2016-05-16 14:34:04 +00:00
|
|
|
enum PolicyScopeRule
|
|
|
|
{
|
|
|
|
NoPolicyScope,
|
|
|
|
DoPolicyScope
|
|
|
|
};
|
2009-01-22 18:18:40 +00:00
|
|
|
bool ReadListFile(const char* f, PolicyScopeRule psr);
|
2008-01-29 01:38:48 +00:00
|
|
|
void StoreVersionFound();
|
2003-01-21 22:15:22 +00:00
|
|
|
|
2008-01-17 14:02:31 +00:00
|
|
|
void ComputePrefixes();
|
2017-07-17 13:43:16 +00:00
|
|
|
void FillPrefixesPackageRoot();
|
2014-10-09 17:52:54 +00:00
|
|
|
void FillPrefixesCMakeEnvironment();
|
|
|
|
void FillPrefixesCMakeVariable();
|
|
|
|
void FillPrefixesSystemEnvironment();
|
|
|
|
void FillPrefixesUserRegistry();
|
|
|
|
void FillPrefixesSystemRegistry();
|
|
|
|
void FillPrefixesCMakeSystemVariable();
|
|
|
|
void FillPrefixesUserGuess();
|
|
|
|
void FillPrefixesUserHints();
|
2014-10-15 20:36:42 +00:00
|
|
|
void LoadPackageRegistryDir(std::string const& dir, cmSearchPath& outPaths);
|
2011-04-13 17:17:42 +00:00
|
|
|
void LoadPackageRegistryWinUser();
|
|
|
|
void LoadPackageRegistryWinSystem();
|
2014-10-09 17:52:54 +00:00
|
|
|
void LoadPackageRegistryWin(bool user, unsigned int view,
|
2014-10-15 20:36:42 +00:00
|
|
|
cmSearchPath& outPaths);
|
2014-10-09 17:52:54 +00:00
|
|
|
bool CheckPackageRegistryEntry(const std::string& fname,
|
2014-10-15 20:36:42 +00:00
|
|
|
cmSearchPath& outPaths);
|
2008-01-17 14:02:31 +00:00
|
|
|
bool SearchDirectory(std::string const& dir);
|
|
|
|
bool CheckDirectory(std::string const& dir);
|
|
|
|
bool FindConfigFile(std::string const& dir, std::string& file);
|
2008-01-29 01:38:48 +00:00
|
|
|
bool CheckVersion(std::string const& config_file);
|
2010-08-29 15:07:39 +00:00
|
|
|
bool CheckVersionFile(std::string const& version_file,
|
|
|
|
std::string& result_version);
|
2008-01-17 14:02:31 +00:00
|
|
|
bool SearchPrefix(std::string const& prefix);
|
|
|
|
bool SearchFrameworkPrefix(std::string const& prefix_in);
|
|
|
|
bool SearchAppBundlePrefix(std::string const& prefix_in);
|
|
|
|
|
|
|
|
friend class cmFindPackageFileList;
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
struct OriginalDef
|
|
|
|
{
|
|
|
|
bool exists;
|
|
|
|
std::string value;
|
|
|
|
};
|
2014-02-10 05:21:34 +00:00
|
|
|
std::map<std::string, OriginalDef> OriginalDefs;
|
2008-12-09 15:08:54 +00:00
|
|
|
|
2014-02-10 05:21:34 +00:00
|
|
|
std::string Name;
|
|
|
|
std::string Variable;
|
|
|
|
std::string Version;
|
2008-01-21 13:48:33 +00:00
|
|
|
unsigned int VersionMajor;
|
|
|
|
unsigned int VersionMinor;
|
|
|
|
unsigned int VersionPatch;
|
2008-09-10 14:11:48 +00:00
|
|
|
unsigned int VersionTweak;
|
2008-01-21 13:48:33 +00:00
|
|
|
unsigned int VersionCount;
|
2008-01-29 01:38:48 +00:00
|
|
|
bool VersionExact;
|
2014-02-10 05:21:34 +00:00
|
|
|
std::string FileFound;
|
|
|
|
std::string VersionFound;
|
2008-01-29 01:38:48 +00:00
|
|
|
unsigned int VersionFoundMajor;
|
|
|
|
unsigned int VersionFoundMinor;
|
|
|
|
unsigned int VersionFoundPatch;
|
2008-09-10 14:11:48 +00:00
|
|
|
unsigned int VersionFoundTweak;
|
2008-01-29 01:38:48 +00:00
|
|
|
unsigned int VersionFoundCount;
|
2015-12-17 20:03:42 +00:00
|
|
|
KWIML_INT_uint64_t RequiredCMakeVersion;
|
2008-01-17 14:02:31 +00:00
|
|
|
bool Quiet;
|
|
|
|
bool Required;
|
2012-02-20 21:09:10 +00:00
|
|
|
bool UseConfigFiles;
|
2012-02-17 20:31:08 +00:00
|
|
|
bool UseFindModules;
|
2011-04-13 14:36:45 +00:00
|
|
|
bool NoUserRegistry;
|
2011-04-13 17:14:41 +00:00
|
|
|
bool NoSystemRegistry;
|
2008-01-17 14:02:31 +00:00
|
|
|
bool DebugMode;
|
2016-06-10 14:11:18 +00:00
|
|
|
bool UseLib32Paths;
|
2008-08-12 23:01:04 +00:00
|
|
|
bool UseLib64Paths;
|
2017-02-27 21:06:51 +00:00
|
|
|
bool UseLibx32Paths;
|
2009-01-22 18:18:40 +00:00
|
|
|
bool PolicyScope;
|
2011-06-08 12:46:31 +00:00
|
|
|
std::string LibraryArchitecture;
|
2008-01-17 14:02:31 +00:00
|
|
|
std::vector<std::string> Names;
|
|
|
|
std::vector<std::string> Configs;
|
2010-08-12 22:20:47 +00:00
|
|
|
std::set<std::string> IgnoredPaths;
|
2010-08-29 15:51:44 +00:00
|
|
|
|
2016-09-08 18:26:59 +00:00
|
|
|
/*! the selected sortOrder (None by default)*/
|
|
|
|
SortOrderType SortOrder;
|
|
|
|
/*! the selected sortDirection (Asc by default)*/
|
|
|
|
SortDirectionType SortDirection;
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
struct ConfigFileInfo
|
|
|
|
{
|
|
|
|
std::string filename;
|
|
|
|
std::string version;
|
2016-06-13 15:10:59 +00:00
|
|
|
|
|
|
|
bool operator<(ConfigFileInfo const& rhs) const
|
|
|
|
{
|
|
|
|
return this->filename < rhs.filename;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(ConfigFileInfo const& rhs) const
|
|
|
|
{
|
|
|
|
return this->filename == rhs.filename;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=(ConfigFileInfo const& rhs) const
|
|
|
|
{
|
|
|
|
return !(*this == rhs);
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
};
|
2010-08-29 15:51:44 +00:00
|
|
|
std::vector<ConfigFileInfo> ConsideredConfigs;
|
2003-01-21 22:15:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|