[M6] resolver: pkg-config probe + codegen for PkgConfig
This commit is contained in:
@@ -86,11 +86,33 @@ auto emit_find_packages(const std::vector<linkdb::Recipe>& recipes,
|
||||
return {};
|
||||
}
|
||||
std::string out = "\n# ----- dependencies -----\n";
|
||||
|
||||
bool pkgconfig_emitted = false;
|
||||
auto emit_one = [&](const linkdb::Recipe& r) {
|
||||
if (r.pkg_config_module && !r.pkg_config_module->empty()) {
|
||||
if (!pkgconfig_emitted) {
|
||||
out += "find_package(PkgConfig REQUIRED)\n";
|
||||
pkgconfig_emitted = true;
|
||||
}
|
||||
std::string upper;
|
||||
upper.reserve(r.pkg_config_module->size());
|
||||
for (char c : *r.pkg_config_module) {
|
||||
upper += std::isalnum(static_cast<unsigned char>(c))
|
||||
? static_cast<char>(std::toupper(
|
||||
static_cast<unsigned char>(c)))
|
||||
: '_';
|
||||
}
|
||||
out += std::format("pkg_check_modules({} REQUIRED IMPORTED_TARGET {})\n",
|
||||
upper, *r.pkg_config_module);
|
||||
} else {
|
||||
out += std::format("find_package({})\n", r.find_package);
|
||||
}
|
||||
};
|
||||
for (const auto& r : recipes) {
|
||||
out += std::format("find_package({})\n", r.find_package);
|
||||
emit_one(r);
|
||||
}
|
||||
for (const auto& r : dev_recipes) {
|
||||
out += std::format("find_package({})\n", r.find_package);
|
||||
emit_one(r);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user