summaryrefslogtreecommitdiffstats
path: root/ConfigureChecks.cmake
blob: 21423943d4ff647d02006e4debcaac71875648d1 (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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
#################################################
#
#  (C) 2010-2011 Serghei Amelian
#  serghei (DOT) amelian (AT) gmail.com
#
#  Improvements and feedback are welcome
#
#  This file is released under GPL >= 2
#
#################################################

tde_setup_architecture_flags( )

include(TestBigEndian)
test_big_endian(WORDS_BIGENDIAN)

tde_setup_largefiles( )

check_symbol_exists( strlcpy "string.h" HAVE_STRLCPY_PROTO )
check_symbol_exists( strlcat "string.h" HAVE_STRLCAT_PROTO )

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

if( WITH_GCC_VISIBILITY )
  tde_setup_gcc_visibility( )
endif( )


if( BUILD_KMAIL )
  check_include_file( "byteswap.h" HAVE_BYTESWAP_H )
endif( )


if( BUILD_INDEXLIB OR BUILD_KMAIL )

  # check for stl coping with namespace std
  tde_save( CMAKE_CXX_FLAGS )
  check_cxx_source_compiles("
      #include <iterator>
      struct s : public std::iterator<std::forward_iterator_tag, int> {};
      int main(int, char**) { return 0; } "
      HAVE_STLNAMESPACE )
  tde_restore( CMAKE_CXX_FLAGS )
  if( HAVE_STLNAMESPACE )
    set( STD_NAMESPACE_PREFIX "std::" )
  endif( )

endif( )


if( BUILD_KMOBILE )
  # FIXME not checked because Gentoo don't provide baudboy.h
  check_include_file( "baudboy.h" HAVE_BAUDBOY_H )
endif( )


if( WITH_GNOKII AND (BUILD_KADDRESSBOOK OR BUILD_KMOBILE) )
  pkg_search_module( GNOKII gnokii )
  if( NOT GNOKII_FOUND )
    tde_message_fatal( "gnokii are requested, but was not found on your system" )
  else( )
    tde_save_and_set( CMAKE_REQUIRED_INCLUDES "${GNOKII_INCLUDE_DIRS}" )
    check_include_file( "gnokii.h" HAVE_GNOKII_H )
    tde_restore( CMAKE_REQUIRED_INCLUDES )
  endif( )
endif( )


if( (BUILD_LIBTDENETWORK OR BUILD_CERTMANAGER OR BUILD_KMAIL OR BUILD_KADDRESSBOOK OR BUILD_KONTACT) AND NOT HAVE_GPGME_0_4_BRANCH )

  message( STATUS "checking for 'gpgme'" )

  # check for gpgme
  pkg_search_module( GPGME gpgme )
  if( NOT GPGME_FOUND )

    # find gpgme-config
    find_program( GPGME_EXECUTABLE NAMES gpgme-config )
    if( NOT GPGME_EXECUTABLE )
      tde_message_fatal( "gpgme-config was NOT found.\n gpgme library is installed?" )
    endif( )

    macro( __run_gpgme_config  __type __var )
      execute_process(
        COMMAND ${GPGME_EXECUTABLE} --${__type}
        OUTPUT_VARIABLE ${__var}
        RESULT_VARIABLE __result
        OUTPUT_STRIP_TRAILING_WHITESPACE )
      if( _result )
        tde_message_fatal( "Unable to run ${GPGME_EXECUTABLE}!\n gpgme library incorrectly installed?\n Path to gpgme-config incorrect?" )
      endif( )
    endmacro( )

    __run_gpgme_config( version GPGME_VERSION )
    __run_gpgme_config( cflags GPGME_INCLUDE_DIRS )
    __run_gpgme_config( libs GPGME_LIBRARIES )

    if( GPGME_INCLUDE_DIRS )
      string( REGEX REPLACE "(^| +)-I" ";" GPGME_INCLUDE_DIRS "${GPGME_INCLUDE_DIRS}" )
    endif( )
    if( GPGME_LIBRARIES )
      string( REGEX REPLACE "(^| +)-l" ";" GPGME_LIBRARIES "${GPGME_LIBRARIES}" )
    endif( )

  endif()

  # check for gpg-error
  pkg_search_module( GPGERR gpg-error )
  if( NOT GPGERR_FOUND )

    # find gpg-error-config
    find_program( GPG_ERR_EXECUTABLE NAMES gpgrt-config gpg-error-config )
    if( NOT GPG_ERR_EXECUTABLE )
      tde_message_fatal( "gpgrt-config or gpg-error-config was NOT found.\n gpg-error library is installed?" )
    endif( )

    macro( __run_gpgerr_config  __type __var )
      execute_process(
        COMMAND ${GPG_ERR_EXECUTABLE} --${__type}
        OUTPUT_VARIABLE ${__var}
        RESULT_VARIABLE __result
        OUTPUT_STRIP_TRAILING_WHITESPACE )
      if( _result )
        tde_message_fatal( "Unable to run ${GPG_ERR_EXECUTABLE}!\n gpg-error library incorrectly installed?\n Path to gpgme-config are incorrect?" )
      endif( )
    endmacro( )

    __run_gpgerr_config( version GPGERR_VERSION )
    __run_gpgerr_config( cflags GPGERR_INCLUDE_DIRS )
    __run_gpgerr_config( libs GPGERR_LIBRARIES )

    if( GPGERR_INCLUDE_DIRS )
      string( REGEX REPLACE "(^| +)-I" ";" GPGERR_INCLUDE_DIRS "${GPGERR_INCLUDE_DIRS}" )
    endif( )
    if( GPGERR_LIBRARIES )
      string( REGEX REPLACE "(^| +)-l" ";" GPGERR_LIBRARIES "${GPGERR_LIBRARIES}" )
    endif( )

  endif()

  # assuming that all newer system have gpgme >= 0.4
  set( GPGME_INCLUDE_DIRS "${GPGME_INCLUDE_DIRS};${GPGERR_INCLUDE_DIRS}" CACHE INTERNAL "" FORCE )
  set( GPGME_LIBRARIES "${GPGME_LIBRARIES};${GPGERR_LIBRARIES}" CACHE INTERNAL "" FORCE )
  set( HAVE_GPGME_0_4_BRANCH 1 CACHE INTERNAL "" )
  message( STATUS "  found 'gpgme', version ${GPGME_VERSION}" )

  # check for various GPGME features
  tde_save( CMAKE_CXX_FLAGS )
  tde_save( CMAKE_REQUIRED_INCLUDES )
  tde_save( CMAKE_REQUIRED_LIBRARIES )
  set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LARGEFILES_DEFINITIONS}")
  set( CMAKE_REQUIRED_INCLUDES "${GPGME_INCLUDE_DIRS}")
  set( CMAKE_REQUIRED_LIBRARIES "${GPGME_LIBRARIES}")

  # check for GPGME_KEYLIST_MODE_VALIDATE
  check_cxx_source_compiles("
      #include <gpgme.h>
      int main() {
        gpgme_keylist_mode_t mode = GPGME_KEYLIST_MODE_VALIDATE;
      };"
      HAVE_GPGME_KEYLIST_MODE_VALIDATE )

  # check for gpgme_cancel
  check_cxx_source_compiles("
      #include <gpgme.h>
      int main() {
        gpgme_ctx_t ctx = 0;
        gpgme_error_t e = gpgme_cancel( ctx );
      };"
      HAVE_GPGME_CANCEL )

  # check for gpgme_key_t->keylist_mode
  check_cxx_source_compiles("
      #include <gpgme.h>
      int main() {
        gpgme_key_t key = 0;
        key->keylist_mode = 0;
      };"
      HAVE_GPGME_KEY_T_KEYLIST_MODE )

  # check for gpgme_decrypt_result_t->wrong_key_usage
  check_cxx_source_compiles("
      #include <gpgme.h>
      int main() {
        gpgme_decrypt_result_t res;
        unsigned int wku = res->wrong_key_usage;
      };"
      HAVE_GPGME_WRONG_KEY_USAGE )

  # check for GPGME_INCLUDE_CERTS_DEFAULT
  check_cxx_source_compiles("
      #include <gpgme.h>
      int main() {
        int i = GPGME_INCLUDE_CERTS_DEFAULT;
      };"
      HAVE_GPGME_INCLUDE_CERTS_DEFAULT )

  # check for gpgme_op_getauditlog
  check_cxx_source_compiles("
      #include <gpgme.h>
      int main() {
        gpgme_ctx_t ctx = 0;
        gpgme_data_t data = 0;
        unsigned int flags = 0;
        gpgme_error_t e = gpgme_op_getauditlog( ctx, data, flags );
      };"
      HAVE_GPGME_OP_GETAUDITLOG )

  # done checking for GPGME features
  tde_restore( CMAKE_CXX_FLAGS )
  tde_restore( CMAKE_REQUIRED_INCLUDES )
  tde_restore( CMAKE_REQUIRED_LIBRARIES )

