add more spacing
[personal-kdebase.git] / workspace / kdm / ConfigureChecks.cmake
blob55d9e1c679458f2c28625e0c27dca90301b3de03
1 macro_optional_find_package(CkConnector)
2 macro_bool_to_01(CKCONNECTOR_FOUND HAVE_CKCONNECTOR)
3 if(CKCONNECTOR_FOUND)
4   # when building with libck-connector, we also need the low-level D-Bus API
5   find_package(DBus REQUIRED)
6 endif(CKCONNECTOR_FOUND)
8 macro_log_feature(CKCONNECTOR_FOUND "ck-connector" "The ConsoleKit connector library" "http://freedesktop.org/wiki/Software/ConsoleKit" FALSE "" "Provides ConsoleKit integration in KDM")
10 include(CheckCSourceRuns)
11 include(CheckStructMember)
13 check_struct_member("struct passwd" "pw_expire" "pwd.h" HAVE_STRUCT_PASSWD_PW_EXPIRE)
14 check_struct_member("struct utmp" "ut_user" "utmp.h" HAVE_STRUCT_UTMP_UT_USER)
15 check_struct_member("struct utmp" "ut_host" "utmp.h" HAVE_STRUCT_UTMP_UT_HOST)
17 check_include_files(lastlog.h HAVE_LASTLOG_H)
18 check_include_files(termio.h HAVE_TERMIO_H)
19 check_include_files(termios.h HAVE_TERMIOS_H)
21 check_symbol_exists(sysinfo "sys/sysinfo.h" HAVE_SYSINFO)
22 check_symbol_exists(systeminfo "sys/systeminfo.h" HAVE_SYS_SYSTEMINFO)
23 check_symbol_exists(getdomainname   "unistd.h"    HAVE_GETDOMAINNAME)
25 check_function_exists(initgroups HAVE_INITGROUPS)
26 check_function_exists(mkstemp HAVE_MKSTEMP)
27 check_function_exists(getusershell HAVE_GETUSERSHELL)
29 check_c_source_runs("
30 #include <errno.h>
31 #include <unistd.h>
32 int main()
34         setlogin(0);
35         return errno == ENOSYS;
37 " HAVE_SETLOGIN)
39 # for config-kdm.h
40 check_function_exists(seteuid HAVE_SETEUID)
42 # for environ in config-kdm.h
43 check_include_files(crt_externs.h HAVE_CRT_EXTERNS_H)
44 check_function_exists(_NSGetEnviron HAVE_NSGETENVIRON)
46 find_library(UTIL_LIBRARIES util)
47 mark_as_advanced(UTIL_LIBRARIES)
49 macro_push_required_vars()
50 set(CMAKE_REQUIRED_LIBRARIES ${UTIL_LIBRARIES})
51 check_function_exists(setusercontext HAVE_SETUSERCONTEXT)
52 check_function_exists(login_getclass HAVE_LOGIN_GETCLASS)
53 check_function_exists(auth_timeok HAVE_AUTH_TIMEOK)
54 if (PAM_FOUND)
55         set(CMAKE_REQUIRED_LIBRARIES ${PAM_LIBRARIES})
56         check_function_exists(pam_getenvlist HAVE_PAM_GETENVLIST)
57 endif (PAM_FOUND)
58 macro_pop_required_vars()
61 macro(define_library LIB FN)
62         set(varname ${FN}_in_${LIB})
63         string(TOUPPER ${LIB}_LIBRARIES libname)
64         check_library_exists(${LIB} ${FN} "" ${varname})
65         set(${libname})
66         if (${varname})
67                 set(${libname} ${LIB})
68         endif (${varname})
69 endmacro(define_library)
71 define_library(s authenticate)
72 define_library(posix4 sched_yield)
73 define_library(socket connect)
74 define_library(resolv dn_expand)
76 # for genkdmconf; this is TODO
77 #if (EXISTS /etc/ttys)
78 #       set(BSD_INIT 1)
79 #       check_function_exists(getttyent HAVE_GETTTYENT)
80 #endif (EXISTS /etc/ttys)
82 if (CMAKE_SYSTEM_NAME MATCHES Linux OR CMAKE_SYSTEM_NAME MATCHES Darwin OR CMAKE_SYSTEM_NAME MATCHES GNU/FreeBSD)
83         set(HAVE_UTMPX)
84         set(HAVE_LASTLOGX)
85 else (CMAKE_SYSTEM_NAME MATCHES Linux OR CMAKE_SYSTEM_NAME MATCHES Darwin OR CMAKE_SYSTEM_NAME MATCHES GNU/FreeBSD)
86         check_function_exists(getutxent HAVE_UTMPX)
87         check_function_exists(updlastlogx HAVE_LASTLOGX)
88 endif (CMAKE_SYSTEM_NAME MATCHES Linux OR CMAKE_SYSTEM_NAME MATCHES Darwin OR CMAKE_SYSTEM_NAME MATCHES GNU/FreeBSD)
89 set(BSD_UTMP)
90 if (NOT HAVE_UTMPX)
91         check_function_exists(getutent have_getutent)
92         if (NOT have_getutent)
93                 set(BSD_UTMP 1)
94         endif (NOT have_getutent)
95 endif (NOT HAVE_UTMPX)
96 check_function_exists(updwtmp HAVE_UPDWTMP)
98 check_function_exists(arc4random HAVE_ARC4RANDOM)
99 if (NOT HAVE_ARC4RANDOM)
100         # assume that /dev/random is non-blocking if /dev/urandom does not exist
101         if (EXISTS /dev/urandom)
102                 set(DEV_RANDOM "\"/dev/urandom\"")
103         else (EXISTS /dev/urandom)
104                 if (EXISTS /dev/random)
105                         set(DEV_RANDOM "\"/dev/random\"")
106                 endif (EXISTS /dev/random)
107         endif (EXISTS /dev/urandom)
108 endif (NOT HAVE_ARC4RANDOM)
110 option(KDE4_RPCAUTH "Use Sun's secure RPC for Xauth cookies in KDM" OFF)
111 if (KDE4_RPCAUTH)
112         find_path(RPC_INCLUDE_DIR rpc/rpc.h)
113         if (RPC_INCLUDE_DIR)
114                 set(RPCAUTH_FOUND TRUE)
115         else (RPC_INCLUDE_DIR)
116                 message(STATUS "Sun's secure RPC header was not found")
117         endif (RPC_INCLUDE_DIR)
118 endif (KDE4_RPCAUTH)
119 mark_as_advanced(RPC_INCLUDE_DIR)
120 macro_bool_to_01(RPCAUTH_FOUND SECURE_RPC)
122 option(KDE4_KRB5AUTH "Use Sun's secure RPC for Xauth cookies in KDM" OFF)
123 if (KDE4_KRB5AUTH)
124         find_library(KRB5_LIBRARIES krb5)
125         if (KRB5_LIBRARIES)
126                 find_path(KRB5_INCLUDE_DIR krb5/krb5.h)
127                 if (KRB5_INCLUDE_DIR)
128                                 set(KRB5AUTH_FOUND TRUE)
129                 else (KRB5_INCLUDE_DIR)
130                                 message(STATUS "KDE4_KRB5AUTH requires Kerberos5 header files.
131 Due to a problem with X includes you probably have to run \"ln -s . krb5\"
132 in the directory where the krb5.h include resides to make things actually work.")
133                 endif (KRB5_INCLUDE_DIR)
134         endif (KRB5_LIBRARIES)
135         mark_as_advanced(KRB5_INCLUDE_DIR KRB5_LIBRARIES)
136         macro_bool_to_01(KRB5AUTH_FOUND K5AUTH)
137 endif (KDE4_KRB5AUTH)
139 if (X11_Xdmcp_FOUND)
140         macro_push_required_vars()
141         set(CMAKE_REQUIRED_LIBRARIES ${X11_LIBRARIES})
142         check_function_exists(XdmcpWrap HASXDMAUTH)
143         macro_pop_required_vars()
144 endif (X11_Xdmcp_FOUND)
146 option(KDE4_KERBEROS4 "Compile KDM with Kerberos v4 support" OFF)
147 if (KDE4_KERBEROS4)
148         find_path(KRB4_INCLUDE_DIR krb.h)
149         find_library(KRB4_LIBRARY krb)
150         find_library(DES_LIBRARY des)
151         if (KRB4_INCLUDE_DIR AND KRB4_LIBRARY)
152                 set(KERBEROS 1)
153                 set(KRB4_LIBRARIES ${KRB4_LIBRARY} ${DES_LIBRARY} ${RESOLV_LIBRARIES})
154         endif (KRB4_INCLUDE_DIR AND KRB4_LIBRARY)
155         option(KDE4_AFS "Compile KDM with AFS support" OFF)
156         if (KDE4_AFS)
157                 find_path(AFS_INCLUDE_DIR kafs.h)
158                 find_library(AFS_LIBRARY kafs)
159                 if (AFS_INCLUDE_DIR AND AFS_LIBRARY)
160                         set(AFS 1)
161                         set(KRB4_LIBRARIES ${KRB4_LIBRARIES} ${AFS_LIBRARY})
162                 endif (AFS_INCLUDE_DIR AND AFS_LIBRARY)
163         endif (KDE4_AFS)
164 endif (KDE4_KERBEROS4)
166 option(KDE4_XDMCP "Build KDM with XDMCP support" ON)
167 if (KDE4_XDMCP AND X11_Xdmcp_FOUND)
168         set(XDMCP 1)
169 endif (KDE4_XDMCP AND X11_Xdmcp_FOUND)
171 option(KDE4_KDM_XCONSOLE "Build KDM with built-in xconsole" OFF)
172 macro_bool_to_01(KDE4_KDM_XCONSOLE WITH_KDM_XCONSOLE)
174 check_function_exists(getifaddrs  HAVE_GETIFADDRS)
175 check_function_exists(getloadavg  HAVE_GETLOADAVG)
176 check_function_exists(setproctitle HAVE_SETPROCTITLE)
177 check_function_exists(strnlen     HAVE_STRNLEN)
179 check_struct_member("struct sockaddr_in" "sin_len" "sys/socket.h;netinet/in.h" HAVE_STRUCT_SOCKADDR_IN_SIN_LEN)
180 check_struct_member("struct sockaddr_in6" "sin6_len" "sys/socket.h;netinet/in.h" HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN)
182 FOREACH(path /usr/local/bin /usr/bin /bin)
183         if (XBINDIR STREQUAL ${path})
184                 set(dont_add_xbin 1)
185         endif (XBINDIR STREQUAL ${path})
186 ENDFOREACH(path)
187 if (dont_add_xbin)
188         set(KDM_DEF_USER_PATH "/usr/local/bin:/usr/bin:/bin:/usr/games")
189         set(KDM_DEF_SYSTEM_PATH "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin")
190 else (dont_add_xbin)
191         set(KDM_DEF_USER_PATH "/usr/local/bin:/usr/bin:/bin:${XBINDIR}:/usr/games")
192         set(KDM_DEF_SYSTEM_PATH "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${XBINDIR}")
193 endif (dont_add_xbin)
195 set(KDM_LIBEXEC_STRIP 0)
196 if (NOT LIBEXEC_INSTALL_DIR STREQUAL "${BIN_INSTALL_DIR}")
197     STRING(LENGTH "${BIN_INSTALL_DIR}" bidl)
198     STRING(LENGTH "${LIBEXEC_INSTALL_DIR}" lxidl)
199     set(ips "${CMAKE_INSTALL_PREFIX}/")
200     STRING(LENGTH "${ips}" ipsl)
201     set(inip 1)
202     if (bild LESS ${ipsl} OR lxild LESS ${ipsl})
203         set(inip)
204     else (bild LESS ${ipsl} OR lxild LESS ${ipsl})
205         STRING(SUBSTRING "${BIN_INSTALL_DIR}" 0 ${ipsl} bpr)
206         STRING(SUBSTRING "${LIBEXEC_INSTALL_DIR}" 0 ${ipsl} lpr)
207         if (NOT bpr STREQUAL "${lpr}")
208             set(inip)
209         endif (NOT bpr STREQUAL "${lpr}")
210     endif (bild LESS ${ipsl} OR lxild LESS ${ipsl})
211     if (NOT inip)
212         set(KDM_LIBEXEC_STRIP -1)
213         set(KDM_LIBEXEC_SUFFIX "${LIBEXEC_INSTALL_DIR}")
214     else (NOT inip)
215         MATH(EXPR bsfxl "${bidl} - ${ipsl}")
216         STRING(SUBSTRING "${BIN_INSTALL_DIR}" ${ipsl} ${bsfxl} bsfx)
217         STRING(REPLACE "/" ";" bsfxl "${bsfx}")
218         LIST(LENGTH bsfxl KDM_LIBEXEC_STRIP)
219         MATH(EXPR klxsfxl "${lxidl} - ${ipsl}")
220         STRING(SUBSTRING "${LIBEXEC_INSTALL_DIR}" ${ipsl} ${klxsfxl} KDM_LIBEXEC_SUFFIX)
221     endif (NOT inip)
222 endif (NOT LIBEXEC_INSTALL_DIR STREQUAL "${BIN_INSTALL_DIR}")
224 configure_file(config-kdm.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kdm.h)