cmake/Source/cmFindBase.h

112 lines
2.9 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
2017-07-20 19:35:53 +02:00
#include "cmConfigure.h" // IWYU pragma: keep
2017-04-14 19:02:05 +02:00
#include <string>
2020-08-30 11:54:41 +02:00
#include <utility>
2017-04-14 19:02:05 +02:00
#include <vector>
#include "cmFindCommon.h"
2021-09-14 00:13:48 +02:00
#include "cmStateTypes.h"
2020-02-01 23:06:01 +01:00
class cmExecutionStatus;
/** \class cmFindBase
* \brief Base class for most FIND_XXX commands.
*
* cmFindBase is a parent class for cmFindProgramCommand, cmFindPathCommand,
* and cmFindLibraryCommand, cmFindFileCommand
*/
class cmFindBase : public cmFindCommon
{
public:
2021-09-14 00:13:48 +02:00
cmFindBase(std::string findCommandName, cmExecutionStatus& status);
2020-02-01 23:06:01 +01:00
virtual ~cmFindBase() = default;
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool ParseArguments(std::vector<std::string> const& args);
2013-03-16 19:13:01 +02:00
2022-11-16 20:14:03 +01:00
/**
* To check validity of a found path using user's validator, if any
*/
bool Validate(const std::string& path) const;
protected:
2020-08-30 11:54:41 +02:00
friend class cmFindBaseDebugState;
void ExpandPaths();
2021-09-14 00:13:48 +02:00
// see if the VariableName is already set,
// also copy the documentation from the cache to VariableDocumentation
// if it has documentation in the cache
2021-09-14 00:13:48 +02:00
bool CheckForVariableDefined();
void NormalizeFindResult();
void StoreFindResult(const std::string& value);
// actual find command name
std::string FindCommandName;
2013-03-16 19:13:01 +02:00
// use by command during find
2015-04-27 22:25:09 +02:00
std::string VariableDocumentation;
2021-09-14 00:13:48 +02:00
cmStateEnums::CacheEntryType VariableType = cmStateEnums::UNINITIALIZED;
2015-04-27 22:25:09 +02:00
std::string VariableName;
std::vector<std::string> Names;
2020-08-30 11:54:41 +02:00
bool NamesPerDir = false;
bool NamesPerDirAllowed = false;
// CMAKE_*_PATH CMAKE_SYSTEM_*_PATH FRAMEWORK|LIBRARY|INCLUDE|PROGRAM
2015-04-27 22:25:09 +02:00
std::string EnvironmentPath; // LIB,INCLUDE
2021-09-14 00:13:48 +02:00
bool AlreadyDefined = false;
2020-08-30 11:54:41 +02:00
bool AlreadyInCacheWithoutMetaInfo = false;
2021-09-14 00:13:48 +02:00
bool StoreResultInCache = true;
2020-08-30 11:54:41 +02:00
bool Required = false;
2016-07-09 11:21:54 +02:00
2022-11-16 20:14:03 +01:00
std::string ValidatorName;
private:
// Add pieces of the search.
2017-07-20 19:35:53 +02:00
void FillPackageRootPath();
2015-04-27 22:25:09 +02:00
void FillCMakeVariablePath();
void FillCMakeEnvironmentPath();
void FillUserHintsPath();
void FillSystemEnvironmentPath();
void FillCMakeSystemVariablePath();
void FillUserGuessPath();
};
2020-08-30 11:54:41 +02:00
class cmFindBaseDebugState
{
public:
explicit cmFindBaseDebugState(std::string name, cmFindBase const* findBase);
~cmFindBaseDebugState();
void FoundAt(std::string const& path, std::string regexName = std::string());
void FailedAt(std::string const& path,
std::string regexName = std::string());
private:
struct DebugLibState
{
DebugLibState() = default;
DebugLibState(std::string&& n, std::string p)
: regexName(n)
, path(std::move(p))
{
}
std::string regexName;
std::string path;
};
cmFindBase const* FindCommand;
std::string CommandName;
std::vector<DebugLibState> FailedSearchLocations;
DebugLibState FoundSearchLocation;
};