diff --git a/src/cmake_generator.cpp b/src/cmake_generator.cpp index 42072b8..e15eb54 100644 --- a/src/cmake_generator.cpp +++ b/src/cmake_generator.cpp @@ -718,11 +718,7 @@ void generate_cmake(const char *path, const parser::Project *parent_project) { version_info = " (" + content.arguments.at("SVN_REVISION") + ")"; } cmd("message")("STATUS", "Fetching " + content.name + version_info + "..."); - ss << "FetchContent_Declare(\n\t" << content.name << "\n"; - for (const auto &arg : content.arguments) { - ss << "\t" << arg.first << "\n\t\t" << arg.second << "\n"; - } - ss << ")\n"; + cmd("FetchContent_Declare")(content.name, content.arguments); cmd("FetchContent_MakeAvailable")(content.name).endl(); gen.conditional_includes(content.include_after); diff --git a/src/project_parser.cpp b/src/project_parser.cpp index d466c0c..380a723 100644 --- a/src/project_parser.cpp +++ b/src/project_parser.cpp @@ -426,9 +426,12 @@ Project::Project(const Project *parent, const std::string &path, bool build) { throw std::runtime_error(format_key_error("Unknown key '" + argItr.first + "'", argItr.first, argItr.second)); } - c.visit(argItr.first); + // Make sure not to emit keys like "condition" in the FetchContent call + if (!c.visisted(key)) { + content.arguments.emplace(key, value); + } - content.arguments.emplace(key, value); + c.visit(argItr.first); } contents.emplace_back(std::move(content)); }