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
,
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
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;
131 bool NoPackageRootPath
;
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
;