From 41280d7d0e405fe29e876233aba3b86b325f05d2 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Mon, 23 Dec 2024 19:23:45 +0800 Subject: [PATCH] Meson: find more dependencies via pkg-config --- src/meson.build | 49 +++++++++++++++++++++++++-------------- src/sage/libs/meson.build | 8 +++++-- 2 files changed, 37 insertions(+), 20 deletions(-) diff --git a/src/meson.build b/src/meson.build index 1e528727a4f..fb22b2cec22 100644 --- a/src/meson.build +++ b/src/meson.build @@ -56,9 +56,10 @@ print(cypari2.__file__.replace('__init__.py', '')) check: true, ).stdout().strip() cypari2 = declare_dependency(include_directories: inc_cypari2) +# Cannot be found via pkg-config pari = cc.find_library('pari') -mpfr = cc.find_library('mpfr') +mpfr = dependency('mpfr') flint = dependency('flint', version: '>=3.0.0') if flint.version().version_compare('<3.1') @@ -78,35 +79,47 @@ endif # that too to make the fallback detection with CMake work blas_order += ['cblas', 'openblas', 'OpenBLAS', 'flexiblas', 'blis', 'blas'] blas = dependency(blas_order) -gsl = dependency('gsl', version: '>=2.5', required: true) -gd = cc.find_library('gd') +gsl = dependency('gsl', version: '>=2.5') +gd = dependency('gdlib', required: false, version: '>=2.1') +if not gd.found() + gd = cc.find_library('gd', required: true) +endif # Only some platforms have a standalone math library (https://mesonbuild.com/howtox.html#add-math-library-lm-portably) m = cc.find_library('m', required: false) -m4ri = cc.find_library('m4ri') -m4rie = cc.find_library('m4rie') -mtx = cc.find_library('mtx', required: false, disabler: true) -png = cc.find_library('png', required: false) -if not png.found() - png = cc.find_library('png16') +m4ri = dependency('m4ri', version: '>=20140914') +m4rie = dependency('m4rie', required: false) +if not m4rie.found() + # For some reason, m4rie is not found via pkg-config on some systems (eg Conda) + m4rie = cc.find_library('m4rie') endif -zlib = cc.find_library('z') # Cannot be found via pkg-config -ec = cc.find_library('ec') +mtx = cc.find_library('mtx', required: false, disabler: true) +png = dependency(['libpng', 'png', 'png16'], version: '>=1.2') +zlib = dependency('zlib', version: '>=1.2.11') +# We actually want >= 20231212, but the version number is not updated in the pkgconfig +# https://github.com/conda-forge/eclib-feedstock/issues/48 +ec = dependency('eclib', version: '>=20231211') +# Cannot be found via pkg-config ecm = cc.find_library('ecm') +# Cannot be found via pkg-config ppl = cc.find_library('ppl') -gmpxx = cc.find_library('gmpxx') -fflas = dependency('fflas-ffpack') +gmpxx = dependency('gmpxx') +fflas = dependency('fflas-ffpack', version: '>=2.5.0') fplll = dependency('fplll') -givaro = cc.find_library('givaro') -linbox = dependency('linbox', required: false) +givaro = dependency('givaro', version: '>=4.2.0') +linbox = dependency('linbox', required: false, version: '>=1.7.0') if not linbox.found() linbox = cc.find_library('linbox') endif mpc = cc.find_library('mpc') mpfi = cc.find_library('mpfi') -# Cannot be found via pkg-config (pkg-config file will be added in 4.13) -# Test for common.h header that was added in 4.12 as a indirect version check -gap = cc.find_library('gap', has_headers: ['gap/common.h']) + +gap = dependency('libgap', version: '>=4.13.0', required: false) +if not gap.found() + # Fallback in case pkg-config info is not available + # Test for common.h header that was added in 4.12 as a indirect version check + gap = cc.find_library('gap', has_headers: ['gap/common.h']) +endif singular = dependency('Singular') maxima = find_program('maxima', required: true) # Cannot be found via pkg-config diff --git a/src/sage/libs/meson.build b/src/sage/libs/meson.build index 34b26b09ff1..53470399d46 100644 --- a/src/sage/libs/meson.build +++ b/src/sage/libs/meson.build @@ -1,8 +1,12 @@ sirocco = cc.find_library('sirocco', required: false, disabler: true) # cannot be found via pkg-config ecl = cc.find_library('ecl') -braiding = cc.find_library('braiding') -gc = cc.find_library('gc') +braiding = dependency('libbraiding', required: false) +if not braiding.found() + # Fallback since pkg-config support was only added in v1.3.1 + braiding = cc.find_library('braiding') +endif +gc = dependency(['bdw-gc-threaded', 'bdw-gc'], version: '>=7.6.4') homfly = cc.find_library('homfly', has_headers: ['homfly.h']) py.install_sources(