From 1e4c17256adb81eb72be282742e4390e062d424e Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Thu, 28 Mar 2024 15:55:30 +0000 Subject: [PATCH] WEBP - add fallback pkg-config check if WEBP_INCLUDES and/or WEBP_LIBS aren't set. --- SConstruct | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/SConstruct b/SConstruct index 6179e2dad..0c2b618d8 100644 --- a/SConstruct +++ b/SConstruct @@ -1582,11 +1582,25 @@ if not preconfigured: env['SKIPPED_DEPS'].append('png') if env['WEBP']: - OPTIONAL_LIBSHEADERS.append(['webp', 'webp/decode.h', False,'C','-DHAVE_WEBP']) - inc_path = env['%s_INCLUDES' % 'WEBP'] - lib_path = env['%s_LIBS' % 'WEBP'] - env.AppendUnique(CPPPATH = fix_path(inc_path)) - env.AppendUnique(LIBPATH = fix_path(lib_path)) + if env.get('WEBP_LIBS') or env.get('WEBP_INCLUDES'): + OPTIONAL_LIBSHEADERS.append(['webp', 'webp/decode.h', False,'C','-DHAVE_WEBP']) + inc_path = env['WEBP_INCLUDES'] + lib_path = env['WEBP_LIBS'] + env.AppendUnique(CPPPATH = fix_path(inc_path)) + env.AppendUnique(LIBPATH = fix_path(lib_path)) + else: + cmd = 'pkg-config libwebp --libs --cflags' + if env['RUNTIME_LINK'] == 'static': + cmd += ' --static' + temp_env = Environment(ENV=os.environ) + try: + temp_env.ParseConfig(cmd) + for lib in temp_env['LIBS']: + env.AppendUnique(LIBPATH = fix_path(lib)) + for inc in temp_env['CPPPATH']: + env.AppendUnique(CPPPATH = fix_path(inc)) + except OSError as e: + pass else: env['SKIPPED_DEPS'].append('webp')