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