Support inject and include for targets

vcpkg-wip
Duncan Ogilvie 4 years ago
parent db4e710446
commit f32ea490fe

@ -222,6 +222,19 @@ CMake::CMake(const std::string &path, bool build) {
target.properties = toml::find<prop_map>(t, "properties"); target.properties = toml::find<prop_map>(t, "properties");
} }
if (t.contains("inject-before")) {
target.inject_before = toml::find(t, "inject-before").as_string();
}
if (t.contains("inject-after")) {
target.inject_after = toml::find(t, "inject-after").as_string();
}
if (t.contains("include-before")) {
target.include_before = detail::to_string_vec(toml::find(t, "include-before").as_array());
}
if (t.contains("include-after")) {
target.include_after = detail::to_string_vec(toml::find(t, "include-after").as_array());
}
targets.push_back(target); targets.push_back(target);
} }
} }

@ -48,6 +48,11 @@ struct Target {
std::string alias; std::string alias;
tsl::ordered_map<std::string, std::string> properties; tsl::ordered_map<std::string, std::string> properties;
std::string inject_before;
std::string inject_after;
std::vector<std::string> include_before;
std::vector<std::string> include_after;
}; };
struct Test { struct Test {

@ -428,6 +428,18 @@ int generate_cmake(const char *path, bool root) {
cmd("set")(target.name + "_SOURCES", sources).endl(); cmd("set")(target.name + "_SOURCES", sources).endl();
} }
if (!target.inject_before.empty()) {
ss << target.inject_before << "\n\n";
}
if (!target.include_before.empty()) {
for (const auto &file : target.include_before) {
// TODO: warn/error if file doesn't exist?
cmd("include")(file);
}
endl();
}
cmd(add_command)(target.name, target_type, "${" + target.name + "_SOURCES}").endl(); cmd(add_command)(target.name, target_type, "${" + target.name + "_SOURCES}").endl();
if (!target.sources.empty()) { if (!target.sources.empty()) {
@ -455,6 +467,18 @@ int generate_cmake(const char *path, bool root) {
if (!target.properties.empty()) { if (!target.properties.empty()) {
cmd("set_target_properties")(target.name, "PROPERTIES", target.properties).endl(); cmd("set_target_properties")(target.name, "PROPERTIES", target.properties).endl();
} }
if (!target.inject_after.empty()) {
ss << target.inject_after << "\n\n";
}
if (!target.include_after.empty()) {
for (const auto &file : target.include_after) {
// TODO: warn/error if file doesn't exist?
cmd("include")(file);
}
endl();
}
} }
} }

Loading…
Cancel
Save