Don't require X11 in CMake builds using Wayland-only GTK

X11 headers and libraries are only required if we're actually using X11
which may not be the case.

This allows to build wxGTK on the systems using Wayland-only GTK.
This commit is contained in:
Vadim Zeitlin 2021-03-01 13:09:06 +01:00
parent a8e918727a
commit 9a84e0b25e
2 changed files with 10 additions and 6 deletions

View File

@ -46,5 +46,6 @@ endif ()
include(CheckSymbolExists)
set(CMAKE_REQUIRED_INCLUDES ${GTK3_INCLUDE_DIRS})
check_symbol_exists(GDK_WINDOWING_WAYLAND "gdk/gdk.h" wxHAVE_GDK_WAYLAND)
check_symbol_exists(GDK_WINDOWING_X11 "gdk/gdk.h" wxHAVE_GDK_X11)
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK3 DEFAULT_MSG GTK3_INCLUDE_DIRS GTK3_LIBRARIES VERSION_OK)

View File

@ -69,12 +69,6 @@ set(wxTOOLKIT_INCLUDE_DIRS)
set(wxTOOLKIT_LIBRARIES)
set(wxTOOLKIT_VERSION)
if(UNIX AND NOT APPLE AND NOT WIN32)
find_package(X11 REQUIRED)
list(APPEND wxTOOLKIT_INCLUDE_DIRS ${X11_INCLUDE_DIR})
list(APPEND wxTOOLKIT_LIBRARIES ${X11_LIBRARIES})
endif()
if(WXGTK)
if(WXGTK4)
set(gtk_lib GTK4)
@ -121,6 +115,15 @@ if(WXGTK)
endif()
endif()
# We need X11 for non-GTK Unix ports (X11, Motif) and for GTK with X11
# support, but not for Wayland-only GTK (which is why we have to do this after
# find_package(GTKx) above, as this is what sets wxHAVE_GDK_X11).
if(UNIX AND NOT APPLE AND NOT WIN32 AND (WXX11 OR WXMOTIF OR (WXGTK AND wxHAVE_GDK_X11)))
find_package(X11 REQUIRED)
list(APPEND wxTOOLKIT_INCLUDE_DIRS ${X11_INCLUDE_DIR})
list(APPEND wxTOOLKIT_LIBRARIES ${X11_LIBRARIES})
endif()
if(WXQT)
set(QT_COMPONENTS Core Widgets Gui OpenGL Test)
foreach(QT_COMPONENT ${QT_COMPONENTS})