Skip to content

Commit

Permalink
FindNettle: Prefer pkg-config Nettle version
Browse files Browse the repository at this point in the history
Gentoo Linux rewrites /usr/include/nettle/version.h to support multiple ABIs.

Even with Nettle 3.10 installed this results in:
-- Could NOT find Nettle: Found unsuitable version ".", but required is at least "3.0" (found /usr/lib64/libnettle.so)
  • Loading branch information
cjmayo committed Mar 4, 2025
1 parent f2148dd commit 0e5bca2
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions cmake/Modules/FindNettle.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,12 @@ find_library(Nettle_LIBRARY
PATHS ${PC_Nettle_LIBRARY_DIRS}
)

# Extract version information from the header file
if(Nettle_INCLUDE_DIR)
# This file only exists in nettle>=3.0
if(EXISTS ${Nettle_INCLUDE_DIR}/nettle/version.h)
if(PC_Nettle_VERSION)
set(Nettle_VERSION ${PC_Nettle_VERSION})
elseif(EXISTS ${Nettle_INCLUDE_DIR}/nettle/version.h)
# Extract version information from the header file
# This file only exists in nettle>=3.0
file(STRINGS ${Nettle_INCLUDE_DIR}/nettle/version.h _ver_major_line
REGEX "^#define NETTLE_VERSION_MAJOR *[0-9]+"
LIMIT_COUNT 1)
Expand All @@ -100,11 +102,7 @@ if(Nettle_INCLUDE_DIR)
unset(_ver_major_line)
unset(_ver_minor_line)
else()
if(PC_Nettle_VERSION)
set(Nettle_VERSION ${PC_Nettle_VERSION})
else()
set(Nettle_VERSION "1.0")
endif()
set(Nettle_VERSION "1.0")
endif()
endif()

Expand Down

0 comments on commit 0e5bca2

Please sign in to comment.