not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / cmake / modules / UnixAuth.cmake
blob904f0cb88e795e5600bfef808dc8dd7fd82a0205
1 find_package(PAM)
3 include(CheckFunctionExists)
4 include(CheckLibraryExists)
5 include(CheckIncludeFiles)
7 set(UNIXAUTH_LIBRARIES)
8 set(UNIXAUTH_INCLUDE_DIRS)
10 set(SHADOW_LIBRARIES)
11 check_function_exists(getspnam found_getspnam)
12 if (found_getspnam)
13     set(HAVE_GETSPNAM 1)
14 else (found_getspnam)
15     macro_push_required_vars()
16     set(CMAKE_REQUIRED_LIBRARIES -lshadow)
17     check_function_exists(getspnam found_getspnam_shadow)
18     if (found_getspnam_shadow)
19         set(HAVE_GETSPNAM 1)
20         set(SHADOW_LIBRARIES shadow)
21         check_function_exists(pw_encrypt HAVE_PW_ENCRYPT) # ancient Linux shadow
22     else (found_getspnam_shadow)
23         set(CMAKE_REQUIRED_LIBRARIES -lgen) # UnixWare
24         check_function_exists(getspnam found_getspnam_gen)
25         if (found_getspnam_gen)
26             set(HAVE_GETSPNAM 1)
27             set(SHADOW_LIBRARIES gen)
28         endif (found_getspnam_gen)
29     endif (found_getspnam_shadow)
30     macro_pop_required_vars()
31 endif (found_getspnam)
33 set(CRYPT_LIBRARIES)
34 check_library_exists(crypt crypt "" HAVE_CRYPT)
35 if (HAVE_CRYPT)
36     set(CRYPT_LIBRARIES crypt)
37     check_include_files(crypt.h HAVE_CRYPT_H)
38 endif (HAVE_CRYPT)
40 if (PAM_FOUND)
42     set(HAVE_PAM 1)
43     set(UNIXAUTH_LIBRARIES ${PAM_LIBRARIES})
44     set(UNIXAUTH_INCLUDE_DIRS ${PAM_INCLUDE_DIR})
46 else (PAM_FOUND)
48     if (HAVE_GETSPNAM)
49         set(UNIXAUTH_LIBRARIES ${SHADOW_LIBRARIES})
50     endif (HAVE_GETSPNAM)
51     if (NOT HAVE_PW_ENCRYPT)
52         set(UNIXAUTH_LIBRARIES ${UNIXAUTH_LIBRARIES} ${CRYPT_LIBRARIES})
53     endif (NOT HAVE_PW_ENCRYPT)
55 endif (PAM_FOUND)