diff options
author | Xavier Claessens <xclaesse@gmail.com> | 2018-05-25 03:13:38 +0000 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2018-05-25 03:13:38 +0000 |
commit | 8f2d68da658831a443f08cb8bc181d615a5095fe (patch) | |
tree | bbe3ca3f48c86d734f71b992a034f9073e8fb3ec | |
parent | 534e939500706af0ea02b56cffa22202014f578e (diff) | |
parent | c627fb492624bdbbb9206d88e7852bddeacfcb00 (diff) | |
download | glib-8f2d68da658831a443f08cb8bc181d615a5095fe.tar.gz |
Merge branch 'macosx-objc' into 'master'
Macosx fixes
Closes #528 and #1381
See merge request GNOME/glib!3
-rw-r--r-- | gio/Makefile.am | 25 | ||||
-rw-r--r-- | gio/gcocoanotificationbackend.m (renamed from gio/gcocoanotificationbackend.c) | 0 | ||||
-rw-r--r-- | gio/gnextstepsettingsbackend.m (renamed from gio/gnextstepsettingsbackend.c) | 0 | ||||
-rw-r--r-- | gio/gosxappinfo.m (renamed from gio/gosxappinfo.c) | 0 | ||||
-rw-r--r-- | gio/gosxcontenttype.m (renamed from gio/gosxcontenttype.c) | 0 | ||||
-rw-r--r-- | gio/meson.build | 20 | ||||
-rw-r--r-- | meson.build | 60 |
7 files changed, 66 insertions, 39 deletions
diff --git a/gio/Makefile.am b/gio/Makefile.am index df4f24014..8eaf22e0a 100644 --- a/gio/Makefile.am +++ b/gio/Makefile.am @@ -601,11 +601,28 @@ libgio_2_0_la_LDFLAGS = $(GLIB_LINK_FLAGS) \ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ -export-dynamic $(no_undefined) +# We cannot build .m files because it would require adding AC_PROG_OBJC in +# configure.ac, and it cannot be added conditionally. That means we would always +# depend on an objective-c compiler even when not needed. To work around that +# limitation we rename .m files to .c and compile them separately with +# -xobjective-c into an intermediary library. Note that we cannot rename those +# files to .c directly in the source tree because Meson needs the .m extension. +# This must be done outside of "if OS_COCOA" block otherwise distcheck fails. +# See https://bugzilla.gnome.org/show_bug.cgi?id=672777. +OBJC_FILES = \ + gnextstepsettingsbackend.m \ + gosxcontenttype.m \ + gosxappinfo.m \ + gcocoanotificationbackend.m \ + $(NULL) +OBJC_C_FILES = $(OBJC_FILES:.m=.c) +BUILT_SOURCES += $(OBJC_C_FILES) +CLEANFILES += $(OBJC_C_FILES) +EXTRA_DIST += $(OBJC_FILES) +$(OBJC_C_FILES): %.c: %.m Makefile + cp $< $@ + if OS_COCOA -# Let's avoid polluting the CFLAGS of libgio with -xobjective-c -# We cannot simply rename the ObjC files to .m because it plays -# tricks with Automake. For further reference, see: -# https://bugzilla.gnome.org/show_bug.cgi?id=672777 libgio_objc_2_0_la_CFLAGS = $(libgio_2_0_la_CFLAGS) -xobjective-c libgio_objc_2_0_la_CPPFLAGS = $(libgio_2_0_la_CPPFLAGS) libgio_objc_2_0_la_LDFLAGS = $(libgio_2_0_la_LDFLAGS) -Wl,-framework,Foundation -Wl,-framework,AppKit diff --git a/gio/gcocoanotificationbackend.c b/gio/gcocoanotificationbackend.m index ae4ad8833..ae4ad8833 100644 --- a/gio/gcocoanotificationbackend.c +++ b/gio/gcocoanotificationbackend.m diff --git a/gio/gnextstepsettingsbackend.c b/gio/gnextstepsettingsbackend.m index 44ea845d8..44ea845d8 100644 --- a/gio/gnextstepsettingsbackend.c +++ b/gio/gnextstepsettingsbackend.m diff --git a/gio/gosxappinfo.c b/gio/gosxappinfo.m index 463b2da3c..463b2da3c 100644 --- a/gio/gosxappinfo.c +++ b/gio/gosxappinfo.m diff --git a/gio/gosxcontenttype.c b/gio/gosxcontenttype.m index 52ba5763a..52ba5763a 100644 --- a/gio/gosxcontenttype.c +++ b/gio/gosxcontenttype.m diff --git a/gio/meson.build b/gio/meson.build index 42f67715d..b8baaa639 100644 --- a/gio/meson.build +++ b/gio/meson.build @@ -292,11 +292,6 @@ if host_system == 'windows' settings_sources += files('gregistrysettingsbackend.c') endif -# FIXME: -#if OS_COCOA -#settings_sources += files('gnextstepsettingsbackend.c') -#endif - application_headers = files( 'gapplication.h', 'gapplicationcommandline.h', @@ -412,19 +407,21 @@ if host_system != 'windows' ) if glib_have_cocoa - contenttype_sources += files('gosxcontenttype.c') - appinfo_sources += files('gosxappinfo.c') + settings_sources += files('gnextstepsettingsbackend.m') + contenttype_sources += files('gosxcontenttype.m') + appinfo_sources += files('gosxappinfo.m') if glib_have_os_x_9_or_later - unix_sources += files('gcocoanotificationbackend.c') + unix_sources += files('gcocoanotificationbackend.m') endif else contenttype_sources += files('gcontenttype.c') appinfo_sources += files('gdesktopappinfo.c') gio_unix_include_headers += files('gdesktopappinfo.h') - subdir('xdgmime') - internal_deps += [xdgmime_lib] endif + subdir('xdgmime') + internal_deps += [xdgmime_lib] + install_headers(gio_unix_include_headers, subdir : 'gio-unix-2.0/gio') if glib_conf.has('HAVE_NETLINK') @@ -798,6 +795,7 @@ libgio = library('gio-2.0', libgobject_dep, libgmodule_dep, selinux_dep, xattr_dep, platform_deps, network_libs], c_args : gio_c_args, + objc_args : gio_c_args, # intl.lib is not compatible with SAFESEH link_args : [noseh_link_args, glib_link_flags], ) @@ -943,7 +941,7 @@ executable('gdbus', 'gdbus-tool.c', link_args : noseh_link_args, dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep]) -if host_system != 'windows' +if host_system != 'windows' and not glib_have_cocoa executable('gapplication', 'gapplication-tool.c', install : true, c_args : gio_c_args, diff --git a/meson.build b/meson.build index 9f498d7ab..3194da4ec 100644 --- a/meson.build +++ b/meson.build @@ -572,36 +572,48 @@ if host_system == 'linux' endif osx_ldflags = [] +glib_have_os_x_9_or_later = false +glib_have_carbon = false +glib_have_cocoa = false +if host_system == 'darwin' + add_languages('objc') + objcc = meson.get_compiler('objc') -# Mac OS X Carbon support -glib_have_carbon = cc.compiles('''#include <Carbon/Carbon.h> - #include <CoreServices/CoreServices.h>''', - name : 'Mac OS X Carbon support') + # FIXME: Should this be conditional? glib-gettext.m4 has some checks + osx_ldflags += ['-Wl,-framework,CoreFoundation'] -glib_have_os_x_9_or_later = false + # Mac OS X Carbon support + glib_have_carbon = objcc.compiles('''#include <Carbon/Carbon.h> + #include <CoreServices/CoreServices.h>''', + name : 'Mac OS X Carbon support') -if glib_have_carbon - glib_conf.set('HAVE_CARBON', true) - osx_ldflags += '-Wl,-framework,Carbon' - glib_have_os_x_9_or_later = cc.compiles('''#include <AvailabilityMacros.h> - #if MAC_OS_X_VERSION_MIN_REQUIRED < 1090 - #error Compiling for minimum OS X version before 10.9 - #endif''', name : 'OS X 9 or later') -endif + if glib_have_carbon + glib_conf.set('HAVE_CARBON', true) + osx_ldflags += '-Wl,-framework,Carbon' + glib_have_os_x_9_or_later = objcc.compiles('''#include <AvailabilityMacros.h> + #if MAC_OS_X_VERSION_MIN_REQUIRED < 1090 + #error Compiling for minimum OS X version before 10.9 + #endif''', + name : 'OS X 9 or later') + endif -# Mac OS X Cocoa support -glib_have_cocoa = cc.compiles('''#include <Cocoa/Cocoa.h> - #ifdef GNUSTEP_BASE_VERSION - #error "Detected GNUstep, not Cocoa" - #endif''', - name : 'Mac OS X Cocoa support') + # Mac OS X Cocoa support + glib_have_cocoa = objcc.compiles('''#include <Cocoa/Cocoa.h> + #ifdef GNUSTEP_BASE_VERSION + #error "Detected GNUstep, not Cocoa" + #endif''', + name : 'Mac OS X Cocoa support') -if glib_have_cocoa - glib_conf.set('HAVE_COCOA', true) - osx_ldflags += ['-Wl,-framework,Foundation', '-Wl,-framework,AppKit'] -endif + if glib_have_cocoa + glib_conf.set('HAVE_COCOA', true) + osx_ldflags += ['-Wl,-framework,Foundation', '-Wl,-framework,AppKit'] + endif -add_project_link_arguments(osx_ldflags, language : 'c') + # FIXME: libgio mix C and objC source files and there is no way to reliably + # know which language flags it's going to use to link. Add to both languages + # for now. See https://github.com/mesonbuild/meson/issues/3585. + add_project_link_arguments(osx_ldflags, language : ['objc', 'c']) +endif # Check for futex(2) if cc.links('''#include <linux/futex.h> |