Merge topic 'windows-kernel-mode-driver-includes'
[kiteware-cmake.git] / Source / cmFindCommon.h
blob1abf567264256eaa778f76a1b7079fbe7c19d20f
1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
3 #pragma once
5 #include "cmConfigure.h" // IWYU pragma: keep
7 #include <map>
8 #include <set>
9 #include <string>
10 #include <vector>
12 #include "cmPathLabel.h"
13 #include "cmSearchPath.h"
14 #include "cmWindowsRegistry.h"
16 class cmExecutionStatus;
17 class cmMakefile;
19 /** \class cmFindCommon
20 * \brief Base class for FIND_XXX implementations.
22 * cmFindCommon is a parent class for cmFindBase,
23 * cmFindProgramCommand, cmFindPathCommand, cmFindLibraryCommand,
24 * cmFindFileCommand, and cmFindPackageCommand.
26 class cmFindCommon
28 public:
29 cmFindCommon(cmExecutionStatus& status);
31 void SetError(std::string const& e);
33 bool DebugModeEnabled() const { return this->DebugMode; }
35 protected:
36 friend class cmSearchPath;
37 friend class cmFindBaseDebugState;
39 /** Used to define groups of path labels */
40 class PathGroup : public cmPathLabel
42 protected:
43 PathGroup();
45 public:
46 PathGroup(const std::string& label)
47 : cmPathLabel(label)
50 static PathGroup All;
53 /* Individual path types */
54 class PathLabel : public cmPathLabel
56 protected:
57 PathLabel();
59 public:
60 PathLabel(const std::string& label)
61 : cmPathLabel(label)
64 static PathLabel PackageRoot;
65 static PathLabel CMake;
66 static PathLabel CMakeEnvironment;
67 static PathLabel Hints;
68 static PathLabel SystemEnvironment;
69 static PathLabel CMakeSystem;
70 static PathLabel Guess;
73 enum RootPathMode
75 RootPathModeNever,
76 RootPathModeOnly,
77 RootPathModeBoth
80 /** Construct the various path groups and labels */
81 void InitializeSearchPathGroups();
83 /** Place a set of search paths under the search roots. */
84 void RerootPaths(std::vector<std::string>& paths,
85 std::string* debugBuffer = nullptr);
87 /** Get ignored paths from CMAKE_[SYSTEM_]IGNORE_PATH variables. */
88 void GetIgnoredPaths(std::vector<std::string>& ignore);
89 void GetIgnoredPaths(std::set<std::string>& ignore);
91 /** Get ignored paths from CMAKE_[SYSTEM_]IGNORE_PREFIX_PATH variables. */
92 void GetIgnoredPrefixPaths(std::vector<std::string>& ignore);
93 void GetIgnoredPrefixPaths(std::set<std::string>& ignore);
95 /** Compute final search path list (reroot + trailing slash). */
96 enum class IgnorePaths
98 No,
99 Yes,
101 void ComputeFinalPaths(IgnorePaths ignorePaths,
102 std::string* debugBuffer = nullptr);
104 /** Compute the current default root path mode. */
105 void SelectDefaultRootPathMode();
107 /** Compute the current default bundle/framework search policy. */
108 void SelectDefaultMacMode();
110 /** Compute the current default search modes based on global variables. */
111 void SelectDefaultSearchModes();
113 /** The `InitialPass` functions of the child classes should set
114 this->DebugMode to the result of these. */
115 bool ComputeIfDebugModeWanted();
116 bool ComputeIfDebugModeWanted(std::string const& var);
118 // Path arguments prior to path manipulation routines
119 std::vector<std::string> UserHintsArgs;
120 std::vector<std::string> UserGuessArgs;
122 std::string CMakePathName;
123 RootPathMode FindRootPathMode;
125 bool CheckCommonArgument(std::string const& arg);
126 void AddPathSuffix(std::string const& arg);
128 void DebugMessage(std::string const& msg) const;
129 bool DebugMode;
130 bool NoDefaultPath;
131 bool NoPackageRootPath;
132 bool NoCMakePath;
133 bool NoCMakeEnvironmentPath;
134 bool NoSystemEnvironmentPath;
135 bool NoCMakeSystemPath;
136 bool NoCMakeInstallPath;
137 cmWindowsRegistry::View RegistryView = cmWindowsRegistry::View::Target;
139 std::vector<std::string> SearchPathSuffixes;
141 std::map<PathGroup, std::vector<PathLabel>> PathGroupLabelMap;
142 std::vector<PathGroup> PathGroupOrder;
143 std::map<std::string, PathLabel> PathLabelStringMap;
144 std::map<PathLabel, cmSearchPath> LabeledPaths;
146 std::vector<std::string> SearchPaths;
147 std::set<cmSearchPath::PathWithPrefix> SearchPathsEmitted;
149 bool SearchFrameworkFirst;
150 bool SearchFrameworkOnly;
151 bool SearchFrameworkLast;
153 bool SearchAppBundleFirst;
154 bool SearchAppBundleOnly;
155 bool SearchAppBundleLast;
157 cmMakefile* Makefile;
158 cmExecutionStatus& Status;