build: fix linking support on macOS with Clang

This was preventing any sort of building on macOS, even though the quartz
backend is currently non-functional. Fixing this is a pre-requisite to
getting a new macOS backend compiling.
This commit is contained in:
Christian Hergert 2020-07-17 17:57:17 -07:00
parent d66ac4981e
commit 7884ab6161
4 changed files with 18 additions and 12 deletions

View File

@ -216,6 +216,11 @@ if wayland_enabled or broadway_enabled
endif
endif
libgdk_c_args = [
'-DGTK_COMPILATION',
'-DG_LOG_DOMAIN="Gdk"',
]
gdk_backends = []
gdk_backends_gen_headers = [] # non-public generated headers
foreach backend : ['broadway', 'quartz', 'wayland', 'win32', 'x11']
@ -235,16 +240,12 @@ if gdk_backends.length() == 0
error('No backends enabled')
endif
# FIXME: might have to add '-xobjective-c' to c_args for quartz backend?
libgdk = static_library('gdk',
sources: [gdk_sources, gdk_backends_gen_headers, gdkconfig],
dependencies: gdk_deps + [libgtk_css_dep],
link_with: [libgtk_css, ],
include_directories: [confinc, gdkx11_inc, wlinc],
c_args: [
'-DGTK_COMPILATION',
'-DG_LOG_DOMAIN="Gdk"',
] + common_cflags,
c_args: libgdk_c_args + common_cflags,
link_whole: gdk_backends,
link_args: common_ldflags)

View File

@ -1053,6 +1053,12 @@ if cc.has_header('langinfo.h')
endforeach
endif
# Maintain compatibility with autotools
gtk_ldflags = []
if os_darwin
gtk_ldflags += [ '-compatibility_version 1', '-current_version 1.0', ]
endif
# Library
libgtk = library('gtk-4',
soversion: gtk_soversion,
@ -1062,7 +1068,7 @@ libgtk = library('gtk-4',
include_directories: [confinc, gdkinc, gskinc, gtkinc],
dependencies: gtk_deps + [libgtk_css_dep, libgdk_dep, libgsk_dep],
link_with: [libgtk_css, libgdk, libgsk, ],
link_args: common_ldflags,
link_args: common_ldflags + gtk_ldflags,
install: true)
gtk_dep_sources = [gtkversion, gtktypebuiltins_h]

View File

@ -314,11 +314,6 @@ if os_unix and not os_darwin
endforeach
endif
# Maintain compatibility with autotools
if os_darwin
common_ldflags += [ '-compatibility_version 1', '-current_version 1.0', ]
endif
confinc = include_directories('.')
gdkinc = include_directories('gdk')
gskinc = include_directories('gsk')

View File

@ -4,7 +4,11 @@ testdatadir = join_paths(installed_test_datadir, 'gtk')
gtk_tests_export_dynamic_ldflag = []
if cc.get_id() != 'msvc'
gtk_tests_export_dynamic_ldflag = ['-Wl,--export-dynamic']
if os_darwin
gtk_tests_export_dynamic_ldflag = ['-Wl,-export_dynamic']
else
gtk_tests_export_dynamic_ldflag = ['-Wl,--export-dynamic']
endif
endif
# Available keys for each test: