From 915951b87b05b7fa5eb51f6d4aa0bb9ad9fb8c39 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sun, 16 Jun 2024 18:19:42 -0700 Subject: [PATCH 1/2] meson: add DEFS to CFLAGS Adding a configuration flag as an include directory is wrong and errors on BSDs. ERROR: Include dir -DU_DISABLE_RENAMING=1 does not exist. Matches the autotools build now. Requires has_argument to fix non BSDs because of an annoying meson quirk. Signed-off-by: Rosen Penev --- meson.build | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index b3d330581..e8c08fe41 100644 --- a/meson.build +++ b/meson.build @@ -32,8 +32,10 @@ dir_locale = dir_prefix / get_option('localedir') host_os = host_machine.system() +bsd = ['freebsd', 'openbsd', 'dragonfly'] cygwin = 'cygwin' windows = 'windows' +sys_bsd = bsd.contains(host_os) sys_cygwin = cygwin.contains(host_os) sys_windows = windows.contains(host_os) @@ -576,10 +578,12 @@ endif # icu icu_dep = dependency('icu-i18n', method: 'pkg-config', required: get_option('icu')) if icu_dep.found() - def_var = icu_dep.get_variable(pkgconfig: 'DEFS') - config_dir += include_directories(def_var) - xml_deps += icu_dep + defs = icu_dep.get_variable(pkgconfig: 'DEFS') + if cc.has_argument(defs) + libxml2_cflags += defs + endif endif +xml_deps += icu_dep subdir('include/libxml') -- GitLab From b4b4162fc7ea89772b691833fdf76b790d5aac43 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sat, 15 Jun 2024 19:41:08 -0700 Subject: [PATCH 2/2] meson: fix compilation on BSDs with icu+iconv on BSDs, icu is installed and included from /usr/local. When found, libiconv headers override the normal ones and thus result in a missing link. Work around this oddity and add the link. Signed-off-by: Rosen Penev --- meson.build | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/meson.build b/meson.build index e8c08fe41..f69633b50 100644 --- a/meson.build +++ b/meson.build @@ -561,9 +561,24 @@ else endif xml_deps += lzma_dep +# icu +icu_dep = dependency('icu-i18n', method: 'pkg-config', required: get_option('icu')) +if icu_dep.found() + defs = icu_dep.get_variable(pkgconfig: 'DEFS') + if cc.has_argument(defs) + libxml2_cflags += defs + endif +endif +xml_deps += icu_dep + ### iconv if not get_option('minimum') - iconv_dep = dependency('iconv', required: get_option('iconv')) +# this is a hack for the BSDs. The iconv dependency works as long as libiconv is not in the include path. + if sys_bsd and icu_dep.found() + iconv_dep = cc.find_library('iconv', dirs: icu_dep.get_variable(pkgconfig: 'includedir'), required: get_option('iconv')) + else + iconv_dep = dependency('iconv', required: get_option('iconv')) + endif else iconv_dep = dependency('', required: false) endif @@ -575,16 +590,6 @@ else want_iso8859x = true endif -# icu -icu_dep = dependency('icu-i18n', method: 'pkg-config', required: get_option('icu')) -if icu_dep.found() - defs = icu_dep.get_variable(pkgconfig: 'DEFS') - if cc.has_argument(defs) - libxml2_cflags += defs - endif -endif -xml_deps += icu_dep - subdir('include/libxml') # Set config_h after all subdirs and dependencies have set values -- GitLab