1 # - Try to detect the GSSAPI support
2 # Once done this will define
4 # GSSAPI_FOUND - system supports GSSAPI
5 # GSSAPI_INCS - the GSSAPI include directory
6 # GSSAPI_LIBS - the libraries needed to use GSSAPI
7 # GSSAPI_FLAVOR - the type of API - MIT or HEIMDAL
9 # Copyright (c) 2006, Pino Toscano, <toscano.pino@tiscali.it>
11 # Redistribution and use is allowed according to the terms of the BSD license.
12 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
15 if(GSSAPI_LIBS AND GSSAPI_FLAVOR)
18 set(GSSAPI_FOUND TRUE)
20 else(GSSAPI_LIBS AND GSSAPI_FLAVOR)
22 find_program(KRB5_CONFIG NAMES krb5-config PATHS
24 ONLY_CMAKE_FIND_ROOT_PATH # this is required when cross compiling with cmake 2.6 and ignored with cmake 2.4, Alex
26 mark_as_advanced(KRB5_CONFIG)
35 set(HAVE_KRB5_GSSAPI TRUE)
36 exec_program(${KRB5_CONFIG} ARGS --libs gssapi RETURN_VALUE _return_VALUE OUTPUT_VARIABLE GSSAPI_LIBS)
38 message(STATUS "GSSAPI configure check failed.")
39 set(HAVE_KRB5_GSSAPI FALSE)
42 exec_program(${KRB5_CONFIG} ARGS --cflags gssapi RETURN_VALUE _return_VALUE OUTPUT_VARIABLE GSSAPI_INCS)
43 string(REGEX REPLACE "(\r?\n)+$" "" GSSAPI_INCS "${GSSAPI_INCS}")
44 string(REGEX REPLACE " *-I" ";" GSSAPI_INCS "${GSSAPI_INCS}")
46 exec_program(${KRB5_CONFIG} ARGS --vendor RETURN_VALUE _return_VALUE OUTPUT_VARIABLE gssapi_flavor_tmp)
47 set(GSSAPI_FLAVOR_MIT)
48 if(gssapi_flavor_tmp MATCHES ".*Massachusetts.*")
49 set(GSSAPI_FLAVOR "MIT")
50 else(gssapi_flavor_tmp MATCHES ".*Massachusetts.*")
51 set(GSSAPI_FLAVOR "HEIMDAL")
52 endif(gssapi_flavor_tmp MATCHES ".*Massachusetts.*")
54 if(NOT HAVE_KRB5_GSSAPI)
55 if (gssapi_flavor_tmp MATCHES "Sun Microsystems.*")
56 message(STATUS "Solaris Kerberos does not have GSSAPI; this is normal.")
59 else(gssapi_flavor_tmp MATCHES "Sun Microsystems.*")
60 message(WARNING "${KRB5_CONFIG} failed unexpectedly.")
61 endif(gssapi_flavor_tmp MATCHES "Sun Microsystems.*")
62 endif(NOT HAVE_KRB5_GSSAPI)
64 if(GSSAPI_LIBS) # GSSAPI_INCS can be also empty, so don't rely on that
65 set(GSSAPI_FOUND TRUE)
66 message(STATUS "Found GSSAPI: ${GSSAPI_LIBS}")
68 set(GSSAPI_INCS ${GSSAPI_INCS})
69 set(GSSAPI_LIBS ${GSSAPI_LIBS})
70 set(GSSAPI_FLAVOR ${GSSAPI_FLAVOR})
72 mark_as_advanced(GSSAPI_INCS GSSAPI_LIBS GSSAPI_FLAVOR)
78 endif(GSSAPI_LIBS AND GSSAPI_FLAVOR)