diff options
author | Daniel Eklöf <daniel@ekloef.se> | 2024-07-18 18:21:11 +0200 |
---|---|---|
committer | Daniel Eklöf <daniel@ekloef.se> | 2024-07-18 18:21:43 +0200 |
commit | d91789cf42d88852709bfc62fab5f242a36fdf84 (patch) | |
tree | 6365fc20514ccda860ea7a64382f7876772ddb14 /meson.build | |
parent | c89bbfe6012275afe500c0c862329f37c4021d73 (diff) | |
download | wbg-d91789cf42d88852709bfc62fab5f242a36fdf84.tar.gz |
meson/nanosvg: add support for linking against system's nanosvg
Nanosvg upstream is header only, and does not support/provide a
library, neither shared nor static.
However, most distributions still provide a nanosvg package with
either a static library, or shared. Arch does the latter.
So, let's support building against a system provided nanosvg library.
The default is still to use bundled version, but this can be changed
with
-Dsystem-nanosvg=enabled
when configuring the build tree.
Diffstat (limited to 'meson.build')
-rw-r--r-- | meson.build | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/meson.build b/meson.build index ea310ca..69ff14e 100644 --- a/meson.build +++ b/meson.build @@ -48,17 +48,28 @@ endif math = cc.find_library('m') pixman = dependency('pixman-1') +system_nanosvg = cc.find_library('nanosvg', required: get_option('system-nanosvg')) +system_nanosvgrast = cc.find_library('nanosvgrast', required: get_option('system-nanosvg')) png = dependency('libpng', required: get_option('png')) jpg = dependency('libjpeg', required: get_option('jpeg')) webp = dependency('libwebp', required: get_option('webp')) jxl = dependency('libjxl', required: get_option('jxl')) jxl_threads = dependency('libjxl_threads', required: false) -svg = declare_dependency( - sources: ['nanosvg.c', '3rd-party/nanosvg/src/nanosvg.h', - 'nanosvgrast.c', '3rd-party/nanosvg/src/nanosvgrast.h'], - include_directories: '3rd-party/nanosvg/src', - dependencies: math, -) + +if system_nanosvg.found() and system_nanosvgrast.found() + svg = declare_dependency( + dependencies: [system_nanosvg, system_nanosvgrast, math] + ) + svg_lib = 'nanosvg (system)' +else + svg = declare_dependency( + sources: ['nanosvg.c', '3rd-party/nanosvg/src/nanosvg.h', + 'nanosvgrast.c', '3rd-party/nanosvg/src/nanosvgrast.h'], + include_directories: '.', + dependencies: math, + ) + svg_lib = 'nanosvg (bundled)' +endif have_svg = get_option('svg') if not png.found() and not jpg.found() and not jxl.found() and not webp.found() and not have_svg @@ -158,7 +169,7 @@ summary( 'JPEG support': jpg.found(), 'JPEG XL support': jxl.found(), 'WebP support': webp.found(), - 'SVG support': have_svg + 'SVG support': svg_lib, }, bool_yn: true ) |