From 0f6ca21188399e13e6ec2db6a4086be20b8ba9e7 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Tue, 31 Jan 2017 14:43:25 +0100 Subject: [PATCH] Add static linkage argument in meson.build. Those options were added by the kiwix-build.py script. But it's better to add them in the meson.build script to allow people not using kiwix-build to compile static binaries either. --- README.md | 4 +++- meson.build | 5 +++++ meson_options.txt | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index de300a8..2bb4574 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,9 @@ $ ninja install ``` By default, it will compile dynamic linked binaries. -If you want statically linked binaries, you can add `--default-library=static` +If you want statically linked binaries, you can add `-Dstatic-linkage=true` option to the meson command. +Be aware that you must have static library dependencies installed on your +system. Licensed as GPLv3 or later, see COPYING for more details. diff --git a/meson.build b/meson.build index 4ceaa0b..b47d6e7 100644 --- a/meson.build +++ b/meson.build @@ -2,6 +2,11 @@ project('kiwix-tools', 'cpp') compiler = meson.get_compiler('cpp') +static_linkage = get_option('static-linkage') +if static_linkage + add_global_link_arguments('-static-libstdc++', '--static', language:'cpp') +endif + thread_dep = dependency('threads') kiwixlib_dep = dependency('kiwix') microhttpd_dep = dependency('libmicrohttpd') diff --git a/meson_options.txt b/meson_options.txt index 886efcc..b8da3dc 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,2 +1,4 @@ +option('static-linkage', type : 'boolean', value : false, + description : 'Create statically linked binaries.') option('ctpp2-install-prefix', type : 'string', value : '', description : 'Prefix where ctpp libs has been installed')