cmPackageInfoReader.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. #include "cmConfigure.h" // IWYU pragma: keep
  5. #include <memory>
  6. #include <string>
  7. #include <vector>
  8. #include <cm/optional>
  9. #include <cm3p/json/value.h>
  10. // class cmExecutionStatus;
  11. /** \class cmPackageInfoReader
  12. * \brief Read and parse CPS files.
  13. *
  14. * This class encapsulates the functionality to read package configuration
  15. * files which use the Common Package Specification, and provides utilities to
  16. * translate the declarations therein into imported targets.
  17. */
  18. class cmPackageInfoReader
  19. {
  20. public:
  21. static std::unique_ptr<cmPackageInfoReader> Read(std::string const& path);
  22. std::string GetName() const;
  23. cm::optional<std::string> GetVersion() const;
  24. /// If the package uses the 'simple' version scheme, obtain the version as
  25. /// a numeric tuple. Returns an empty vector for other schemes or if no
  26. /// version is specified.
  27. std::vector<unsigned> ParseVersion() const;
  28. private:
  29. cmPackageInfoReader() = default;
  30. std::string Path;
  31. Json::Value Data;
  32. };