Skip to content

Commit 5ec2c52

Browse files
committed
meson: Add dependency lookups via names used by cmake
Particularly on windows it's useful to look up dependencies via cmake, instead of pkg-config. Meson supports doing so. Unfortunately the dependency names used by various projects often differs between their pkg-config and cmake files. This would look a lot neater if we could rely on meson >= 0.60.0... Reviewed-by: Tristan Partin <tristan@partin.io> Discussion: https://postgr.es/m/20240709065101.xhc74r3mdg2lmn4w@awork3.anarazel.de Backpatch: 16-, where meson support was added
1 parent 2416fdb commit 5ec2c52

File tree

1 file changed

+40
-6
lines changed

1 file changed

+40
-6
lines changed

meson.build

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -813,11 +813,25 @@ endif
813813

814814
icuopt = get_option('icu')
815815
if not icuopt.disabled()
816-
icu = dependency('icu-uc', required: icuopt)
817-
icu_i18n = dependency('icu-i18n', required: icuopt)
816+
icu = dependency('icu-uc', required: false)
817+
if icu.found()
818+
icu_i18n = dependency('icu-i18n', required: true)
819+
endif
820+
821+
# Unfortunately the dependency is named differently with cmake
822+
if not icu.found() # combine with above once meson 0.60.0 is required
823+
icu = dependency('ICU', required: icuopt,
824+
components: ['uc'], modules: ['ICU::uc'], method: 'cmake')
825+
if icu.found()
826+
icu_i18n = dependency('ICU', required: true,
827+
components: ['i18n'], modules: ['ICU::i18n'])
828+
endif
829+
endif
818830

819831
if icu.found()
820832
cdata.set('USE_ICU', 1)
833+
else
834+
icu_i18n = not_found_dep
821835
endif
822836

823837
else
@@ -833,7 +847,12 @@ endif
833847

834848
libxmlopt = get_option('libxml')
835849
if not libxmlopt.disabled()
836-
libxml = dependency('libxml-2.0', required: libxmlopt, version: '>= 2.6.23')
850+
libxml = dependency('libxml-2.0', required: false, version: '>= 2.6.23')
851+
# Unfortunately the dependency is named differently with cmake
852+
if not libxml.found() # combine with above once meson 0.60.0 is required
853+
libxml = dependency('LibXml2', required: libxmlopt, version: '>= 2.6.23',
854+
method: 'cmake')
855+
endif
837856

838857
if libxml.found()
839858
cdata.set('USE_LIBXML', 1)
@@ -850,7 +869,11 @@ endif
850869

851870
libxsltopt = get_option('libxslt')
852871
if not libxsltopt.disabled()
853-
libxslt = dependency('libxslt', required: libxsltopt)
872+
libxslt = dependency('libxslt', required: false)
873+
# Unfortunately the dependency is named differently with cmake
874+
if not libxslt.found() # combine with above once meson 0.60.0 is required
875+
libxslt = dependency('LibXslt', required: libxsltopt, method: 'cmake')
876+
endif
854877

855878
if libxslt.found()
856879
cdata.set('USE_LIBXSLT', 1)
@@ -867,7 +890,13 @@ endif
867890

868891
lz4opt = get_option('lz4')
869892
if not lz4opt.disabled()
870-
lz4 = dependency('liblz4', required: lz4opt)
893+
lz4 = dependency('liblz4', required: false)
894+
# Unfortunately the dependency is named differently with cmake
895+
if not lz4.found() # combine with above once meson 0.60.0 is required
896+
lz4 = dependency('lz4', required: lz4opt,
897+
method: 'cmake', modules: ['LZ4::lz4_shared'],
898+
)
899+
endif
871900

872901
if lz4.found()
873902
cdata.set('USE_LZ4', 1)
@@ -1486,7 +1515,12 @@ endif
14861515

14871516
zstdopt = get_option('zstd')
14881517
if not zstdopt.disabled()
1489-
zstd = dependency('libzstd', required: zstdopt, version: '>=1.4.0')
1518+
zstd = dependency('libzstd', required: false, version: '>=1.4.0')
1519+
# Unfortunately the dependency is named differently with cmake
1520+
if not zstd.found() # combine with above once meson 0.60.0 is required
1521+
zstd = dependency('zstd', required: zstdopt, version: '>=1.4.0',
1522+
method: 'cmake', modules: ['zstd::libzstd_shared'])
1523+
endif
14901524

14911525
if zstd.found()
14921526
cdata.set('USE_ZSTD', 1)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy