cmake/Source/cmFindBase.h

99 lines
2.5 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. */
#ifndef cmFindBase_h
#define cmFindBase_h
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"
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:
2020-02-01 23:06:01 +01:00
cmFindBase(cmExecutionStatus& status);
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
protected:
2020-08-30 11:54:41 +02:00
friend class cmFindBaseDebugState;
void ExpandPaths();
// see if the VariableName is already set in the cache,
// also copy the documentation from the cache to VariableDocumentation
// if it has documentation in the cache
bool CheckForVariableInCache();
2013-03-16 19:13:01 +02:00
// use by command during find
2015-04-27 22:25:09 +02:00
std::string VariableDocumentation;
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
2020-08-30 11:54:41 +02:00
bool AlreadyInCache = false;
bool AlreadyInCacheWithoutMetaInfo = false;
bool Required = false;
2016-07-09 11:21:54 +02:00
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;
};
#endif