Skip to content

Commit 9b0f18e

Browse files
committed
Fix a bug in fetch-content generation
1 parent 887086d commit 9b0f18e

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/cmake_generator.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -718,11 +718,7 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {
718718
version_info = " (" + content.arguments.at("SVN_REVISION") + ")";
719719
}
720720
cmd("message")("STATUS", "Fetching " + content.name + version_info + "...");
721-
ss << "FetchContent_Declare(\n\t" << content.name << "\n";
722-
for (const auto &arg : content.arguments) {
723-
ss << "\t" << arg.first << "\n\t\t" << arg.second << "\n";
724-
}
725-
ss << ")\n";
721+
cmd("FetchContent_Declare")(content.name, content.arguments);
726722
cmd("FetchContent_MakeAvailable")(content.name).endl();
727723

728724
gen.conditional_includes(content.include_after);

src/project_parser.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,12 @@ Project::Project(const Project *parent, const std::string &path, bool build) {
426426
throw std::runtime_error(format_key_error("Unknown key '" + argItr.first + "'", argItr.first, argItr.second));
427427
}
428428

429-
c.visit(argItr.first);
429+
// Make sure not to emit keys like "condition" in the FetchContent call
430+
if (!c.visisted(key)) {
431+
content.arguments.emplace(key, value);
432+
}
430433

431-
content.arguments.emplace(key, value);
434+
c.visit(argItr.first);
432435
}
433436
contents.emplace_back(std::move(content));
434437
}

0 commit comments

Comments
 (0)