summaryrefslogtreecommitdiffstats
path: root/ConfigureChecks.cmake
blob: bab3b80db13860650d9f0e98cbe2931f5b1f69bc (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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
#################################################
#
#  (C) 2010 Serghei Amelian
#  serghei (DOT) amelian (AT) gmail.com
#
#  Improvements and feedback are welcome
#
#  This file is released under GPL >= 2
#
#################################################

# required stuff
find_package( TQt )
find_package( TDE )

tde_setup_architecture_flags( )

include(TestBigEndian)
test_big_endian(WORDS_BIGENDIAN)

tde_setup_largefiles( )


##### check for gcc visibility support

if( WITH_GCC_VISIBILITY )
  tde_setup_gcc_visibility( )
endif( WITH_GCC_VISIBILITY )


find_package( Threads )
find_package( X11 )

check_type_size( "int" SIZEOF_INT BUILTIN_TYPES_ONLY )
check_type_size( "long" SIZEOF_LONG BUILTIN_TYPES_ONLY )

check_include_file( stdint.h HAVE_STDINT_H )
check_include_file( systems.h HAVE_SYSTEMS_H )

##### check for inotify ###########################

if( WITH_INOTIFY )
  check_include_file( "inotify.h" INOTIFY_FOUND )
  check_include_file( "sys/inotify.h" INOTIFY_SYS_FOUND )
  if( NOT INOTIFY_FOUND )
    if( NOT INOTIFY_SYS_FOUND )
      message(FATAL_ERROR "\ninotify support was requested, but inotify was not found on your system" )
    endif( NOT INOTIFY_SYS_FOUND )
  endif( NOT INOTIFY_FOUND )
  if( INOTIFY_FOUND )
      set( HAVE_INOTIFY 1 )
  endif( INOTIFY_FOUND )
  if( INOTIFY_SYS_FOUND )
      set( HAVE_INOTIFY 1 )
      set( HAVE_SYS_INOTIFY 1 )
  endif( INOTIFY_SYS_FOUND )
endif( )

check_function_exists( statvfs HAVE_STATVFS )


# sched_setaffinity buggy glibc check
check_c_source_compiles("
  #define _GNU_SOURCE
  #include <sched.h>
  int main() {
    cpu_set_t mask;
    CPU_ZERO(&mask);
    CPU_SET(0, &mask);
    sched_setaffinity(0, sizeof(mask), &mask);
    return 0;
  } "
  SCHEDAFFINITY_3PARAMS )

if( SCHEDAFFINITY_3PARAMS )
  set( SCHEDAFFINITY_SUPPORT 1 )
else( )
  check_c_source_compiles("
  #define _GNU_SOURCE
  #include <sched.h>
  int main() {
    cpu_set_t mask;
    CPU_ZERO(&mask);
    CPU_SET(0, &mask);
    sched_setaffinity(0, &mask);
    return 0;
  } "
  SCHEDAFFINITY_SUPPORT )
endif( )


# fabsf
tde_save( CMAKE_REQUIRED_LIBRARIES )
set( CMAKE_REQUIRED_LIBRARIES m )
check_function_exists( fabsf HAVE_FABSF )
tde_restore( CMAKE_REQUIRED_LIBRARIES )


# taglib
pkg_search_module( TAGLIB taglib )
if( TAGLIB_FOUND )
  if( ${TAGLIB_VERSION} VERSION_LESS "1.5" )
    tde_message_fatal( "taglib version must be at least 1.5" )
  else( )
    set( TAGLIB_15 1 )
    message( STATUS "Found TAGLIB: ${TAGLIB_INCLUDE_DIRS}" )
  endif( )
else( )
  tde_message_fatal( "taglib is required, but not found on your system" )
endif( )


# libvisual
if( WITH_LIBVISUAL )

  pkg_search_module( SDL sdl )
  if( NOT SDL_FOUND )
    check_include_file( SDL/SDL.h HAVE_SDL_H )
    if( NOT HAVE_SDL_H )
      tde_message_fatal( "SDL is required, but not found on your system" )
    endif ( )
    set ( SDL_INCLUDE_DIRS /usr/include/SDL )
    set ( SDL_LIBRARIES SDL pthread )
  endif( )

  pkg_search_module( LIBVISUAL libvisual-0.4 )
  if( LIBVISUAL_FOUND )
    if( ${LIBVISUAL_VERSION} VERSION_LESS "0.4.0" )
      tde_message_fatal( "libvisual version must be at least 0.4.0" )
    endif( )
  else( )
    tde_message_fatal( "libvisual is requested, but not found on your system" )
  endif( )
  set( HAVE_LIBVISUAL 1 )

endif( )


# xine-engine
if( WITH_XINE )
  pkg_search_module( XINE libxine )
  if( XINE_FOUND )
    if( ${XINE_VERSION} VERSION_LESS "1.0.2" )
      tde_message_fatal( "your xine version is too old; at least 1.0.2 is required" )
    endif( )
  else( )
    tde_message_fatal( "xine is requested, but was not found on your system" )
  endif( )
endif( )

# akode-engine
if( WITH_AKODE )
  pkg_search_module( AKODE akode )
  if( AKODE_FOUND )
    if( ${AKODE_VERSION} VERSION_LESS "2.0.0" )
      tde_message_fatal( "your akode version is too old; at least 2.0.0 is required" )
    endif( )
  else( )
    tde_message_fatal( "akode is requested, but was not found on your system" )
  endif( )
endif( )


##### check for libgpod - iPod

if( WITH_IPOD )

pkg_search_module( GLIB2 glib-2.0 )

  pkg_search_module( GPOD libgpod-1.0 )
  if( GPOD_FOUND )
    if( ${GPOD_VERSION} VERSION_LESS "0.4.2" )
      tde_message_fatal( "your libgpod version is too old; at least 0.4.2 is required" )
    elseif( NOT ${GPOD_VERSION} VERSION_LESS "0.6.0" )
      set( HAVE_GPOD_060 1 )
    endif( )
  else( )
    tde_message_fatal( "libgpod-1.0 is requested, but was not found on your system" )
  endif( )

  tde_save( CMAKE_REQUIRED_INCLUDES )
  set( CMAKE_REQUIRED_INCLUDES ${GPOD_INCLUDE_DIRS} )
  check_struct_has_member( "struct _Itdb_Track" mediatype "gpod/itdb.h" HAVE_ITDB_MEDIATYPE )
  tde_restore( CMAKE_REQUIRED_INCLUDES )

  set( GPOD_LIBRARY gpod )

endif( )


if( WITH_OPENGL )
set( OpenGL_GL_PREFERENCE LEGACY )
find_package( GLUT )
find_package( OpenGL )

##### check for OpenGL support within tqt

tde_save( CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_LIBRARIES )
set( CMAKE_REQUIRED_INCLUDES ${TQT_INCLUDE_DIRS} )
foreach( _dirs ${TQT_LIBRARY_DIRS} )
  list( APPEND CMAKE_REQUIRED_LIBRARIES "-L${_dirs}" )
endforeach()
list( APPEND CMAKE_REQUIRED_LIBRARIES ${TQT_LIBRARIES} )

check_cxx_source_compiles("
#include <cstdlib>
#include <tqgl.h>
int main( int, char** )
{
	(void) new TQGLWidget( (TQWidget*)0, \"qgl\" ) ;
	return EXIT_SUCCESS ;
}"
HAVE_TQGLWIDGET )

tde_restore( CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_LIBRARIES )
endif( WITH_OPENGL )


# konqsidebarplugin.h
if( WITH_KONQSIDEBAR )
  tde_save( CMAKE_REQUIRED_DEFINITIONS CMAKE_REQUIRED_FLAGS CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_LIBRARIES )
  set( CMAKE_REQUIRED_DEFINITIONS ${TQT_CFLAGS_OTHER} )
  set( CMAKE_REQUIRED_INCLUDES ${TDE_INCLUDE_DIR};${TQT_INCLUDE_DIRS};${CMAKE_INCLUDE_PATH} )
  set( CMAKE_REQUIRED_FLAGS "-include tqt.h" )
  foreach( _dirs ${TQT_LIBRARY_DIRS} )
    list( APPEND CMAKE_REQUIRED_LIBRARIES "-L${_dirs}" )
  endforeach()
  list( APPEND CMAKE_REQUIRED_LIBRARIES ${TQT_LIBRARIES} )
  check_cxx_source_compiles("
    #include <konqsidebarplugin.h>
    int main(int, char**) { return 0; } "
    HAVE_KONQSIDEBARPLUGIN_H )
  tde_restore( CMAKE_REQUIRED_DEFINITIONS CMAKE_REQUIRED_FLAGS CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_LIBRARIES )
  if( NOT HAVE_KONQSIDEBARPLUGIN_H )
    tde_message_fatal( "Konqueror sidebar is requested, but konqsidebarplugin.h was not found on your system" )
  endif( )
endif( )


if( WITH_MP4V2 )
##### check for mp4v2

check_include_file( "mp4v2/mp4v2.h" MP4V2_H_FOUND )
if( MP4V2_H_FOUND )
    set( HAVE_MP4V2_H 1)

    find_path( MP4V2_INCLUDE_DIR "mp4v2/mp4v2.h" )
    set( MP4V2_INCLUDE_DIRS "${MP4V2_INCLUDE_DIR}" )

    find_library( MP4V2_LIBRARY mp4v2 )
    set( MP4V2_LIBRARIES "${MP4V2_LIBRARY}" )
endif()

check_include_file( "mp4.h" MP4_H_FOUND )
if( MP4_H_FOUND )
    set( HAVE_MP4_H 1)

    find_path( MP4_INCLUDE_DIR "mp4.h" )
    set( MP4V2_INCLUDE_DIRS "${MP4_INCLUDE_DIR}" )

    find_library( MP4_LIBRARY mp4 )
    set( MP4V2_LIBRARIES "${MP4_LIBRARY}" )
endif()

if( HAVE_MP4V2_H OR HAVE_MP4_H )
    set( HAVE_MP4V2 1 )
  else()
    tde_message_fatal( "MP4V2 support was requested but was not found on your system" )
endif()
endif( WITH_MP4V2 )


if( WITH_MYSQL )
  #### check for MySql or Mariadb

  message( STATUS "Check for MariaDB or MySQL" )
  find_program( MYSQL_CONFIG NAMES mariadb_config mysql_config )

  if( NOT MYSQL_CONFIG )
    tde_message_fatal( "MySql support is requested but neither MySql or Mariadb have been found on your system" )
  else()

  macro( _mysql_config  __type __var )
    execute_process(
      COMMAND ${MYSQL_CONFIG} --${__type}
      OUTPUT_VARIABLE ${__var}
      RESULT_VARIABLE __result
      OUTPUT_STRIP_TRAILING_WHITESPACE )
    if( _result )
      tde_message_fatal( "Unable to run ${MYSQL_CONFIG}!" )
    endif()
  endmacro()

  _mysql_config( include MYSQL_INCLUDE_DIRS )
  _mysql_config( libs   MYSQL_LIBRARIES    )

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

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

  set( MYSQL_INCLUDE_DIRS "${MYSQL_INCLUDE_DIRS}" CACHE INTERNAL "" FORCE )
  set( MYSQL_LIBRARIES "${MYSQL_LIBRARIES}" CACHE INTERNAL "" FORCE )

  message( STATUS "    includes ${MYSQL_INCLUDE_DIRS} ")
  message( STATUS "    libraries ${MYSQL_LIBRARIES} ")
  set( USE_MYSQL 1 )

  tde_save_and_set( CMAKE_REQUIRED_INCLUDES ${MYSQL_INCLUDE_DIRS} )

  check_cxx_source_compiles("
    #include <mysql.h>
    typedef struct st_mysql MYSQL;
    int main(int, char**)
    {
	 return 1;
    }"
    HAVE_STRUCT_ST_MYSQL )

  if( HAVE_STRUCT_ST_MYSQL )
    set( MYSQL_STRUCT "st_mysql" )
  else()
    check_cxx_source_compiles("
      #include <mysql.h>
      typedef struct MYSQL MYSQL;

      int main()
      {
        return 1;
      }"
      HAVE_STRUCT_MYSQL )

    if( HAVE_STRUCT_MYSQL )
      set( MYSQL_STRUCT "MYSQL" )
    else()
      tde_message_fatal( "MySQL is requested, but it is not possible to determine the type of MySQL structure" )
    endif()
  endif()

  tde_restore( CMAKE_REQUIRED_INCLUDES )

  endif( NOT MYSQL_CONFIG )

endif( WITH_MYSQL )


if( WITH_POSTGRESQL )
##### check for PostgreSQL

  message( STATUS "Check for PostgreSQL" )
  find_package( PostgreSQL )

  if( PostgreSQL_INCLUDE_DIR AND PostgreSQL_LIBRARY )
    message( STATUS "    includes ${PostgreSQL_INCLUDE_DIR} ")
    message( STATUS "    library ${PostgreSQL_LIBRARY} ")
    set( USE_POSTGRESQL 1 )
  else()
    pkg_search_module( LIBPQ libpq )

    if( NOT LIBPQ_FOUND )
      tde_message_fatal( "Postgresql support is requested but Postgresql was not found on your system." )
    endif()

    set( PostgreSQL_INCLUDE_DIR "${LIBPQ_INCLUDE_DIRS}" )
    set( PostgreSQL_LIBRARY "${LIBPQ_LIBRARIES}" )
    set( PostgreSQL_LIBRARY_DIRS "${LIBPQ_LIBRARY_DIRS}" )
    set( USE_POSTGRESQL 1 )
  endif()

endif( WITH_POSTGRESQL )


if( WITH_EMBEDDED_SQLITE )
  set( SQLITE_LIBRARIES sqlite-static )
  message( STATUS "sqlite3 linking: ${SQLITE_LIBRARIES}" )
endif()


if( WITH_SYSTEM_SQLITE )
##### check for sqlite3

pkg_search_module( SQLITE sqlite3 )
if( NOT SQLITE_FOUND )
    tde_message_fatal( "sqlite3 is required, but not found on your system" )
  else()
    message( STATUS "sqlite3 linking: ${SQLITE_LIBRARIES}" )
endif( )
endif( WITH_SYSTEM_SQLITE )

if( WITH_AMAZON )
    set( AMAZON_SUPPORT 1 )
endif()