diff --git a/cmake/modules/FindDL.cmake b/cmake/modules/FindDL.cmake new file mode 100644 index 0000000..a0d2c46 --- /dev/null +++ b/cmake/modules/FindDL.cmake @@ -0,0 +1,40 @@ +# - find where dlopen and friends are located. +# DL_FOUND - system has dynamic linking interface available +# DL_INCLUDE_DIR - where dlfcn.h is located. +# DL_LIBRARY - libraries needed to use dlopen + +include(CheckFunctionExists) + +find_path(DL_INCLUDE_DIR NAMES dlfcn.h) +find_library(DL_LIBRARY NAMES dl) +if(DL_LIBRARY) + set(DL_FOUND TRUE) +else(DL_LIBRARY) + check_function_exists(dlopen DL_FOUND) + # If dlopen can be found without linking in dl then dlopen is part + # of libc, so don't need to link extra libs. + set(DL_LIBRARY "") +endif(DL_LIBRARY) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(DL + FOUND_VAR + DL_FOUND + REQUIRED_VARS + DL_INCLUDE_DIR +) + +mark_as_advanced(DL_INCLUDE_DIR DL_LIBRARY) + +if(DL_FOUND AND NOT TARGET DL::DL) + if (DL_LIBRARY) + add_library(DL::DL UNKNOWN IMPORTED) + set_target_properties(DL::DL PROPERTIES + IMPORTED_LOCATION "${DL_LIBRARY}") + else() + add_library(DL::DL INTERFACE IMPORTED ) + endif() + set_target_properties(DL::DL PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${DL_INCLUDE_DIR}" + ) +endif() diff --git a/cmake/modules/FindPAM.cmake b/cmake/modules/FindPAM.cmake new file mode 100644 index 0000000..8bb8beb --- /dev/null +++ b/cmake/modules/FindPAM.cmake @@ -0,0 +1,76 @@ +# - Try to find the PAM libraries +# Once done this will define +# +# PAM_FOUND - system has pam +# PAM_INCLUDE_DIR - the pam include directory +# PAM_LIBRARIES - libpam library +# +# SPDX-License-Identifier: BSD-3-Clause + +if (PAM_INCLUDE_DIR AND PAM_LIBRARY) + # Already in cache, be silent + set(PAM_FIND_QUIETLY TRUE) +endif (PAM_INCLUDE_DIR AND PAM_LIBRARY) + +find_path(PAM_INCLUDE_DIR NAMES security/pam_appl.h pam/pam_appl.h) +find_library(PAM_LIBRARY pam) +find_library(DL_LIBRARY dl) + +if (PAM_INCLUDE_DIR AND PAM_LIBRARY) + set(PAM_FOUND TRUE) + if (DL_LIBRARY) + set(PAM_LIBRARIES ${PAM_LIBRARY} ${DL_LIBRARY}) + else (DL_LIBRARY) + set(PAM_LIBRARIES ${PAM_LIBRARY}) + endif (DL_LIBRARY) + + if (EXISTS ${PAM_INCLUDE_DIR}/pam/pam_appl.h) + # darwin claims to be something special + set(HAVE_PAM_PAM_APPL_H 1) + endif (EXISTS ${PAM_INCLUDE_DIR}/pam/pam_appl.h) + + if (NOT DEFINED PAM_MESSAGE_CONST) + include(CheckCXXSourceCompiles) + # XXX does this work with plain c? + check_cxx_source_compiles(" +#if ${HAVE_PAM_PAM_APPL_H}+0 +# include +#else +# include +#endif + +static int PAM_conv( + int num_msg, + const struct pam_message **msg, /* this is the culprit */ + struct pam_response **resp, + void *ctx) +{ + return 0; +} + +int main(void) +{ + struct pam_conv PAM_conversation = { + &PAM_conv, /* this bombs out if the above does not match */ + 0 + }; + + return 0; +} +" PAM_MESSAGE_CONST) + endif (NOT DEFINED PAM_MESSAGE_CONST) + set(PAM_MESSAGE_CONST ${PAM_MESSAGE_CONST} CACHE BOOL "PAM expects a conversation function with const pam_message") + +endif (PAM_INCLUDE_DIR AND PAM_LIBRARY) + +if (PAM_FOUND) + if (NOT PAM_FIND_QUIETLY) + message(STATUS "Found PAM: ${PAM_LIBRARIES}") + endif (NOT PAM_FIND_QUIETLY) +else (PAM_FOUND) + if (PAM_FIND_REQUIRED) + message(FATAL_ERROR "PAM was not found") + endif(PAM_FIND_REQUIRED) +endif (PAM_FOUND) + +mark_as_advanced(PAM_INCLUDE_DIR PAM_LIBRARY DL_LIBRARY PAM_MESSAGE_CONST) diff --git a/smart b/smart index ed3acbe..0d3bbde 160000 --- a/smart +++ b/smart @@ -1 +1 @@ -Subproject commit ed3acbe2d47d911b9e3a9bfa05726982940ba01c +Subproject commit 0d3bbdec8e50aff1ee2e33b99669e6b2233be288