CMake: clean up FindGCRYPT.cmake

Use consistent lowercase capitalization and whitespace. Windows: clarify
libgpg-error names and remove libgcc_s (1.7.6/1.8.3 do not need it).

Change-Id: I5d1b1a67f7a992ccfca4c28d0e19bbbfc41b7a4d
Reviewed-on: https://code.wireshark.org/review/31244
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
This commit is contained in:
Peter Wu 2018-12-29 12:11:18 +01:00
parent 54f0159950
commit 932edd0878
1 changed files with 32 additions and 31 deletions

View File

@ -9,24 +9,28 @@
# GCRYPT_DLLS - (Windows) List of required Libgcrypt DLLs.
IF (GCRYPT_INCLUDE_DIRS)
if(GCRYPT_INCLUDE_DIRS)
# Already in cache, be silent
SET(GCRYPT_FIND_QUIETLY TRUE)
ENDIF (GCRYPT_INCLUDE_DIRS)
set(GCRYPT_FIND_QUIETLY TRUE)
endif()
INCLUDE(FindWSWinLibs)
include(FindWSWinLibs)
FindWSWinLibs("libgcrypt-.*" "GCRYPT_HINTS")
FIND_PATH(GCRYPT_INCLUDE_DIR gcrypt.h
find_path(GCRYPT_INCLUDE_DIR gcrypt.h
HINTS
"${GCRYPT_HINTS}"
PATH_SUFFIXES
include
"${GCRYPT_HINTS}/include"
)
SET(GCRYPT_NAMES gcrypt libgcrypt-20)
FIND_LIBRARY(GCRYPT_LIBRARY NAMES ${GCRYPT_NAMES} libgcc_s_sjlj-1 HINTS "${GCRYPT_HINTS}/bin")
FIND_LIBRARY(GCRYPT_ERROR_LIBRARY NAMES gpg-error libgpg-error-0 libgpg-error6-0 HINTS "${GCRYPT_HINTS}/bin")
find_library(GCRYPT_LIBRARY
NAMES gcrypt libgcrypt-20
HINTS "${GCRYPT_HINTS}/bin")
# libgpg-error6-0 is used in libgcrypt-1.7.6-win??ws (built from source).
# libgpg-error-0 is used in libgcrypt-1.8.3-win??ws (from Debian).
find_library(GCRYPT_ERROR_LIBRARY
NAMES gpg-error libgpg-error-0 libgpg-error6-0
HINTS "${GCRYPT_HINTS}/bin")
# Try to retrieve version from header if found (available since libgcrypt 1.3.0)
if(GCRYPT_INCLUDE_DIR)
@ -36,36 +40,33 @@ if(GCRYPT_INCLUDE_DIR)
unset(_version_regex)
endif()
# handle the QUIETLY and REQUIRED arguments and set GCRYPT_FOUND to TRUE if
# all listed variables are TRUE and the requested version matches.
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GCRYPT
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GCRYPT
REQUIRED_VARS GCRYPT_LIBRARY GCRYPT_INCLUDE_DIR
VERSION_VAR GCRYPT_VERSION)
IF(GCRYPT_FOUND)
SET( GCRYPT_LIBRARIES ${GCRYPT_LIBRARY} ${GCRYPT_ERROR_LIBRARY})
SET( GCRYPT_INCLUDE_DIRS ${GCRYPT_INCLUDE_DIR})
if (WIN32)
set ( GCRYPT_DLL_DIR "${GCRYPT_HINTS}/bin"
if(GCRYPT_FOUND)
set(GCRYPT_LIBRARIES ${GCRYPT_LIBRARY} ${GCRYPT_ERROR_LIBRARY})
set(GCRYPT_INCLUDE_DIRS ${GCRYPT_INCLUDE_DIR})
if(WIN32)
set(GCRYPT_DLL_DIR "${GCRYPT_HINTS}/bin"
CACHE PATH "Path to the Libgcrypt DLLs"
)
file( GLOB _gcrypt_dlls RELATIVE "${GCRYPT_DLL_DIR}"
#"${GCRYPT_DLL_DIR}/libgcc_s_*.dll"
file(GLOB _gcrypt_dlls RELATIVE "${GCRYPT_DLL_DIR}"
"${GCRYPT_DLL_DIR}/libgcrypt-*.dll"
"${GCRYPT_DLL_DIR}/libgpg-error*.dll"
)
set ( GCRYPT_DLLS ${_gcrypt_dlls}
set(GCRYPT_DLLS ${_gcrypt_dlls}
# We're storing filenames only. Should we use STRING instead?
CACHE FILEPATH "Libgcrypt DLL list"
)
mark_as_advanced( GCRYPT_DLL_DIR GCRYPT_DLLS )
mark_as_advanced(GCRYPT_DLL_DIR GCRYPT_DLLS)
endif()
ELSE(GCRYPT_FOUND)
SET( GCRYPT_LIBRARIES )
SET( GCRYPT_INCLUDE_DIRS )
SET( GCRYPT_DLL_DIR )
SET( GCRYPT_DLLS )
ENDIF(GCRYPT_FOUND)
else()
set(GCRYPT_LIBRARIES)
set(GCRYPT_INCLUDE_DIRS)
set(GCRYPT_DLL_DIR)
set(GCRYPT_DLLS)
endif()
MARK_AS_ADVANCED( GCRYPT_LIBRARIES GCRYPT_INCLUDE_DIRS )
mark_as_advanced(GCRYPT_LIBRARIES GCRYPT_INCLUDE_DIRS)