mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 01:48:00 +00:00
732ec31a17
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.
89 lines
2.7 KiB
CMake
89 lines
2.7 KiB
CMake
# Look for GTK, of any version.
|
|
|
|
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 NONE)
|
|
|
|
set(GTK_FOUND FALSE)
|
|
|
|
macro(try_pkg_config_gtk VER PACKAGENAME)
|
|
if(NOT GTK_FOUND AND
|
|
(PUTTY_GTK_VERSION STREQUAL ANY OR PUTTY_GTK_VERSION STREQUAL ${VER}))
|
|
find_package(PkgConfig)
|
|
pkg_check_modules(GTK ${PACKAGENAME})
|
|
if(GTK_FOUND)
|
|
set(GTK_VERSION ${VER})
|
|
endif()
|
|
endif()
|
|
endmacro()
|
|
try_pkg_config_gtk(3 gtk+-3.0)
|
|
try_pkg_config_gtk(2 gtk+-2.0)
|
|
|
|
if(NOT GTK_FOUND AND
|
|
(PUTTY_GTK_VERSION STREQUAL ANY OR PUTTY_GTK_VERSION STREQUAL 1))
|
|
message("-- Checking for GTK1 (via gtk-config)")
|
|
find_program(GTK_CONFIG gtk-config)
|
|
if(GTK_CONFIG)
|
|
execute_process(COMMAND ${GTK_CONFIG} --cflags
|
|
OUTPUT_VARIABLE gtk_config_cflags
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
RESULT_VARIABLE gtk_config_cflags_result)
|
|
execute_process(COMMAND ${GTK_CONFIG} --libs
|
|
OUTPUT_VARIABLE gtk_config_libs
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
RESULT_VARIABLE gtk_config_libs_result)
|
|
|
|
if(gtk_config_cflags_result EQUAL 0 AND gtk_config_libs_result EQUAL 0)
|
|
|
|
set(GTK_INCLUDE_DIRS)
|
|
set(GTK_LIBRARY_DIRS)
|
|
set(GTK_LIBRARIES)
|
|
|
|
separate_arguments(gtk_config_cflags NATIVE_COMMAND
|
|
${gtk_config_cflags})
|
|
foreach(opt ${gtk_config_cflags})
|
|
string(REGEX MATCH "^-I" ok ${opt})
|
|
if(ok)
|
|
string(REGEX REPLACE "^-I" "" optval ${opt})
|
|
list(APPEND GTK_INCLUDE_DIRS ${optval})
|
|
endif()
|
|
endforeach()
|
|
|
|
separate_arguments(gtk_config_libs NATIVE_COMMAND
|
|
${gtk_config_libs})
|
|
foreach(opt ${gtk_config_libs})
|
|
string(REGEX MATCH "^-l" ok ${opt})
|
|
if(ok)
|
|
list(APPEND GTK_LIBRARIES ${opt})
|
|
endif()
|
|
string(REGEX MATCH "^-L" ok ${opt})
|
|
if(ok)
|
|
string(REGEX REPLACE "^-L" "" optval ${opt})
|
|
list(APPEND GTK_LIBRARY_DIRS ${optval})
|
|
endif()
|
|
endforeach()
|
|
|
|
message("-- Found GTK1")
|
|
set(GTK_FOUND TRUE)
|
|
endif()
|
|
endif()
|
|
endif()
|
|
|
|
if(GTK_FOUND)
|
|
# Check for some particular Pango functions.
|
|
function(pango_check_subscope)
|
|
set(CMAKE_REQUIRED_INCLUDES ${GTK_INCLUDE_DIRS})
|
|
set(CMAKE_REQUIRED_LIBRARIES ${GTK_LIBRARIES})
|
|
check_symbol_exists(pango_font_family_is_monospace "pango/pango.h"
|
|
HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE)
|
|
check_symbol_exists(pango_font_map_list_families "pango/pango.h"
|
|
HAVE_PANGO_FONT_MAP_LIST_FAMILIES)
|
|
set(HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE
|
|
${HAVE_PANGO_FONT_FAMILY_IS_MONOSPACE} PARENT_SCOPE)
|
|
set(HAVE_PANGO_FONT_MAP_LIST_FAMILIES
|
|
${HAVE_PANGO_FONT_MAP_LIST_FAMILIES} PARENT_SCOPE)
|
|
endfunction()
|
|
pango_check_subscope()
|
|
endif()
|