endif( )


if( BUILD_KARM AND WITH_XSCREENSAVER )
  pkg_search_module( XSS xscrnsaver )

  if( XSS_FOUND )
    tde_save_and_set( CMAKE_REQUIRED_INCLUDES "${XSS_INCLUDE_DIRS}" )
    check_library_exists( Xss XScreenSaverQueryInfo "${XSS_LIBRARY_DIRS}" HAVE_XSSLIB )
    tde_restore( CMAKE_REQUIRED_INCLUDES )
  else( XSS_FOUND )
    check_library_exists( Xss XScreenSaverQueryInfo "" HAVE_XSSLIB )
  endif( XSS_FOUND )

  if( NOT HAVE_XSSLIB )
    check_library_exists( Xext XScreenSaverQueryInfo "$(XEXT_LIBRARY_DIRS}" HAVE_XSSLIB )
    if( HAVE_XSSLIB )
      pkg_search_module( XSS xext )
    endif( )
  endif( )

  check_include_file( X11/extensions/scrnsaver.h HAVE_XSCREENSAVER_H )
  if( HAVE_XSSLIB AND HAVE_XSCREENSAVER_H )
    set( HAVE_LIBXSS 1 )
  else( )
    tde_message_fatal( "xscreensaver is requested, but was not found on your system" )
  endif( )
