diff --git a/project.cpp b/project.cpp index 87fb040..c295d30 100644 --- a/project.cpp +++ b/project.cpp @@ -40,12 +40,16 @@ struct GioFlags { static GioFlags ComputeGioFlags(const Configuration& cfg) { GioFlags f; if (!cfg.sysroot.empty()) { - // cross build (e.g. --target=aarch64-alpine-linux-musl - // --sysroot=): the host's - // pkg-config would answer for the wrong architecture. glib's - // include layout is stable across distros; the `-I=` form makes - // clang resolve the paths inside the sysroot. - f.compile = { "-I=/usr/include/glib-2.0", "-I=/usr/lib/glib-2.0/include" }; + // cross build (--target=aarch64-unknown-linux-gnu against a + // Freedesktop Sdk, or --target=aarch64-alpine-linux-musl against + // an Alpine sysroot): the host's pkg-config would answer for the + // wrong architecture. glib's headers are in + // include/glib-2.0, its glibconfig.h in lib/glib-2.0/include or, on + // a multiarch layout like the Freedesktop Sdk's, under + // lib/-linux-gnu; the `-I=` form makes clang resolve the + // paths inside the sysroot. + const std::string arch = cfg.target.substr(0, cfg.target.find('-')); + f.compile = { "-I=/usr/include/glib-2.0", "-I=/usr/lib/glib-2.0/include", std::format("-I=/usr/lib/{}-linux-gnu/glib-2.0/include", arch) }; f.link = { "-lgio-2.0", "-lgobject-2.0", "-lglib-2.0" }; return f; }