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
11 #include "cmFindCommon.h"
12 #include "cmStateTypes.h"
14 class cmExecutionStatus
;
17 * \brief Base class for most FIND_XXX commands.
19 * cmFindBase is a parent class for cmFindProgramCommand, cmFindPathCommand,
20 * and cmFindLibraryCommand, cmFindFileCommand
22 class cmFindBase
: public cmFindCommon
25 cmFindBase(std::string findCommandName
, cmExecutionStatus
& status
);
26 virtual ~cmFindBase() = default;
29 * This is called when the command is first encountered in
30 * the CMakeLists.txt file.
32 virtual bool ParseArguments(std::vector
<std::string
> const& args
);
35 * To check validity of a found path using user's validator, if any
37 bool Validate(const std::string
& path
) const;
40 friend class cmFindBaseDebugState
;
43 // see if the VariableName is already set,
44 // also copy the documentation from the cache to VariableDocumentation
45 // if it has documentation in the cache
46 bool CheckForVariableDefined();
48 void NormalizeFindResult();
49 void StoreFindResult(const std::string
& value
);
51 // actual find command name
52 std::string FindCommandName
;
54 // use by command during find
55 std::string VariableDocumentation
;
56 cmStateEnums::CacheEntryType VariableType
= cmStateEnums::UNINITIALIZED
;
57 std::string VariableName
;
58 std::vector
<std::string
> Names
;
59 bool NamesPerDir
= false;
60 bool NamesPerDirAllowed
= false;
62 // CMAKE_*_PATH CMAKE_SYSTEM_*_PATH FRAMEWORK|LIBRARY|INCLUDE|PROGRAM
63 std::string EnvironmentPath
; // LIB,INCLUDE
65 bool AlreadyDefined
= false;
66 bool AlreadyInCacheWithoutMetaInfo
= false;
67 bool StoreResultInCache
= true;
69 bool Required
= false;
71 std::string ValidatorName
;
74 // Add pieces of the search.
75 void FillPackageRootPath();
76 void FillCMakeVariablePath();
77 void FillCMakeEnvironmentPath();
78 void FillUserHintsPath();
79 void FillSystemEnvironmentPath();
80 void FillCMakeSystemVariablePath();
81 void FillUserGuessPath();
84 class cmFindBaseDebugState
87 explicit cmFindBaseDebugState(std::string name
, cmFindBase
const* findBase
);
88 ~cmFindBaseDebugState();
90 void FoundAt(std::string
const& path
, std::string regexName
= std::string());
91 void FailedAt(std::string
const& path
,
92 std::string regexName
= std::string());
97 DebugLibState() = default;
98 DebugLibState(std::string
&& n
, std::string p
)
103 std::string regexName
;
107 cmFindBase
const* FindCommand
;
108 std::string CommandName
;
109 std::vector
<DebugLibState
> FailedSearchLocations
;
110 DebugLibState FoundSearchLocation
;