[PATCH 3/8] meson: convert libsodium version detection to compile-time test

Daniel Golle <[email protected]> Fri, 10 Oct 2025 02:13:22 +0100
Newsgroups gmane.network.gnunet.devel
Message-ID <[email protected]>
--cncAl+R1EEd4ZHJK
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Use compile-time test instead of relying on testing the libsodium version
at runtime. This is done to make cross-compilation possible again.
---
 meson.build | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/meson.build b/meson.build
index 99ab1ba14..a1afd8495 100644
--- a/meson.build
+++ b/meson.build
@@ -244,16 +244,19 @@ if not sodium_dep.found()
     sodium_dep =3D cc.find_library('sodium', required: true)
     sodium_version_check =3D '''#include <sodium.h>
   int main(int argc, char **argv) {
-    return ((SODIUM_LIBRARY_VERSION_MAJOR > 10) ||
-            ((SODIUM_LIBRARY_VERSION_MAJOR =3D=3D 10) &&
-             (SODIUM_LIBRARY_VERSION_MINOR >=3D 3))) ? 0 : 1;
+    #if !((SODIUM_LIBRARY_VERSION_MAJOR > 10) || \
+         ((SODIUM_LIBRARY_VERSION_MAJOR =3D=3D 10) && \
+         (SODIUM_LIBRARY_VERSION_MINOR >=3D 3)))
+      #error "libsodium version >=3D 1.0.18 required"
+    #endif
+    return 0
     }
   '''
-    if cc.run(
+    if not cc.compiles(
         sodium_version_check,
         name: 'sodium version check',
         dependencies: sodium_dep,
-    ).returncode() !=3D 0
+    )
         error('libsodium version >=3D1.0.18 required')
     endif
 endif
--=20
2.51.0

--cncAl+R1EEd4ZHJK
Content-Type: application/pgp-signature; name=signature.asc

-----BEGIN PGP SIGNATURE-----

iHUEABEIAB0WIQQ8WXOkSQLJP/KOu5qX7zeyq+FyywUCaOhdsQAKCRCX7zeyq+Fy
y5GQAP467KhcR/YekxbxlKRBmy4g4ZHZJ3ChaVjn1KkaxUhKSQD9G38B9hFTIOBk
gP69EpdYAAKKy9MXec2twoKwj88E9DU=
=xjyZ
-----END PGP SIGNATURE-----

--cncAl+R1EEd4ZHJK--