From caa5fd0584c2a9a51de4875bb5c7ed0f99200662 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Sat, 22 May 2021 22:11:05 +0800 Subject: [PATCH] gtk/meson.build: Fix linking on Visual Studio 2013 Visual Studio 2013's linker does not suport `/WHOLEARCHIVE:`, just explicitly extract the objects from the static libraries that will form the final GTK DLL. --- gtk/meson.build | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/gtk/meson.build b/gtk/meson.build index fe0ec456d9..f56d4da8bb 100644 --- a/gtk/meson.build +++ b/gtk/meson.build @@ -1116,11 +1116,28 @@ libgtk_static = static_library('gtk', link_with: [libgtk_css, libgdk, libgsk ], ) +# `link_whole:` is actually only supported on Visual Studio 2015 Update 2 +# or later via the linker flag `/WHOLEARCHIVE:`, so we need +# to work around it for Visual Studio 2013. Note that all needed static +# libs are required so that we grab the object files from each of them to +# link the final GTK DLL. +whole_archives = [] +gtk4_objs = [] + +if cc.get_id() == 'msvc' and cc.version().split('.').get(0) < '19' + foreach target : [ libgtk_static, libgtk_css, libgdk, libgdk_win32, libgsk ] + gtk4_objs += target.extract_all_objects(recursive: false) + endforeach +else + whole_archives = [libgtk_static, libgtk_css, libgdk, libgsk ] +endif + libgtk = shared_library('gtk-4', c_args: gtk_cargs + common_cflags, include_directories: [confinc, gdkinc, gskinc, gtkinc], dependencies: gtk_deps + [libgtk_css_dep, libgdk_dep, libgsk_dep], - link_whole: [libgtk_static, libgtk_css, libgdk, libgsk ], + link_whole: whole_archives, + objects: gtk4_objs, link_args: common_ldflags, soversion: gtk_soversion, version: gtk_library_version,