From 1cf9240579cecea6aa4e7abcadf56cc6317a4b09 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Mon, 26 Apr 2021 01:01:14 +0200 Subject: [PATCH] Support an array of properties [target.example.properties] SOME_LIST = [ "item1", "item2", ] --- src/cmkrlib/cmake.cpp | 17 +++++++++++++++-- src/cmkrlib/gen.cpp | 5 +++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/cmkrlib/cmake.cpp b/src/cmkrlib/cmake.cpp index a7b18d1..3042e6f 100644 --- a/src/cmkrlib/cmake.cpp +++ b/src/cmkrlib/cmake.cpp @@ -186,8 +186,21 @@ CMake::CMake(const std::string &path, bool build) { } if (t.contains("properties")) { - using prop_map = tsl::ordered_map; - target.properties = toml::find(t, "properties"); + const auto &props = toml::find(t, "properties").as_table(); + for (const auto &propKv : props) { + if (propKv.second.is_array()) { + std::string property_list; + for (const auto &list_val : propKv.second.as_array()) { + if (!property_list.empty()) { + property_list += ';'; + } + property_list += list_val.as_string(); + } + target.properties[propKv.first] = property_list; + } else { + target.properties[propKv.first] = propKv.second.as_string(); + } + } } get_optional(t, "cmake-before", target.cmake_before); diff --git a/src/cmkrlib/gen.cpp b/src/cmkrlib/gen.cpp index 4c5063a..0fe32fa 100644 --- a/src/cmkrlib/gen.cpp +++ b/src/cmkrlib/gen.cpp @@ -160,7 +160,8 @@ struct Command { std::string quote(const std::string &str) { // Don't quote arguments that don't need quoting - if (str.find(' ') == std::string::npos && str.find('\"') == std::string::npos && str.find('/') == std::string::npos) { + if (str.find(' ') == std::string::npos && str.find('\"') == std::string::npos && str.find('/') == std::string::npos && + str.find(';') == std::string::npos) { return str; } std::string result; @@ -442,7 +443,7 @@ int generate_cmake(const char *path, bool root) { comment("Bootstrap vcpkg"); cmd("include")("${pmm_SOURCE_DIR}/pmm.cmake"); tsl::ordered_map> vcpkg_args; - vcpkg_args["REVISION"] = { cmake.vcpkg.version }; + vcpkg_args["REVISION"] = {cmake.vcpkg.version}; vcpkg_args["REQUIRES"] = cmake.vcpkg.packages; auto vcpkg = std::make_pair("VCPKG", vcpkg_args); cmd("pmm")(vcpkg).endl();