~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to cmake/modules/FindPAM.cmake

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# - Try to find the PAM libraries
 
2
# Once done this will define
 
3
#
 
4
#  PAM_FOUND - system has pam
 
5
#  PAM_INCLUDE_DIR - the pam include directory
 
6
#  PAM_LIBRARIES - libpam library
 
7
 
 
8
if (PAM_INCLUDE_DIR AND PAM_LIBRARY)
 
9
        # Already in cache, be silent
 
10
        set(PAM_FIND_QUIETLY TRUE)
 
11
endif (PAM_INCLUDE_DIR AND PAM_LIBRARY)
 
12
 
 
13
find_path(PAM_INCLUDE_DIR NAMES security/pam_appl.h pam/pam_appl.h)
 
14
find_library(PAM_LIBRARY pam)
 
15
find_library(DL_LIBRARY dl)
 
16
 
 
17
if (PAM_INCLUDE_DIR AND PAM_LIBRARY)
 
18
        set(PAM_FOUND TRUE)
 
19
        if (DL_LIBRARY)
 
20
                set(PAM_LIBRARIES ${PAM_LIBRARY} ${DL_LIBRARY})
 
21
        else (DL_LIBRARY)
 
22
                set(PAM_LIBRARIES ${PAM_LIBRARY})
 
23
        endif (DL_LIBRARY)
 
24
 
 
25
        if (EXISTS ${PAM_INCLUDE_DIR}/pam/pam_appl.h)
 
26
                # darwin claims to be something special
 
27
                set(HAVE_PAM_PAM_APPL_H 1)
 
28
        endif (EXISTS ${PAM_INCLUDE_DIR}/pam/pam_appl.h)
 
29
 
 
30
        if (NOT DEFINED PAM_MESSAGE_CONST)
 
31
                include(CheckCXXSourceCompiles)
 
32
                # XXX does this work with plain c?
 
33
                check_cxx_source_compiles("
 
34
#if ${HAVE_PAM_PAM_APPL_H}+0
 
35
# include <pam/pam_appl.h>
 
36
#else
 
37
# include <security/pam_appl.h>
 
38
#endif
 
39
 
 
40
static int PAM_conv(
 
41
        int num_msg,
 
42
        const struct pam_message **msg, /* this is the culprit */
 
43
        struct pam_response **resp,
 
44
        void *ctx)
 
45
{
 
46
        return 0;
 
47
}
 
48
 
 
49
int main(void)
 
50
{
 
51
        struct pam_conv PAM_conversation = {
 
52
                &PAM_conv, /* this bombs out if the above does not match */
 
53
                0
 
54
        };
 
55
 
 
56
        return 0;
 
57
}
 
58
" PAM_MESSAGE_CONST)
 
59
        endif (NOT DEFINED PAM_MESSAGE_CONST)
 
60
        set(PAM_MESSAGE_CONST ${PAM_MESSAGE_CONST} CACHE BOOL "PAM expects a conversation function with const pam_message")
 
61
 
 
62
endif (PAM_INCLUDE_DIR AND PAM_LIBRARY)
 
63
 
 
64
if (PAM_FOUND)
 
65
        if (NOT PAM_FIND_QUIETLY)
 
66
                message(STATUS "Found PAM: ${PAM_LIBRARIES}")
 
67
        endif (NOT PAM_FIND_QUIETLY)
 
68
else (PAM_FOUND)
 
69
        if (PAM_FIND_REQUIRED)
 
70
                message(FATAL_ERROR "PAM was not found")
 
71
        endif(PAM_FIND_REQUIRED)
 
72
endif (PAM_FOUND)
 
73
 
 
74
mark_as_advanced(PAM_INCLUDE_DIR PAM_LIBRARY DL_LIBRARY PAM_MESSAGE_CONST)