From 6f8b07a801565f5d1e157e503d22ecc50583272a Mon Sep 17 00:00:00 2001 From: cursey Date: Fri, 28 Jan 2022 17:15:48 -0800 Subject: [PATCH] Allow specifying install component name --- include/project_parser.hpp | 1 + src/cmake_generator.cpp | 6 +++++- src/project_parser.cpp | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/project_parser.hpp b/include/project_parser.hpp index 7c5ea11..e77b957 100644 --- a/include/project_parser.hpp +++ b/include/project_parser.hpp @@ -127,6 +127,7 @@ struct Install { std::vector dirs; std::vector configs; std::string destination; + std::string component; }; struct Subdir { diff --git a/src/cmake_generator.cpp b/src/cmake_generator.cpp index 2bbc1f9..2a86a06 100644 --- a/src/cmake_generator.cpp +++ b/src/cmake_generator.cpp @@ -1030,7 +1030,11 @@ void generate_cmake(const char *path, const parser::Project *parent_project) { auto files = std::make_pair("FILES", inst.files); auto configs = std::make_pair("CONFIGURATIONS", inst.configs); auto destination = std::make_pair("DESTINATION", inst.destination); - auto component = std::make_pair("COMPONENT", inst.targets.empty() ? "" : inst.targets.front()); + auto component_name = inst.component; + if (component_name.empty() && !inst.targets.empty()) { + component_name = inst.targets.front(); + } + auto component = std::make_pair("COMPONENT", component_name); ConditionScope cs(gen, inst.condition); cmd("install")(targets, dirs, files, configs, destination, component); } diff --git a/src/project_parser.cpp b/src/project_parser.cpp index 713d03c..386b391 100644 --- a/src/project_parser.cpp +++ b/src/project_parser.cpp @@ -551,6 +551,7 @@ Project::Project(const Project *parent, const std::string &path, bool build) { i.optional("dirs", inst.dirs); i.optional("configs", inst.configs); i.required("destination", inst.destination); + i.optional("component", inst.component); installs.push_back(inst); } }