summaryrefslogtreecommitdiffstats
path: root/ConfigureChecks.cmake
blob: d1db8e3b267698377913bc160de6b313326a2d48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
#################################################
#
#  (C) 2012 Golubev Alexander
#  fatzer2 (AT) gmail.com
#
#  Improvements and feedback are welcome
#
#  This file is released under GPL >= 2
#
#################################################

# required stuff

tde_setup_architecture_flags( )

include(TestBigEndian)
test_big_endian(WORDS_BIGENDIAN)

tde_setup_largefiles( )

find_package( TQt )
find_package( TDE )


##### check for gcc visibility support #########

if( WITH_GCC_VISIBILITY )
  tde_setup_gcc_visibility( )
endif( )

# strlcat and strlcpy check
check_symbol_exists( strlcpy string.h HAVE_STRLCPY_PROTO )
check_symbol_exists( strlcat string.h HAVE_STRLCAT_PROTO )


##### kcalc #####################################

if( BUILD_KCALC )
  check_type_size( "unsigned long" SIZEOF_UNSIGNED_LONG )
  check_include_file( "stdlib.h" HAVE_STDLIB_H )
  check_include_file( "ieeefp.h" HAVE_IEEEFP_H )

# NOTE: this check could be insufficiant for build on some
#       buggy, very old or unusual system configurations
  check_type_size( "long double" SIZEOF_LONG_DOUBLE)
  if( SIZEOF_LONG_DOUBLE )
    set( HAVE_LONG_DOUBLE 1 )
  endif( SIZEOF_LONG_DOUBLE )

  set( CMAKE_REQUIRED_LIBRARIES m )
  check_symbol_exists( "fabsl"  "math.h" HAVE_L_FUNCS)
  check_symbol_exists( "isinf"  "math.h" HAVE_FUNC_ISINF)
  check_symbol_exists( "round"  "math.h" HAVE_FUNC_ROUND)
  check_symbol_exists( "roundl" "math.h" HAVE_FUNC_ROUNDL)
  
# also libgmp is requred
  set( CMAKE_REQUIRED_LIBRARIES gmp )
# most functions are defined as macros so we can't use check_library exists
  check_symbol_exists( "gmp_asprintf" "gmp.h" HAVE_GMPLIB  )
  set( CMAKE_REQUIRED_LIBRARIES )

  if( HAVE_GMPLIB )
    set( GMP_LIBRARY gmp CACHE INTERNAL "" )
  else( )
    tde_message_fatal( "libgmp is required, but was not found on your system" )
  endif( )
endif ( BUILD_KCALC )


##### klaptopdaemon #############################

if( BUILD_KLAPTOPDAEMON )
# stdint.h
  check_include_file( "stdint.h" HAVE_STDINT_H )
  if( NOT HAVE_STDINT_H )
    tde_message_fatal( "stdint.h header is required, but was not found on your system" )
  endif( NOT HAVE_STDINT_H )

# NetBSD apm support
  check_include_files( "unistd.h;machine/apm_bios.h" HAVE_MACHINE_APM_BIOS_H )
  check_include_files( "unistd.h;dev/apm/apmio.h" HAVE_DEV_APM_APMIO_H )

# xtest
  pkg_search_module( XTEST xtst )
   if( XTEST_FOUND )
     set( HAVE_XTEST 1 )
   else( XTEST_FOUND )
     tde_message_fatal( "libXtst is requested, but was not found on your system" )
   endif( XTEST_FOUND )

  if( WITH_XSCREENSAVER )
    pkg_search_module( XSCREENSAVER xscrnsaver )
     if( XSCREENSAVER_FOUND )
       set( HAVE_XSCREENSAVER 1 )
     else( XSCREENSAVER_FOUND )
       tde_message_fatal( "xscreensaver is requested, but was not found on your system" )
     endif( )
  endif( WITH_XSCREENSAVER )
endif( BUILD_KLAPTOPDAEMON )


##### klaptopdaemon and ksim ####################

if( ( BUILD_KLAPTOPDAEMON AND WITH_DPMS ) OR ( BUILD_KSIM AND WITH_SENSORS ) )
  pkg_search_module( XEXT xext )

  if( XEXT_FOUND )
    if( WITH_DPMS )
      set( CMAKE_REQUIRED_LIBRARIES ${XEXT_LIBRARIES} )
      check_symbol_exists( DPMSInfo 
          "X11/Xlib.h;X11/extensions/dpms.h" 
          HAVE_DPMSINFO_PROTO )
      set( CMAKE_REQUIRED_LIBRARIES )
      set( HAVE_DPMS 1 )
    endif( WITH_DPMS )
  else( XEXT_FOUND )
    tde_message_fatal( "libXext is requested, but was not found on your system" )
  endif( XEXT_FOUND )
endif( )


##### kmilo #####################################

if( BUILD_KMILO )
# FIXME: If anybody will ever compile trinity for POWERPC and especialy for 
#        POWERBOOK he or she should test workability of those modules
  if( WITH_POWERBOOK OR WITH_POWERBOOK2 )
    check_library_exists( "pbb" "init_libpbb" "" HAVE_PBBIPC_LIBRARY )
    check_include_file( "pbbipc.h" HAVE_PBBIPC_H )
    check_include_file( "pbb.h" HAVE_PBB_H )
    if( HAVE_PBBIPC_LIBRARY AND ( ( WITH_POWERBOOK AND HAVE_PBBIPC_H ) OR 
                                  ( WITH_POWERBOOK2 AND HAVE_PBB_H ) ) )
      set( PBB_LIBRARY pbb CACHE INTERNAL "" )
    else()
      tde_message_fatal( "suitable pbbuttonosd is required, but was not found on your system" )
    endif()
  endif( WITH_POWERBOOK  OR WITH_POWERBOOK2 )
