/src/CMake/Source/cmSearchPath.h
Line | Count | Source |
1 | | /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying |
2 | | file LICENSE.rst or https://cmake.org/licensing for details. */ |
3 | | #pragma once |
4 | | |
5 | | #include "cmConfigure.h" // IWYU pragma: keep |
6 | | |
7 | | #include <cstddef> |
8 | | #include <set> |
9 | | #include <string> |
10 | | #include <vector> |
11 | | |
12 | | class cmFindCommon; |
13 | | |
14 | | /** \class cmSearchPath |
15 | | * \brief Container for encapsulating a set of search paths |
16 | | * |
17 | | * cmSearchPath is a container that encapsulates search path construction and |
18 | | * management |
19 | | */ |
20 | | class cmSearchPath |
21 | | { |
22 | | public: |
23 | | // cmSearchPath must be initialized from a valid pointer. The only reason |
24 | | // for the default is to allow it to be easily used in stl containers. |
25 | | // Attempting to initialize with a NULL value will fail an assertion |
26 | | cmSearchPath(cmFindCommon* findCmd = nullptr); |
27 | | ~cmSearchPath(); |
28 | | |
29 | 0 | cmSearchPath(cmSearchPath const&) = default; |
30 | | cmSearchPath& operator=(cmSearchPath const&) = default; |
31 | | |
32 | | struct PathWithPrefix |
33 | | { |
34 | | std::string Path; |
35 | | std::string Prefix; |
36 | | |
37 | | bool operator<(PathWithPrefix const& other) const |
38 | 0 | { |
39 | 0 | return this->Path < other.Path || |
40 | 0 | (this->Path == other.Path && this->Prefix < other.Prefix); |
41 | 0 | } |
42 | | }; |
43 | 0 | std::vector<PathWithPrefix> const& GetPaths() const { return this->Paths; } |
44 | 0 | std::size_t size() const { return this->Paths.size(); } |
45 | | |
46 | | void ExtractWithout(std::set<std::string> const& ignorePaths, |
47 | | std::set<std::string> const& ignorePrefixes, |
48 | | std::vector<std::string>& outPaths) const; |
49 | | |
50 | | void AddPath(std::string const& path); |
51 | | void AddUserPath(std::string const& path); |
52 | | void AddCMakePath(std::string const& variable); |
53 | | void AddEnvPath(std::string const& variable); |
54 | | void AddCMakePrefixPath(std::string const& variable); |
55 | | void AddEnvPrefixPath(std::string const& variable, bool stripBin = false); |
56 | | void AddSuffixes(std::vector<std::string> const& suffixes); |
57 | | void AddPrefixPaths(std::vector<std::string> const& paths); |
58 | | |
59 | | protected: |
60 | | void AddPathInternal(std::string const& path, std::string const& prefix); |
61 | | |
62 | | cmFindCommon* FC; |
63 | | std::vector<PathWithPrefix> Paths; |
64 | | }; |