cmake/Source/cmFindCommon.h

160 lines
4.2 KiB
C
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
2021-09-14 00:13:48 +02:00
#pragma once
2018-01-26 17:06:56 +01:00
#include "cmConfigure.h" // IWYU pragma: keep
2017-04-14 19:02:05 +02:00
#include <map>
#include <set>
#include <string>
#include <vector>
2015-04-27 22:25:09 +02:00
#include "cmPathLabel.h"
2016-07-09 11:21:54 +02:00
#include "cmSearchPath.h"
2022-08-04 22:12:04 +02:00
#include "cmWindowsRegistry.h"
2020-02-01 23:06:01 +01:00
class cmExecutionStatus;
class cmMakefile;
/** \class cmFindCommon
* \brief Base class for FIND_XXX implementations.
*
* cmFindCommon is a parent class for cmFindBase,
* cmFindProgramCommand, cmFindPathCommand, cmFindLibraryCommand,
* cmFindFileCommand, and cmFindPackageCommand.
*/
2020-02-01 23:06:01 +01:00
class cmFindCommon
{
public:
2020-02-01 23:06:01 +01:00
cmFindCommon(cmExecutionStatus& status);
void SetError(std::string const& e);
2020-08-30 11:54:41 +02:00
bool DebugModeEnabled() const { return this->DebugMode; }
protected:
2015-04-27 22:25:09 +02:00
friend class cmSearchPath;
2020-08-30 11:54:41 +02:00
friend class cmFindBaseDebugState;
2015-04-27 22:25:09 +02:00
/** Used to define groups of path labels */
class PathGroup : public cmPathLabel
{
protected:
PathGroup();
2016-07-09 11:21:54 +02:00
2015-04-27 22:25:09 +02:00
public:
2016-07-09 11:21:54 +02:00
PathGroup(const std::string& label)
: cmPathLabel(label)
{
}
2015-04-27 22:25:09 +02:00
static PathGroup All;
};
/* Individual path types */
class PathLabel : public cmPathLabel
{
protected:
PathLabel();
2016-07-09 11:21:54 +02:00
2015-04-27 22:25:09 +02:00
public:
2016-07-09 11:21:54 +02:00
PathLabel(const std::string& label)
: cmPathLabel(label)
{
}
2017-07-20 19:35:53 +02:00
static PathLabel PackageRoot;
2015-04-27 22:25:09 +02:00
static PathLabel CMake;
static PathLabel CMakeEnvironment;
static PathLabel Hints;
static PathLabel SystemEnvironment;
static PathLabel CMakeSystem;
static PathLabel Guess;
};
2016-07-09 11:21:54 +02:00
enum RootPathMode
{
RootPathModeNever,
RootPathModeOnly,
RootPathModeBoth
};
2015-04-27 22:25:09 +02:00
/** Construct the various path groups and labels */
void InitializeSearchPathGroups();
/** Place a set of search paths under the search roots. */
2024-11-11 15:18:55 +01:00
void RerootPaths(std::vector<std::string>& paths,
std::string* debugBuffer = nullptr);
2022-03-29 21:10:50 +02:00
/** Get ignored paths from CMAKE_[SYSTEM_]IGNORE_PATH variables. */
2010-11-13 01:00:53 +02:00
void GetIgnoredPaths(std::vector<std::string>& ignore);
void GetIgnoredPaths(std::set<std::string>& ignore);
2022-03-29 21:10:50 +02:00
/** Get ignored paths from CMAKE_[SYSTEM_]IGNORE_PREFIX_PATH variables. */
void GetIgnoredPrefixPaths(std::vector<std::string>& ignore);
void GetIgnoredPrefixPaths(std::set<std::string>& ignore);
2012-02-18 12:40:36 +02:00
/** Compute final search path list (reroot + trailing slash). */
2022-03-29 21:10:50 +02:00
enum class IgnorePaths
{
No,
Yes,
};
2024-11-11 15:18:55 +01:00
void ComputeFinalPaths(IgnorePaths ignorePaths,
std::string* debugBuffer = nullptr);
/** Compute the current default root path mode. */
void SelectDefaultRootPathMode();
/** Compute the current default bundle/framework search policy. */
void SelectDefaultMacMode();
2020-02-01 23:06:01 +01:00
/** Compute the current default search modes based on global variables. */
void SelectDefaultSearchModes();
2020-08-30 11:54:41 +02:00
/** The `InitialPass` functions of the child classes should set
2022-03-29 21:10:50 +02:00
this->DebugMode to the result of these. */
2020-08-30 11:54:41 +02:00
bool ComputeIfDebugModeWanted();
2022-03-29 21:10:50 +02:00
bool ComputeIfDebugModeWanted(std::string const& var);
2020-08-30 11:54:41 +02:00
2015-04-27 22:25:09 +02:00
// Path arguments prior to path manipulation routines
std::vector<std::string> UserHintsArgs;
std::vector<std::string> UserGuessArgs;
std::string CMakePathName;
RootPathMode FindRootPathMode;
bool CheckCommonArgument(std::string const& arg);
void AddPathSuffix(std::string const& arg);
2010-06-23 01:18:35 +03:00
2020-08-30 11:54:41 +02:00
void DebugMessage(std::string const& msg) const;
bool DebugMode;
bool NoDefaultPath;
2017-07-20 19:35:53 +02:00
bool NoPackageRootPath;
bool NoCMakePath;
bool NoCMakeEnvironmentPath;
bool NoSystemEnvironmentPath;
bool NoCMakeSystemPath;
2022-08-04 22:12:04 +02:00
bool NoCMakeInstallPath;
cmWindowsRegistry::View RegistryView = cmWindowsRegistry::View::Target;
std::vector<std::string> SearchPathSuffixes;
2015-04-27 22:25:09 +02:00
2018-01-26 17:06:56 +01:00
std::map<PathGroup, std::vector<PathLabel>> PathGroupLabelMap;
2015-04-27 22:25:09 +02:00
std::vector<PathGroup> PathGroupOrder;
std::map<std::string, PathLabel> PathLabelStringMap;
std::map<PathLabel, cmSearchPath> LabeledPaths;
std::vector<std::string> SearchPaths;
2022-03-29 21:10:50 +02:00
std::set<cmSearchPath::PathWithPrefix> SearchPathsEmitted;
bool SearchFrameworkFirst;
bool SearchFrameworkOnly;
bool SearchFrameworkLast;
bool SearchAppBundleFirst;
bool SearchAppBundleOnly;
bool SearchAppBundleLast;
2020-02-01 23:06:01 +01:00
cmMakefile* Makefile;
cmExecutionStatus& Status;
};