rvthtool/cmake/libs/CheckNettle2or3.cmake
David Korth 2029a71346 [cmake] CheckNettle2or3.cmake: Also export NETTLE_FOUND in the PARENT_SCOPE.
NETTLE_FOUND may be used to determine if libnettle should be
linked to other libraries and/or executables.

This fixes a regression from commit 03ce73c612.
([cmake] CheckNettle2or3.cmake: Convert the macro to a function.)
2024-05-17 22:42:35 -04:00

26 lines
1.0 KiB
CMake

# Check for Nettle v2 or v3.
# If either version is found, HAVE_NETTLE will be set.
# If Nettle v3 is found, HAVE_NETTLE_3 will be set.
FUNCTION(CHECK_NETTLE_2_OR_3)
FIND_PACKAGE(NETTLE)
SET(HAVE_NETTLE ${NETTLE_FOUND})
SET(HAVE_NETTLE ${NETTLE_FOUND} PARENT_SCOPE)
SET(NETTLE_FOUND ${NETTLE_FOUND} PARENT_SCOPE)
IF(HAVE_NETTLE)
# Check if this is Nettle 3.x.
# Nettle 3.1 added version.h, which isn't available
# in older verisons, so we can't simply check that.
INCLUDE(CheckSymbolExists)
SET(CMAKE_REQUIRED_INCLUDES ${NETTLE_INCLUDE_DIRS})
SET(CMAKE_REQUIRED_LIBRARIES ${NETTLE_LIBRARY})
CHECK_SYMBOL_EXISTS(aes128_set_decrypt_key "nettle/aes.h" HAVE_NETTLE_3)
IF(HAVE_NETTLE_3)
# Check for Nettle versioning symbols.
# Nettle 3.1 added version.h.
CHECK_SYMBOL_EXISTS(NETTLE_VERSION_MAJOR "nettle/version.h" HAVE_NETTLE_VERSION_H)
CHECK_SYMBOL_EXISTS(nettle_version_major "nettle/version.h" HAVE_NETTLE_VERSION_FUNCTIONS)
ENDIF(HAVE_NETTLE_3)
ENDIF(HAVE_NETTLE)
ENDFUNCTION(CHECK_NETTLE_2_OR_3)