diff options
author | Andres Mejia <amejia004@gmail.com> | 2013-02-01 22:10:15 -0500 |
---|---|---|
committer | Andres Mejia <amejia004@gmail.com> | 2013-02-01 22:10:15 -0500 |
commit | 5972a554b2641ab7875f91ab41aa106014bb522a (patch) | |
tree | ab5a1e1d54663e8f94ff1f98a1ce24e796846233 | |
parent | 4b234e8bf8a0f6a42400635ee784b02d160b95e4 (diff) | |
download | libarchive-5972a554b2641ab7875f91ab41aa106014bb522a.tar.gz |
Use cmake module similar to FindLZMA.cmake to find Nettle include dir and library.
-rw-r--r-- | CMakeLists.txt | 17 | ||||
-rw-r--r-- | build/cmake/FindNettle.cmake | 23 | ||||
-rw-r--r-- | build/cmake/config.h.in | 12 |
3 files changed, 44 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ac9186e9..bba08c85 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 00000000..54ec9f5d --- /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 <nettle/sha.h>, 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 0631195d..50faae5c 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 <ndir.h> header file, and it defines `DIR'. */ #cmakedefine HAVE_NDIR_H 1 +/* Define to 1 if you have the <nettle/md5.h> header file. */ +#cmakedefine HAVE_NETTLE_MD5_H 1 + +/* Define to 1 if you have the <nettle/ripemd160.h> header file. */ +#cmakedefine HAVE_NETTLE_RIPEMD160_H 1 + +/* Define to 1 if you have the <nettle/sha.h> header file. */ +#cmakedefine HAVE_NETTLE_SHA_H 1 + /* Define to 1 if you have the `nl_langinfo' function. */ #cmakedefine HAVE_NL_LANGINFO 1 |