diff --git a/cmake/gtk.cmake b/cmake/gtk.cmake index 145f214b..85ecb7de 100644 --- a/cmake/gtk.cmake +++ b/cmake/gtk.cmake @@ -12,6 +12,9 @@ macro(try_pkg_config_gtk VER PACKAGENAME) (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) diff --git a/unix/CMakeLists.txt b/unix/CMakeLists.txt index 0490cf5c..9bdd2522 100644 --- a/unix/CMakeLists.txt +++ b/unix/CMakeLists.txt @@ -155,17 +155,19 @@ if(GTK_FOUND) ${GTK_LIBRARIES} ${X11_LIBRARIES}) installed_program(pterm) - add_executable(ptermapp - pterm.c - main-gtk-application.c - ${CMAKE_SOURCE_DIR}/stubs/nocmdline.c - ${CMAKE_SOURCE_DIR}/stubs/nogss.c - ${CMAKE_SOURCE_DIR}/proxy/nosshproxy.c - pty.c) - be_list(ptermapp pterm) - target_link_libraries(ptermapp - guiterminal eventloop settings charset utils - ${GTK_LIBRARIES} ${X11_LIBRARIES}) + if(GTK_VERSION GREATER_EQUAL 3) + add_executable(ptermapp + pterm.c + main-gtk-application.c + ${CMAKE_SOURCE_DIR}/stubs/nocmdline.c + ${CMAKE_SOURCE_DIR}/stubs/nogss.c + ${CMAKE_SOURCE_DIR}/proxy/nosshproxy.c + pty.c) + be_list(ptermapp pterm) + target_link_libraries(ptermapp + guiterminal eventloop settings charset utils + ${GTK_LIBRARIES} ${X11_LIBRARIES}) + endif() add_executable(putty putty.c @@ -179,15 +181,17 @@ if(GTK_FOUND) PROPERTIES LINK_INTERFACE_MULTIPLICITY 2) installed_program(putty) - add_executable(puttyapp - putty.c - main-gtk-application.c - ${CMAKE_SOURCE_DIR}/stubs/nocmdline.c) - be_list(puttyapp PuTTY SSH SERIAL OTHERBACKENDS) - target_link_libraries(puttyapp - guiterminal eventloop sshclient otherbackends settings - network crypto charset utils - ${GTK_LIBRARIES} ${X11_LIBRARIES}) + if(GTK_VERSION GREATER_EQUAL 3) + add_executable(puttyapp + putty.c + main-gtk-application.c + ${CMAKE_SOURCE_DIR}/stubs/nocmdline.c) + be_list(puttyapp PuTTY SSH SERIAL OTHERBACKENDS) + target_link_libraries(puttyapp + guiterminal eventloop sshclient otherbackends settings + network crypto charset utils + ${GTK_LIBRARIES} ${X11_LIBRARIES}) + endif() add_executable(puttytel putty.c diff --git a/unix/main-gtk-application.c b/unix/main-gtk-application.c index fb924009..b6c2807b 100644 --- a/unix/main-gtk-application.c +++ b/unix/main-gtk-application.c @@ -84,21 +84,8 @@ char *x_get_default(const char *key) { return NULL; } const bool buildinfo_gtk_relevant = true; #if !GTK_CHECK_VERSION(3,0,0) -/* This front end only works in GTK 3. If that's not what we've got, - * it's easier to just turn this program into a trivial stub by ifdef - * in the source than it is to remove it in the makefile edifice. */ -int main(int argc, char **argv) -{ - fprintf(stderr, "GtkApplication frontend doesn't work pre-GTK3\n"); - return 1; -} -GtkWidget *make_gtk_toplevel_window(GtkFrontend *frontend) { return NULL; } -void launch_duplicate_session(Conf *conf) {} -void launch_new_session(void) {} -void launch_saved_session(const char *str) {} -void session_window_closed(void) {} -void window_setup_error(const char *errmsg) {} -#else /* GTK_CHECK_VERSION(3,0,0) */ +#error This front end only works in GTK 3 +#endif static void startup(GApplication *app, gpointer user_data) { @@ -336,5 +323,3 @@ int main(int argc, char **argv) return status; } - -#endif /* GTK_CHECK_VERSION(3,0,0) */