Merge pull request #138 from build-cpp/find-package-first

Generate find-package before fetch-content
main
Duncan Ogilvie 9 months ago committed by GitHub
commit 7165986190
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -900,6 +900,20 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {
ofs << "}\n";
}
if (!project.packages.empty()) {
comment("Packages");
for (const auto &dep : project.packages) {
auto version = dep.version;
if (version == "*")
version.clear();
auto required = dep.required ? "REQUIRED" : "";
auto config = dep.config ? "CONFIG" : "";
auto components = std::make_pair("COMPONENTS", dep.components);
ConditionScope cs(gen, dep.condition);
cmd("find_package")(dep.name, version, required, config, components).endl();
}
}
if (!project.contents.empty()) {
cmd("include")("FetchContent").endl();
if (!project.root()->vcpkg.enabled()) {
@ -935,20 +949,6 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {
}
}
if (!project.packages.empty()) {
comment("Packages");
for (const auto &dep : project.packages) {
auto version = dep.version;
if (version == "*")
version.clear();
auto required = dep.required ? "REQUIRED" : "";
auto config = dep.config ? "CONFIG" : "";
auto components = std::make_pair("COMPONENTS", dep.components);
ConditionScope cs(gen, dep.condition);
cmd("find_package")(dep.name, version, required, config, components).endl();
}
}
auto add_subdir = [&](const std::string &dir) {
// clang-format off
comment("Subdirectory: " + dir);

Loading…
Cancel
Save