[M6] brute-force probe + INTERFACE IMPORTED target codegen
This commit is contained in:
@@ -89,7 +89,34 @@ auto emit_find_packages(const std::vector<linkdb::Recipe>& recipes,
|
||||
|
||||
bool pkgconfig_emitted = false;
|
||||
auto emit_one = [&](const linkdb::Recipe& r) {
|
||||
if (r.pkg_config_module && !r.pkg_config_module->empty()) {
|
||||
if (!r.brute_force_libs.empty() || !r.brute_force_includes.empty()) {
|
||||
// Synthesize a single INTERFACE IMPORTED target named after
|
||||
// the first entry in `targets` (e.g. `<pkg>::<pkg>`). No
|
||||
// find_package — every artifact path is baked in.
|
||||
if (r.targets.empty()) {
|
||||
return;
|
||||
}
|
||||
const auto& target = r.targets.front();
|
||||
out += std::format("add_library({} INTERFACE IMPORTED)\n", target);
|
||||
if (!r.brute_force_libs.empty()) {
|
||||
out += std::format("set_property(TARGET {} APPEND PROPERTY "
|
||||
"INTERFACE_LINK_LIBRARIES",
|
||||
target);
|
||||
for (const auto& l : r.brute_force_libs) {
|
||||
out += std::format("\n \"{}\"", l);
|
||||
}
|
||||
out += ")\n";
|
||||
}
|
||||
if (!r.brute_force_includes.empty()) {
|
||||
out += std::format("set_property(TARGET {} APPEND PROPERTY "
|
||||
"INTERFACE_INCLUDE_DIRECTORIES",
|
||||
target);
|
||||
for (const auto& i : r.brute_force_includes) {
|
||||
out += std::format("\n \"{}\"", i);
|
||||
}
|
||||
out += ")\n";
|
||||
}
|
||||
} else if (r.pkg_config_module && !r.pkg_config_module->empty()) {
|
||||
if (!pkgconfig_emitted) {
|
||||
out += "find_package(PkgConfig REQUIRED)\n";
|
||||
pkgconfig_emitted = true;
|
||||
|
||||
Reference in New Issue
Block a user