Permalink
Browse files

Improve C-Client building on external systems by detecting SSL and PA…

…M requirements
  • Loading branch information...
1 parent d2f8861 commit 2814e264700cecb70e08e760257d28e4dcec2c90 @scottmac scottmac committed Nov 4, 2010
Showing with 45 additions and 0 deletions.
  1. +23 −0 CMake/FindLibpam.cmake
  2. +22 −0 CMake/HPHPFindLibs.cmake
View
@@ -0,0 +1,23 @@
+IF(PAM_FOUND)
+ SET(PAM_FIND_QUIETLY TRUE)
+ENDIF(PAM_FOUND)
+
+FIND_PATH(PAM_INCLUDE_PATH
+ NAMES pam_modules.h
+ PATH_SUFFIXES security
+ PATHS /usr/include /usr/local/include /usr/pkg/include
+)
+
+FIND_LIBRARY(PAM_LIBRARY
+ NAMES pam
+ PATHS /lib /usr/lib /usr/local/lib /usr/pkg/lib
+)
+
+IF (PAM_INCLUDE_PATH AND PAM_LIBRARY)
+ SET(PAM_FOUND TRUE)
+ENDIF()
+
+MARK_AS_ADVANCED(
+ PAM_INCLUDE_PATH
+ PAM_LIBRARY
+)
View
@@ -15,6 +15,8 @@
# +----------------------------------------------------------------------+
#
+include(CheckFunctionExists)
+
# boost checks
find_package(Boost 1.37.0 COMPONENTS system;program_options;filesystem REQUIRED)
@@ -191,6 +193,21 @@ include_directories(${READLINE_INCLUDE_DIR})
find_package(CClient REQUIRED)
include_directories(${CCLIENT_INCLUDE_PATH})
+CHECK_LIBRARY_EXISTS(${CCLIENT_LIBRARY} auth_gss "" CCLIENT_NEEDS_PAM)
+
+CHECK_LIBRARY_EXISTS(${CCLIENT_LIBRARY} ssl_onceonlyinit "" CCLIENT_HAS_SSL)
+
+if (CCLIENT_NEEDS_PAM)
+ find_package(Libpam REQUIRED)
+ include_directories(${PAM_INCLUDE_PATH})
+else()
+ add_definitions(-DSKIP_IMAP_GSS=1)
+endif()
+
+if (NOT CCLIENT_HAS_SSL)
+ add_definitions(-DSKIP_IMAP_SSL=1)
+endif()
+
if (LINUX OR FREEBSD)
FIND_LIBRARY (CRYPT_LIB crypt)
FIND_LIBRARY (RT_LIB rt)
@@ -304,4 +321,9 @@ endif()
target_link_libraries(${target} ${READLINE_LIBRARY})
target_link_libraries(${target} ${NCURSES_LIBRARY})
target_link_libraries(${target} ${CCLIENT_LIBRARY})
+
+ if (CCLIENT_NEEDS_PAM)
+ target_link_libraries(${target} ${PAM_LIBRARY})
+ endif()
+
endmacro()

0 comments on commit 2814e26

Please sign in to comment.