1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
5 #include "cmConfigure.h" // IWYU pragma: keep
12 #include "cmPathLabel.h"
13 #include "cmSearchPath.h"
14 #include "cmWindowsRegistry.h"
16 class cmExecutionStatus
;
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.
29 cmFindCommon(cmExecutionStatus
& status
);
31 void SetError(std::string
const& e
);
33 bool DebugModeEnabled() const { return this->DebugMode
; }
36 friend class cmSearchPath
;
37 friend class cmFindBaseDebugState
;
39 /** Used to define groups of path labels */
40 class PathGroup
: public cmPathLabel
46 PathGroup(const std::string
& label
)
53 /* Individual path types */
54 class PathLabel
: public cmPathLabel
60 PathLabel(const std::string
& 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
;
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
);
86 /** Get ignored paths from CMAKE_[SYSTEM_]IGNORE_PATH variables. */
87 void GetIgnoredPaths(std::vector
<std::string
>& ignore
);
88 void GetIgnoredPaths(std::set
<std::string
>& ignore
);
90 /** Get ignored paths from CMAKE_[SYSTEM_]IGNORE_PREFIX_PATH variables. */
91 void GetIgnoredPrefixPaths(std::vector
<std::string
>& ignore
);
92 void GetIgnoredPrefixPaths(std::set
<std::string
>& ignore
);
94 /** Compute final search path list (reroot + trailing slash). */
95 enum class IgnorePaths
100 void ComputeFinalPaths(IgnorePaths ignorePaths
);
102 /** Compute the current default root path mode. */
103 void SelectDefaultRootPathMode();
105 /** Compute the current default bundle/framework search policy. */
106 void SelectDefaultMacMode();
108 /** Compute the current default search modes based on global variables. */
109 void SelectDefaultSearchModes();
111 /** The `InitialPass` functions of the child classes should set
112 this->DebugMode to the result of these. */
113 bool ComputeIfDebugModeWanted();
114 bool ComputeIfDebugModeWanted(std::string
const& var
);
116 // Path arguments prior to path manipulation routines
117 std::vector
<std::string
> UserHintsArgs
;
118 std::vector
<std::string
> UserGuessArgs
;
120 std::string CMakePathName
;
121 RootPathMode FindRootPathMode
;
123 bool CheckCommonArgument(std::string
const& arg
);
124 void AddPathSuffix(std::string
const& arg
);
126 void DebugMessage(std::string
const& msg
) const;
129 bool NoPackageRootPath
;
131 bool NoCMakeEnvironmentPath
;
132 bool NoSystemEnvironmentPath
;
133 bool NoCMakeSystemPath
;
134 bool NoCMakeInstallPath
;
135 cmWindowsRegistry::View RegistryView
= cmWindowsRegistry::View::Target
;
137 std::vector
<std::string
> SearchPathSuffixes
;
139 std::map
<PathGroup
, std::vector
<PathLabel
>> PathGroupLabelMap
;
140 std::vector
<PathGroup
> PathGroupOrder
;
141 std::map
<std::string
, PathLabel
> PathLabelStringMap
;
142 std::map
<PathLabel
, cmSearchPath
> LabeledPaths
;
144 std::vector
<std::string
> SearchPaths
;
145 std::set
<cmSearchPath::PathWithPrefix
> SearchPathsEmitted
;
147 bool SearchFrameworkFirst
;
148 bool SearchFrameworkOnly
;
149 bool SearchFrameworkLast
;
151 bool SearchAppBundleFirst
;
152 bool SearchAppBundleOnly
;
153 bool SearchAppBundleLast
;
155 cmMakefile
* Makefile
;
156 cmExecutionStatus
& Status
;