Ed Tanous | 4758d5b | 2017-06-06 15:28:13 -0700 | [diff] [blame] | 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 | static int PAM_conv( |
| 40 | int num_msg, |
| 41 | const struct pam_message **msg, /* this is the culprit */ |
| 42 | struct pam_response **resp, |
| 43 | void *ctx) |
| 44 | { |
| 45 | return 0; |
| 46 | } |
| 47 | int main(void) |
| 48 | { |
| 49 | struct pam_conv PAM_conversation = { |
| 50 | &PAM_conv, /* this bombs out if the above does not match */ |
| 51 | 0 |
| 52 | }; |
| 53 | return 0; |
| 54 | } |
| 55 | " PAM_MESSAGE_CONST) |
| 56 | endif (NOT DEFINED PAM_MESSAGE_CONST) |
| 57 | set(PAM_MESSAGE_CONST ${PAM_MESSAGE_CONST} CACHE BOOL "PAM expects a conversation function with const pam_message") |
| 58 | |
| 59 | endif (PAM_INCLUDE_DIR AND PAM_LIBRARY) |
| 60 | |
| 61 | if (PAM_FOUND) |
| 62 | if (NOT PAM_FIND_QUIETLY) |
| 63 | message(STATUS "Found PAM: ${PAM_LIBRARIES}") |
| 64 | endif (NOT PAM_FIND_QUIETLY) |
| 65 | else (PAM_FOUND) |
| 66 | if (PAM_FIND_REQUIRED) |
| 67 | message(FATAL_ERROR "PAM was not found") |
| 68 | endif(PAM_FIND_REQUIRED) |
| 69 | endif (PAM_FOUND) |
| 70 | |
| 71 | mark_as_advanced(PAM_INCLUDE_DIR PAM_LIBRARY DL_LIBRARY PAM_MESSAGE_CONST) |