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); } }