Skip to content

Commit e69cf4d

Browse files
committed
Add install.optional flag
1 parent e98a906 commit e69cf4d

File tree

4 files changed

+5
-1
lines changed

4 files changed

+5
-1
lines changed

docs/cmake-toml.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,5 @@ component = "mycomponent"
204204
files = ["content/my.png"]
205205
dirs = ["include"]
206206
configs = ["Release", "Debug"]
207+
optional = false
207208
```

include/project_parser.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ struct Install {
128128
std::vector<std::string> configs;
129129
std::string destination;
130130
std::string component;
131+
bool optional = false;
131132
};
132133

133134
struct Subdir {

src/cmake_generator.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1045,8 +1045,9 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {
10451045
component_name = inst.targets.front();
10461046
}
10471047
auto component = std::make_pair("COMPONENT", component_name);
1048+
auto optional = inst.optional ? "OPTIONAL" : "";
10481049
ConditionScope cs(gen, inst.condition);
1049-
cmd("install")(targets, dirs, files, configs, destination, component);
1050+
cmd("install")(targets, dirs, files, configs, destination, component, optional);
10501051
}
10511052
}
10521053

src/project_parser.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,7 @@ Project::Project(const Project *parent, const std::string &path, bool build) {
619619
i.optional("configs", inst.configs);
620620
i.required("destination", inst.destination);
621621
i.optional("component", inst.component);
622+
i.optional("optional", inst.optional);
622623
installs.push_back(inst);
623624
}
624625
}

0 commit comments

Comments
 (0)