From 732ec31a17a7feac9c24c427f79734e9a97b922f Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 18 Sep 2022 15:02:32 +0100 Subject: [PATCH] Add explicit cmake setting for 'build without GTK'. If you have GTK installed on your system but want to build without it anyway (e.g. if you're buliding a package suitable for headless systems), it's useful to be able to explicitly instruct PuTTY's build system not to use GTK even if it's there. This would already work if you unilaterally set PUTTY_GTK_VERSION to some value other than 1, 2, 3 or ANY. Added NONE as an officially supported option, and included it in the list that cmake-gui will present. Also, made the check for libX11 conditional on having GTK, since there's no need to bother with it otherwise. --- cmake/gtk.cmake | 2 +- cmake/platforms/unix.cmake | 28 +++++++++++++++------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/cmake/gtk.cmake b/cmake/gtk.cmake index 85ecb7de..34396d2f 100644 --- a/cmake/gtk.cmake +++ b/cmake/gtk.cmake @@ -3,7 +3,7 @@ set(PUTTY_GTK_VERSION "ANY" CACHE STRING "Which major version of GTK to build with") set_property(CACHE PUTTY_GTK_VERSION - PROPERTY STRINGS ANY 3 2 1) + PROPERTY STRINGS ANY 3 2 1 NONE) set(GTK_FOUND FALSE) diff --git a/cmake/platforms/unix.cmake b/cmake/platforms/unix.cmake index 95339f22..04db8129 100644 --- a/cmake/platforms/unix.cmake +++ b/cmake/platforms/unix.cmake @@ -65,21 +65,23 @@ 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(GTK_FOUND) + # See if we have X11 available. This requires libX11 itself, and also + # the GDK integration to X11. + find_package(X11) -function(check_x11) - list(APPEND CMAKE_REQUIRED_INCLUDES ${GTK_INCLUDE_DIRS}) - check_include_file(gdk/gdkx.h HAVE_GDK_GDKX_H) + 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() + 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() +endif() include_directories(${CMAKE_SOURCE_DIR}/charset ${GTK_INCLUDE_DIRS} ${X11_INCLUDE_DIR}) link_directories(${GTK_LIBRARY_DIRS})