1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

Fix pre-GTK3 build failures in puttyapp / ptermapp.

These alternate frontends using the GtkApplication class don't work
before GTK3, because the GtkApplication class didn't exist. In the old
mkfiles.pl system, the simplest way to prevent a build failure was to
just compile them anyway but make them reduce to a stub main(). But
now, with the new library-based code organisation, library search
order issues mean that these applications won't build at all.

Happily, with cmake, it's also easy to simply omit these binaries from
the build completely depending on our GTK version.
This commit is contained in:
Simon Tatham 2021-12-18 11:43:57 +00:00
parent a759e303b0
commit 0e630bc4f1
3 changed files with 29 additions and 37 deletions

View File

@ -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)

View File

@ -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

View File

@ -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) */