resolve cyclic dependency with zstd
[platform/upstream/cmake.git] / Source / cmSearchPath.h
1 /* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2    file Copyright.txt 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   cmSearchPath(const cmSearchPath&) = default;
30   cmSearchPath& operator=(const cmSearchPath&) = default;
31
32   struct PathWithPrefix
33   {
34     std::string Path;
35     std::string Prefix;
36
37     bool operator<(const PathWithPrefix& other) const
38     {
39       return this->Path < other.Path ||
40         (this->Path == other.Path && this->Prefix < other.Prefix);
41     }
42   };
43   const std::vector<PathWithPrefix>& GetPaths() const { return this->Paths; }
44   std::size_t size() const { return this->Paths.size(); }
45
46   void ExtractWithout(const std::set<std::string>& ignorePaths,
47                       const std::set<std::string>& ignorePrefixes,
48                       std::vector<std::string>& outPaths,
49                       bool clear = false) const;
50
51   void AddPath(const std::string& path);
52   void AddUserPath(const std::string& path);
53   void AddCMakePath(const std::string& variable);
54   void AddEnvPath(const std::string& variable);
55   void AddCMakePrefixPath(const std::string& variable);
56   void AddEnvPrefixPath(const std::string& variable, bool stripBin = false);
57   void AddSuffixes(const std::vector<std::string>& suffixes);
58   void AddPrefixPaths(const std::vector<std::string>& paths,
59                       const char* base = nullptr);
60
61 protected:
62   void AddPathInternal(const std::string& path, const std::string& prefix,
63                        const char* base = nullptr);
64
65   cmFindCommon* FC;
66   std::vector<PathWithPrefix> Paths;
67 };