From 084cbd6159cce011f4d6ae9a53d0f882fd60e266 Mon Sep 17 00:00:00 2001 From: cursey Date: Mon, 27 Dec 2021 01:08:56 -0800 Subject: [PATCH] Cleanup vcpkg.json generation a little --- src/cmake_generator.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/cmake_generator.cpp b/src/cmake_generator.cpp index ea9df19..a07143b 100644 --- a/src/cmake_generator.cpp +++ b/src/cmake_generator.cpp @@ -611,24 +611,25 @@ void generate_cmake(const char *path, const parser::Project *parent_project) { const auto &packages = project.vcpkg.packages; for (size_t i = 0; i < packages.size(); i++) { const auto &package = packages[i]; + const auto &features = package.features; if (!vcpkg_valid_identifier(package.name)) { throw std::runtime_error("Invalid vcpkg package name '" + package.name + "'"); } - for (const auto &feature : package.features) { + for (const auto &feature : features) { if (!vcpkg_valid_identifier(feature)) { throw std::runtime_error("Invalid vcpkg package feature '" + feature + "'"); } } - if (package.features.empty()) { + if (features.empty()) { ofs << " \"" << package.name << '\"'; } else { ofs << " {\n"; ofs << " \"name\": \"" << package.name << "\",\n"; ofs << " \"features\": ["; - for (size_t j = 0; j < package.features.size(); j++) { - const auto &feature = package.features[j]; + for (size_t j = 0; j < features.size(); j++) { + const auto &feature = features[j]; ofs << '\"' << feature << '\"'; - if (j + 1 < package.features.size()) { + if (j + 1 < features.size()) { ofs << ','; } }