From e69cf4d2b93a1a9ebebec74ca0ea547301c70be4 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Wed, 1 Jun 2022 19:06:53 +0200 Subject: [PATCH] Add install.optional flag --- docs/cmake-toml.md | 1 + include/project_parser.hpp | 1 + src/cmake_generator.cpp | 3 ++- src/project_parser.cpp | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/cmake-toml.md b/docs/cmake-toml.md index 8ea8eb9..82a832d 100644 --- a/docs/cmake-toml.md +++ b/docs/cmake-toml.md @@ -204,4 +204,5 @@ component = "mycomponent" files = ["content/my.png"] dirs = ["include"] configs = ["Release", "Debug"] +optional = false ``` \ No newline at end of file diff --git a/include/project_parser.hpp b/include/project_parser.hpp index c8f8186..a4ce581 100644 --- a/include/project_parser.hpp +++ b/include/project_parser.hpp @@ -128,6 +128,7 @@ struct Install { std::vector configs; std::string destination; std::string component; + bool optional = false; }; struct Subdir { diff --git a/src/cmake_generator.cpp b/src/cmake_generator.cpp index 1034eaa..d290122 100644 --- a/src/cmake_generator.cpp +++ b/src/cmake_generator.cpp @@ -1045,8 +1045,9 @@ void generate_cmake(const char *path, const parser::Project *parent_project) { component_name = inst.targets.front(); } auto component = std::make_pair("COMPONENT", component_name); + auto optional = inst.optional ? "OPTIONAL" : ""; ConditionScope cs(gen, inst.condition); - cmd("install")(targets, dirs, files, configs, destination, component); + cmd("install")(targets, dirs, files, configs, destination, component, optional); } } diff --git a/src/project_parser.cpp b/src/project_parser.cpp index 8b5166b..e152e0d 100644 --- a/src/project_parser.cpp +++ b/src/project_parser.cpp @@ -619,6 +619,7 @@ Project::Project(const Project *parent, const std::string &path, bool build) { i.optional("configs", inst.configs); i.required("destination", inst.destination); i.optional("component", inst.component); + i.optional("optional", inst.optional); installs.push_back(inst); } }