OSDN Git Service

solid: set Solid::OpticalDisc::UnknownDiscType to be zero
[kde/kdelibs.git] / ConfigureChecks.cmake
1 # NOTE: only add something here if it is really needed by all of kdelibs.
2 #     Otherwise please prefer adding to the relevant config-foo.h.cmake file,
3 #     and the CMakeLists.txt that generates it (or a separate ConfigureChecks.make file if you prefer)
4 #     to minimize recompilations and increase modularity.
5
6 include(CheckIncludeFiles)
7 include(CheckSymbolExists)
8 include(CheckFunctionExists)
9 include(CheckLibraryExists)
10 include(CheckStructHasMember)
11 include(CheckCXXSourceCompiles)
12 include(CMakePushCheckState)
13
14 # KatieConfig.cmake sets QT_DEFINITIONS with definitions like _GNU_SOURCE that
15 # are needed on each platform.
16 set(CMAKE_REQUIRED_DEFINITIONS ${QT_DEFINITIONS})
17
18 kde4_bool_to_01(LibArchive_FOUND HAVE_LIBARCHIVE)       # karchive
19 kde4_bool_to_01(BZIP2_FOUND HAVE_BZIP2)                 # karchive
20 kde4_bool_to_01(LIBLZMA_FOUND HAVE_LIBLZMA)             # karchive
21 kde4_bool_to_01(AVAHI_FOUND HAVE_AVAHI)                 # kdnssd
22 kde4_bool_to_01(EXIV2_FOUND HAVE_EXIV2)                 # kexiv2
23 kde4_bool_to_01(MPV_FOUND HAVE_MPV)                     # kmediaplayer
24 kde4_bool_to_01(OPENSSL_FOUND HAVE_OPENSSL)             # kpasswdstore
25 kde4_bool_to_01(ACL_FOUND HAVE_POSIX_ACL)               # kio
26
27 check_include_files(fstab.h       HAVE_FSTAB_H)                        # kio, kdecore
28 check_include_files(mntent.h      HAVE_MNTENT_H)                       # solid, kio, kdecore
29 check_include_files(sys/param.h   HAVE_SYS_PARAM_H)                    # various
30 check_include_files("stdio.h;sys/mnttab.h"  HAVE_SYS_MNTTAB_H)         # kio, kdecore
31 check_include_files(sys/mntent.h  HAVE_SYS_MNTENT_H)                   # solid, kio, kdecore
32 check_include_files("sys/param.h;sys/mount.h"  HAVE_SYS_MOUNT_H)       # kio, kdecore
33 check_include_files(paths.h       HAVE_PATHS_H)                        # kdecore
34
35 # TODO: separate to config-x11.h
36 kde4_bool_to_01(X11_XTest_FOUND HAVE_XTEST)                           # kdecore
37 kde4_bool_to_01(X11_Xcursor_FOUND HAVE_XCURSOR)                       # kdeui
38 kde4_bool_to_01(X11_Xfixes_FOUND HAVE_XFIXES)                         # kdeui
39 kde4_bool_to_01(X11_Xscreensaver_FOUND HAVE_XSCREENSAVER)             # kidletime
40 kde4_bool_to_01(X11_XSync_FOUND HAVE_XSYNC)                           # kidletime
41
42
43 # Use check_symbol_exists to check for symbols in a reliable
44 # cross-platform manner.  It accounts for different calling
45 # conventions and the possibility that the symbol is defined as a
46 # macro.  Note that some symbols require multiple includes in a
47 # specific order.  Refer to the man page for each symbol for which a
48 # check is to be added to get the proper set of headers.
49 check_symbol_exists(strtoll         "stdlib.h"           HAVE_STRTOLL)      # kioslave
50 check_symbol_exists(strmode         "string.h"           HAVE_STRMODE)      # karchive
51
52 check_function_exists(backtrace          HAVE_BACKTRACE)                    # kdecore, kio
53 check_function_exists(fdatasync          HAVE_FDATASYNC)                    # kdecore
54 check_function_exists(arc4random_uniform HAVE_ARC4RANDOM_UNIFORM)           # kdecore
55 check_function_exists(sendfile           HAVE_SENDFILE)                     # kioslave
56
57 # for kpty
58 check_include_files("sys/types.h;libutil.h" HAVE_LIBUTIL_H)
59 check_include_files(termio.h      HAVE_TERMIO_H)
60 check_include_files(pty.h         HAVE_PTY_H)
61 check_include_files(sys/stropts.h HAVE_SYS_STROPTS_H)
62 check_include_files(sys/filio.h   HAVE_SYS_FILIO_H)
63
64 set(UTIL_LIBRARY)
65
66 check_symbol_exists(setutxent "utmpx.h" HAVE_UTMPX)
67 if(HAVE_UTMPX)
68     set(utmp utmpx)
69 else()
70     set(utmp utmp)
71 endif()
72
73 cmake_reset_check_state()
74 set(CMAKE_REQUIRED_LIBRARIES "util")
75 check_symbol_exists(loginx "util.h" HAVE_UTIL_LOGINX)
76 cmake_reset_check_state()
77 check_symbol_exists(login "${utmp}.h" HAVE_LOGIN)
78 if (NOT HAVE_LOGIN)
79     cmake_reset_check_state()
80     set(CMAKE_REQUIRED_LIBRARIES "util")
81     check_symbol_exists(login "util.h" HAVE_UTIL_LOGIN)
82     cmake_reset_check_state()
83 endif()
84
85 if(HAVE_UTIL_LOGINX OR HAVE_UTIL_LOGIN)
86     set(UTIL_LIBRARY "util")
87 endif()
88
89 check_struct_has_member("struct ${utmp}" "ut_user" "${utmp}.h"    HAVE_STRUCT_UTMP_UT_USER)
90 check_struct_has_member("struct ${utmp}" "ut_type" "${utmp}.h"    HAVE_STRUCT_UTMP_UT_TYPE)
91 check_struct_has_member("struct ${utmp}" "ut_pid" "${utmp}.h"     HAVE_STRUCT_UTMP_UT_PID)
92 check_struct_has_member("struct ${utmp}" "ut_session" "${utmp}.h" HAVE_STRUCT_UTMP_UT_SESSION)
93 check_struct_has_member("struct ${utmp}" "ut_syslen" "${utmp}.h"  HAVE_STRUCT_UTMP_UT_SYSLEN)
94 check_struct_has_member("struct ${utmp}" "ut_id" "${utmp}.h"      HAVE_STRUCT_UTMP_UT_ID)
95
96 check_function_exists(openpty openpty_in_libc)
97 if (NOT openpty_in_libc)
98     check_library_exists(util openpty "" openpty_in_libutil)
99     if(openpty_in_libutil)
100         set(UTIL_LIBRARY util)
101     endif()
102 endif()
103
104 check_function_exists(ptsname_r  HAVE_PTSNAME_R)         # kpty
105 check_function_exists(getmntinfo HAVE_GETMNTINFO)        # kdecore
106 check_function_exists(setmntent  HAVE_SETMNTENT)         # kdecore
107
108 # check for existing datatypes
109
110 check_cxx_source_compiles("
111   #include <sys/types.h>
112   #include <sys/statvfs.h>
113   int main(){
114     struct statvfs *mntbufp;
115     int flags;
116     return getmntinfo(&mntbufp, flags);
117   }
118 " GETMNTINFO_USES_STATVFS )
119
120 check_struct_has_member("struct dirent" d_type dirent.h HAVE_DIRENT_D_TYPE) # kdecore, kioslave/file
121