cmSearchPath.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 <set>
  7. #include <string>
  8. #include <vector>
  9. class cmFindCommon;
  10. /** \class cmSearchPath
  11. * \brief Container for encapsulating a set of search paths
  12. *
  13. * cmSearchPath is a container that encapsulates search path construction and
  14. * management
  15. */
  16. class cmSearchPath
  17. {
  18. public:
  19. // cmSearchPath must be initialized from a valid pointer. The only reason
  20. // for the default is to allow it to be easily used in stl containers.
  21. // Attempting to initialize with a NULL value will fail an assertion
  22. cmSearchPath(cmFindCommon* findCmd = nullptr);
  23. ~cmSearchPath();
  24. const std::vector<std::string>& GetPaths() const { return this->Paths; }
  25. void ExtractWithout(const std::set<std::string>& ignore,
  26. std::vector<std::string>& outPaths,
  27. bool clear = false) const;
  28. void AddPath(const std::string& path);
  29. void AddUserPath(const std::string& path);
  30. void AddCMakePath(const std::string& variable);
  31. void AddEnvPath(const std::string& variable);
  32. void AddCMakePrefixPath(const std::string& variable);
  33. void AddEnvPrefixPath(const std::string& variable, bool stripBin = false);
  34. void AddSuffixes(const std::vector<std::string>& suffixes);
  35. protected:
  36. void AddPrefixPaths(const std::vector<std::string>& paths,
  37. const char* base = nullptr);
  38. void AddPathInternal(const std::string& path, const char* base = nullptr);
  39. cmFindCommon* FC;
  40. std::vector<std::string> Paths;
  41. };
  42. #endif