From d91789cf42d88852709bfc62fab5f242a36fdf84 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Thu, 18 Jul 2024 18:21:11 +0200 Subject: 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. --- meson.build | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'meson.build') 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 ) -- cgit v1.2.3