From: Andres Mejia Date: Sat, 2 Feb 2013 03:10:15 +0000 (-0500) Subject: Use cmake module similar to FindLZMA.cmake to find Nettle include dir and library. X-Git-Tag: v3.1.2~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5972a554b2641ab7875f91ab41aa106014bb522a;p=thirdparty%2Flibarchive.git Use cmake module similar to FindLZMA.cmake to find Nettle include dir and library. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index ac9186e99..bba08c85a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -514,16 +514,17 @@ LIBARCHIVE_CHECK_C_SOURCE_COMPILES( # Find Nettle # IF(ENABLE_NETTLE) - CHECK_LIBRARY_EXISTS(nettle "nettle_sha1_digest" "" NETTLE_FOUND) + FIND_PACKAGE(Nettle) IF(NETTLE_FOUND) - CMAKE_PUSH_CHECK_STATE() # Save the state of the variables - SET(CMAKE_REQUIRED_LIBRARIES "nettle") - FIND_LIBRARY(NETTLE_LIBRARY NAMES nettle) - LIST(APPEND ADDITIONAL_LIBS ${NETTLE_LIBRARY}) - CMAKE_POP_CHECK_STATE() # Restore the state of the variables - ELSE(NETTLE_FOUND) - SET(ENABLE_NETTLE OFF) + SET(HAVE_LIBNETTLE 1) + SET(HAVE_NETTLE_MD5_H 1) + SET(HAVE_NETTLE_RIPEMD160_H 1) + SET(HAVE_NETTLE_SHA_H 1) + INCLUDE_DIRECTORIES(${NETTLE_INCLUDE_DIR}) + LIST(APPEND ADDITIONAL_LIBS ${NETTLE_LIBRARIES}) ENDIF(NETTLE_FOUND) + MARK_AS_ADVANCED(CLEAR NETTLE_INCLUDE_DIR) + MARK_AS_ADVANCED(CLEAR NETTLE_LIBRARIES) ENDIF(ENABLE_NETTLE) # diff --git a/build/cmake/FindNettle.cmake b/build/cmake/FindNettle.cmake new file mode 100644 index 000000000..54ec9f5d3 --- /dev/null +++ b/build/cmake/FindNettle.cmake @@ -0,0 +1,23 @@ +# - Find Nettle +# Find the Nettle include directory and library +# +# NETTLE_INCLUDE_DIR - where to find , etc. +# NETTLE_LIBRARIES - List of libraries when using libnettle. +# NETTLE_FOUND - True if libnettle found. + +IF (NETTLE_INCLUDE_DIR) + # Already in cache, be silent + SET(NETTLE_FIND_QUIETLY TRUE) +ENDIF (NETTLE_INCLUDE_DIR) + +FIND_PATH(NETTLE_INCLUDE_DIR nettle/md5.h nettle/ripemd160.h nettle/sha.h) +FIND_LIBRARY(NETTLE_LIBRARY NAMES nettle libnettle) + +# handle the QUIETLY and REQUIRED arguments and set NETTLE_FOUND to TRUE if +# all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(NETTLE DEFAULT_MSG NETTLE_LIBRARY NETTLE_INCLUDE_DIR) + +IF(NETTLE_FOUND) + SET(NETTLE_LIBRARIES ${NETTLE_LIBRARY}) +ENDIF(NETTLE_FOUND) diff --git a/build/cmake/config.h.in b/build/cmake/config.h.in index 0631195d6..50faae5c1 100644 --- a/build/cmake/config.h.in +++ b/build/cmake/config.h.in @@ -588,6 +588,9 @@ typedef uint64_t uintmax_t; /* Define to 1 if you have the `lzo2' library (-llzo2). */ #cmakedefine HAVE_LIBLZO2 1 +/* Define to 1 if you have the `nettle' library (-lnettle). */ +#cmakedefine HAVE_LIBNETTLE 1 + /* Define to 1 if you have the `pcre' library (-lpcre). */ #cmakedefine HAVE_LIBPCRE 1 @@ -703,6 +706,15 @@ typedef uint64_t uintmax_t; /* Define to 1 if you have the header file, and it defines `DIR'. */ #cmakedefine HAVE_NDIR_H 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_NETTLE_MD5_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_NETTLE_RIPEMD160_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_NETTLE_SHA_H 1 + /* Define to 1 if you have the `nl_langinfo' function. */ #cmakedefine HAVE_NL_LANGINFO 1