endif( )

if( BUILD_TDERESOURCES AND WITH_GROUPWISE )
  check_symbol_exists( strrchr "string.h" HAVE_STRRCHR )
  check_symbol_exists( strtod "stdlib.h" HAVE_STRTOD )
  check_symbol_exists( sscanf "stdio.h" HAVE_SSCANF )
  check_symbol_exists( strtol "stdlib.h" HAVE_STRTOL )
  check_symbol_exists( strtoul "stdlib.h" HAVE_STRTOUL )
  check_symbol_exists( strtoll "stdlib.h" HAVE_STRTOLL )
  check_symbol_exists( strtoull "stdlib.h" HAVE_STRTOULL )
  check_symbol_exists( gettimeofday "sys/time.h" HAVE_GETTIMEOFDAY )
  check_include_file( "sys/timeb.h" HAVE_SYS_TIMEB_H )
  check_symbol_exists( ftime "sys/timeb.h" HAVE_FTIME )
  check_symbol_exists( rand_r "stdlib.h" HAVE_RAND_R )
  check_symbol_exists( gmtime_r "time.h" HAVE_GMTIME_R )
  check_symbol_exists( localtime_r "time.h" HAVE_LOCALTIME_R )
  check_symbol_exists( timegm "time.h" HAVE_TIMEGM )
  check_symbol_exists( wctomb "stdlib.h" HAVE_WCTOMB )
  check_symbol_exists( mbtowc "stdlib.h" HAVE_MBTOWC )
  check_symbol_exists( isnan "math.h" HAVE_ISNAN )
endif ( )

# required stuff
find_package( TQt )
find_package( TDE )