aboutsummaryrefslogtreecommitdiffstats
path: root/cmake/Modules/FindPAM.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/Modules/FindPAM.cmake')
-rw-r--r--cmake/Modules/FindPAM.cmake47
1 files changed, 47 insertions, 0 deletions
diff --git a/cmake/Modules/FindPAM.cmake b/cmake/Modules/FindPAM.cmake
new file mode 100644
index 00000000..a41cb421
--- /dev/null
+++ b/cmake/Modules/FindPAM.cmake
@@ -0,0 +1,47 @@
+#[=======================================================================[.rst:
+FindPAM
+-------
+
+Find the Pluggable Authentication Modules library
+
+Result variables
+^^^^^^^^^^^^^^^^
+
+This module will set the following variables if found:
+
+``PAM_INCLUDE_DIRS``
+ where to find security/pam_appl.h, etc.
+``PAM_LIBRARIES``
+ the libraries to link against to use PAM.
+``PAM_FOUND``
+ TRUE if found
+
+#]=======================================================================]
+
+find_package(PkgConfig QUIET)
+if(PKG_CONFIG_FOUND)
+ pkg_check_modules(PC_PAM QUIET pam)
+endif()
+
+find_path(PAM_INCLUDE_DIR NAMES security/pam_appl.h
+ HINTS
+ ${PC_PAM_INCLUDE_DIRS}
+)
+mark_as_advanced(PAM_INCLUDE_DIR)
+
+find_library(PAM_LIBRARY NAMES pam
+ HINTS
+ ${PC_PAM_LIBRARY_DIRS}
+)
+mark_as_advanced(PAM_LIBRARY)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(PAM
+ REQUIRED_VARS
+ PAM_LIBRARY PAM_INCLUDE_DIR
+)
+
+if(PAM_FOUND)
+ set(PAM_INCLUDE_DIRS ${PAM_INCLUDE_DIR})
+ set(PAM_LIBRARIES ${PAM_LIBRARY})
+endif()