eglplatform.h as provided by mesa supports the ability to disable inclusion of X11 headers by #define MESA_EGL_NO_X11_HEADERS - the only reasonable thing to do when compiling without X11 support, because otherwise the compile fails. Though implementation specific for MESA, WK should probably use it until Khronos provides this from upstream.
<EGL/eglplatform.h> allows to use EGL_NO_X11 for this, which seems less implementation specific. I think should be defined via adding -DEGL_NO_X11 to the C(XX)FLAGS as without this flag I also get fails on Source/WebCore/platform/graphics/opengl/ExtensionsGLOpenGLES.cpp:40 (#include <EGL/egl.h> when USE(LIBEPOXY) is false).
The correct thing to do here is picking the compiler flags from the Mesa pkg-config file (mesa.pc) correctly, using the _CFLAGS_OTHER variable defined by CMake's find_package() command. For example this was done here: https://github.com/WebPlatformForEmbedded/libwpe/pull/4/ Hardcoding a certain -DFOO will not work in all cases because different drivers may need different compiler options. The suggested options are Mesa-specific, but will fail for example with the proprietary Vivante drivers that target Wayland or the framebuffer. Picking the correct flags from the .pc file should work for all reasonable drivers :)
Well it sure would be better to use pkg-config files but it doesn't seems to work. > Mesa pkg-config file (mesa.pc) I do not have a mesa.pc [0] $ pkg-config --path mesa [1] $ qlist mesa | grep mesa.pc [1] $ > libwpe as example libwpe is among the packages where I need to add -DEGL_NO_X11 for it to build on my libX11-free setup (gentoo system with USE=-X). As you seem to hint, maybe the blame of not defining -DEGL_NO_X11 when X is disabled lies on the provider of egl.pc? For me it's libGLVND.
(In reply to Haelwenn (lanodan) Monnier from comment #3) > Well it sure would be better to use pkg-config files but it doesn't seems to > work. > > > Mesa pkg-config file (mesa.pc) > > I do not have a mesa.pc I was sleepy when I wrote this. I meant “egl.pc” > [0] $ pkg-config --path mesa > [1] $ qlist mesa | grep mesa.pc > [1] $ > > > libwpe as example > > libwpe is among the packages where I need to add -DEGL_NO_X11 for it to > build on my libX11-free setup (gentoo system with USE=-X). > > As you seem to hint, maybe the blame of not defining -DEGL_NO_X11 when X is > disabled lies on the provider of egl.pc? For me it's libGLVND. Sounds like libGLVND should include the needed flags in “egl.pc”. Using Mesa's (without libGLVND) works as expected; for example I have a Wayland only Buildroot configuration here right know which contains this: % cat output-rpi3-wpe/staging/usr/lib/pkgconfig/egl.pc prefix=/usr libdir=${prefix}/lib includedir=${prefix}/include Name: egl Description: Mesa EGL Library Version: 21.1.5 Requires.private: libdrm >= 2.4.75 Libs: -L${libdir} -lEGL Libs.private: -lpthread -pthread -lm Cflags: -I${includedir} -DEGL_NO_X11 % I see at https://github.com/NVIDIA/libglvnd/blob/master/src/EGL/egl.pc.in that libGLVND's “egl.pc.in” template does not put anything in the “Cflags:” field. Probably nobody thought about it when X11 support was made optional in libGLVND in https://github.com/NVIDIA/libglvnd/pull/184 😉
(In reply to Adrian Perez from comment #4) > Sounds like libGLVND should include the needed flags in “egl.pc”. Yeah, sounds reasonable, so I sent https://gitlab.freedesktop.org/glvnd/libglvnd/-/merge_requests/246 And a backport for gentoo: https://github.com/gentoo/gentoo/pull/21832/files
(In reply to Haelwenn (lanodan) Monnier from comment #5) > (In reply to Adrian Perez from comment #4) > > Sounds like libGLVND should include the needed flags in “egl.pc”. > > Yeah, sounds reasonable, so I sent > https://gitlab.freedesktop.org/glvnd/libglvnd/-/merge_requests/246 > > And a backport for gentoo: https://github.com/gentoo/gentoo/pull/21832/files Nice, I subscribed to the PR—I'm curious to see how it goes. I suppose we could close this bug report, then. How does that sound?
With the fix being done on Kronos side (not requiring -DEGL_NO_X11 anywhere), I think this bug can be closed.
(In reply to Haelwenn (lanodan) Monnier from comment #7) > With the fix being done on Kronos side (not requiring -DEGL_NO_X11 > anywhere), I think this bug can be closed. Yes, I agree. Thanks for helping pushing the fix in the most suitable location =)