endif( BUILD_KMILO )


##### ksim ######################################

if ( BUILD_KSIM )
  check_include_file( "sys/statvfs.h" HAVE_SYS_STATVFS_H )
  check_include_file( "sys/statfs.h"  HAVE_SYS_STATFS_H )
  check_include_file( "sys/vfs.h"     HAVE_SYS_VFS_H )
  check_include_file( "sys/mount.h"   HAVE_SYS_MOUNT_H )
  check_include_file( "mntent.h"      HAVE_MNTENT_H )
  check_include_file( "sys/ucred.h"   HAVE_SYS_UCRED_H )
  check_include_files( "stdio.h;sys/mnttab.h"  HAVE_SYS_MNTTAB_H )

  check_include_files( "sys/time.h;sys/loadavg.h"  HAVE_SYS_LOADAVG_H )
  check_function_exists( getloadavg    HAVE_GETLOADAVG )
  check_function_exists( statfs        HAVE_STATFS )
  check_function_exists( statvfs       HAVE_STATVFS )
  check_function_exists( getmntinfo    HAVE_GETMNTINFO )
  if( HAVE_GETMNTINFO )
    check_cxx_source_compiles("
      #include <sys/types.h>
      #include <sys/statvfs.h>
      int main(){
        struct statvfs *mntbufp;
        int flags;
        return getmntinfo(&mntbufp, flags);
      }"
      GETMNTINFO_USES_STATVFS )
  endif( HAVE_GETMNTINFO )

  check_c_source_compiles(
    "#include <linux/kernel.h>
     int main() { struct sysinfo system; 
     int totalhigh = system.totalhigh; 
     int freehigh = system.freehigh; return 0; }"
    HAVE_SYSINFO_HIGH )

  if( WITH_SNMP )
    check_include_file( "net-snmp/net-snmp-config.h" HAVE_NET_SNMP_NET_SNMP_CONFIG_H )
    check_library_exists( netsnmp init_snmp "" HAVE_NETSNMP )
    if( HAVE_NET_SNMP_NET_SNMP_CONFIG_H AND HAVE_NETSNMP )
     set( NETSNMP_LIBRARIES netsnmp )
    else ()
      tde_message_fatal( "netsnmp is required, but was not found on your system" )
    endif ()
  endif( WITH_SNMP )

  check_library_exists( devstat selectdevs "" HAVE_DEVSTAT_SELECTDEVS )
  if( HAVE_DEVSTAT_SELECTDEVS )
    set( DEVSTAT_LIBRARIES devstat )
  else( )
    check_library_exists( devstat devstat_selectdevs "" HAVE_DEVSTAT_DEVSTAT_SELECTDEVS )
    if( HAVE_DEVSTAT_DEVSTAT_SELECTDEVS )
      set( DEVSTAT_LIBRARIES devstat )
    endif( )
  endif( HAVE_DEVSTAT_SELECTDEVS )

endif ( BUILD_KSIM )


##### superkaramba ##############################

if ( BUILD_SUPERKARAMBA )
  check_include_file( "sys/types.h" HAVE_SYS_TYPES_H )

  if( ${CMAKE_VERSION} VERSION_LESS "3.12" )
    find_package( PythonLibs )
    if( NOT PYTHONLIBS_FOUND )
      tde_message_fatal( "Python is required, but was not found on your system" )
    endif( NOT PYTHONLIBS_FOUND )
  else( )
    find_package( Python COMPONENTS Development )
    if( NOT Python_Development_FOUND )
      tde_message_fatal( "Python is required, but was not found on your system" )
    endif( )
    set( PYTHONLIBS_VERSION_STRING "${Python_VERSION}" )
    set( PYTHON_VERSION_STRING "${Python_VERSION}" )
    set( PYTHON_VERSION_MAJOR  "${Python_VERSION_MAJOR}" )
    set( PYTHON_VERSION_MINOR  "${Python_VERSION_MINOR}" )
    set( PYTHON_INCLUDE_DIRS   "${Python_INCLUDE_DIRS}" )
    set( PYTHON_LIBRARIES      "${Python_LIBRARIES}" )
  endif( )

  if( "${PYTHONLIBS_VERSION_STRING}" LESS "3" )
    tde_message_fatal( "Python3 is required, but was not found on your system" )
  endif( )

  if( WITH_TDENEWSTUFF )
    set( HAVE_TDENEWSTUFF 1 )
    set( TDENEWSTUFF_LIBRARIES tdenewstuff-shared )
  endif( WITH_TDENEWSTUFF )

  if( WITH_XMMS )
    set( HAVE_XMMS 1 )
  endif( WITH_XMMS )

  if( ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" )
    check_library_exists( kvm kvm_getswapinfo "" HAVE_LIBKVM )
    if( HAVE_LIBKVM )
      set( LIBKVM_LIBRARIES kvm )
    endif( )
  endif( )
endif ( BUILD_SUPERKARAMBA )