Add inject-before and inject-after

toml-checker
Duncan Ogilvie 4 years ago
parent 0e2cddcbe6
commit f4ef95eabc

@ -73,6 +73,12 @@ CMake::CMake(const std::string &path, bool build) {
const auto &project = toml::find(toml, "project");
project_name = toml::find(project, "name").as_string();
project_version = toml::find(project, "version").as_string();
if (project.contains("inject-before")) {
inject_before = toml::find(project, "inject-before").as_string();
}
if (project.contains("inject-after")) {
inject_after = toml::find(project, "inject-after").as_string();
}
if (project.contains("include-before")) {
include_before = detail::to_string_vec(toml::find(project, "include-before").as_array());
}

@ -69,6 +69,8 @@ struct CMake {
std::vector<std::string> build_args;
std::string project_name;
std::string project_version;
std::string inject_before;
std::string inject_after;
std::vector<std::string> include_before;
std::vector<std::string> include_after;
std::vector<Setting> settings;

@ -230,6 +230,10 @@ int generate_cmake(const char *path) {
comment("This file was generated automatically by cmkr.").endl();
if (!cmake.inject_before.empty()) {
ss << cmake.inject_before << "\n\n";
}
if (!cmake.include_before.empty()) {
for (const auto &file : cmake.include_before) {
// TODO: warn/error if file doesn't exist?
@ -292,6 +296,10 @@ int generate_cmake(const char *path) {
cmd("project")(name, "VERSION", "${" + name + "_PROJECT_VERSION}").endl();
}
if (!cmake.inject_after.empty()) {
ss << cmake.inject_after << "\n\n";
}
if (!cmake.include_after.empty()) {
for (const auto &file : cmake.include_after) {
// TODO: warn/error if file doesn't exist?

Loading…
Cancel
Save