annotate cmake/Modules/FindGnuTLS.cmake @ 1562:6219359a36a9 default tip

Merge latest changes from proposed branch
author Sebastien Decugis <sdecugis@freediameter.net>
date Mon, 21 Jun 2021 19:08:18 +0800
parents 56c36d1007b4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1 # - Find gnutls
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
2 # Find the native GNUTLS includes and library
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
3 #
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
4 # GNUTLS_FOUND - True if gnutls found.
493
d68f27e7e814 Fixed a few CMake variable names
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 304
diff changeset
5 # GNUTLS_INCLUDE_DIR - where to find gnutls.h, etc.
15
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
6 # GNUTLS_LIBRARIES - List of libraries when using gnutls.
797
36821971d47b Renamed GNUTLS_NEW_VERSION and added GNUTLS_VERSION_300 to prepare for API change in gnutls
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 747
diff changeset
7 # GNUTLS_VERSION_210 - true if GnuTLS version is >= 2.10.0 (does not require additional separate gcrypt initialization)
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 802
diff changeset
8 # GNUTLS_VERSION_212 - true if GnuTLS version is >= 2.12.0 (supports gnutls_transport_set_vec_push_function)
797
36821971d47b Renamed GNUTLS_NEW_VERSION and added GNUTLS_VERSION_300 to prepare for API change in gnutls
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 747
diff changeset
9 # GNUTLS_VERSION_300 - true if GnuTLS version is >= 3.00.0 (x509 verification functions changed)
802
6dde862ba119 Also detect GNUTLS version 3.1.x
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 801
diff changeset
10 # GNUTLS_VERSION_310 - true if GnuTLS version is >= 3.01.0 (stabilization branch with new APIs)
15
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
11
493
d68f27e7e814 Fixed a few CMake variable names
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 304
diff changeset
12 if (GNUTLS_INCLUDE_DIR AND GNUTLS_LIBRARIES)
15
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
13 set(GNUTLS_FIND_QUIETLY TRUE)
493
d68f27e7e814 Fixed a few CMake variable names
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 304
diff changeset
14 endif (GNUTLS_INCLUDE_DIR AND GNUTLS_LIBRARIES)
15
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
15
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
16 # Include dir
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
17 find_path(GNUTLS_INCLUDE_DIR
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
18 NAMES
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
19 gnutls.h
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
20 gnutls/gnutls.h
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
21 )
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
22
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
23 # Library
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
24 find_library(GNUTLS_LIBRARY
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
25 NAMES gnutls
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
26 )
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
27
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
28 # handle the QUIETLY and REQUIRED arguments and set GNUTLS_FOUND to TRUE if
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
29 # all listed variables are TRUE
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
30 INCLUDE(FindPackageHandleStandardArgs)
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
31 FIND_PACKAGE_HANDLE_STANDARD_ARGS(GNUTLS DEFAULT_MSG GNUTLS_LIBRARY GNUTLS_INCLUDE_DIR)
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
32
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
33 IF(GNUTLS_FOUND)
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
34 SET( GNUTLS_LIBRARIES ${GNUTLS_LIBRARY} )
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
35 ELSE(GNUTLS_FOUND)
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
36 SET( GNUTLS_LIBRARIES )
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
37 ENDIF(GNUTLS_FOUND)
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
38
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
39 # Lastly make it so that the GNUTLS_LIBRARY and GNUTLS_INCLUDE_DIR variables
050f4f6f9f2a Added new FindGNUTLS cmake module
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
40 # only show up under the advanced options in the gui cmake applications.
304
ad3c46016584 Added install directives for cmake; also allow default directory to seek for extensions and configuration files
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
41 MARK_AS_ADVANCED( GNUTLS_LIBRARY GNUTLS_INCLUDE_DIR )
746
96c75744d3c4 Attempt to support newer GNU TLS libraries. Need more work...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 493
diff changeset
42
96c75744d3c4 Attempt to support newer GNU TLS libraries. Need more work...
Sebastien Decugis <sdecugis@freediameter.net>
parents: 493
diff changeset
43 # Now check if the library is recent. gnutls_hash was added in 2.10.0.
797
36821971d47b Renamed GNUTLS_NEW_VERSION and added GNUTLS_VERSION_300 to prepare for API change in gnutls
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 747
diff changeset
44 # Also test library is even more recent. gnutls_x509_trust_list_verify_crt was added in 3.00.0.
801
728cc60a7be5 Test version only on found library
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 797
diff changeset
45 IF(GNUTLS_FOUND)
728cc60a7be5 Test version only on found library
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 797
diff changeset
46 IF( NOT( "${GNUTLS_VERSION_TEST_FOR}" STREQUAL "${GNUTLS_LIBRARY}" ))
728cc60a7be5 Test version only on found library
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 797
diff changeset
47 INCLUDE (CheckLibraryExists)
802
6dde862ba119 Also detect GNUTLS version 3.1.x
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 801
diff changeset
48 MESSAGE(STATUS "Checking GNUTLS version")
801
728cc60a7be5 Test version only on found library
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 797
diff changeset
49 UNSET(GNUTLS_VERSION_210)
728cc60a7be5 Test version only on found library
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 797
diff changeset
50 UNSET(GNUTLS_VERSION_210 CACHE)
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 802
diff changeset
51 UNSET(GNUTLS_VERSION_212)
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 802
diff changeset
52 UNSET(GNUTLS_VERSION_212 CACHE)
801
728cc60a7be5 Test version only on found library
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 797
diff changeset
53 UNSET(GNUTLS_VERSION_300)
728cc60a7be5 Test version only on found library
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 797
diff changeset
54 UNSET(GNUTLS_VERSION_300 CACHE)
802
6dde862ba119 Also detect GNUTLS version 3.1.x
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 801
diff changeset
55 UNSET(GNUTLS_VERSION_310)
6dde862ba119 Also detect GNUTLS version 3.1.x
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 801
diff changeset
56 UNSET(GNUTLS_VERSION_310 CACHE)
801
728cc60a7be5 Test version only on found library
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 797
diff changeset
57 GET_FILENAME_COMPONENT(GNUTLS_PATH ${GNUTLS_LIBRARY} PATH)
728cc60a7be5 Test version only on found library
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 797
diff changeset
58 CHECK_LIBRARY_EXISTS(gnutls gnutls_hash ${GNUTLS_PATH} GNUTLS_VERSION_210)
1186
56c36d1007b4 Further preparation of the DTLS integration. Some cleanups in the GNUTLS handling.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 802
diff changeset
59 CHECK_LIBRARY_EXISTS(gnutls gnutls_transport_set_vec_push_function ${GNUTLS_PATH} GNUTLS_VERSION_212)
801
728cc60a7be5 Test version only on found library
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 797
diff changeset
60 CHECK_LIBRARY_EXISTS(gnutls gnutls_x509_trust_list_verify_crt ${GNUTLS_PATH} GNUTLS_VERSION_300)
802
6dde862ba119 Also detect GNUTLS version 3.1.x
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 801
diff changeset
61 CHECK_LIBRARY_EXISTS(gnutls gnutls_handshake_set_timeout ${GNUTLS_PATH} GNUTLS_VERSION_310)
801
728cc60a7be5 Test version only on found library
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 797
diff changeset
62 SET( GNUTLS_VERSION_TEST_FOR ${GNUTLS_LIBRARY} CACHE INTERNAL "Version the test was made against" )
728cc60a7be5 Test version only on found library
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 797
diff changeset
63 ENDIF (NOT( "${GNUTLS_VERSION_TEST_FOR}" STREQUAL "${GNUTLS_LIBRARY}" ))
728cc60a7be5 Test version only on found library
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 797
diff changeset
64 ENDIF(GNUTLS_FOUND)
"Welcome to our mercurial repository"