/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ #pragma once #include "cmConfigure.h" // IWYU pragma: keep #include #include #include #include #include // From cmPkgConfigParser.h, IWYU doesn't like including the header struct cmPkgConfigEntry; struct cmPkgConfigCflagsResult { std::string Flagline; std::vector Includes; std::vector CompileOptions; }; struct cmPkgConfigLibsResult { std::string Flagline; std::vector LibDirs; std::vector LibNames; std::vector LinkOptions; }; struct cmPkgConfigVersionReq { enum { ANY = 0, LT, LT_EQ, EQ, NEQ, GT_EQ, GT, } Operation = ANY; std::string Version; }; struct cmPkgConfigDependency { std::string Name; cmPkgConfigVersionReq VerReq; }; struct cmPkgConfigEnv { cm::optional> Path; cm::optional> LibDirs; cm::optional> SysCflags; cm::optional> SysLibs; cm::optional SysrootDir; cm::optional TopBuildDir; cm::optional DisableUninstalled; bool AllowSysCflags = true; bool AllowSysLibs = true; }; class cmPkgConfigResult { public: std::unordered_map Keywords; std::unordered_map Variables; std::string Name(); std::string Description(); std::string Version(); std::vector Conflicts(); std::vector Provides(); std::vector Requires(bool priv = false); cmPkgConfigCflagsResult Cflags(bool priv = false); cmPkgConfigLibsResult Libs(bool priv = false); cmPkgConfigEnv env; private: std::string StrOrDefault(const std::string& key, cm::string_view def = ""); }; class cmPkgConfigResolver { friend class cmPkgConfigResult; public: static cm::optional ResolveStrict( const std::vector& entries, cmPkgConfigEnv env); static cm::optional ResolvePermissive( const std::vector& entries, cmPkgConfigEnv env); static cmPkgConfigResult ResolveBestEffort( const std::vector& entries, cmPkgConfigEnv env); static cmPkgConfigVersionReq ParseVersion(const std::string& version); static bool CheckVersion(const cmPkgConfigVersionReq& desired, const std::string& provided); static void ReplaceSep(std::string& list); #ifdef _WIN32 static const char Sep = ';'; #else static const char Sep = ':'; #endif private: static std::string HandleVariablePermissive( const cmPkgConfigEntry& entry, const std::unordered_map& variables); static cm::optional HandleVariableStrict( const cmPkgConfigEntry& entry, const std::unordered_map& variables); static std::string HandleKeyword( const cmPkgConfigEntry& entry, const std::unordered_map& variables); static std::vector TokenizeFlags( const std::string& flagline); static cmPkgConfigCflagsResult MangleCflags( const std::vector& flags); static cmPkgConfigCflagsResult MangleCflags( const std::vector& flags, const std::string& sysroot); static cmPkgConfigCflagsResult MangleCflags( const std::vector& flags, const std::vector& syspaths); static cmPkgConfigCflagsResult MangleCflags( const std::vector& flags, const std::string& sysroot, const std::vector& syspaths); static cmPkgConfigLibsResult MangleLibs( const std::vector& flags); static cmPkgConfigLibsResult MangleLibs( const std::vector& flags, const std::string& sysroot); static cmPkgConfigLibsResult MangleLibs( const std::vector& flags, const std::vector& syspaths); static cmPkgConfigLibsResult MangleLibs( const std::vector& flags, const std::string& sysroot, const std::vector& syspaths); static std::string Reroot(cm::string_view flag, cm::string_view prefix, const std::string& sysroot); static cmPkgConfigVersionReq ParseVersion(std::string::const_iterator& cur, std::string::const_iterator end); static std::vector ParseDependencies( const std::string& deps); };