diff --git a/src/apk_crypto.h b/src/apk_crypto.h
index 5cae3bfe0b9dfdc2321b4a810e4ae83e159f8dde..eaed4be4395031444369ac2807a19b6b4df717f5 100644
--- a/src/apk_crypto.h
+++ b/src/apk_crypto.h
@@ -17,6 +17,8 @@
 #include "apk_crypto_openssl.h"
 #elif defined(CRYPTO_USE_MBEDTLS)
 #include "apk_crypto_mbedtls.h"
+#else
+#error Crypto backend not selected
 #endif
 
 // Digest
diff --git a/src/meson.build b/src/meson.build
index e1204fc053c426c2d5e95474a2fcc91a6f365cf6..ec054f6b25db7e61fc37b2a43ab107aa7d81eaf1 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -91,16 +91,11 @@ apk_src = [
 ]
 
 apk_cargs = [
-	'-DAPK_VERSION="' + meson.project_version() + '"',
 	'-D_ATFILE_SOURCE',
+	'-DAPK_VERSION="' + meson.project_version() + '"',
+	'-DCRYPTO_USE_@0@'.format(crypto_backend.to_upper()),
 ]
 
-if crypto_backend == 'openssl'
-	apk_cargs += [ '-DCRYPTO_USE_OPENSSL' ]
-elif crypto_backend == 'mbedtls'
-	apk_cargs += [ '-DCRYPTO_USE_MBEDTLS' ]
-endif
-
 if lua_bin.found()
 	genhelp_script = files('genhelp.lua')
 	genhelp_args = [lua_bin, genhelp_script, '@INPUT@']