[json-glib: 6/11] build: Test all common compiler and linker flags
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [json-glib: 6/11] build: Test all common compiler and linker flags
- Date: Mon, 10 Jul 2017 15:22:36 +0000 (UTC)
commit 0c474b495a2c1b12a6b0c33d112f2b86460998fc
Author: Emmanuele Bassi <ebassi gnome org>
Date: Mon Jul 10 10:44:47 2017 +0100
build: Test all common compiler and linker flags
Instead of assuming some compiler and linker flags will work depending
on the platform, we should test them all.
Additionally, we should move all the compiler and linker flag checks in
the same place.
json-glib/meson.build | 13 +------------
meson.build | 40 ++++++++++++++++++++++++++--------------
2 files changed, 27 insertions(+), 26 deletions(-)
---
diff --git a/json-glib/meson.build b/json-glib/meson.build
index a23b443..45c3247 100644
--- a/json-glib/meson.build
+++ b/json-glib/meson.build
@@ -64,24 +64,13 @@ json_c_args = [
'-DJSON_LOCALEDIR="@0@"'.format(json_localedir)
]
-common_ldflags = []
-
-if host_system == 'linux'
- common_ldflags = [ '-Wl,-Bsymbolic', '-Wl,-z,relro', '-Wl,-z,now', ]
-endif
-
-# Maintain compatibility with autotools
-if host_system == 'darwin'
- common_ldflags += [ '-compatibility_version=1', '-current_version=1.0', ]
-endif
-
json_lib = library(json_api_name,
source_c + json_glib_enums,
version: libversion,
soversion: soversion,
include_directories: root_dir,
dependencies: [ gio_dep, gobject_dep, ],
- c_args: json_c_args + common_cflags + extra_args,
+ c_args: json_c_args + common_cflags,
link_args: common_ldflags,
install: true)
diff --git a/meson.build b/meson.build
index aa32885..631116c 100644
--- a/meson.build
+++ b/meson.build
@@ -40,7 +40,6 @@ gio_dep = dependency('gio-2.0', version: glib_req_version)
# Configurations
cc = meson.get_compiler('c')
host_system = host_machine.system()
-extra_args = []
cdata = configuration_data()
check_headers = [
@@ -116,26 +115,39 @@ else
test_cflags = []
endif
-common_cflags = []
-foreach cflag: test_cflags
- if cc.has_argument(cflag)
- common_cflags += [ cflag ]
- endif
-endforeach
-
if get_option('default_library') != 'static'
if host_system == 'windows'
cdata.set('DLL_EXPORT', true)
- if cc.get_id() == 'msvc'
- cdata.set('_JSON_EXTERN', '__declspec(dllexport) extern')
- else
- cdata.set('_JSON_EXTERN', '__attribute__((visibility("default"))) __declspec(dllexport) extern')
- extra_args += ['-fvisibility=hidden']
+ cdata.set('_JSON_EXTERN', '__declspec(dllexport) extern')
+ if cc.get_id() != 'msvc'
+ test_cflags += '-fvisibility=hidden'
endif
else
cdata.set('_JSON_EXTERN', '__attribute__((visibility("default"))) extern')
- extra_args += ['-fvisibility=hidden']
+ test_cflags += '-fvisibility=hidden'
+ endif
+endif
+
+common_cflags = []
+foreach cflag: test_cflags
+ if cc.has_argument(cflag)
+ common_cflags += cflag
endif
+endforeach
+
+common_ldflags = []
+
+if host_system == 'linux'
+ foreach ldflag: [ '-Wl,-Bsymbolic', '-Wl,-z,relro', '-Wl,-z,now', ]
+ if cc.has_argument(ldflag)
+ common_ldflags += ldflag
+ endif
+ endforeach
+endif
+
+# Maintain compatibility with autotools
+if host_system == 'darwin'
+ common_ldflags += [ '-compatibility_version 1', '-current_version 1.0', ]
endif
root_dir = include_directories('.')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]