From c037aef285f052cec31a0c346d8ab1fa9fc171a3 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Mon, 3 May 2021 16:42:03 +0100 Subject: [PATCH] Better detection of NOT_X_WINDOWS. When building against the Mac Homebrew installation of GTK, you find that GTK exists, libX11 exists, but the integration between the two (in the form of the header file gdk/gdkx.h) doesn't exist. In that situation, we need to compile out X11 support. --- cmake/platforms/unix.cmake | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/cmake/platforms/unix.cmake b/cmake/platforms/unix.cmake index c586577d..156919e7 100644 --- a/cmake/platforms/unix.cmake +++ b/cmake/platforms/unix.cmake @@ -57,12 +57,21 @@ endif() include(cmake/gtk.cmake) +# See if we have X11 available. This requires libX11 itself, and also +# the GDK integration to X11. find_package(X11) -if(NOT X11_FOUND) - set(NOT_X_WINDOWS ON) -else() - set(NOT_X_WINDOWS OFF) -endif() + +function(check_x11) + list(APPEND CMAKE_REQUIRED_INCLUDES ${GTK_INCLUDE_DIRS}) + check_include_file(gdk/gdkx.h HAVE_GDK_GDKX_H) + + if(X11_FOUND AND HAVE_GDK_GDKX_H) + set(NOT_X_WINDOWS OFF PARENT_SCOPE) + else() + set(NOT_X_WINDOWS ON PARENT_SCOPE) + endif() +endfunction() +check_x11() include_directories(${CMAKE_SOURCE_DIR}/charset ${GTK_INCLUDE_DIRS} ${X11_INCLUDE_DIR}) link_directories(${GTK_LIBRARY_DIRS})