cmSearchPath.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #ifndef cmSearchPath_h
  4. #define cmSearchPath_h
  5. #include "cmConfigure.h" // IWYU pragma: keep
  6. #include <cstddef>
  7. #include <set>
  8. #include <string>
  9. #include <vector>
  10. class cmFindCommon;
  11. /** \class cmSearchPath
  12. * \brief Container for encapsulating a set of search paths
  13. *
  14. * cmSearchPath is a container that encapsulates search path construction and
  15. * management
  16. */
  17. class cmSearchPath
  18. {
  19. public:
  20. // cmSearchPath must be initialized from a valid pointer. The only reason
  21. // for the default is to allow it to be easily used in stl containers.
  22. // Attempting to initialize with a NULL value will fail an assertion
  23. cmSearchPath(cmFindCommon* findCmd = nullptr);
  24. ~cmSearchPath();
  25. const std::vector<std::string>& GetPaths() const { return this->Paths; }
  26. std::size_t size() const { return this->Paths.size(); }
  27. void ExtractWithout(const std::set<std::string>& ignore,
  28. std::vector<std::string>& outPaths,
  29. bool clear = false) const;
  30. void AddPath(const std::string& path);
  31. void AddUserPath(const std::string& path);
  32. void AddCMakePath(const std::string& variable);
  33. void AddEnvPath(const std::string& variable);
  34. void AddCMakePrefixPath(const std::string& variable);
  35. void AddEnvPrefixPath(const std::string& variable, bool stripBin = false);
  36. void AddSuffixes(const std::vector<std::string>& suffixes);
  37. void AddPrefixPaths(const std::vector<std::string>& paths,
  38. const char* base = nullptr);
  39. protected:
  40. void AddPathInternal(const std::string& path, const char* base = nullptr);
  41. cmFindCommon* FC;
  42. std::vector<std::string> Paths;
  43. };
  44. #endif