| 1 |
snippets = import('snippets') |
| 2 |
|
| 3 |
lib_incdir = include_directories('..') |
| 4 |
lib_args = ['-DMY_LIB_COMPILATION'] |
| 5 |
lib_static_args = ['-DMY_LIB_STATIC_COMPILATION'] |
| 6 |
|
| 7 |
h = snippets.symbol_visibility_header('apiconfig.h') |
| 8 |
install_headers(h, 'lib.h', subdir: 'mylib') |
| 9 |
mylib = both_libraries('mylib', 'lib.c', |
| 10 |
include_directories: lib_incdir, |
| 11 |
gnu_symbol_visibility: 'hidden', |
| 12 |
c_args: lib_args, |
| 13 |
c_static_args: lib_static_args, |
| 14 |
install: true) |
| 15 |
mylib_sta_dep = declare_dependency(link_with: mylib.get_static_lib(), |
| 16 |
include_directories: lib_incdir, |
| 17 |
compile_args: lib_static_args) |
| 18 |
mylib_sha_dep = declare_dependency(link_with: mylib.get_shared_lib(), |
| 19 |
include_directories: lib_incdir) |
| 20 |
meson.override_dependency('mylib-sta', mylib_sta_dep) |
| 21 |
meson.override_dependency('mylib-sha', mylib_sha_dep) |
| 22 |
pkg.generate(mylib, |
| 23 |
extra_cflags: lib_static_args, |
| 24 |
) |
| 25 |
|
| 26 |
# When using static_only, we don't need lib_static_args because |
| 27 |
# MY_LIB_STATIC_COMPILATION gets defined in the generated header. |
| 28 |
h = snippets.symbol_visibility_header('apiconfig-static-only.h', |
| 29 |
static_only: true) |
| 30 |
install_headers(h, 'lib-static-only.h', subdir: 'mylib') |
| 31 |
libstaticonly = static_library('static-only', 'lib-static-only.c', |
| 32 |
include_directories: lib_incdir, |
| 33 |
gnu_symbol_visibility: 'hidden', |
| 34 |
c_args: lib_args, |
| 35 |
install: true) |
| 36 |
static_only_dep = declare_dependency(link_with: libstaticonly, |
| 37 |
include_directories: lib_incdir) |
| 38 |
meson.override_dependency('static-only', static_only_dep) |
| 39 |
pkg.generate(libstaticonly) |