properly compute width of containing block of inline elements
[kdelibs.git] / cmake / modules / FindGSSAPI.cmake
blob0951c67542f66ab826c714c478d5f328214762ca
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)
17   # in cache already
18   set(GSSAPI_FOUND TRUE)
20 else(GSSAPI_LIBS AND GSSAPI_FLAVOR)
22   find_program(KRB5_CONFIG NAMES krb5-config PATHS
23      /opt/local/bin
24      ONLY_CMAKE_FIND_ROOT_PATH               # this is required when cross compiling with cmake 2.6 and ignored with cmake 2.4, Alex
25   )
26   mark_as_advanced(KRB5_CONFIG)
27   
28   #reset vars
29   set(GSSAPI_INCS)
30   set(GSSAPI_LIBS)
31   set(GSSAPI_FLAVOR)
32   
33   if(KRB5_CONFIG)
34   
35     set(HAVE_KRB5_GSSAPI TRUE)
36     exec_program(${KRB5_CONFIG} ARGS --libs gssapi RETURN_VALUE _return_VALUE OUTPUT_VARIABLE GSSAPI_LIBS)
37     if(_return_VALUE)
38       message(STATUS "GSSAPI configure check failed.")
39       set(HAVE_KRB5_GSSAPI FALSE)
40     endif(_return_VALUE)
41   
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.*")
53   
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.")
57          set(GSSAPI_LIBS)
58          set(GSSAPI_INCS)
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)
74     endif(GSSAPI_LIBS)
75   
76   endif(KRB5_CONFIG)
78 endif(GSSAPI_LIBS AND GSSAPI_FLAVOR)