From b3b2688a28952a825aa189c2428b59cfcc490223 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Sun, 2 May 2021 02:15:28 +0200 Subject: [PATCH] Add support for overlays (still needs a custom pmm to work) --- include/cmake.hpp | 4 ++++ src/cmake.cpp | 3 +++ src/gen.cpp | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/include/cmake.hpp b/include/cmake.hpp index d790271..09d29de 100644 --- a/include/cmake.hpp +++ b/include/cmake.hpp @@ -34,7 +34,11 @@ struct Package { struct Vcpkg { std::string version; + std::string triplet; std::vector packages; + std::vector ports; + std::vector overlay_ports; + std::vector overlay_triplets; }; enum TargetType { diff --git a/src/cmake.cpp b/src/cmake.cpp index 9a2c2e1..60681b4 100644 --- a/src/cmake.cpp +++ b/src/cmake.cpp @@ -33,6 +33,7 @@ static EnumType to_enum(const std::string &str, const std::string &help_name) { return value; } +// If the key is found, get strongly-typed value (throws on user-error) template static void get_optional(const TomlBasicValue &v, const toml::key &ky, T &destination); @@ -249,6 +250,8 @@ CMake::CMake(const std::string &path, bool build) { const auto &v = toml::find(toml, "vcpkg"); vcpkg.version = toml::find(v, "version").as_string(); vcpkg.packages = toml::find(v, "packages"); + get_optional(v, "overlay-ports", vcpkg.overlay_ports); + get_optional(v, "overlay-triplets", vcpkg.overlay_triplets); // This allows the user to use a custom pmm version if desired if (contents.count("pmm") == 0) { diff --git a/src/gen.cpp b/src/gen.cpp index 352c678..4cb912e 100644 --- a/src/gen.cpp +++ b/src/gen.cpp @@ -526,7 +526,11 @@ int generate_cmake(const char *path, bool root) { cmd("include")("${pmm_SOURCE_DIR}/pmm.cmake"); tsl::ordered_map> vcpkg_args; vcpkg_args["REVISION"] = {cmake.vcpkg.version}; + vcpkg_args["TRIPLET"] = {cmake.vcpkg.triplet}; vcpkg_args["REQUIRES"] = cmake.vcpkg.packages; + vcpkg_args["PORTS"] = cmake.vcpkg.ports; + vcpkg_args["OVERLAY_PORTS"] = cmake.vcpkg.overlay_ports; + vcpkg_args["OVERLAY_TRIPLETS"] = cmake.vcpkg.overlay_triplets; auto vcpkg = std::make_pair("VCPKG", vcpkg_args); cmd("pmm")(vcpkg).endl(); }