2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2003-01-22 01:15:22 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2003-01-22 01:15:22 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2003-01-22 01:15:22 +03:00
|
|
|
#include "cmFindPackageCommand.h"
|
2009-09-01 22:04:27 +04:00
|
|
|
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmAlgorithms.h"
|
2009-09-01 22:04:27 +04:00
|
|
|
#include <cmsys/Directory.hxx>
|
2013-12-05 09:17:24 +04:00
|
|
|
#include <cmsys/Encoding.hxx>
|
2016-04-29 17:53:13 +03:00
|
|
|
#include <cmsys/RegularExpression.hxx>
|
2003-01-22 01:15:22 +03:00
|
|
|
|
2004-10-27 18:47:14 +04:00
|
|
|
#ifdef CMAKE_BUILD_WITH_CMAKE
|
2003-08-08 00:50:38 +04:00
|
|
|
#include "cmVariableWatch.h"
|
2004-10-27 18:47:14 +04:00
|
|
|
#endif
|
2003-08-08 00:50:38 +04:00
|
|
|
|
2009-09-28 17:45:34 +04:00
|
|
|
#if defined(__HAIKU__)
|
2013-10-05 18:31:36 +04:00
|
|
|
#include <FindDirectory.h>
|
|
|
|
#include <StorageDefs.h>
|
2016-04-29 17:53:13 +03:00
|
|
|
#include <string.h>
|
2009-09-28 17:45:34 +04:00
|
|
|
#endif
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmFindPackageCommand::PathLabel cmFindPackageCommand::PathLabel::UserRegistry(
|
|
|
|
"PACKAGE_REGISTRY");
|
|
|
|
cmFindPackageCommand::PathLabel cmFindPackageCommand::PathLabel::Builds(
|
|
|
|
"BUILDS");
|
2014-10-17 21:07:26 +04:00
|
|
|
cmFindPackageCommand::PathLabel
|
|
|
|
cmFindPackageCommand::PathLabel::SystemRegistry("SYSTEM_PACKAGE_REGISTRY");
|
|
|
|
|
2008-01-17 17:02:31 +03:00
|
|
|
cmFindPackageCommand::cmFindPackageCommand()
|
|
|
|
{
|
|
|
|
this->CMakePathName = "PACKAGE";
|
|
|
|
this->Quiet = false;
|
|
|
|
this->Required = false;
|
2011-04-13 18:36:45 +04:00
|
|
|
this->NoUserRegistry = false;
|
2011-04-13 21:14:41 +04:00
|
|
|
this->NoSystemRegistry = false;
|
2012-02-21 01:09:10 +04:00
|
|
|
this->UseConfigFiles = true;
|
2012-02-18 00:31:08 +04:00
|
|
|
this->UseFindModules = true;
|
2008-01-17 17:02:31 +03:00
|
|
|
this->DebugMode = false;
|
2008-08-13 03:01:04 +04:00
|
|
|
this->UseLib64Paths = false;
|
2009-01-22 21:18:40 +03:00
|
|
|
this->PolicyScope = true;
|
2008-01-21 16:48:33 +03:00
|
|
|
this->VersionMajor = 0;
|
|
|
|
this->VersionMinor = 0;
|
|
|
|
this->VersionPatch = 0;
|
2008-09-10 18:11:48 +04:00
|
|
|
this->VersionTweak = 0;
|
2008-01-21 16:48:33 +03:00
|
|
|
this->VersionCount = 0;
|
2008-01-29 04:38:48 +03:00
|
|
|
this->VersionExact = false;
|
|
|
|
this->VersionFoundMajor = 0;
|
|
|
|
this->VersionFoundMinor = 0;
|
|
|
|
this->VersionFoundPatch = 0;
|
2008-09-10 18:11:48 +04:00
|
|
|
this->VersionFoundTweak = 0;
|
2008-01-29 04:38:48 +03:00
|
|
|
this->VersionFoundCount = 0;
|
2012-02-28 18:51:10 +04:00
|
|
|
this->RequiredCMakeVersion = 0;
|
2014-10-17 21:07:26 +04:00
|
|
|
|
|
|
|
this->AppendSearchPathGroups();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmFindPackageCommand::AppendSearchPathGroups()
|
|
|
|
{
|
|
|
|
std::vector<cmFindCommon::PathLabel>* labels;
|
|
|
|
|
|
|
|
// Update the All group with new paths
|
|
|
|
labels = &this->PathGroupLabelMap[PathGroup::All];
|
2016-05-16 17:34:04 +03:00
|
|
|
labels->insert(
|
|
|
|
std::find(labels->begin(), labels->end(), PathLabel::CMakeSystem),
|
|
|
|
PathLabel::UserRegistry);
|
|
|
|
labels->insert(
|
|
|
|
std::find(labels->begin(), labels->end(), PathLabel::CMakeSystem),
|
|
|
|
PathLabel::Builds);
|
2014-10-17 21:07:26 +04:00
|
|
|
labels->insert(std::find(labels->begin(), labels->end(), PathLabel::Guess),
|
|
|
|
PathLabel::SystemRegistry);
|
|
|
|
|
|
|
|
// Create the new path objects
|
2016-05-16 17:34:04 +03:00
|
|
|
this->LabeledPaths.insert(
|
|
|
|
std::make_pair(PathLabel::UserRegistry, cmSearchPath(this)));
|
|
|
|
this->LabeledPaths.insert(
|
|
|
|
std::make_pair(PathLabel::Builds, cmSearchPath(this)));
|
|
|
|
this->LabeledPaths.insert(
|
|
|
|
std::make_pair(PathLabel::SystemRegistry, cmSearchPath(this)));
|
2010-11-12 18:47:28 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args,
|
|
|
|
cmExecutionStatus&)
|
2003-01-22 01:15:22 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (args.size() < 1) {
|
2003-01-22 01:15:22 +03:00
|
|
|
this->SetError("called with incorrect number of arguments");
|
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-04-26 18:49:34 +04:00
|
|
|
|
2012-02-28 18:51:10 +04:00
|
|
|
// Lookup required version of CMake.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* rv =
|
|
|
|
this->Makefile->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION")) {
|
|
|
|
unsigned int v[3] = { 0, 0, 0 };
|
2012-02-28 18:51:10 +04:00
|
|
|
sscanf(rv, "%u.%u.%u", &v[0], &v[1], &v[2]);
|
2016-05-16 17:34:04 +03:00
|
|
|
this->RequiredCMakeVersion = CMake_VERSION_ENCODE(v[0], v[1], v[2]);
|
|
|
|
}
|
2012-02-28 18:51:10 +04:00
|
|
|
|
2008-01-17 17:02:31 +03:00
|
|
|
// Check for debug mode.
|
|
|
|
this->DebugMode = this->Makefile->IsOn("CMAKE_FIND_DEBUG_MODE");
|
|
|
|
|
2011-06-08 16:46:31 +04:00
|
|
|
// Lookup target architecture, if any.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* arch =
|
|
|
|
this->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE")) {
|
2011-06-08 16:46:31 +04:00
|
|
|
this->LibraryArchitecture = arch;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-06-08 16:46:31 +04:00
|
|
|
|
2008-08-13 03:01:04 +04:00
|
|
|
// Lookup whether lib64 paths should be used.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Makefile->PlatformIs64Bit() &&
|
|
|
|
this->Makefile->GetState()->GetGlobalPropertyAsBool(
|
|
|
|
"FIND_LIBRARY_USE_LIB64_PATHS")) {
|
2009-09-30 21:45:14 +04:00
|
|
|
this->UseLib64Paths = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-08-13 03:01:04 +04:00
|
|
|
|
2014-04-02 18:32:54 +04:00
|
|
|
// Check if User Package Registry should be disabled
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Makefile->IsOn("CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY")) {
|
2014-04-02 18:32:54 +04:00
|
|
|
this->NoUserRegistry = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-04-02 18:32:54 +04:00
|
|
|
|
|
|
|
// Check if System Package Registry should be disabled
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Makefile->IsOn("CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY")) {
|
2014-04-02 18:32:54 +04:00
|
|
|
this->NoSystemRegistry = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-04-02 18:32:54 +04:00
|
|
|
|
2008-01-17 17:02:31 +03:00
|
|
|
// Find the current root path mode.
|
|
|
|
this->SelectDefaultRootPathMode();
|
|
|
|
|
|
|
|
// Find the current bundle/framework search policy.
|
|
|
|
this->SelectDefaultMacMode();
|
|
|
|
|
2006-10-26 19:39:56 +04:00
|
|
|
// Record options.
|
2003-01-22 01:15:22 +03:00
|
|
|
this->Name = args[0];
|
2006-10-26 19:39:56 +04:00
|
|
|
std::string components;
|
|
|
|
const char* components_sep = "";
|
2012-03-18 15:41:28 +04:00
|
|
|
std::set<std::string> requiredComponents;
|
|
|
|
std::set<std::string> optionalComponents;
|
2006-10-26 19:39:56 +04:00
|
|
|
|
2008-01-17 17:02:31 +03:00
|
|
|
// Always search directly in a generated path.
|
|
|
|
this->SearchPathSuffixes.push_back("");
|
|
|
|
|
2006-10-26 19:39:56 +04:00
|
|
|
// Parse the arguments.
|
2016-05-16 17:34:04 +03:00
|
|
|
enum Doing
|
|
|
|
{
|
|
|
|
DoingNone,
|
|
|
|
DoingComponents,
|
|
|
|
DoingOptionalComponents,
|
|
|
|
DoingNames,
|
|
|
|
DoingPaths,
|
|
|
|
DoingPathSuffixes,
|
|
|
|
DoingConfigs,
|
|
|
|
DoingHints
|
|
|
|
};
|
2008-01-17 17:02:31 +03:00
|
|
|
Doing doing = DoingNone;
|
2006-10-26 19:39:56 +04:00
|
|
|
cmsys::RegularExpression version("^[0-9.]+$");
|
|
|
|
bool haveVersion = false;
|
2012-02-28 17:56:50 +04:00
|
|
|
std::set<unsigned int> configArgs;
|
|
|
|
std::set<unsigned int> moduleArgs;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (unsigned int i = 1; i < args.size(); ++i) {
|
|
|
|
if (args[i] == "QUIET") {
|
2008-01-17 17:02:31 +03:00
|
|
|
this->Quiet = true;
|
|
|
|
doing = DoingNone;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (args[i] == "EXACT") {
|
2008-01-29 04:38:48 +03:00
|
|
|
this->VersionExact = true;
|
|
|
|
doing = DoingNone;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (args[i] == "MODULE") {
|
2012-02-28 17:56:50 +04:00
|
|
|
moduleArgs.insert(i);
|
2012-02-21 01:09:10 +04:00
|
|
|
doing = DoingNone;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (args[i] == "CONFIG") {
|
2012-02-28 17:56:50 +04:00
|
|
|
configArgs.insert(i);
|
2012-02-21 01:09:10 +04:00
|
|
|
doing = DoingNone;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (args[i] == "NO_MODULE") {
|
2012-02-28 17:56:50 +04:00
|
|
|
configArgs.insert(i);
|
2008-01-17 17:02:31 +03:00
|
|
|
doing = DoingNone;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (args[i] == "REQUIRED") {
|
2008-01-17 17:02:31 +03:00
|
|
|
this->Required = true;
|
|
|
|
doing = DoingComponents;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (args[i] == "COMPONENTS") {
|
2008-01-17 17:02:31 +03:00
|
|
|
doing = DoingComponents;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (args[i] == "OPTIONAL_COMPONENTS") {
|
2012-03-18 15:41:28 +04:00
|
|
|
doing = DoingOptionalComponents;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (args[i] == "NAMES") {
|
2012-02-28 17:56:50 +04:00
|
|
|
configArgs.insert(i);
|
2008-01-17 17:02:31 +03:00
|
|
|
doing = DoingNames;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (args[i] == "PATHS") {
|
2012-02-28 17:56:50 +04:00
|
|
|
configArgs.insert(i);
|
2008-01-17 17:02:31 +03:00
|
|
|
doing = DoingPaths;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (args[i] == "HINTS") {
|
2012-02-28 17:56:50 +04:00
|
|
|
configArgs.insert(i);
|
2008-06-09 23:08:59 +04:00
|
|
|
doing = DoingHints;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (args[i] == "PATH_SUFFIXES") {
|
2012-02-28 17:56:50 +04:00
|
|
|
configArgs.insert(i);
|
2008-01-17 17:02:31 +03:00
|
|
|
doing = DoingPathSuffixes;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (args[i] == "CONFIGS") {
|
2012-02-28 17:56:50 +04:00
|
|
|
configArgs.insert(i);
|
2008-01-17 17:02:31 +03:00
|
|
|
doing = DoingConfigs;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (args[i] == "NO_POLICY_SCOPE") {
|
2009-01-22 21:18:40 +03:00
|
|
|
this->PolicyScope = false;
|
|
|
|
doing = DoingNone;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (args[i] == "NO_CMAKE_PACKAGE_REGISTRY") {
|
2011-04-13 18:36:45 +04:00
|
|
|
this->NoUserRegistry = true;
|
2012-02-28 17:56:50 +04:00
|
|
|
configArgs.insert(i);
|
2009-09-01 22:04:27 +04:00
|
|
|
doing = DoingNone;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (args[i] == "NO_CMAKE_SYSTEM_PACKAGE_REGISTRY") {
|
2011-04-13 21:14:41 +04:00
|
|
|
this->NoSystemRegistry = true;
|
2012-02-28 17:56:50 +04:00
|
|
|
configArgs.insert(i);
|
2011-04-13 21:14:41 +04:00
|
|
|
doing = DoingNone;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (args[i] == "NO_CMAKE_BUILDS_PATH") {
|
2015-05-07 23:21:29 +03:00
|
|
|
// Ignore legacy option.
|
2012-02-28 17:56:50 +04:00
|
|
|
configArgs.insert(i);
|
2008-01-17 17:02:31 +03:00
|
|
|
doing = DoingNone;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (this->CheckCommonArgument(args[i])) {
|
2012-02-28 17:56:50 +04:00
|
|
|
configArgs.insert(i);
|
2008-01-17 17:02:31 +03:00
|
|
|
doing = DoingNone;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if ((doing == DoingComponents) ||
|
|
|
|
(doing == DoingOptionalComponents)) {
|
2012-03-18 15:41:28 +04:00
|
|
|
// Set a variable telling the find script whether this component
|
2006-10-26 19:39:56 +04:00
|
|
|
// is required.
|
2012-03-18 15:41:28 +04:00
|
|
|
const char* isRequired = "1";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (doing == DoingOptionalComponents) {
|
2012-03-18 15:41:28 +04:00
|
|
|
isRequired = "0";
|
|
|
|
optionalComponents.insert(args[i]);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2012-03-18 15:41:28 +04:00
|
|
|
requiredComponents.insert(args[i]);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-03-18 15:41:28 +04:00
|
|
|
|
2008-09-07 03:10:02 +04:00
|
|
|
std::string req_var = this->Name + "_FIND_REQUIRED_" + args[i];
|
2014-03-11 03:04:11 +04:00
|
|
|
this->AddFindDefinition(req_var, isRequired);
|
2006-07-12 01:10:00 +04:00
|
|
|
|
2006-10-26 19:39:56 +04:00
|
|
|
// Append to the list of required components.
|
|
|
|
components += components_sep;
|
|
|
|
components += args[i];
|
|
|
|
components_sep = ";";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (doing == DoingNames) {
|
2008-01-17 17:02:31 +03:00
|
|
|
this->Names.push_back(args[i]);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (doing == DoingPaths) {
|
2014-10-16 00:36:42 +04:00
|
|
|
this->UserGuessArgs.push_back(args[i]);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (doing == DoingHints) {
|
2014-10-16 00:36:42 +04:00
|
|
|
this->UserHintsArgs.push_back(args[i]);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (doing == DoingPathSuffixes) {
|
2008-01-17 17:02:31 +03:00
|
|
|
this->AddPathSuffix(args[i]);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (doing == DoingConfigs) {
|
|
|
|
if (args[i].find_first_of(":/\\") != args[i].npos ||
|
|
|
|
cmSystemTools::GetFilenameLastExtension(args[i]) != ".cmake") {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2016-05-16 17:34:04 +03:00
|
|
|
e << "given CONFIGS option followed by invalid file name \"" << args[i]
|
|
|
|
<< "\". The names given must be file names without "
|
2008-01-29 04:38:48 +03:00
|
|
|
<< "a path and with a \".cmake\" extension.";
|
2014-03-11 03:04:11 +04:00
|
|
|
this->SetError(e.str());
|
2008-01-29 04:38:48 +03:00
|
|
|
return false;
|
2008-01-17 17:02:31 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Configs.push_back(args[i]);
|
|
|
|
} else if (!haveVersion && version.find(args[i].c_str())) {
|
2006-10-26 19:39:56 +04:00
|
|
|
haveVersion = true;
|
2008-01-21 16:48:33 +03:00
|
|
|
this->Version = args[i];
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2014-03-11 16:35:32 +04:00
|
|
|
e << "called with invalid argument \"" << args[i] << "\"";
|
2014-03-11 03:04:11 +04:00
|
|
|
this->SetError(e.str());
|
2006-10-26 19:39:56 +04:00
|
|
|
return false;
|
2003-07-16 22:52:51 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-04-26 18:49:34 +04:00
|
|
|
|
2012-03-18 15:41:28 +04:00
|
|
|
std::vector<std::string> doubledComponents;
|
|
|
|
std::set_intersection(requiredComponents.begin(), requiredComponents.end(),
|
|
|
|
optionalComponents.begin(), optionalComponents.end(),
|
|
|
|
std::back_inserter(doubledComponents));
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!doubledComponents.empty()) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2012-03-18 15:41:28 +04:00
|
|
|
e << "called with components that are both required and optional:\n";
|
2015-02-19 00:14:26 +03:00
|
|
|
e << cmWrap(" ", doubledComponents, "", "\n") << "\n";
|
2014-03-11 03:04:11 +04:00
|
|
|
this->SetError(e.str());
|
2012-03-18 15:41:28 +04:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-03-18 15:41:28 +04:00
|
|
|
|
2012-02-28 17:56:50 +04:00
|
|
|
// Maybe choose one mode exclusively.
|
|
|
|
this->UseFindModules = configArgs.empty();
|
|
|
|
this->UseConfigFiles = moduleArgs.empty();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->UseFindModules && !this->UseConfigFiles) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2012-02-28 17:56:50 +04:00
|
|
|
e << "given options exclusive to Module mode:\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::set<unsigned int>::const_iterator si = moduleArgs.begin();
|
|
|
|
si != moduleArgs.end(); ++si) {
|
2012-02-28 17:56:50 +04:00
|
|
|
e << " " << args[*si] << "\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-02-28 17:56:50 +04:00
|
|
|
e << "and options exclusive to Config mode:\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::set<unsigned int>::const_iterator si = configArgs.begin();
|
|
|
|
si != configArgs.end(); ++si) {
|
2012-02-28 17:56:50 +04:00
|
|
|
e << " " << args[*si] << "\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-02-28 17:56:50 +04:00
|
|
|
e << "The options are incompatible.";
|
2014-03-11 03:04:11 +04:00
|
|
|
this->SetError(e.str());
|
2012-02-28 17:56:50 +04:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-02-28 17:56:50 +04:00
|
|
|
|
2008-10-03 18:39:53 +04:00
|
|
|
// Ignore EXACT with no version.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Version.empty() && this->VersionExact) {
|
2008-10-03 18:39:53 +04:00
|
|
|
this->VersionExact = false;
|
|
|
|
this->Makefile->IssueMessage(
|
|
|
|
cmake::AUTHOR_WARNING, "Ignoring EXACT since no version is requested.");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-10-03 18:39:53 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Version.empty() || components.empty()) {
|
2008-10-03 18:40:07 +04:00
|
|
|
// Check whether we are recursing inside "Find<name>.cmake" within
|
|
|
|
// another find_package(<name>) call.
|
|
|
|
std::string mod = this->Name;
|
|
|
|
mod += "_FIND_MODULE";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Makefile->IsOn(mod)) {
|
|
|
|
if (this->Version.empty()) {
|
2011-04-07 23:36:05 +04:00
|
|
|
// Get version information from the outer call if necessary.
|
|
|
|
// Requested version string.
|
|
|
|
std::string ver = this->Name;
|
|
|
|
ver += "_FIND_VERSION";
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Version = this->Makefile->GetSafeDefinition(ver);
|
2008-10-03 18:40:07 +04:00
|
|
|
|
2011-04-07 23:36:05 +04:00
|
|
|
// Whether an exact version is required.
|
|
|
|
std::string exact = this->Name;
|
|
|
|
exact += "_FIND_VERSION_EXACT";
|
2014-03-11 03:04:11 +04:00
|
|
|
this->VersionExact = this->Makefile->IsOn(exact);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (components.empty()) {
|
2011-04-07 23:36:05 +04:00
|
|
|
std::string components_var = this->Name + "_FIND_COMPONENTS";
|
2014-03-11 03:04:11 +04:00
|
|
|
components = this->Makefile->GetSafeDefinition(components_var);
|
2008-10-03 18:40:07 +04:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-10-03 18:40:07 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->Version.empty()) {
|
2008-01-21 16:48:33 +03:00
|
|
|
// Try to parse the version number and store the results that were
|
|
|
|
// successfully parsed.
|
|
|
|
unsigned int parsed_major;
|
|
|
|
unsigned int parsed_minor;
|
|
|
|
unsigned int parsed_patch;
|
2008-09-10 18:11:48 +04:00
|
|
|
unsigned int parsed_tweak;
|
2016-05-16 17:34:04 +03:00
|
|
|
this->VersionCount =
|
|
|
|
sscanf(this->Version.c_str(), "%u.%u.%u.%u", &parsed_major,
|
|
|
|
&parsed_minor, &parsed_patch, &parsed_tweak);
|
|
|
|
switch (this->VersionCount) {
|
|
|
|
case 4:
|
|
|
|
this->VersionTweak = parsed_tweak; // no break!
|
|
|
|
case 3:
|
|
|
|
this->VersionPatch = parsed_patch; // no break!
|
|
|
|
case 2:
|
|
|
|
this->VersionMinor = parsed_minor; // no break!
|
|
|
|
case 1:
|
|
|
|
this->VersionMajor = parsed_major; // no break!
|
|
|
|
default:
|
|
|
|
break;
|
2008-01-21 16:48:33 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-21 16:48:33 +03:00
|
|
|
|
2011-06-16 23:11:06 +04:00
|
|
|
std::string disableFindPackageVar = "CMAKE_DISABLE_FIND_PACKAGE_";
|
|
|
|
disableFindPackageVar += this->Name;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Makefile->IsOn(disableFindPackageVar)) {
|
|
|
|
if (this->Required) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2011-06-16 23:11:06 +04:00
|
|
|
e << "for module " << this->Name << " called with REQUIRED, but "
|
|
|
|
<< disableFindPackageVar
|
|
|
|
<< " is enabled. A REQUIRED package cannot be disabled.";
|
2014-03-11 03:04:11 +04:00
|
|
|
this->SetError(e.str());
|
2011-06-16 23:11:06 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
return true;
|
|
|
|
}
|
2011-06-16 23:11:06 +04:00
|
|
|
|
2008-09-07 03:10:02 +04:00
|
|
|
this->SetModuleVariables(components);
|
2006-10-26 19:39:56 +04:00
|
|
|
|
2008-01-17 17:02:31 +03:00
|
|
|
// See if there is a Find<package>.cmake module.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->UseFindModules) {
|
2006-10-26 19:39:56 +04:00
|
|
|
bool foundModule = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->FindModule(foundModule)) {
|
2008-01-17 17:02:31 +03:00
|
|
|
this->AppendSuccessInformation();
|
2006-10-26 19:39:56 +04:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (foundModule) {
|
2008-01-17 17:02:31 +03:00
|
|
|
this->AppendSuccessInformation();
|
2006-10-26 19:39:56 +04:00
|
|
|
return true;
|
2003-01-22 01:15:22 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2003-08-08 00:50:38 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->UseFindModules && this->UseConfigFiles &&
|
|
|
|
this->Makefile->IsOn("CMAKE_FIND_PACKAGE_WARN_NO_MODULE")) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream aw;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->RequiredCMakeVersion >= CMake_VERSION_ENCODE(2, 8, 8)) {
|
2012-02-28 18:51:10 +04:00
|
|
|
aw << "find_package called without either MODULE or CONFIG option and "
|
2016-05-16 17:34:04 +03:00
|
|
|
"no Find"
|
|
|
|
<< this->Name
|
|
|
|
<< ".cmake module is in CMAKE_MODULE_PATH. "
|
|
|
|
"Add MODULE to exclusively request Module mode and fail if "
|
|
|
|
"Find"
|
|
|
|
<< this->Name
|
|
|
|
<< ".cmake is missing. "
|
|
|
|
"Add CONFIG to exclusively request Config mode and search for a "
|
|
|
|
"package configuration file provided by "
|
|
|
|
<< this->Name << " (" << this->Name << "Config.cmake or "
|
|
|
|
<< cmSystemTools::LowerCase(this->Name) << "-config.cmake). ";
|
|
|
|
} else {
|
|
|
|
aw
|
|
|
|
<< "find_package called without NO_MODULE option and no "
|
|
|
|
"Find"
|
|
|
|
<< this->Name
|
|
|
|
<< ".cmake module is in CMAKE_MODULE_PATH. "
|
|
|
|
"Add NO_MODULE to exclusively request Config mode and search for a "
|
|
|
|
"package configuration file provided by "
|
|
|
|
<< this->Name << " (" << this->Name << "Config.cmake or "
|
|
|
|
<< cmSystemTools::LowerCase(this->Name) << "-config.cmake). "
|
|
|
|
"Otherwise make Find"
|
|
|
|
<< this->Name << ".cmake available in "
|
|
|
|
"CMAKE_MODULE_PATH.";
|
|
|
|
}
|
2012-02-28 18:51:10 +04:00
|
|
|
aw << "\n"
|
2016-05-16 17:34:04 +03:00
|
|
|
"(Variable CMAKE_FIND_PACKAGE_WARN_NO_MODULE enabled this warning.)";
|
2012-02-28 18:51:10 +04:00
|
|
|
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, aw.str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-02-28 18:51:10 +04:00
|
|
|
|
2003-01-22 01:15:22 +03:00
|
|
|
// No find module. Assume the project has a CMake config file. Use
|
2008-01-17 17:02:31 +03:00
|
|
|
// a <package>_DIR cache variable to locate it.
|
2003-07-16 22:52:51 +04:00
|
|
|
this->Variable = this->Name;
|
2003-01-22 01:15:22 +03:00
|
|
|
this->Variable += "_DIR";
|
2004-04-26 18:49:34 +04:00
|
|
|
|
2008-01-17 17:02:31 +03:00
|
|
|
// Add the default name.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Names.empty()) {
|
2008-01-17 17:02:31 +03:00
|
|
|
this->Names.push_back(this->Name);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
|
|
|
|
// Add the default configs.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Configs.empty()) {
|
|
|
|
for (std::vector<std::string>::const_iterator ni = this->Names.begin();
|
|
|
|
ni != this->Names.end(); ++ni) {
|
2008-01-17 17:02:31 +03:00
|
|
|
std::string config = *ni;
|
|
|
|
config += "Config.cmake";
|
|
|
|
this->Configs.push_back(config);
|
|
|
|
|
|
|
|
config = cmSystemTools::LowerCase(*ni);
|
|
|
|
config += "-config.cmake";
|
|
|
|
this->Configs.push_back(config);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
|
2010-08-13 02:20:47 +04:00
|
|
|
// get igonored paths from vars and reroot them.
|
|
|
|
std::vector<std::string> ignored;
|
|
|
|
this->GetIgnoredPaths(ignored);
|
|
|
|
this->RerootPaths(ignored);
|
|
|
|
|
|
|
|
// Construct a set of ignored paths
|
|
|
|
this->IgnoredPaths.clear();
|
|
|
|
this->IgnoredPaths.insert(ignored.begin(), ignored.end());
|
|
|
|
|
2008-01-17 17:02:31 +03:00
|
|
|
// Find and load the package.
|
|
|
|
bool result = this->HandlePackageMode();
|
|
|
|
this->AppendSuccessInformation();
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2008-09-07 14:52:06 +04:00
|
|
|
void cmFindPackageCommand::SetModuleVariables(const std::string& components)
|
2008-01-17 17:02:31 +03:00
|
|
|
{
|
2012-09-23 20:40:40 +04:00
|
|
|
this->AddFindDefinition("CMAKE_FIND_PACKAGE_NAME", this->Name.c_str());
|
|
|
|
|
2008-09-07 03:10:02 +04:00
|
|
|
// Store the list of components.
|
|
|
|
std::string components_var = this->Name + "_FIND_COMPONENTS";
|
2014-03-11 03:04:11 +04:00
|
|
|
this->AddFindDefinition(components_var, components.c_str());
|
2010-08-29 19:07:39 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Quiet) {
|
2008-09-07 03:10:02 +04:00
|
|
|
// Tell the module that is about to be read that it should find
|
|
|
|
// quietly.
|
|
|
|
std::string quietly = this->Name;
|
|
|
|
quietly += "_FIND_QUIETLY";
|
2014-03-11 03:04:11 +04:00
|
|
|
this->AddFindDefinition(quietly, "1");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Required) {
|
2008-09-07 03:10:02 +04:00
|
|
|
// Tell the module that is about to be read that it should report
|
|
|
|
// a fatal error if the package is not found.
|
|
|
|
std::string req = this->Name;
|
|
|
|
req += "_FIND_REQUIRED";
|
2014-03-11 03:04:11 +04:00
|
|
|
this->AddFindDefinition(req, "1");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->Version.empty()) {
|
2008-09-07 03:10:02 +04:00
|
|
|
// Tell the module that is about to be read what version of the
|
|
|
|
// package has been requested.
|
|
|
|
std::string ver = this->Name;
|
|
|
|
ver += "_FIND_VERSION";
|
2014-03-11 03:04:11 +04:00
|
|
|
this->AddFindDefinition(ver, this->Version.c_str());
|
2008-09-07 03:10:02 +04:00
|
|
|
char buf[64];
|
2008-09-10 18:11:48 +04:00
|
|
|
sprintf(buf, "%u", this->VersionMajor);
|
2016-05-16 17:34:04 +03:00
|
|
|
this->AddFindDefinition(ver + "_MAJOR", buf);
|
2008-09-10 18:11:48 +04:00
|
|
|
sprintf(buf, "%u", this->VersionMinor);
|
2016-05-16 17:34:04 +03:00
|
|
|
this->AddFindDefinition(ver + "_MINOR", buf);
|
2008-09-10 18:11:48 +04:00
|
|
|
sprintf(buf, "%u", this->VersionPatch);
|
2016-05-16 17:34:04 +03:00
|
|
|
this->AddFindDefinition(ver + "_PATCH", buf);
|
2008-09-10 18:11:48 +04:00
|
|
|
sprintf(buf, "%u", this->VersionTweak);
|
2016-05-16 17:34:04 +03:00
|
|
|
this->AddFindDefinition(ver + "_TWEAK", buf);
|
2008-09-10 18:11:48 +04:00
|
|
|
sprintf(buf, "%u", this->VersionCount);
|
2016-05-16 17:34:04 +03:00
|
|
|
this->AddFindDefinition(ver + "_COUNT", buf);
|
2008-01-21 16:48:33 +03:00
|
|
|
|
2008-09-07 03:10:02 +04:00
|
|
|
// Tell the module whether an exact version has been requested.
|
|
|
|
std::string exact = this->Name;
|
|
|
|
exact += "_FIND_VERSION_EXACT";
|
2016-05-16 17:34:04 +03:00
|
|
|
this->AddFindDefinition(exact, this->VersionExact ? "1" : "0");
|
|
|
|
}
|
2008-09-07 03:10:02 +04:00
|
|
|
}
|
|
|
|
|
2014-02-05 01:06:56 +04:00
|
|
|
void cmFindPackageCommand::AddFindDefinition(const std::string& var,
|
|
|
|
const char* val)
|
2008-12-09 18:08:54 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* old = this->Makefile->GetDefinition(var)) {
|
2008-12-09 18:08:54 +03:00
|
|
|
this->OriginalDefs[var].exists = true;
|
|
|
|
this->OriginalDefs[var].value = old;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2008-12-09 18:08:54 +03:00
|
|
|
this->OriginalDefs[var].exists = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-12-09 18:08:54 +03:00
|
|
|
this->Makefile->AddDefinition(var, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmFindPackageCommand::RestoreFindDefinitions()
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::map<std::string, OriginalDef>::iterator i =
|
|
|
|
this->OriginalDefs.begin();
|
|
|
|
i != this->OriginalDefs.end(); ++i) {
|
2008-12-09 18:08:54 +03:00
|
|
|
OriginalDef const& od = i->second;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (od.exists) {
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->AddDefinition(i->first, od.value.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->RemoveDefinition(i->first);
|
2008-12-09 18:08:54 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-12-09 18:08:54 +03:00
|
|
|
}
|
2008-09-07 03:10:02 +04:00
|
|
|
|
|
|
|
bool cmFindPackageCommand::FindModule(bool& found)
|
|
|
|
{
|
|
|
|
std::string module = "Find";
|
|
|
|
module += this->Name;
|
|
|
|
module += ".cmake";
|
|
|
|
std::string mfile = this->Makefile->GetModulesFile(module.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!mfile.empty()) {
|
2008-10-03 18:40:07 +04:00
|
|
|
// Load the module we found, and set "<name>_FIND_MODULE" to true
|
|
|
|
// while inside it.
|
2008-01-17 17:02:31 +03:00
|
|
|
found = true;
|
2008-10-03 18:40:07 +04:00
|
|
|
std::string var = this->Name;
|
|
|
|
var += "_FIND_MODULE";
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->AddDefinition(var, "1");
|
2009-01-22 21:18:40 +03:00
|
|
|
bool result = this->ReadListFile(mfile.c_str(), DoPolicyScope);
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->RemoveDefinition(var);
|
2008-10-03 18:40:07 +04:00
|
|
|
return result;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmFindPackageCommand::HandlePackageMode()
|
|
|
|
{
|
2010-08-29 19:51:44 +04:00
|
|
|
this->ConsideredConfigs.clear();
|
2010-08-29 19:07:39 +04:00
|
|
|
|
2003-08-08 00:50:38 +04:00
|
|
|
// Support old capitalization behavior.
|
|
|
|
std::string upperDir = cmSystemTools::UpperCase(this->Name);
|
|
|
|
std::string upperFound = cmSystemTools::UpperCase(this->Name);
|
|
|
|
upperDir += "_DIR";
|
|
|
|
upperFound += "_FOUND";
|
2004-04-26 18:49:34 +04:00
|
|
|
|
2003-08-08 00:50:38 +04:00
|
|
|
// Try to find the config file.
|
2014-03-11 03:04:11 +04:00
|
|
|
const char* def = this->Makefile->GetDefinition(this->Variable);
|
2008-01-17 17:02:31 +03:00
|
|
|
|
2009-01-09 01:57:52 +03:00
|
|
|
// Try to load the config file if the directory is known
|
2009-10-07 22:37:30 +04:00
|
|
|
bool fileFound = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->UseConfigFiles) {
|
|
|
|
if (!cmSystemTools::IsOff(def)) {
|
2012-02-21 01:09:10 +04:00
|
|
|
// Get the directory from the variable value.
|
|
|
|
std::string dir = def;
|
|
|
|
cmSystemTools::ConvertToUnixSlashes(dir);
|
|
|
|
|
|
|
|
// Treat relative paths with respect to the current source dir.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::FileIsFullPath(dir.c_str())) {
|
2012-02-21 01:09:10 +04:00
|
|
|
dir = "/" + dir;
|
2015-04-16 22:17:41 +03:00
|
|
|
dir = this->Makefile->GetCurrentSourceDirectory() + dir;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-02-21 01:09:10 +04:00
|
|
|
// The file location was cached. Look for the correct file.
|
|
|
|
std::string file;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->FindConfigFile(dir, file)) {
|
2012-02-21 01:09:10 +04:00
|
|
|
this->FileFound = file;
|
|
|
|
fileFound = true;
|
2007-08-20 16:49:21 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
def = this->Makefile->GetDefinition(this->Variable);
|
|
|
|
}
|
2012-02-21 01:09:10 +04:00
|
|
|
|
|
|
|
// Search for the config file if it is not already found.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::IsOff(def) || !fileFound) {
|
2012-02-21 01:09:10 +04:00
|
|
|
fileFound = this->FindConfig();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-01-09 01:57:52 +03:00
|
|
|
|
2012-02-21 01:09:10 +04:00
|
|
|
// Sanity check.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (fileFound && this->FileFound.empty()) {
|
2012-02-21 01:09:10 +04:00
|
|
|
this->Makefile->IssueMessage(
|
|
|
|
cmake::INTERNAL_ERROR, "fileFound is true but FileFound is empty!");
|
|
|
|
fileFound = false;
|
2009-10-07 22:37:30 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-10-07 22:37:30 +04:00
|
|
|
|
2012-03-10 14:21:05 +04:00
|
|
|
std::string foundVar = this->Name;
|
|
|
|
foundVar += "_FOUND";
|
2012-09-19 23:50:55 +04:00
|
|
|
std::string notFoundMessageVar = this->Name;
|
|
|
|
notFoundMessageVar += "_NOT_FOUND_MESSAGE";
|
|
|
|
std::string notFoundMessage;
|
2012-03-10 14:21:05 +04:00
|
|
|
|
2009-01-09 01:57:52 +03:00
|
|
|
// If the directory for the config file was found, try to read the file.
|
|
|
|
bool result = true;
|
|
|
|
bool found = false;
|
2012-03-10 14:21:05 +04:00
|
|
|
bool configFileSetFOUNDFalse = false;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (fileFound) {
|
|
|
|
if ((this->Makefile->IsDefinitionSet(foundVar)) &&
|
|
|
|
(this->Makefile->IsOn(foundVar) == false)) {
|
2012-03-10 14:21:05 +04:00
|
|
|
// by removing Foo_FOUND here if it is FALSE, we don't really change
|
|
|
|
// the situation for the Config file which is about to be included,
|
|
|
|
// but we make it possible to detect later on whether the Config file
|
|
|
|
// has set Foo_FOUND to FALSE itself:
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->RemoveDefinition(foundVar);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->RemoveDefinition(notFoundMessageVar);
|
2012-03-10 14:21:05 +04:00
|
|
|
|
2009-01-09 01:57:52 +03:00
|
|
|
// Set the version variables before loading the config file.
|
|
|
|
// It may override them.
|
|
|
|
this->StoreVersionFound();
|
|
|
|
|
|
|
|
// Parse the configuration file.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->ReadListFile(this->FileFound.c_str(), DoPolicyScope)) {
|
2009-01-09 01:57:52 +03:00
|
|
|
// The package has been found.
|
|
|
|
found = true;
|
2012-03-10 14:21:05 +04:00
|
|
|
|
|
|
|
// Check whether the Config file has set Foo_FOUND to FALSE:
|
2016-05-16 17:34:04 +03:00
|
|
|
if ((this->Makefile->IsDefinitionSet(foundVar)) &&
|
|
|
|
(this->Makefile->IsOn(foundVar) == false)) {
|
2012-03-10 14:21:05 +04:00
|
|
|
// we get here if the Config file has set Foo_FOUND actively to FALSE
|
|
|
|
found = false;
|
|
|
|
configFileSetFOUNDFalse = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
notFoundMessage =
|
|
|
|
this->Makefile->GetSafeDefinition(notFoundMessageVar);
|
2003-01-22 01:15:22 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2009-01-09 01:57:52 +03:00
|
|
|
// The configuration file is invalid.
|
2008-01-17 17:02:31 +03:00
|
|
|
result = false;
|
2003-01-22 01:15:22 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-03-10 14:21:05 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (result && !found && (!this->Quiet || this->Required)) {
|
2008-01-17 17:02:31 +03:00
|
|
|
// The variable is not set.
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
|
|
|
std::ostringstream aw;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (configFileSetFOUNDFalse) {
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format off */
|
2012-03-10 14:21:05 +04:00
|
|
|
e << "Found package configuration file:\n"
|
|
|
|
" " << this->FileFound << "\n"
|
|
|
|
"but it set " << foundVar << " to FALSE so package \"" <<
|
|
|
|
this->Name << "\" is considered to be NOT FOUND.";
|
2016-05-06 21:19:04 +03:00
|
|
|
/* clang-format on */
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!notFoundMessage.empty()) {
|
2012-09-19 23:50:55 +04:00
|
|
|
e << " Reason given by package: \n" << notFoundMessage << "\n";
|
2012-03-10 14:21:05 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-08-29 19:43:45 +04:00
|
|
|
// If there are files in ConsideredConfigs, it means that FooConfig.cmake
|
|
|
|
// have been found, but they didn't have appropriate versions.
|
2016-05-16 17:34:04 +03:00
|
|
|
else if (!this->ConsideredConfigs.empty()) {
|
|
|
|
e << "Could not find a configuration file for package \"" << this->Name
|
|
|
|
<< "\" that "
|
|
|
|
<< (this->VersionExact ? "exactly matches" : "is compatible with")
|
2010-08-31 23:10:00 +04:00
|
|
|
<< " requested version \"" << this->Version << "\".\n"
|
|
|
|
<< "The following configuration files were considered but not "
|
|
|
|
"accepted:\n";
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<ConfigFileInfo>::size_type i = 0;
|
|
|
|
i < this->ConsideredConfigs.size(); i++) {
|
2010-08-29 19:51:44 +04:00
|
|
|
e << " " << this->ConsideredConfigs[i].filename
|
|
|
|
<< ", version: " << this->ConsideredConfigs[i].version << "\n";
|
2008-01-17 17:02:31 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2012-02-17 14:37:29 +04:00
|
|
|
std::string requestedVersionString;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->Version.empty()) {
|
2012-02-17 14:37:29 +04:00
|
|
|
requestedVersionString = " (requested version ";
|
|
|
|
requestedVersionString += this->Version;
|
|
|
|
requestedVersionString += ")";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-02-17 14:37:29 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->UseConfigFiles) {
|
|
|
|
if (this->UseFindModules) {
|
|
|
|
e << "By not providing \"Find" << this->Name
|
|
|
|
<< ".cmake\" in "
|
2012-02-21 01:09:10 +04:00
|
|
|
"CMAKE_MODULE_PATH this project has asked CMake to find a "
|
2016-05-16 17:34:04 +03:00
|
|
|
"package configuration file provided by \""
|
|
|
|
<< this->Name << "\", "
|
|
|
|
"but CMake did not find one.\n";
|
|
|
|
}
|
2012-02-24 23:33:21 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Configs.size() == 1) {
|
2012-02-21 01:09:10 +04:00
|
|
|
e << "Could not find a package configuration file named \""
|
2016-05-16 17:34:04 +03:00
|
|
|
<< this->Configs[0] << "\" provided by package \"" << this->Name
|
|
|
|
<< "\"" << requestedVersionString << ".\n";
|
|
|
|
} else {
|
2012-02-21 01:09:10 +04:00
|
|
|
e << "Could not find a package configuration file provided by \""
|
2012-02-17 14:37:29 +04:00
|
|
|
<< this->Name << "\"" << requestedVersionString
|
2015-02-19 00:14:26 +03:00
|
|
|
<< " with any of the following names:\n"
|
|
|
|
<< cmWrap(" ", this->Configs, "", "\n") << "\n";
|
2008-01-17 17:02:31 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
|
|
|
|
e << "Add the installation prefix of \"" << this->Name
|
|
|
|
<< "\" to "
|
|
|
|
"CMAKE_PREFIX_PATH or set \""
|
|
|
|
<< this->Variable << "\" to a "
|
|
|
|
"directory containing one of the above files. "
|
|
|
|
"If \""
|
|
|
|
<< this->Name << "\" provides a separate development "
|
|
|
|
"package or SDK, be sure it has been installed.";
|
|
|
|
} else // if(!this->UseFindModules && !this->UseConfigFiles)
|
|
|
|
{
|
2012-02-21 01:09:10 +04:00
|
|
|
e << "No \"Find" << this->Name << ".cmake\" found in "
|
|
|
|
<< "CMAKE_MODULE_PATH.";
|
2010-08-29 19:43:45 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
aw << "Find" << this->Name
|
|
|
|
<< ".cmake must either be part of this "
|
|
|
|
"project itself, in this case adjust CMAKE_MODULE_PATH so that "
|
|
|
|
"it points to the correct location inside its source tree.\n"
|
|
|
|
"Or it must be installed by a package which has already been "
|
|
|
|
"found via find_package(). In this case make sure that "
|
|
|
|
"package has indeed been found and adjust CMAKE_MODULE_PATH to "
|
|
|
|
"contain the location where that package has installed "
|
|
|
|
"Find"
|
|
|
|
<< this->Name
|
|
|
|
<< ".cmake. This must be a location "
|
|
|
|
"provided by that package. This error in general means that "
|
|
|
|
"the buildsystem of this project is relying on a Find-module "
|
|
|
|
"without ensuring that it is actually available.\n";
|
2012-02-24 23:33:21 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-02-21 01:09:10 +04:00
|
|
|
|
2008-09-08 18:08:33 +04:00
|
|
|
this->Makefile->IssueMessage(
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Required ? cmake::FATAL_ERROR : cmake::WARNING, e.str());
|
|
|
|
if (this->Required) {
|
2012-03-07 00:16:24 +04:00
|
|
|
cmSystemTools::SetFatalErrorOccured();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-02-21 01:09:10 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!aw.str().empty()) {
|
|
|
|
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, aw.str());
|
2003-01-22 01:15:22 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-04-26 18:49:34 +04:00
|
|
|
|
2003-08-08 00:50:38 +04:00
|
|
|
// Set a variable marking whether the package was found.
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Makefile->AddDefinition(foundVar, found ? "1" : "0");
|
2004-04-26 18:49:34 +04:00
|
|
|
|
2008-01-17 17:02:31 +03:00
|
|
|
// Set a variable naming the configuration file that was found.
|
|
|
|
std::string fileVar = this->Name;
|
|
|
|
fileVar += "_CONFIG";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (found) {
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->AddDefinition(fileVar, this->FileFound.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->RemoveDefinition(fileVar);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
|
2010-08-29 19:07:39 +04:00
|
|
|
std::string consideredConfigsVar = this->Name;
|
|
|
|
consideredConfigsVar += "_CONSIDERED_CONFIGS";
|
|
|
|
std::string consideredVersionsVar = this->Name;
|
|
|
|
consideredVersionsVar += "_CONSIDERED_VERSIONS";
|
|
|
|
|
|
|
|
std::string consideredConfigFiles;
|
|
|
|
std::string consideredVersions;
|
2010-08-29 19:43:45 +04:00
|
|
|
|
2010-08-31 23:10:00 +04:00
|
|
|
const char* sep = "";
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<ConfigFileInfo>::size_type i = 0;
|
|
|
|
i < this->ConsideredConfigs.size(); i++) {
|
2010-08-31 23:10:00 +04:00
|
|
|
consideredConfigFiles += sep;
|
|
|
|
consideredVersions += sep;
|
2010-08-29 19:51:44 +04:00
|
|
|
consideredConfigFiles += this->ConsideredConfigs[i].filename;
|
|
|
|
consideredVersions += this->ConsideredConfigs[i].version;
|
2010-08-31 23:10:00 +04:00
|
|
|
sep = ";";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-08-29 19:07:39 +04:00
|
|
|
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->AddDefinition(consideredConfigsVar,
|
2010-08-29 19:07:39 +04:00
|
|
|
consideredConfigFiles.c_str());
|
|
|
|
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->AddDefinition(consideredVersionsVar,
|
2010-08-29 19:07:39 +04:00
|
|
|
consideredVersions.c_str());
|
|
|
|
|
2003-01-22 01:15:22 +03:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2009-10-07 22:37:30 +04:00
|
|
|
bool cmFindPackageCommand::FindConfig()
|
2003-01-22 01:15:22 +03:00
|
|
|
{
|
2008-01-17 17:02:31 +03:00
|
|
|
// Compute the set of search prefixes.
|
|
|
|
this->ComputePrefixes();
|
2004-02-29 02:59:19 +03:00
|
|
|
|
2008-01-17 17:02:31 +03:00
|
|
|
// Look for the project's configuration file.
|
|
|
|
bool found = false;
|
2004-04-19 18:36:42 +04:00
|
|
|
|
2008-01-17 17:02:31 +03:00
|
|
|
// Search for frameworks.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!found && (this->SearchFrameworkFirst || this->SearchFrameworkOnly)) {
|
2008-01-17 17:02:31 +03:00
|
|
|
found = this->FindFrameworkConfig();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2003-01-22 01:15:22 +03:00
|
|
|
|
2008-01-17 17:02:31 +03:00
|
|
|
// Search for apps.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!found && (this->SearchAppBundleFirst || this->SearchAppBundleOnly)) {
|
2008-01-17 17:02:31 +03:00
|
|
|
found = this->FindAppBundleConfig();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-04-26 18:49:34 +04:00
|
|
|
|
2008-01-17 17:02:31 +03:00
|
|
|
// Search prefixes.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!found && !(this->SearchFrameworkOnly || this->SearchAppBundleOnly)) {
|
2008-01-17 17:02:31 +03:00
|
|
|
found = this->FindPrefixedConfig();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-04-26 18:49:34 +04:00
|
|
|
|
2008-01-17 17:02:31 +03:00
|
|
|
// Search for frameworks.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!found && this->SearchFrameworkLast) {
|
2008-01-17 17:02:31 +03:00
|
|
|
found = this->FindFrameworkConfig();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-04-26 18:49:34 +04:00
|
|
|
|
2008-01-17 17:02:31 +03:00
|
|
|
// Search for apps.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!found && this->SearchAppBundleLast) {
|
2008-01-17 17:02:31 +03:00
|
|
|
found = this->FindAppBundleConfig();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-04-26 18:49:34 +04:00
|
|
|
|
2003-01-22 01:15:22 +03:00
|
|
|
// Store the entry in the cache so it can be set by the user.
|
2008-01-17 17:02:31 +03:00
|
|
|
std::string init;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (found) {
|
2008-01-17 17:02:31 +03:00
|
|
|
init = cmSystemTools::GetFilenamePath(this->FileFound);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2008-01-17 17:02:31 +03:00
|
|
|
init = this->Variable + "-NOTFOUND";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
std::string help =
|
|
|
|
"The directory containing a CMake configuration file for ";
|
|
|
|
help += this->Name;
|
|
|
|
help += ".";
|
2009-10-07 22:37:30 +04:00
|
|
|
// We force the value since we do not get here if it was already set.
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Makefile->AddCacheDefinition(this->Variable, init.c_str(),
|
|
|
|
help.c_str(), cmState::PATH, true);
|
2009-10-07 22:37:30 +04:00
|
|
|
return found;
|
2003-01-22 01:15:22 +03:00
|
|
|
}
|
|
|
|
|
2008-01-17 17:02:31 +03:00
|
|
|
bool cmFindPackageCommand::FindPrefixedConfig()
|
2003-01-22 01:15:22 +03:00
|
|
|
{
|
2008-06-06 02:20:16 +04:00
|
|
|
std::vector<std::string>& prefixes = this->SearchPaths;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator pi = prefixes.begin();
|
|
|
|
pi != prefixes.end(); ++pi) {
|
|
|
|
if (this->SearchPrefix(*pi)) {
|
2008-01-17 17:02:31 +03:00
|
|
|
return true;
|
2004-04-26 19:00:41 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
return false;
|
|
|
|
}
|
2004-04-26 19:00:41 +04:00
|
|
|
|
2008-01-17 17:02:31 +03:00
|
|
|
bool cmFindPackageCommand::FindFrameworkConfig()
|
|
|
|
{
|
2008-06-06 02:20:16 +04:00
|
|
|
std::vector<std::string>& prefixes = this->SearchPaths;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator i = prefixes.begin();
|
|
|
|
i != prefixes.end(); ++i) {
|
|
|
|
if (this->SearchFrameworkPrefix(*i)) {
|
2008-01-17 17:02:31 +03:00
|
|
|
return true;
|
2003-01-22 01:15:22 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
return false;
|
|
|
|
}
|
2004-04-26 18:49:34 +04:00
|
|
|
|
2008-01-17 17:02:31 +03:00
|
|
|
bool cmFindPackageCommand::FindAppBundleConfig()
|
|
|
|
{
|
2008-06-06 02:20:16 +04:00
|
|
|
std::vector<std::string>& prefixes = this->SearchPaths;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator i = prefixes.begin();
|
|
|
|
i != prefixes.end(); ++i) {
|
|
|
|
if (this->SearchAppBundlePrefix(*i)) {
|
2008-01-17 17:02:31 +03:00
|
|
|
return true;
|
2003-01-22 01:15:22 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
return false;
|
2003-01-22 01:15:22 +03:00
|
|
|
}
|
|
|
|
|
2009-01-22 21:18:40 +03:00
|
|
|
bool cmFindPackageCommand::ReadListFile(const char* f, PolicyScopeRule psr)
|
2003-01-22 01:15:22 +03:00
|
|
|
{
|
2015-04-18 15:50:32 +03:00
|
|
|
const bool noPolicyScope = !this->PolicyScope || psr == NoPolicyScope;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Makefile->ReadDependentFile(f, noPolicyScope)) {
|
2003-01-22 01:15:22 +03:00
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2003-01-22 01:15:22 +03:00
|
|
|
std::string e = "Error reading CMake code from \"";
|
|
|
|
e += f;
|
|
|
|
e += "\".";
|
2014-03-11 03:04:11 +04:00
|
|
|
this->SetError(e);
|
2003-01-22 01:15:22 +03:00
|
|
|
return false;
|
|
|
|
}
|
2007-08-07 23:41:57 +04:00
|
|
|
|
2012-05-06 18:32:10 +04:00
|
|
|
void cmFindPackageCommand::AppendToFoundProperty(bool found)
|
2007-08-07 23:41:57 +04:00
|
|
|
{
|
2012-05-06 18:32:10 +04:00
|
|
|
std::vector<std::string> foundContents;
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* foundProp =
|
|
|
|
this->Makefile->GetState()->GetGlobalProperty("PACKAGES_FOUND");
|
|
|
|
if (foundProp && *foundProp) {
|
2012-05-06 18:32:10 +04:00
|
|
|
std::string tmp = foundProp;
|
2007-12-15 22:17:21 +03:00
|
|
|
|
2012-05-06 18:32:10 +04:00
|
|
|
cmSystemTools::ExpandListArgument(tmp, foundContents, false);
|
2016-05-16 17:34:04 +03:00
|
|
|
std::vector<std::string>::iterator nameIt =
|
|
|
|
std::find(foundContents.begin(), foundContents.end(), this->Name);
|
|
|
|
if (nameIt != foundContents.end()) {
|
2012-05-06 18:32:10 +04:00
|
|
|
foundContents.erase(nameIt);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-05-06 18:32:10 +04:00
|
|
|
|
|
|
|
std::vector<std::string> notFoundContents;
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* notFoundProp =
|
|
|
|
this->Makefile->GetState()->GetGlobalProperty("PACKAGES_NOT_FOUND");
|
|
|
|
if (notFoundProp && *notFoundProp) {
|
2012-05-06 18:32:10 +04:00
|
|
|
std::string tmp = notFoundProp;
|
|
|
|
|
|
|
|
cmSystemTools::ExpandListArgument(tmp, notFoundContents, false);
|
2016-05-16 17:34:04 +03:00
|
|
|
std::vector<std::string>::iterator nameIt =
|
|
|
|
std::find(notFoundContents.begin(), notFoundContents.end(), this->Name);
|
|
|
|
if (nameIt != notFoundContents.end()) {
|
2012-05-06 18:32:10 +04:00
|
|
|
notFoundContents.erase(nameIt);
|
2007-08-07 23:41:57 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-05-06 18:32:10 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (found) {
|
2012-05-06 18:32:10 +04:00
|
|
|
foundContents.push_back(this->Name);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2012-05-06 18:32:10 +04:00
|
|
|
notFoundContents.push_back(this->Name);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-05-06 18:32:10 +04:00
|
|
|
|
2015-01-14 23:31:46 +03:00
|
|
|
std::string tmp = cmJoin(foundContents, ";");
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Makefile->GetState()->SetGlobalProperty("PACKAGES_FOUND", tmp.c_str());
|
2012-05-06 18:32:10 +04:00
|
|
|
|
2015-01-14 23:31:46 +03:00
|
|
|
tmp = cmJoin(notFoundContents, ";");
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Makefile->GetState()->SetGlobalProperty("PACKAGES_NOT_FOUND",
|
|
|
|
tmp.c_str());
|
2012-05-06 18:32:10 +04:00
|
|
|
}
|
2007-08-07 23:41:57 +04:00
|
|
|
|
2008-01-17 17:02:31 +03:00
|
|
|
void cmFindPackageCommand::AppendSuccessInformation()
|
2007-08-07 23:41:57 +04:00
|
|
|
{
|
2014-02-03 23:18:37 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string transitivePropName = "_CMAKE_";
|
|
|
|
transitivePropName += this->Name + "_TRANSITIVE_DEPENDENCY";
|
|
|
|
this->Makefile->GetState()->SetGlobalProperty(transitivePropName, "False");
|
2014-02-03 23:18:37 +04:00
|
|
|
}
|
2007-08-07 23:41:57 +04:00
|
|
|
std::string found = this->Name;
|
|
|
|
found += "_FOUND";
|
|
|
|
std::string upperFound = cmSystemTools::UpperCase(found);
|
|
|
|
|
2014-03-11 03:04:11 +04:00
|
|
|
const char* upperResult = this->Makefile->GetDefinition(upperFound);
|
|
|
|
const char* result = this->Makefile->GetDefinition(found);
|
2016-05-16 17:34:04 +03:00
|
|
|
bool packageFound =
|
|
|
|
((cmSystemTools::IsOn(result)) || (cmSystemTools::IsOn(upperResult)));
|
2012-05-06 18:32:10 +04:00
|
|
|
|
|
|
|
this->AppendToFoundProperty(packageFound);
|
2008-12-09 18:08:54 +03:00
|
|
|
|
2011-07-17 19:48:00 +04:00
|
|
|
// Record whether the find was quiet or not, so this can be used
|
|
|
|
// e.g. in FeatureSummary.cmake
|
|
|
|
std::string quietInfoPropName = "_CMAKE_";
|
|
|
|
quietInfoPropName += this->Name;
|
|
|
|
quietInfoPropName += "_QUIET";
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Makefile->GetState()->SetGlobalProperty(
|
|
|
|
quietInfoPropName, this->Quiet ? "TRUE" : "FALSE");
|
2011-07-17 19:48:00 +04:00
|
|
|
|
2010-08-24 23:24:54 +04:00
|
|
|
// set a global property to record the required version of this package
|
|
|
|
std::string versionInfoPropName = "_CMAKE_";
|
|
|
|
versionInfoPropName += this->Name;
|
|
|
|
versionInfoPropName += "_REQUIRED_VERSION";
|
|
|
|
std::string versionInfo;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->Version.empty()) {
|
2010-08-24 23:24:54 +04:00
|
|
|
versionInfo = this->VersionExact ? "==" : ">=";
|
|
|
|
versionInfo += " ";
|
|
|
|
versionInfo += this->Version;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
this->Makefile->GetState()->SetGlobalProperty(versionInfoPropName,
|
|
|
|
versionInfo.c_str());
|
|
|
|
if (this->Required) {
|
2012-02-11 21:04:26 +04:00
|
|
|
std::string requiredInfoPropName = "_CMAKE_";
|
|
|
|
requiredInfoPropName += this->Name;
|
|
|
|
requiredInfoPropName += "_TYPE";
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Makefile->GetState()->SetGlobalProperty(requiredInfoPropName,
|
|
|
|
"REQUIRED");
|
|
|
|
}
|
2010-08-24 23:24:54 +04:00
|
|
|
|
2008-12-09 18:08:54 +03:00
|
|
|
// Restore original state of "_FIND_" variables we set.
|
|
|
|
this->RestoreFindDefinitions();
|
2007-08-07 23:41:57 +04:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
|
2008-06-06 02:20:16 +04:00
|
|
|
void cmFindPackageCommand::ComputePrefixes()
|
2008-01-17 17:02:31 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->NoDefaultPath) {
|
|
|
|
if (!this->NoCMakePath) {
|
2014-10-09 21:52:54 +04:00
|
|
|
this->FillPrefixesCMakeVariable();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!this->NoCMakeEnvironmentPath) {
|
2014-10-09 21:52:54 +04:00
|
|
|
this->FillPrefixesCMakeEnvironment();
|
2015-09-09 23:03:04 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-09-09 23:03:04 +03:00
|
|
|
this->FillPrefixesUserHints();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->NoDefaultPath) {
|
|
|
|
if (!this->NoSystemEnvironmentPath) {
|
2014-10-09 21:52:54 +04:00
|
|
|
this->FillPrefixesSystemEnvironment();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!this->NoUserRegistry) {
|
2014-10-09 21:52:54 +04:00
|
|
|
this->FillPrefixesUserRegistry();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!this->NoCMakeSystemPath) {
|
2014-10-09 21:52:54 +04:00
|
|
|
this->FillPrefixesCMakeSystemVariable();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!this->NoSystemRegistry) {
|
2014-10-09 21:52:54 +04:00
|
|
|
this->FillPrefixesSystemRegistry();
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-10-09 21:52:54 +04:00
|
|
|
this->FillPrefixesUserGuess();
|
|
|
|
|
2011-09-23 22:27:25 +04:00
|
|
|
this->ComputeFinalPaths();
|
2008-01-17 17:02:31 +03:00
|
|
|
}
|
|
|
|
|
2014-10-09 21:52:54 +04:00
|
|
|
void cmFindPackageCommand::FillPrefixesCMakeEnvironment()
|
2008-01-17 17:02:31 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSearchPath& paths = this->LabeledPaths[PathLabel::CMakeEnvironment];
|
2014-10-17 21:07:26 +04:00
|
|
|
|
2014-10-09 21:52:54 +04:00
|
|
|
// Check the environment variable with the same name as the cache
|
|
|
|
// entry.
|
2014-10-17 21:07:26 +04:00
|
|
|
paths.AddEnvPath(this->Variable);
|
2014-10-09 21:52:54 +04:00
|
|
|
|
2014-10-16 00:36:42 +04:00
|
|
|
// And now the general CMake environment variables
|
2014-10-17 21:07:26 +04:00
|
|
|
paths.AddEnvPath("CMAKE_PREFIX_PATH");
|
|
|
|
paths.AddEnvPath("CMAKE_FRAMEWORK_PATH");
|
|
|
|
paths.AddEnvPath("CMAKE_APPBUNDLE_PATH");
|
2008-06-06 02:20:16 +04:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
|
2014-10-09 21:52:54 +04:00
|
|
|
void cmFindPackageCommand::FillPrefixesCMakeVariable()
|
2008-06-06 02:20:16 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSearchPath& paths = this->LabeledPaths[PathLabel::CMake];
|
2014-10-17 21:07:26 +04:00
|
|
|
|
|
|
|
paths.AddCMakePath("CMAKE_PREFIX_PATH");
|
|
|
|
paths.AddCMakePath("CMAKE_FRAMEWORK_PATH");
|
|
|
|
paths.AddCMakePath("CMAKE_APPBUNDLE_PATH");
|
2008-06-06 02:20:16 +04:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
|
2014-10-09 21:52:54 +04:00
|
|
|
void cmFindPackageCommand::FillPrefixesSystemEnvironment()
|
2008-06-06 02:20:16 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSearchPath& paths = this->LabeledPaths[PathLabel::SystemEnvironment];
|
2014-10-17 21:07:26 +04:00
|
|
|
|
2014-10-09 21:52:54 +04:00
|
|
|
// Use the system search path to generate prefixes.
|
|
|
|
// Relative paths are interpreted with respect to the current
|
|
|
|
// working directory.
|
|
|
|
std::vector<std::string> tmp;
|
|
|
|
cmSystemTools::GetPath(tmp);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::iterator i = tmp.begin(); i != tmp.end();
|
|
|
|
++i) {
|
2014-10-09 21:52:54 +04:00
|
|
|
// If the path is a PREFIX/bin case then add its parent instead.
|
2016-05-16 17:34:04 +03:00
|
|
|
if ((cmHasLiteralSuffix(*i, "/bin")) ||
|
|
|
|
(cmHasLiteralSuffix(*i, "/sbin"))) {
|
2014-10-17 21:07:26 +04:00
|
|
|
paths.AddPath(cmSystemTools::GetFilenamePath(*i));
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-10-17 21:07:26 +04:00
|
|
|
paths.AddPath(*i);
|
2008-01-17 17:02:31 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-06-06 02:20:16 +04:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
|
2014-10-09 21:52:54 +04:00
|
|
|
void cmFindPackageCommand::FillPrefixesUserRegistry()
|
2009-09-01 22:04:27 +04:00
|
|
|
{
|
|
|
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
2011-04-13 21:17:42 +04:00
|
|
|
this->LoadPackageRegistryWinUser();
|
2009-09-28 17:45:34 +04:00
|
|
|
#elif defined(__HAIKU__)
|
2013-10-05 18:31:36 +04:00
|
|
|
char dir[B_PATH_NAME_LENGTH];
|
|
|
|
if (find_directory(B_USER_SETTINGS_DIRECTORY, -1, false, dir, sizeof(dir)) ==
|
2016-05-16 17:34:04 +03:00
|
|
|
B_OK) {
|
2013-10-05 18:31:36 +04:00
|
|
|
std::string fname = dir;
|
|
|
|
fname += "/cmake/packages/";
|
|
|
|
fname += Name;
|
2014-10-17 21:07:26 +04:00
|
|
|
this->LoadPackageRegistryDir(fname,
|
|
|
|
this->LabeledPaths[PathLabel::UserRegistry]);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-09-01 22:04:27 +04:00
|
|
|
#else
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* home = cmSystemTools::GetEnv("HOME")) {
|
2009-09-01 22:04:27 +04:00
|
|
|
std::string dir = home;
|
|
|
|
dir += "/.cmake/packages/";
|
|
|
|
dir += this->Name;
|
2014-10-17 21:07:26 +04:00
|
|
|
this->LoadPackageRegistryDir(dir,
|
|
|
|
this->LabeledPaths[PathLabel::UserRegistry]);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-09-01 22:04:27 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-10-09 21:52:54 +04:00
|
|
|
void cmFindPackageCommand::FillPrefixesSystemRegistry()
|
2011-04-13 21:14:41 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->NoSystemRegistry || this->NoDefaultPath) {
|
2011-04-13 21:14:41 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-04-13 21:14:41 +04:00
|
|
|
|
|
|
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
2011-04-13 21:17:42 +04:00
|
|
|
this->LoadPackageRegistryWinSystem();
|
2011-04-13 21:14:41 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-09-01 22:04:27 +04:00
|
|
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
2016-05-16 17:34:04 +03:00
|
|
|
#include <windows.h>
|
|
|
|
#undef GetCurrentDirectory
|
|
|
|
// http://msdn.microsoft.com/en-us/library/aa384253%28v=vs.85%29.aspx
|
|
|
|
#if !defined(KEY_WOW64_32KEY)
|
|
|
|
#define KEY_WOW64_32KEY 0x0200
|
|
|
|
#endif
|
|
|
|
#if !defined(KEY_WOW64_64KEY)
|
|
|
|
#define KEY_WOW64_64KEY 0x0100
|
|
|
|
#endif
|
2011-04-13 21:17:42 +04:00
|
|
|
void cmFindPackageCommand::LoadPackageRegistryWinUser()
|
|
|
|
{
|
|
|
|
// HKEY_CURRENT_USER\\Software shares 32-bit and 64-bit views.
|
2014-10-17 21:07:26 +04:00
|
|
|
this->LoadPackageRegistryWin(true, 0,
|
|
|
|
this->LabeledPaths[PathLabel::UserRegistry]);
|
2011-04-13 21:17:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmFindPackageCommand::LoadPackageRegistryWinSystem()
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSearchPath& paths = this->LabeledPaths[PathLabel::SystemRegistry];
|
2014-10-17 21:07:26 +04:00
|
|
|
|
2011-04-13 21:17:42 +04:00
|
|
|
// HKEY_LOCAL_MACHINE\\SOFTWARE has separate 32-bit and 64-bit views.
|
|
|
|
// Prefer the target platform view first.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Makefile->PlatformIs64Bit()) {
|
2014-10-17 21:07:26 +04:00
|
|
|
this->LoadPackageRegistryWin(false, KEY_WOW64_64KEY, paths);
|
|
|
|
this->LoadPackageRegistryWin(false, KEY_WOW64_32KEY, paths);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-10-17 21:07:26 +04:00
|
|
|
this->LoadPackageRegistryWin(false, KEY_WOW64_32KEY, paths);
|
|
|
|
this->LoadPackageRegistryWin(false, KEY_WOW64_64KEY, paths);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2011-04-13 21:17:42 +04:00
|
|
|
}
|
|
|
|
|
2014-10-09 21:52:54 +04:00
|
|
|
void cmFindPackageCommand::LoadPackageRegistryWin(bool user, unsigned int view,
|
2014-10-16 00:36:42 +04:00
|
|
|
cmSearchPath& outPaths)
|
2009-09-01 22:04:27 +04:00
|
|
|
{
|
2013-12-05 09:17:24 +04:00
|
|
|
std::wstring key = L"Software\\Kitware\\CMake\\Packages\\";
|
|
|
|
key += cmsys::Encoding::ToWide(this->Name);
|
|
|
|
std::set<std::wstring> bad;
|
2009-09-01 22:04:27 +04:00
|
|
|
HKEY hKey;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (RegOpenKeyExW(user ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE, key.c_str(),
|
|
|
|
0, KEY_QUERY_VALUE | view, &hKey) == ERROR_SUCCESS) {
|
2009-09-01 22:04:27 +04:00
|
|
|
DWORD valueType = REG_NONE;
|
2013-12-05 09:17:24 +04:00
|
|
|
wchar_t name[16383]; // RegEnumValue docs limit name to 32767 _bytes_
|
|
|
|
std::vector<wchar_t> data(512);
|
2009-09-01 22:04:27 +04:00
|
|
|
bool done = false;
|
|
|
|
DWORD index = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
while (!done) {
|
2009-09-01 22:04:27 +04:00
|
|
|
DWORD nameSize = static_cast<DWORD>(sizeof(name));
|
2016-05-16 17:34:04 +03:00
|
|
|
DWORD dataSize = static_cast<DWORD>(data.size() * sizeof(data[0]));
|
|
|
|
switch (RegEnumValueW(hKey, index, name, &nameSize, 0, &valueType,
|
|
|
|
(BYTE*)&data[0], &dataSize)) {
|
2009-09-01 22:04:27 +04:00
|
|
|
case ERROR_SUCCESS:
|
|
|
|
++index;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (valueType == REG_SZ) {
|
2009-09-01 22:04:27 +04:00
|
|
|
data[dataSize] = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->CheckPackageRegistryEntry(
|
|
|
|
cmsys::Encoding::ToNarrow(&data[0]), outPaths)) {
|
2011-04-13 19:00:06 +04:00
|
|
|
// The entry is invalid.
|
|
|
|
bad.insert(name);
|
2009-09-01 22:04:27 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-09-01 22:04:27 +04:00
|
|
|
break;
|
|
|
|
case ERROR_MORE_DATA:
|
2016-05-16 17:34:04 +03:00
|
|
|
data.resize((dataSize + sizeof(data[0]) - 1) / sizeof(data[0]));
|
|
|
|
break;
|
|
|
|
case ERROR_NO_MORE_ITEMS:
|
|
|
|
default:
|
|
|
|
done = true;
|
2009-09-01 22:04:27 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
RegCloseKey(hKey);
|
|
|
|
}
|
2009-09-01 22:04:27 +04:00
|
|
|
|
|
|
|
// Remove bad values if possible.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (user && !bad.empty() &&
|
|
|
|
RegOpenKeyExW(HKEY_CURRENT_USER, key.c_str(), 0, KEY_SET_VALUE | view,
|
|
|
|
&hKey) == ERROR_SUCCESS) {
|
|
|
|
for (std::set<std::wstring>::const_iterator vi = bad.begin();
|
|
|
|
vi != bad.end(); ++vi) {
|
2013-12-05 09:17:24 +04:00
|
|
|
RegDeleteValueW(hKey, vi->c_str());
|
2009-09-01 22:04:27 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
RegCloseKey(hKey);
|
|
|
|
}
|
2009-09-01 22:04:27 +04:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
class cmFindPackageCommandHoldFile
|
|
|
|
{
|
|
|
|
const char* File;
|
2016-05-16 17:34:04 +03:00
|
|
|
|
2009-09-01 22:04:27 +04:00
|
|
|
public:
|
2016-05-16 17:34:04 +03:00
|
|
|
cmFindPackageCommandHoldFile(const char* f)
|
|
|
|
: File(f)
|
|
|
|
{
|
|
|
|
}
|
2009-09-01 22:04:27 +04:00
|
|
|
~cmFindPackageCommandHoldFile()
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
|
|
|
if (this->File) {
|
|
|
|
cmSystemTools::RemoveFile(this->File);
|
|
|
|
}
|
|
|
|
}
|
2009-09-01 22:04:27 +04:00
|
|
|
void Release() { this->File = 0; }
|
|
|
|
};
|
|
|
|
|
2014-10-09 21:52:54 +04:00
|
|
|
void cmFindPackageCommand::LoadPackageRegistryDir(std::string const& dir,
|
2014-10-16 00:36:42 +04:00
|
|
|
cmSearchPath& outPaths)
|
2009-09-01 22:04:27 +04:00
|
|
|
{
|
|
|
|
cmsys::Directory files;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!files.Load(dir)) {
|
2009-09-01 22:04:27 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-09-01 22:04:27 +04:00
|
|
|
|
|
|
|
std::string fname;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (unsigned long i = 0; i < files.GetNumberOfFiles(); ++i) {
|
2009-09-01 22:04:27 +04:00
|
|
|
fname = dir;
|
|
|
|
fname += "/";
|
|
|
|
fname += files.GetFile(i);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::FileIsDirectory(fname)) {
|
2009-09-01 22:04:27 +04:00
|
|
|
// Hold this file hostage until it behaves.
|
|
|
|
cmFindPackageCommandHoldFile holdFile(fname.c_str());
|
|
|
|
|
|
|
|
// Load the file.
|
2015-08-20 23:02:20 +03:00
|
|
|
cmsys::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary);
|
2014-10-09 21:52:54 +04:00
|
|
|
std::string fentry;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (fin && cmSystemTools::GetLineFromStream(fin, fentry) &&
|
|
|
|
this->CheckPackageRegistryEntry(fentry, outPaths)) {
|
2009-09-01 22:04:27 +04:00
|
|
|
// The file references an existing package, so release it.
|
|
|
|
holdFile.Release();
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-09-01 22:04:27 +04:00
|
|
|
|
|
|
|
// TODO: Wipe out the directory if it is empty.
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-10-09 21:52:54 +04:00
|
|
|
bool cmFindPackageCommand::CheckPackageRegistryEntry(const std::string& fname,
|
2014-10-16 00:36:42 +04:00
|
|
|
cmSearchPath& outPaths)
|
2009-09-01 22:04:27 +04:00
|
|
|
{
|
|
|
|
// Parse the content of one package registry entry.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::FileIsFullPath(fname.c_str())) {
|
2009-09-01 22:04:27 +04:00
|
|
|
// The first line in the stream is the full path to a file or
|
|
|
|
// directory containing the package.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::FileExists(fname.c_str())) {
|
2009-09-01 22:04:27 +04:00
|
|
|
// The path exists. Look for the package here.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::FileIsDirectory(fname)) {
|
2014-10-16 00:36:42 +04:00
|
|
|
outPaths.AddPath(cmSystemTools::GetFilenamePath(fname));
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-10-16 00:36:42 +04:00
|
|
|
outPaths.AddPath(fname);
|
2009-09-01 22:04:27 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return true;
|
|
|
|
} else {
|
2009-09-01 22:04:27 +04:00
|
|
|
// The path does not exist. Assume the stream content is
|
|
|
|
// associated with an old package that no longer exists, and
|
|
|
|
// delete it to keep the package registry clean.
|
|
|
|
return false;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2009-09-01 22:04:27 +04:00
|
|
|
// The first line in the stream is not the full path to a file or
|
|
|
|
// directory. Assume the stream content was created by a future
|
|
|
|
// version of CMake that uses a different format, and leave it.
|
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-09-01 22:04:27 +04:00
|
|
|
}
|
|
|
|
|
2014-10-09 21:52:54 +04:00
|
|
|
void cmFindPackageCommand::FillPrefixesCMakeSystemVariable()
|
2008-06-06 02:20:16 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSearchPath& paths = this->LabeledPaths[PathLabel::CMakeSystem];
|
2014-10-17 21:07:26 +04:00
|
|
|
|
|
|
|
paths.AddCMakePath("CMAKE_SYSTEM_PREFIX_PATH");
|
|
|
|
paths.AddCMakePath("CMAKE_SYSTEM_FRAMEWORK_PATH");
|
|
|
|
paths.AddCMakePath("CMAKE_SYSTEM_APPBUNDLE_PATH");
|
2008-06-06 02:20:16 +04:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
|
2014-10-09 21:52:54 +04:00
|
|
|
void cmFindPackageCommand::FillPrefixesUserGuess()
|
2008-06-06 02:20:16 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSearchPath& paths = this->LabeledPaths[PathLabel::Guess];
|
2014-10-17 21:07:26 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator p =
|
|
|
|
this->UserGuessArgs.begin();
|
|
|
|
p != this->UserGuessArgs.end(); ++p) {
|
2014-10-17 21:07:26 +04:00
|
|
|
paths.AddUserPath(*p);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-06-09 23:08:59 +04:00
|
|
|
}
|
|
|
|
|
2014-10-09 21:52:54 +04:00
|
|
|
void cmFindPackageCommand::FillPrefixesUserHints()
|
2008-06-09 23:08:59 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSearchPath& paths = this->LabeledPaths[PathLabel::Hints];
|
2014-10-17 21:07:26 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator p =
|
|
|
|
this->UserHintsArgs.begin();
|
|
|
|
p != this->UserHintsArgs.end(); ++p) {
|
2014-10-17 21:07:26 +04:00
|
|
|
paths.AddUserPath(*p);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-06-06 02:20:16 +04:00
|
|
|
}
|
|
|
|
|
2008-01-17 17:02:31 +03:00
|
|
|
bool cmFindPackageCommand::SearchDirectory(std::string const& dir)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
assert(!dir.empty() && dir[dir.size() - 1] == '/');
|
2008-01-17 17:02:31 +03:00
|
|
|
|
|
|
|
// Check each path suffix on this directory.
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator si =
|
|
|
|
this->SearchPathSuffixes.begin();
|
|
|
|
si != this->SearchPathSuffixes.end(); ++si) {
|
2008-01-17 17:02:31 +03:00
|
|
|
std::string d = dir;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!si->empty()) {
|
2008-01-17 17:02:31 +03:00
|
|
|
d += *si;
|
|
|
|
d += "/";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (this->CheckDirectory(d)) {
|
2008-01-17 17:02:31 +03:00
|
|
|
return true;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmFindPackageCommand::CheckDirectory(std::string const& dir)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
assert(!dir.empty() && dir[dir.size() - 1] == '/');
|
2008-01-17 17:02:31 +03:00
|
|
|
|
|
|
|
// Look for the file in this directory.
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string d = dir.substr(0, dir.size() - 1);
|
|
|
|
if (this->FindConfigFile(d, this->FileFound)) {
|
2008-01-29 04:38:48 +03:00
|
|
|
// Remove duplicate slashes.
|
|
|
|
cmSystemTools::ConvertToUnixSlashes(this->FileFound);
|
2008-01-17 17:02:31 +03:00
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmFindPackageCommand::FindConfigFile(std::string const& dir,
|
|
|
|
std::string& file)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->IgnoredPaths.count(dir)) {
|
2010-08-13 02:20:47 +04:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-08-13 02:20:47 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator ci = this->Configs.begin();
|
|
|
|
ci != this->Configs.end(); ++ci) {
|
2008-01-17 17:02:31 +03:00
|
|
|
file = dir;
|
|
|
|
file += "/";
|
|
|
|
file += *ci;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->DebugMode) {
|
2008-01-17 17:02:31 +03:00
|
|
|
fprintf(stderr, "Checking file [%s]\n", file.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (cmSystemTools::FileExists(file.c_str(), true) &&
|
|
|
|
this->CheckVersion(file)) {
|
2008-01-17 17:02:31 +03:00
|
|
|
return true;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-01-29 04:38:48 +03:00
|
|
|
bool cmFindPackageCommand::CheckVersion(std::string const& config_file)
|
|
|
|
{
|
2010-08-29 19:07:39 +04:00
|
|
|
bool result = false; // by default, assume the version is not ok.
|
|
|
|
bool haveResult = false;
|
|
|
|
std::string version = "unknown";
|
|
|
|
|
2008-01-29 04:38:48 +03:00
|
|
|
// Get the filename without the .cmake extension.
|
|
|
|
std::string::size_type pos = config_file.rfind('.');
|
|
|
|
std::string version_file_base = config_file.substr(0, pos);
|
|
|
|
|
|
|
|
// Look for foo-config-version.cmake
|
|
|
|
std::string version_file = version_file_base;
|
|
|
|
version_file += "-version.cmake";
|
2016-05-16 17:34:04 +03:00
|
|
|
if ((haveResult == false) &&
|
|
|
|
(cmSystemTools::FileExists(version_file.c_str(), true))) {
|
2010-08-29 19:07:39 +04:00
|
|
|
result = this->CheckVersionFile(version_file, version);
|
|
|
|
haveResult = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-29 04:38:48 +03:00
|
|
|
|
|
|
|
// Look for fooConfigVersion.cmake
|
|
|
|
version_file = version_file_base;
|
|
|
|
version_file += "Version.cmake";
|
2016-05-16 17:34:04 +03:00
|
|
|
if ((haveResult == false) &&
|
|
|
|
(cmSystemTools::FileExists(version_file.c_str(), true))) {
|
2010-08-29 19:07:39 +04:00
|
|
|
result = this->CheckVersionFile(version_file, version);
|
|
|
|
haveResult = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-08-29 19:07:39 +04:00
|
|
|
|
2008-01-29 04:38:48 +03:00
|
|
|
// If no version was requested a versionless package is acceptable.
|
2016-05-16 17:34:04 +03:00
|
|
|
if ((haveResult == false) && (this->Version.empty())) {
|
2010-08-29 19:07:39 +04:00
|
|
|
result = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-29 04:38:48 +03:00
|
|
|
|
2010-08-29 19:51:44 +04:00
|
|
|
ConfigFileInfo configFileInfo;
|
|
|
|
configFileInfo.filename = config_file;
|
|
|
|
configFileInfo.version = version;
|
|
|
|
this->ConsideredConfigs.push_back(configFileInfo);
|
2010-08-29 19:07:39 +04:00
|
|
|
|
|
|
|
return result;
|
2008-01-29 04:38:48 +03:00
|
|
|
}
|
|
|
|
|
2010-08-29 19:07:39 +04:00
|
|
|
bool cmFindPackageCommand::CheckVersionFile(std::string const& version_file,
|
|
|
|
std::string& result_version)
|
2008-01-29 04:38:48 +03:00
|
|
|
{
|
|
|
|
// The version file will be loaded in an isolated scope.
|
2009-01-22 18:56:58 +03:00
|
|
|
cmMakefile::ScopePushPop varScope(this->Makefile);
|
|
|
|
cmMakefile::PolicyPushPop polScope(this->Makefile);
|
|
|
|
static_cast<void>(varScope);
|
|
|
|
static_cast<void>(polScope);
|
2008-01-29 04:38:48 +03:00
|
|
|
|
|
|
|
// Clear the output variables.
|
|
|
|
this->Makefile->RemoveDefinition("PACKAGE_VERSION");
|
2008-10-03 18:41:15 +04:00
|
|
|
this->Makefile->RemoveDefinition("PACKAGE_VERSION_UNSUITABLE");
|
2008-01-29 04:38:48 +03:00
|
|
|
this->Makefile->RemoveDefinition("PACKAGE_VERSION_COMPATIBLE");
|
|
|
|
this->Makefile->RemoveDefinition("PACKAGE_VERSION_EXACT");
|
|
|
|
|
|
|
|
// Set the input variables.
|
|
|
|
this->Makefile->AddDefinition("PACKAGE_FIND_NAME", this->Name.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Makefile->AddDefinition("PACKAGE_FIND_VERSION", this->Version.c_str());
|
2008-09-10 18:11:48 +04:00
|
|
|
char buf[64];
|
|
|
|
sprintf(buf, "%u", this->VersionMajor);
|
|
|
|
this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_MAJOR", buf);
|
|
|
|
sprintf(buf, "%u", this->VersionMinor);
|
|
|
|
this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_MINOR", buf);
|
|
|
|
sprintf(buf, "%u", this->VersionPatch);
|
|
|
|
this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_PATCH", buf);
|
|
|
|
sprintf(buf, "%u", this->VersionTweak);
|
|
|
|
this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_TWEAK", buf);
|
|
|
|
sprintf(buf, "%u", this->VersionCount);
|
|
|
|
this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_COUNT", buf);
|
2008-01-29 04:38:48 +03:00
|
|
|
|
2009-01-22 21:18:40 +03:00
|
|
|
// Load the version check file. Pass NoPolicyScope because we do
|
|
|
|
// our own policy push/pop independent of CMP0011.
|
2008-10-03 18:41:15 +04:00
|
|
|
bool suitable = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->ReadListFile(version_file.c_str(), NoPolicyScope)) {
|
2008-01-29 04:38:48 +03:00
|
|
|
// Check the output variables.
|
2008-10-03 18:41:15 +04:00
|
|
|
bool okay = this->Makefile->IsOn("PACKAGE_VERSION_EXACT");
|
|
|
|
bool unsuitable = this->Makefile->IsOn("PACKAGE_VERSION_UNSUITABLE");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!okay && !this->VersionExact) {
|
2008-10-03 18:41:15 +04:00
|
|
|
okay = this->Makefile->IsOn("PACKAGE_VERSION_COMPATIBLE");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-10-03 18:41:15 +04:00
|
|
|
|
|
|
|
// The package is suitable if the version is okay and not
|
|
|
|
// explicitly unsuitable.
|
|
|
|
suitable = !unsuitable && (okay || this->Version.empty());
|
2016-05-16 17:34:04 +03:00
|
|
|
if (suitable) {
|
2008-01-29 04:38:48 +03:00
|
|
|
// Get the version found.
|
|
|
|
this->VersionFound =
|
|
|
|
this->Makefile->GetSafeDefinition("PACKAGE_VERSION");
|
|
|
|
|
|
|
|
// Try to parse the version number and store the results that were
|
|
|
|
// successfully parsed.
|
|
|
|
unsigned int parsed_major;
|
|
|
|
unsigned int parsed_minor;
|
|
|
|
unsigned int parsed_patch;
|
2008-09-10 18:11:48 +04:00
|
|
|
unsigned int parsed_tweak;
|
2008-01-29 04:38:48 +03:00
|
|
|
this->VersionFoundCount =
|
2016-05-16 17:34:04 +03:00
|
|
|
sscanf(this->VersionFound.c_str(), "%u.%u.%u.%u", &parsed_major,
|
|
|
|
&parsed_minor, &parsed_patch, &parsed_tweak);
|
|
|
|
switch (this->VersionFoundCount) {
|
|
|
|
case 4:
|
|
|
|
this->VersionFoundTweak = parsed_tweak; // no break!
|
|
|
|
case 3:
|
|
|
|
this->VersionFoundPatch = parsed_patch; // no break!
|
|
|
|
case 2:
|
|
|
|
this->VersionFoundMinor = parsed_minor; // no break!
|
|
|
|
case 1:
|
|
|
|
this->VersionFoundMajor = parsed_major; // no break!
|
|
|
|
default:
|
|
|
|
break;
|
2008-01-29 04:38:48 +03:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-29 04:38:48 +03:00
|
|
|
|
2010-08-29 19:07:39 +04:00
|
|
|
result_version = this->Makefile->GetSafeDefinition("PACKAGE_VERSION");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (result_version.empty()) {
|
2010-08-29 19:07:39 +04:00
|
|
|
result_version = "unknown";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-08-29 19:07:39 +04:00
|
|
|
|
2008-10-03 18:41:15 +04:00
|
|
|
// Succeed if the version is suitable.
|
|
|
|
return suitable;
|
2008-01-29 04:38:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmFindPackageCommand::StoreVersionFound()
|
|
|
|
{
|
|
|
|
// Store the whole version string.
|
|
|
|
std::string ver = this->Name;
|
|
|
|
ver += "_VERSION";
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->VersionFound.empty()) {
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->RemoveDefinition(ver);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->AddDefinition(ver, this->VersionFound.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-29 04:38:48 +03:00
|
|
|
|
2008-09-10 18:11:48 +04:00
|
|
|
// Store the version components.
|
2008-01-29 04:38:48 +03:00
|
|
|
char buf[64];
|
2008-09-10 18:11:48 +04:00
|
|
|
sprintf(buf, "%u", this->VersionFoundMajor);
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Makefile->AddDefinition(ver + "_MAJOR", buf);
|
2008-09-10 18:11:48 +04:00
|
|
|
sprintf(buf, "%u", this->VersionFoundMinor);
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Makefile->AddDefinition(ver + "_MINOR", buf);
|
2008-09-10 18:11:48 +04:00
|
|
|
sprintf(buf, "%u", this->VersionFoundPatch);
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Makefile->AddDefinition(ver + "_PATCH", buf);
|
2008-09-10 18:11:48 +04:00
|
|
|
sprintf(buf, "%u", this->VersionFoundTweak);
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Makefile->AddDefinition(ver + "_TWEAK", buf);
|
2008-09-10 18:11:48 +04:00
|
|
|
sprintf(buf, "%u", this->VersionFoundCount);
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Makefile->AddDefinition(ver + "_COUNT", buf);
|
2008-01-29 04:38:48 +03:00
|
|
|
}
|
|
|
|
|
2008-01-17 17:02:31 +03:00
|
|
|
#include <cmsys/Glob.hxx>
|
|
|
|
#include <cmsys/String.h>
|
|
|
|
#include <cmsys/auto_ptr.hxx>
|
|
|
|
|
|
|
|
class cmFileList;
|
|
|
|
class cmFileListGeneratorBase
|
|
|
|
{
|
2008-01-17 18:32:27 +03:00
|
|
|
public:
|
|
|
|
virtual ~cmFileListGeneratorBase() {}
|
2008-01-17 17:02:31 +03:00
|
|
|
protected:
|
|
|
|
bool Consider(std::string const& fullPath, cmFileList& listing);
|
2016-05-16 17:34:04 +03:00
|
|
|
|
2008-01-17 17:02:31 +03:00
|
|
|
private:
|
|
|
|
bool Search(cmFileList&);
|
|
|
|
virtual bool Search(std::string const& parent, cmFileList&) = 0;
|
|
|
|
virtual cmsys::auto_ptr<cmFileListGeneratorBase> Clone() const = 0;
|
|
|
|
friend class cmFileList;
|
|
|
|
cmFileListGeneratorBase* SetNext(cmFileListGeneratorBase const& next);
|
|
|
|
cmsys::auto_ptr<cmFileListGeneratorBase> Next;
|
|
|
|
};
|
|
|
|
|
|
|
|
class cmFileList
|
|
|
|
{
|
|
|
|
public:
|
2016-05-16 17:34:04 +03:00
|
|
|
cmFileList()
|
|
|
|
: First()
|
|
|
|
, Last(0)
|
|
|
|
{
|
|
|
|
}
|
2008-01-17 18:32:27 +03:00
|
|
|
virtual ~cmFileList() {}
|
2008-01-17 17:02:31 +03:00
|
|
|
cmFileList& operator/(cmFileListGeneratorBase const& rhs)
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
|
|
|
if (this->Last) {
|
2008-01-17 17:02:31 +03:00
|
|
|
this->Last = this->Last->SetNext(rhs);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2008-01-17 17:02:31 +03:00
|
|
|
this->First = rhs.Clone();
|
|
|
|
this->Last = this->First.get();
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return *this;
|
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
bool Search()
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
|
|
|
if (this->First.get()) {
|
2008-01-17 17:02:31 +03:00
|
|
|
return this->First->Search(*this);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-01-17 17:02:31 +03:00
|
|
|
private:
|
|
|
|
virtual bool Visit(std::string const& fullPath) = 0;
|
|
|
|
friend class cmFileListGeneratorBase;
|
|
|
|
cmsys::auto_ptr<cmFileListGeneratorBase> First;
|
|
|
|
cmFileListGeneratorBase* Last;
|
|
|
|
};
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
class cmFindPackageFileList : public cmFileList
|
2008-01-17 17:02:31 +03:00
|
|
|
{
|
|
|
|
public:
|
2016-05-16 17:34:04 +03:00
|
|
|
cmFindPackageFileList(cmFindPackageCommand* fpc, bool use_suffixes = true)
|
|
|
|
: cmFileList()
|
|
|
|
, FPC(fpc)
|
|
|
|
, UseSuffixes(use_suffixes)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-01-17 17:02:31 +03:00
|
|
|
private:
|
|
|
|
bool Visit(std::string const& fullPath)
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
|
|
|
if (this->UseSuffixes) {
|
2008-01-17 17:02:31 +03:00
|
|
|
return this->FPC->SearchDirectory(fullPath);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2008-01-17 17:02:31 +03:00
|
|
|
return this->FPC->CheckDirectory(fullPath);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
cmFindPackageCommand* FPC;
|
|
|
|
bool UseSuffixes;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool cmFileListGeneratorBase::Search(cmFileList& listing)
|
|
|
|
{
|
|
|
|
return this->Search("", listing);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmFileListGeneratorBase* cmFileListGeneratorBase::SetNext(
|
|
|
|
cmFileListGeneratorBase const& next)
|
2008-01-17 17:02:31 +03:00
|
|
|
{
|
|
|
|
this->Next = next.Clone();
|
|
|
|
return this->Next.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmFileListGeneratorBase::Consider(std::string const& fullPath,
|
|
|
|
cmFileList& listing)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Next.get()) {
|
2008-01-17 17:02:31 +03:00
|
|
|
return this->Next->Search(fullPath + "/", listing);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2008-01-17 17:02:31 +03:00
|
|
|
return listing.Visit(fullPath + "/");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
class cmFileListGeneratorFixed : public cmFileListGeneratorBase
|
2008-01-17 17:02:31 +03:00
|
|
|
{
|
|
|
|
public:
|
2016-05-16 17:34:04 +03:00
|
|
|
cmFileListGeneratorFixed(std::string const& str)
|
|
|
|
: cmFileListGeneratorBase()
|
|
|
|
, String(str)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
cmFileListGeneratorFixed(cmFileListGeneratorFixed const& r)
|
|
|
|
: cmFileListGeneratorBase()
|
|
|
|
, String(r.String)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-01-17 17:02:31 +03:00
|
|
|
private:
|
|
|
|
std::string String;
|
|
|
|
virtual bool Search(std::string const& parent, cmFileList& lister)
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
2008-01-17 17:02:31 +03:00
|
|
|
std::string fullPath = parent + this->String;
|
|
|
|
return this->Consider(fullPath, lister);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
virtual cmsys::auto_ptr<cmFileListGeneratorBase> Clone() const
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
|
|
|
cmsys::auto_ptr<cmFileListGeneratorBase> g(
|
|
|
|
new cmFileListGeneratorFixed(*this));
|
2008-01-17 17:02:31 +03:00
|
|
|
return g;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
};
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
class cmFileListGeneratorEnumerate : public cmFileListGeneratorBase
|
2008-01-17 17:02:31 +03:00
|
|
|
{
|
|
|
|
public:
|
2016-05-16 17:34:04 +03:00
|
|
|
cmFileListGeneratorEnumerate(std::vector<std::string> const& v)
|
|
|
|
: cmFileListGeneratorBase()
|
|
|
|
, Vector(v)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
cmFileListGeneratorEnumerate(cmFileListGeneratorEnumerate const& r)
|
|
|
|
: cmFileListGeneratorBase()
|
|
|
|
, Vector(r.Vector)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-01-17 17:02:31 +03:00
|
|
|
private:
|
2008-08-13 03:01:04 +04:00
|
|
|
std::vector<std::string> const& Vector;
|
2008-01-17 17:02:31 +03:00
|
|
|
virtual bool Search(std::string const& parent, cmFileList& lister)
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
|
|
|
for (std::vector<std::string>::const_iterator i = this->Vector.begin();
|
|
|
|
i != this->Vector.end(); ++i) {
|
|
|
|
if (this->Consider(parent + *i, lister)) {
|
2008-01-17 17:02:31 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return false;
|
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
virtual cmsys::auto_ptr<cmFileListGeneratorBase> Clone() const
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
|
|
|
cmsys::auto_ptr<cmFileListGeneratorBase> g(
|
|
|
|
new cmFileListGeneratorEnumerate(*this));
|
2008-01-17 17:02:31 +03:00
|
|
|
return g;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
};
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
class cmFileListGeneratorProject : public cmFileListGeneratorBase
|
2008-01-17 17:02:31 +03:00
|
|
|
{
|
|
|
|
public:
|
2016-05-16 17:34:04 +03:00
|
|
|
cmFileListGeneratorProject(std::vector<std::string> const& names)
|
|
|
|
: cmFileListGeneratorBase()
|
|
|
|
, Names(names)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
cmFileListGeneratorProject(cmFileListGeneratorProject const& r)
|
|
|
|
: cmFileListGeneratorBase()
|
|
|
|
, Names(r.Names)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-01-17 17:02:31 +03:00
|
|
|
private:
|
|
|
|
std::vector<std::string> const& Names;
|
|
|
|
virtual bool Search(std::string const& parent, cmFileList& lister)
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
2008-01-17 17:02:31 +03:00
|
|
|
// Construct a list of matches.
|
|
|
|
std::vector<std::string> matches;
|
|
|
|
cmsys::Directory d;
|
2014-10-15 16:54:05 +04:00
|
|
|
d.Load(parent);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (unsigned long i = 0; i < d.GetNumberOfFiles(); ++i) {
|
2008-01-17 17:02:31 +03:00
|
|
|
const char* fname = d.GetFile(i);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (strcmp(fname, ".") == 0 || strcmp(fname, "..") == 0) {
|
2008-01-17 17:02:31 +03:00
|
|
|
continue;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
for (std::vector<std::string>::const_iterator ni = this->Names.begin();
|
|
|
|
ni != this->Names.end(); ++ni) {
|
|
|
|
if (cmsysString_strncasecmp(fname, ni->c_str(), ni->length()) == 0) {
|
2008-01-17 17:02:31 +03:00
|
|
|
matches.push_back(fname);
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator i = matches.begin();
|
|
|
|
i != matches.end(); ++i) {
|
|
|
|
if (this->Consider(parent + *i, lister)) {
|
2008-01-17 17:02:31 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return false;
|
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
virtual cmsys::auto_ptr<cmFileListGeneratorBase> Clone() const
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
|
|
|
cmsys::auto_ptr<cmFileListGeneratorBase> g(
|
|
|
|
new cmFileListGeneratorProject(*this));
|
2008-01-17 17:02:31 +03:00
|
|
|
return g;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
};
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
class cmFileListGeneratorMacProject : public cmFileListGeneratorBase
|
2008-01-17 17:02:31 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
cmFileListGeneratorMacProject(std::vector<std::string> const& names,
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* ext)
|
|
|
|
: cmFileListGeneratorBase()
|
|
|
|
, Names(names)
|
|
|
|
, Extension(ext)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
cmFileListGeneratorMacProject(cmFileListGeneratorMacProject const& r)
|
|
|
|
: cmFileListGeneratorBase()
|
|
|
|
, Names(r.Names)
|
|
|
|
, Extension(r.Extension)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-01-17 17:02:31 +03:00
|
|
|
private:
|
|
|
|
std::vector<std::string> const& Names;
|
|
|
|
std::string Extension;
|
|
|
|
virtual bool Search(std::string const& parent, cmFileList& lister)
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
2008-01-17 17:02:31 +03:00
|
|
|
// Construct a list of matches.
|
|
|
|
std::vector<std::string> matches;
|
|
|
|
cmsys::Directory d;
|
2014-10-15 16:54:05 +04:00
|
|
|
d.Load(parent);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (unsigned long i = 0; i < d.GetNumberOfFiles(); ++i) {
|
2008-01-17 17:02:31 +03:00
|
|
|
const char* fname = d.GetFile(i);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (strcmp(fname, ".") == 0 || strcmp(fname, "..") == 0) {
|
2008-01-17 17:02:31 +03:00
|
|
|
continue;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
for (std::vector<std::string>::const_iterator ni = this->Names.begin();
|
|
|
|
ni != this->Names.end(); ++ni) {
|
2008-01-17 17:02:31 +03:00
|
|
|
std::string name = *ni;
|
|
|
|
name += this->Extension;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmsysString_strcasecmp(fname, name.c_str()) == 0) {
|
2008-01-17 17:02:31 +03:00
|
|
|
matches.push_back(fname);
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator i = matches.begin();
|
|
|
|
i != matches.end(); ++i) {
|
|
|
|
if (this->Consider(parent + *i, lister)) {
|
2008-01-17 17:02:31 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return false;
|
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
virtual cmsys::auto_ptr<cmFileListGeneratorBase> Clone() const
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
|
|
|
cmsys::auto_ptr<cmFileListGeneratorBase> g(
|
|
|
|
new cmFileListGeneratorMacProject(*this));
|
2008-01-17 17:02:31 +03:00
|
|
|
return g;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
};
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
class cmFileListGeneratorCaseInsensitive : public cmFileListGeneratorBase
|
2008-01-17 17:02:31 +03:00
|
|
|
{
|
|
|
|
public:
|
2016-05-16 17:34:04 +03:00
|
|
|
cmFileListGeneratorCaseInsensitive(std::string const& str)
|
|
|
|
: cmFileListGeneratorBase()
|
|
|
|
, String(str)
|
|
|
|
{
|
|
|
|
}
|
2008-01-18 16:19:37 +03:00
|
|
|
cmFileListGeneratorCaseInsensitive(
|
2016-05-16 17:34:04 +03:00
|
|
|
cmFileListGeneratorCaseInsensitive const& r)
|
|
|
|
: cmFileListGeneratorBase()
|
|
|
|
, String(r.String)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-01-17 17:02:31 +03:00
|
|
|
private:
|
|
|
|
std::string String;
|
|
|
|
virtual bool Search(std::string const& parent, cmFileList& lister)
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
2008-01-17 17:02:31 +03:00
|
|
|
// Look for matching files.
|
|
|
|
std::vector<std::string> matches;
|
|
|
|
cmsys::Directory d;
|
2014-10-15 16:54:05 +04:00
|
|
|
d.Load(parent);
|
2016-05-16 17:34:04 +03:00
|
|
|
for (unsigned long i = 0; i < d.GetNumberOfFiles(); ++i) {
|
2008-01-17 17:02:31 +03:00
|
|
|
const char* fname = d.GetFile(i);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (strcmp(fname, ".") == 0 || strcmp(fname, "..") == 0) {
|
2008-01-17 17:02:31 +03:00
|
|
|
continue;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (cmsysString_strcasecmp(fname, this->String.c_str()) == 0) {
|
|
|
|
if (this->Consider(parent + fname, lister)) {
|
2008-01-17 17:02:31 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return false;
|
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
virtual cmsys::auto_ptr<cmFileListGeneratorBase> Clone() const
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
|
|
|
cmsys::auto_ptr<cmFileListGeneratorBase> g(
|
|
|
|
new cmFileListGeneratorCaseInsensitive(*this));
|
2008-01-17 17:02:31 +03:00
|
|
|
return g;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
};
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
class cmFileListGeneratorGlob : public cmFileListGeneratorBase
|
2008-01-17 17:02:31 +03:00
|
|
|
{
|
|
|
|
public:
|
2016-05-16 17:34:04 +03:00
|
|
|
cmFileListGeneratorGlob(std::string const& str)
|
|
|
|
: cmFileListGeneratorBase()
|
|
|
|
, Pattern(str)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
cmFileListGeneratorGlob(cmFileListGeneratorGlob const& r)
|
|
|
|
: cmFileListGeneratorBase()
|
|
|
|
, Pattern(r.Pattern)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-01-17 17:02:31 +03:00
|
|
|
private:
|
|
|
|
std::string Pattern;
|
|
|
|
virtual bool Search(std::string const& parent, cmFileList& lister)
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
2008-01-17 17:02:31 +03:00
|
|
|
// Glob the set of matching files.
|
|
|
|
std::string expr = parent;
|
|
|
|
expr += this->Pattern;
|
|
|
|
cmsys::Glob g;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!g.FindFiles(expr)) {
|
2008-01-17 17:02:31 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
std::vector<std::string> const& files = g.GetFiles();
|
|
|
|
|
|
|
|
// Look for directories among the matches.
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator fi = files.begin();
|
|
|
|
fi != files.end(); ++fi) {
|
|
|
|
if (cmSystemTools::FileIsDirectory(*fi)) {
|
|
|
|
if (this->Consider(*fi, lister)) {
|
2008-01-17 17:02:31 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return false;
|
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
virtual cmsys::auto_ptr<cmFileListGeneratorBase> Clone() const
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
|
|
|
cmsys::auto_ptr<cmFileListGeneratorBase> g(
|
|
|
|
new cmFileListGeneratorGlob(*this));
|
2008-01-17 17:02:31 +03:00
|
|
|
return g;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
assert(!prefix_in.empty() && prefix_in[prefix_in.size() - 1] == '/');
|
|
|
|
if (this->DebugMode) {
|
2008-01-17 17:02:31 +03:00
|
|
|
fprintf(stderr, "Checking prefix [%s]\n", prefix_in.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
|
|
|
|
// Skip this if the prefix does not exist.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::FileIsDirectory(prefix_in)) {
|
2008-01-17 17:02:31 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
|
|
|
|
// PREFIX/ (useful on windows or in build trees)
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->SearchDirectory(prefix_in)) {
|
2008-01-17 17:02:31 +03:00
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
|
|
|
|
// Strip the trailing slash because the path generator is about to
|
|
|
|
// add one.
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string prefix = prefix_in.substr(0, prefix_in.size() - 1);
|
2008-01-17 17:02:31 +03:00
|
|
|
|
|
|
|
// PREFIX/(cmake|CMake)/ (useful on windows or in build trees)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmFindPackageFileList lister(this);
|
|
|
|
lister / cmFileListGeneratorFixed(prefix) /
|
|
|
|
cmFileListGeneratorCaseInsensitive("cmake");
|
|
|
|
if (lister.Search()) {
|
|
|
|
return true;
|
2008-01-17 17:02:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-17 17:24:05 +03:00
|
|
|
// PREFIX/(Foo|foo|FOO).*/
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmFindPackageFileList lister(this);
|
|
|
|
lister / cmFileListGeneratorFixed(prefix) /
|
|
|
|
cmFileListGeneratorProject(this->Names);
|
|
|
|
if (lister.Search()) {
|
|
|
|
return true;
|
2008-12-17 17:24:05 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// PREFIX/(Foo|foo|FOO).*/(cmake|CMake)/
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmFindPackageFileList lister(this);
|
|
|
|
lister / cmFileListGeneratorFixed(prefix) /
|
|
|
|
cmFileListGeneratorProject(this->Names) /
|
|
|
|
cmFileListGeneratorCaseInsensitive("cmake");
|
|
|
|
if (lister.Search()) {
|
|
|
|
return true;
|
2008-12-17 17:24:05 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-13 03:01:04 +04:00
|
|
|
// Construct list of common install locations (lib and share).
|
|
|
|
std::vector<std::string> common;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->LibraryArchitecture.empty()) {
|
|
|
|
common.push_back("lib/" + this->LibraryArchitecture);
|
|
|
|
}
|
|
|
|
if (this->UseLib64Paths) {
|
2008-08-13 03:01:04 +04:00
|
|
|
common.push_back("lib64");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-08-13 03:01:04 +04:00
|
|
|
common.push_back("lib");
|
|
|
|
common.push_back("share");
|
|
|
|
|
2011-06-08 16:46:31 +04:00
|
|
|
// PREFIX/(lib/ARCH|lib|share)/cmake/(Foo|foo|FOO).*/
|
2008-12-09 22:07:19 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmFindPackageFileList lister(this);
|
|
|
|
lister / cmFileListGeneratorFixed(prefix) /
|
|
|
|
cmFileListGeneratorEnumerate(common) /
|
|
|
|
cmFileListGeneratorFixed("cmake") /
|
|
|
|
cmFileListGeneratorProject(this->Names);
|
|
|
|
if (lister.Search()) {
|
|
|
|
return true;
|
2008-12-09 22:07:19 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-08 16:46:31 +04:00
|
|
|
// PREFIX/(lib/ARCH|lib|share)/(Foo|foo|FOO).*/
|
2008-01-17 17:02:31 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmFindPackageFileList lister(this);
|
|
|
|
lister / cmFileListGeneratorFixed(prefix) /
|
|
|
|
cmFileListGeneratorEnumerate(common) /
|
|
|
|
cmFileListGeneratorProject(this->Names);
|
|
|
|
if (lister.Search()) {
|
|
|
|
return true;
|
2008-01-17 17:02:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-08 16:46:31 +04:00
|
|
|
// PREFIX/(lib/ARCH|lib|share)/(Foo|foo|FOO).*/(cmake|CMake)/
|
2008-01-17 17:02:31 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmFindPackageFileList lister(this);
|
|
|
|
lister / cmFileListGeneratorFixed(prefix) /
|
|
|
|
cmFileListGeneratorEnumerate(common) /
|
|
|
|
cmFileListGeneratorProject(this->Names) /
|
|
|
|
cmFileListGeneratorCaseInsensitive("cmake");
|
|
|
|
if (lister.Search()) {
|
|
|
|
return true;
|
2008-01-17 17:02:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmFindPackageCommand::SearchFrameworkPrefix(std::string const& prefix_in)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
assert(!prefix_in.empty() && prefix_in[prefix_in.size() - 1] == '/');
|
|
|
|
if (this->DebugMode) {
|
2008-01-17 17:02:31 +03:00
|
|
|
fprintf(stderr, "Checking framework prefix [%s]\n", prefix_in.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
|
|
|
|
// Strip the trailing slash because the path generator is about to
|
|
|
|
// add one.
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string prefix = prefix_in.substr(0, prefix_in.size() - 1);
|
2008-01-17 17:02:31 +03:00
|
|
|
|
|
|
|
// <prefix>/Foo.framework/Resources/
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmFindPackageFileList lister(this);
|
|
|
|
lister / cmFileListGeneratorFixed(prefix) /
|
|
|
|
cmFileListGeneratorMacProject(this->Names, ".framework") /
|
|
|
|
cmFileListGeneratorFixed("Resources");
|
|
|
|
if (lister.Search()) {
|
|
|
|
return true;
|
2008-01-17 17:02:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// <prefix>/Foo.framework/Resources/CMake/
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmFindPackageFileList lister(this);
|
|
|
|
lister / cmFileListGeneratorFixed(prefix) /
|
|
|
|
cmFileListGeneratorMacProject(this->Names, ".framework") /
|
|
|
|
cmFileListGeneratorFixed("Resources") /
|
|
|
|
cmFileListGeneratorCaseInsensitive("cmake");
|
|
|
|
if (lister.Search()) {
|
|
|
|
return true;
|
2008-01-17 17:02:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// <prefix>/Foo.framework/Versions/*/Resources/
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmFindPackageFileList lister(this);
|
|
|
|
lister / cmFileListGeneratorFixed(prefix) /
|
|
|
|
cmFileListGeneratorMacProject(this->Names, ".framework") /
|
|
|
|
cmFileListGeneratorFixed("Versions") /
|
|
|
|
cmFileListGeneratorGlob("*/Resources");
|
|
|
|
if (lister.Search()) {
|
|
|
|
return true;
|
2008-01-17 17:02:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// <prefix>/Foo.framework/Versions/*/Resources/CMake/
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmFindPackageFileList lister(this);
|
|
|
|
lister / cmFileListGeneratorFixed(prefix) /
|
|
|
|
cmFileListGeneratorMacProject(this->Names, ".framework") /
|
|
|
|
cmFileListGeneratorFixed("Versions") /
|
|
|
|
cmFileListGeneratorGlob("*/Resources") /
|
|
|
|
cmFileListGeneratorCaseInsensitive("cmake");
|
|
|
|
if (lister.Search()) {
|
|
|
|
return true;
|
2008-01-17 17:02:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmFindPackageCommand::SearchAppBundlePrefix(std::string const& prefix_in)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
assert(!prefix_in.empty() && prefix_in[prefix_in.size() - 1] == '/');
|
|
|
|
if (this->DebugMode) {
|
2008-01-17 17:02:31 +03:00
|
|
|
fprintf(stderr, "Checking bundle prefix [%s]\n", prefix_in.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-01-17 17:02:31 +03:00
|
|
|
|
|
|
|
// Strip the trailing slash because the path generator is about to
|
|
|
|
// add one.
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string prefix = prefix_in.substr(0, prefix_in.size() - 1);
|
2008-01-17 17:02:31 +03:00
|
|
|
|
|
|
|
// <prefix>/Foo.app/Contents/Resources
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmFindPackageFileList lister(this);
|
|
|
|
lister / cmFileListGeneratorFixed(prefix) /
|
|
|
|
cmFileListGeneratorMacProject(this->Names, ".app") /
|
|
|
|
cmFileListGeneratorFixed("Contents/Resources");
|
|
|
|
if (lister.Search()) {
|
|
|
|
return true;
|
2008-01-17 17:02:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// <prefix>/Foo.app/Contents/Resources/CMake
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmFindPackageFileList lister(this);
|
|
|
|
lister / cmFileListGeneratorFixed(prefix) /
|
|
|
|
cmFileListGeneratorMacProject(this->Names, ".app") /
|
|
|
|
cmFileListGeneratorFixed("Contents/Resources") /
|
|
|
|
cmFileListGeneratorCaseInsensitive("cmake");
|
|
|
|
if (lister.Search()) {
|
|
|
|
return true;
|
2008-01-17 17:02:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Debug cmsys::Glob double slash problem.
|