diff options
author | David Robillard <d@drobilla.net> | 2022-07-13 15:51:25 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-07-13 16:18:59 -0400 |
commit | 47adc7d3dec1e1d2454750612d48353944fcf836 (patch) | |
tree | 4ce5621fe794e4aeee61ed8de9180bc49f46e1d0 /meson.build | |
parent | 2465c3f2779617658cf85d3cbc0ca7b786a4ddca (diff) | |
download | serd-47adc7d3dec1e1d2454750612d48353944fcf836.tar.gz serd-47adc7d3dec1e1d2454750612d48353944fcf836.tar.bz2 serd-47adc7d3dec1e1d2454750612d48353944fcf836.zip |
Simplify linking against static libraries
This adds -DSERD_STATIC to the Cflags in the pkg-config file if serd is built
as a static library, to simplify linking against a static serd library with
pkg-config. Note that this only works for default_library=static. For linking
against libraries built with default_library=both, dependant projects must
still specify SERD_STATIC for static builds.
Resolving that requires meson adding support for writing Cflags.local, and the
world migrating to pkgconf (or improving pkg-config) so it is supported.
Diffstat (limited to 'meson.build')
-rw-r--r-- | meson.build | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/meson.build b/meson.build index 2b9c1d3a..217d1772 100644 --- a/meson.build +++ b/meson.build @@ -60,16 +60,17 @@ sources = files( ) # Set appropriate arguments for building against the library type +extra_c_args = [] subdir('meson/library') if get_option('default_library') == 'static' - add_project_arguments(['-DSERD_STATIC'], language: ['c']) + extra_c_args = ['-DSERD_STATIC'] endif # Build shared and/or static library libserd = library( meson.project_name() + library_suffix, sources, - c_args: c_suppressions + [ + c_args: c_suppressions + extra_c_args + [ '-DSERD_INTERNAL', '-DSERD_VERSION="@0@"'.format(meson.project_version()), ], @@ -77,10 +78,12 @@ libserd = library( gnu_symbol_visibility: 'hidden', include_directories: include_dirs, install: true, - version: meson.project_version()) + version: meson.project_version(), +) # Declare dependency for internal meson dependants serd_dep = declare_dependency( + compile_args: extra_c_args, include_directories: include_dirs, link_with: libserd, ) @@ -89,6 +92,7 @@ serd_dep = declare_dependency( pkg.generate( libserd, description: 'A lightweight library for working with RDF', + extra_cflags: extra_c_args, filebase: versioned_name, name: get_option('title'), subdirs: [versioned_name], |