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 
GetPaths()29   const std::vector<std::string>& GetPaths() const { return this->Paths; }
size()30   std::size_t size() const { return this->Paths.size(); }
31 
32   void ExtractWithout(const std::set<std::string>& ignore,
33                       std::vector<std::string>& outPaths,
34                       bool clear = false) const;
35 
36   void AddPath(const std::string& path);
37   void AddUserPath(const std::string& path);
38   void AddCMakePath(const std::string& variable);
39   void AddEnvPath(const std::string& variable);
40   void AddCMakePrefixPath(const std::string& variable);
41   void AddEnvPrefixPath(const std::string& variable, bool stripBin = false);
42   void AddSuffixes(const std::vector<std::string>& suffixes);
43   void AddPrefixPaths(const std::vector<std::string>& paths,
44                       const char* base = nullptr);
45 
46 protected:
47   void AddPathInternal(const std::string& path, const char* base = nullptr);
48 
49   cmFindCommon* FC;
50   std::vector<std::string> Paths;
51 };
52