Commit 27bb59d3 authored by Cedric Roux's avatar Cedric Roux

better handling of NETTLE version in CMake

parent 7c6e48d9
...@@ -1538,20 +1538,17 @@ endif() ...@@ -1538,20 +1538,17 @@ endif()
message ("NETTLE VERSION_INSTALLED = ${NETTLE_VERSION}") message ("NETTLE VERSION_INSTALLED = ${NETTLE_VERSION}")
string(REGEX MATCH "[+-]?[0-9]+([.][0-9]+)?" nv ${NETTLE_VERSION}) string(REGEX REPLACE "([0-9]+).*" "\\1" NETTLE_VERSION_MAJOR ${NETTLE_VERSION})
string(REGEX REPLACE "[0-9]+\\.([0-9]+).*" "\\1" NETTLE_VERSION_MINOR ${NETTLE_VERSION})
message ("NETTLE_VERSION_MAJOR = ${NETTLE_VERSION_MAJOR}")
message ("NETTLE_VERSION_MINOR = ${NETTLE_VERSION_MINOR}")
# WE only pass the major and first minor in the define and ignore the rest if ("${NETTLE_VERSION_MAJOR}" STREQUAL "" OR "${NETTLE_VERSION_MINOR}" STREQUAL "")
#message("NETTLE_VERSION USED = ${nv}")
# we need to remove decimal as floating point arithematic does not work properly with C preprocessor
STRING(REGEX REPLACE "[.]" "" nv ${nv})
if ("${nv}" STREQUAL "")
message( FATAL_ERROR "The nettle version not detected properly. Try to run build_oai -I again" ) message( FATAL_ERROR "The nettle version not detected properly. Try to run build_oai -I again" )
endif() endif()
set (NETTLE_VERSION "${nv}") add_definitions("-DNETTLE_VERSION_MAJOR=${NETTLE_VERSION_MAJOR}")
add_definitions("-DNETTLE_VERSION=${NETTLE_VERSION}") add_definitions("-DNETTLE_VERSION_MINOR=${NETTLE_VERSION_MINOR}")
pkg_search_module(XPM xpm) pkg_search_module(XPM xpm)
if(NOT ${XPM_FOUND}) if(NOT ${XPM_FOUND})
......
...@@ -48,7 +48,7 @@ void test_uncipher_ctr(const struct nettle_cipher *cipher, const uint8_t *key, ...@@ -48,7 +48,7 @@ void test_uncipher_ctr(const struct nettle_cipher *cipher, const uint8_t *key,
uint8_t *data = malloc(length); uint8_t *data = malloc(length);
uint8_t *ctr = malloc(cipher->block_size); uint8_t *ctr = malloc(cipher->block_size);
#if NETTLE_VERSION <= 27 #if NETTLE_VERSION_MAJOR < 3
cipher->set_encrypt_key(ctx, key_length, key); cipher->set_encrypt_key(ctx, key_length, key);
#else #else
cipher->set_encrypt_key(ctx, key); cipher->set_encrypt_key(ctx, key);
......
...@@ -47,7 +47,7 @@ static void test_cipher_ctr(const struct nettle_cipher *cipher, const uint8_t *k ...@@ -47,7 +47,7 @@ static void test_cipher_ctr(const struct nettle_cipher *cipher, const uint8_t *k
uint8_t *data = malloc(length); uint8_t *data = malloc(length);
uint8_t *ctr = malloc(cipher->block_size); uint8_t *ctr = malloc(cipher->block_size);
#if NETTLE_VERSION <= 27 #if NETTLE_VERSION_MAJOR < 3
cipher->set_encrypt_key(ctx, key_length, key); cipher->set_encrypt_key(ctx, key_length, key);
#else #else
cipher->set_encrypt_key(ctx, key); cipher->set_encrypt_key(ctx, key);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment