cmake/Source/cmSearchPath.h

68 lines
2.2 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
2015-04-27 22:25:09 +02:00
2018-01-26 17:06:56 +01:00
#include "cmConfigure.h" // IWYU pragma: keep
2016-10-30 18:24:19 +01:00
2020-08-30 11:54:41 +02:00
#include <cstddef>
2017-04-14 19:02:05 +02:00
#include <set>
#include <string>
#include <vector>
2015-04-27 22:25:09 +02:00
class cmFindCommon;
/** \class cmSearchPath
* \brief Container for encapsulating a set of search paths
*
* cmSearchPath is a container that encapsulates search path construction and
* management
*/
class cmSearchPath
{
public:
// cmSearchPath must be initialized from a valid pointer. The only reason
2016-07-09 11:21:54 +02:00
// for the default is to allow it to be easily used in stl containers.
2015-04-27 22:25:09 +02:00
// Attempting to initialize with a NULL value will fail an assertion
2018-01-26 17:06:56 +01:00
cmSearchPath(cmFindCommon* findCmd = nullptr);
2015-04-27 22:25:09 +02:00
~cmSearchPath();
2022-03-29 21:10:50 +02:00
cmSearchPath(const cmSearchPath&) = default;
cmSearchPath& operator=(const cmSearchPath&) = default;
struct PathWithPrefix
{
std::string Path;
std::string Prefix;
bool operator<(const PathWithPrefix& other) const
{
return this->Path < other.Path ||
(this->Path == other.Path && this->Prefix < other.Prefix);
}
};
const std::vector<PathWithPrefix>& GetPaths() const { return this->Paths; }
2020-08-30 11:54:41 +02:00
std::size_t size() const { return this->Paths.size(); }
2015-04-27 22:25:09 +02:00
2022-03-29 21:10:50 +02:00
void ExtractWithout(const std::set<std::string>& ignorePaths,
const std::set<std::string>& ignorePrefixes,
2015-04-27 22:25:09 +02:00
std::vector<std::string>& outPaths,
bool clear = false) const;
void AddPath(const std::string& path);
void AddUserPath(const std::string& path);
void AddCMakePath(const std::string& variable);
void AddEnvPath(const std::string& variable);
void AddCMakePrefixPath(const std::string& variable);
2015-08-17 11:37:30 +02:00
void AddEnvPrefixPath(const std::string& variable, bool stripBin = false);
2015-04-27 22:25:09 +02:00
void AddSuffixes(const std::vector<std::string>& suffixes);
void AddPrefixPaths(const std::vector<std::string>& paths,
2018-01-26 17:06:56 +01:00
const char* base = nullptr);
2018-08-09 18:06:22 +02:00
protected:
2022-03-29 21:10:50 +02:00
void AddPathInternal(const std::string& path, const std::string& prefix,
const char* base = nullptr);
2015-04-27 22:25:09 +02:00
2016-07-09 11:21:54 +02:00
cmFindCommon* FC;
2022-03-29 21:10:50 +02:00
std::vector<PathWithPrefix> Paths;
2015-04-27 22:25:09 +02:00
};