cmObjectLocation.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. #include "cmConfigure.h" // IWYU pragma: keep
  5. #include <map>
  6. #include <string>
  7. #include <utility>
  8. #include <cm/optional>
  9. #include <cm/string_view>
  10. struct cmObjectLocation
  11. {
  12. public:
  13. cmObjectLocation() = default;
  14. cmObjectLocation(std::string path)
  15. : Path(std::move(path))
  16. {
  17. }
  18. void Update(std::string path);
  19. // Get the path to the object under the common directory for the target's
  20. // objects.
  21. std::string const& GetPath() const;
  22. // Get the directory of the object file under the common directory.
  23. cm::string_view GetDirectory() const;
  24. // Get the name of the object file.
  25. cm::string_view GetName() const;
  26. private:
  27. std::string Path;
  28. };
  29. struct cmObjectLocations
  30. {
  31. cmObjectLocations() = default;
  32. cm::optional<cmObjectLocation> ShortLoc;
  33. cmObjectLocation LongLoc;
  34. std::map<std::string, cmObjectLocation> InstallLongLoc;
  35. enum class UseShortPath
  36. {
  37. Yes,
  38. No,
  39. };
  40. cmObjectLocation const& GetLocation(UseShortPath use) const;
  41. std::string const& GetPath(UseShortPath use) const;
  42. cmObjectLocation const& GetInstallLocation(UseShortPath use,
  43. std::string const& config) const;
  44. std::string const& GetInstallPath(UseShortPath use,
  45. std::string const& config) const;
  46. };