summaryrefslogtreecommitdiffstats
path: root/ConfigureChecks.cmake
blob: eb8a0de26cc6d569ec8311ef3b57dc77d5b53725 (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
#################################################
#
#  (C) 2012 Serghei Amelian
#  serghei (DOT) amelian (AT) gmail.com
#
#  Improvements and feedback are welcome
#
#################################################

# required stuff
tde_setup_architecture_flags( )

include(TestBigEndian)
test_big_endian(WORDS_BIGENDIAN)

tde_setup_largefiles( )

if( NOT CMAKE_ARCHITECTURE )
  execute_process(
    COMMAND ${CMAKE_C_COMPILER} -dumpmachine
    OUTPUT_VARIABLE CMAKE_ARCHITECTURE
    ERROR_VARIABLE CMAKE_ARCHITECTURE
    OUTPUT_STRIP_TRAILING_WHITESPACE
    ERROR_STRIP_TRAILING_WHITESPACE )
  set( CMAKE_ARCHITECTURE "${CMAKE_ARCHITECTURE}" CACHE INTERNAL "" FORCE )
  message( STATUS "Detected ${CMAKE_ARCHITECTURE} target architecture" )
endif( NOT CMAKE_ARCHITECTURE )

if( ${CMAKE_ARCHITECTURE} MATCHES "i.86" )
  if( NOT ASM_COMPILER_VERSION )
    message( STATUS "Checking binutils version" )
    execute_process(
      COMMAND echo
      COMMAND as -v
      OUTPUT_VARIABLE ASM_VERSION
      ERROR_VARIABLE ASM_VERSION
    )
    string(REGEX REPLACE ".*version ([0-9][^ \n]*).*" "\\1" ASM_COMPILER_VERSION ${ASM_VERSION} )
    set( ASM_COMPILER_VERSION "${ASM_COMPILER_VERSION}" CACHE INTERNAL "" FORCE )
    message( STATUS "Checking binutils version - ${ASM_COMPILER_VERSION}" )
  endif( NOT ASM_COMPILER_VERSION )

  if( NOT MMX_SUPPORT )
    message( STATUS "Performing test MMX_SUPPORT" )
    if( ${ASM_COMPILER_VERSION} VERSION_LESS "2.10" )
      message( STATUS "Performing test MMX_SUPPORT - Failed" )
    else( )
      message( STATUS "Performing test MMX_SUPPORT - Success" )
      set( MMX_SUPPORT 1 CACHE INTERNAL "" FORCE )
    endif( )
  endif( NOT MMX_SUPPORT )

  check_c_source_compiles( "
    int main() {
      #if defined(__GNUC__) && defined(__i386__)
      __asm__(\"movups %xmm0, (%esp)\");
      #else
      #error Not gcc on x86
      #endif
      return 0; }"
    HAVE_X86_SSE
  )
endif( ${CMAKE_ARCHITECTURE} MATCHES "i.86" )

message( STATUS "Cheking system type - ${CMAKE_SYSTEM_NAME}" )
if( ${CMAKE_SYSTEM_NAME} MATCHES "AIX" )
  set( OS_AIX 1 )
elseif( ${CMAKE_SYSTEM_NAME} MATCHES "Linux" )
  set( OS_Linux 1 )
elseif( ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD|FreeBSD|DragonFly|NetBSD" )
  set( OS_BSD 1 )
elseif( ${CMAKE_SYSTEM_NAME} MATCHES "SunOS" )
  set( OS_SunOS 1 )
elseif( ${CMAKE_SYSTEM_NAME} MATCHES "IRIX" )
  set( OS_IRIX 1 )
elseif( ${CMAKE_SYSTEM_NAME} MATCHES "HPUX" )
  set( OS_HPUX 1 )
else( )
  message( WARNING "Unknown system type!" )
endif( )

find_package( TQt )
find_package( TDE )


##### check headers #############################

check_include_file( stdint.h HAVE_STDINT_H )
check_include_file( inttypes.h HAVE_INTTYPES_H )
check_include_file( getopt.h HAVE_GETOPT_H )
check_include_file( pthread.h HAVE_LIBPTHREAD )

check_include_file( alsa/asoundlib.h HAVE_ALSA_ASOUNDLIB_H )
check_include_file( sys/asoundlib.h HAVE_SYS_ASOUNDLIB_H )
check_include_file( soundcard.h HAVE_SOUNDCARD_H )
check_include_file( sys/soundcard.h HAVE_SYS_SOUNDCARD_H )
check_include_file( machine/soundcard.h HAVE_MACHINE_SOUNDCARD_H )


##### check libraries ###########################

set( DL_LIBRARIES dl )
check_library_exists( ${DL_LIBRARIES} dlopen /lib HAVE_LIBDL )
if( NOT HAVE_LIBDL )
  unset( DL_LIBRARIES )
  check_function_exists( dlopen HAVE_DLOPEN )
  if( HAVE_DLOPEN )
    set( HAVE_LIBDL 1 )
  endif( HAVE_DLOPEN )
endif( NOT HAVE_LIBDL )


# ALSA
if( WITH_ALSA )
  pkg_check_modules( ALSA alsa>=0.5 )
  if( NOT ALSA_FOUND )
    tde_message_fatal( "ALSA support is requested, but was not found on your system" )
  endif( NOT ALSA_FOUND )
  if( NOT ALSA_VERSION VERSION_LESS "0.9" )
    set( HAVE_LIBASOUND2 1 )
    set( HAVE_ARTS_LIBASOUND2 1 )
  else()
    set( HAVE_ARTS_LIBASOUND 1 )
  endif()
endif( WITH_ALSA )


# aRts
if( BUILD_ARTS OR BUILD_JUK OR BUILD_KABOODLE OR BUILD_KREC OR BUILD_NOATUN )
  pkg_search_module( ARTS arts )
  if( ARTS_FOUND )
    set( ARTS_MCOPIDL_EXECUTABLE ${ARTS_PREFIX}/bin/mcopidl )
    set( HAVE_ARTS 1 )
  else( ARTS_FOUND )
    tde_message_fatal( "aRts is required, but not found on your system" )
  endif( ARTS_FOUND )
endif( BUILD_ARTS OR BUILD_JUK OR BUILD_KABOODLE OR BUILD_KREC OR BUILD_NOATUN )

if( BUILD_KAUDIOCREATOR OR BUILD_KREC OR BUILD_KSCD OR (BUILD_TDEIOSLAVE AND WITH_CDPARANOIA) )
  pkg_search_module( ARTSC artsc )
  if( NOT ARTSC_FOUND )
    tde_message_fatal( "aRtsC is required, but not found on your system" )
  endif( NOT ARTSC_FOUND )
endif( BUILD_KAUDIOCREATOR OR BUILD_KREC OR BUILD_KSCD OR (BUILD_TDEIOSLAVE AND WITH_CDPARANOIA) )

if( (BUILD_ARTS AND WITH_ARTS_AKODE) OR BUILD_JUK )
  pkg_search_module( AKODE akode )
  if( NOT AKODE_FOUND )
    tde_message_fatal( "akode is required, but not found on your system" )
  endif( )
  set( HAVE_AKODE 1 )
endif( (BUILD_ARTS AND WITH_ARTS_AKODE) OR BUILD_JUK )


if( BUILD_ARTS )

  pkg_search_module( GLIB2 glib-2.0 )
  if( GLIB2_FOUND )
    pkg_search_module( GTHREAD2 gthread-2.0 )
    if( NOT GTHREAD2_FOUND )
      tde_message_fatal( "gthread-2.0 are required, but not found on your system" )
    endif( NOT GTHREAD2_FOUND )
  else( GLIB2_FOUND )
    tde_message_fatal( "glib-2.0 are required, but not found on your system" )
  endif( GLIB2_FOUND )

  if( WITH_ARTS_AUDIOFILE )
    pkg_search_module( AUDIOFILE audiofile )
    if( NOT AUDIOFILE_FOUND )
      tde_message_fatal( "audifile is requested, but not found on your system" )
    endif( )
  endif( WITH_ARTS_AUDIOFILE )

  if( WITH_ARTS_XINE )
    pkg_search_module( XINE libxine )
    pkg_search_module( XEXT xext )
    if( NOT XINE_FOUND )
      tde_message_fatal( "xine is requested, but not found on your system" )
    endif( )
  endif( WITH_ARTS_XINE )

endif( BUILD_ARTS )


# CDDA Paranoia
if( WITH_CDPARANOIA )
  if( CDPARANOIA_INCLUDE_DIR AND CDPARANOIA_LIBRARIES )
    set( CDPARANOIA_FOUND TRUE )
  else( )
    message( STATUS "Checking for CDParanonia" )
    find_path( CDPARANOIA_INCLUDE_DIR cdda_interface.h PATH_SUFFIXES cdda )
    find_library( CDPARANOIA_LIBRARY NAMES cdda_paranoia )
    find_library( CDPARANOIA_IF_LIBRARY NAMES cdda_interface )
    if( CDPARANOIA_LIBRARY AND CDPARANOIA_IF_LIBRARY )
      set( CDPARANOIA_LIBRARIES ${CDPARANOIA_LIBRARY} ${CDPARANOIA_IF_LIBRARY} "m" CACHE INTERNAL "" FORCE )
    endif( CDPARANOIA_LIBRARY AND CDPARANOIA_IF_LIBRARY )

    include(FindPackageHandleStandardArgs)
    find_package_handle_standard_args( CDPARANOIA DEFAULT_MSG
                                       CDPARANOIA_LIBRARIES
                                       CDPARANOIA_INCLUDE_DIR )

    if( CDPARANOIA_FOUND )
      tde_save_and_set( CMAKE_REQUIRED_INCLUDES ${CDPARANOIA_INCLUDE_DIR} )
      check_c_source_compiles( "
        #include <cdda_interface.h>
        int main() {
            struct cdrom_drive device;
            device.cdda_device_name = 0;
            return 0;
        }"
        CDPARANOIA_DEVICE_NAME )
      tde_restore( CMAKE_REQUIRED_INCLUDES )
      if( NOT CDPARANOIA_DEVICE_NAME )
        tde_message_fatal( "CDParanoia is too old and can not be used" )
      endif( )
    endif( CDPARANOIA_FOUND )
  endif( )

  if( NOT CDPARANOIA_FOUND )
    tde_message_fatal( "CDParanoia is requested, but not found on your system" )
  endif( NOT CDPARANOIA_FOUND )
  set( CDDA_PARANOIA 1 )
endif( WITH_CDPARANOIA )


# FLAC
if( WITH_FLAC )
  pkg_search_module( FLAC flac )
  if( NOT FLAC_FOUND )
    tde_message_fatal( "FLAC is requested, but not found on your system" )
  endif( )
  set( HAVE_LIBFLAC 1 )
endif( WITH_FLAC )


# OGG/Vorbis
if( WITH_VORBIS )

  pkg_search_module( OGG ogg )
  if( NOT OGG_FOUND )
    tde_message_fatal( "Ogg/Vorbis support are requested, but `libogg` not found" )
  endif( )

  pkg_search_module( VORBIS vorbis )
  if( NOT VORBIS_FOUND )
    tde_message_fatal( "Ogg/Vorbis support are requested, but `libvorbis` not found" )
  endif( )

  pkg_search_module( VORBISFILE vorbisfile )
  if( NOT VORBISFILE_FOUND )
    tde_message_fatal( "Ogg/Vorbis support are requested, but `libvorbisfile` not found" )
  endif( )

  pkg_search_module( VORBISENC vorbisenc )
  if( NOT VORBISENC_FOUND )
    tde_message_fatal( "Ogg/Vorbis support are requested, but `libvorbisenc` not found" )
  endif( )

  check_library_exists( vorbis vorbis_bitrate_addblock "${VORBIS_LIBRARY_DIRS}" HAVE_VORBIS_2 )
  if( HAVE_VORBIS_2 )
    set( HAVE_VORBIS 2 )
  else( )
    set( HAVE_VORBIS 1 )
  endif( )
  set( OGG_VORBIS 1 )

endif( WITH_VORBIS )


# LAME
if( WITH_LAME )

  check_include_file( lame/lame.h HAVE_LAME_H )
  if( NOT HAVE_LAME_H )
    tde_message_fatal( "lame is requested, but not found on your system" )
  endif( )
  check_library_exists( mp3lame lame_init "" HAVE_LAME )
  if( NOT HAVE_LAME )
    tde_message_fatal( "mp3lame is requested, but not found on your system" )
  endif( )
  set( LAME_LIBRARIES mp3lame CACHE INTERNAL "" FORCE )

endif( WITH_LAME )


# taglib
if( BUILD_JUK OR WITH_TAGLIB )

  pkg_search_module( TAGLIB taglib )
  if( NOT TAGLIB_FOUND )
    tde_message_fatal( "taglib is required, but not found on your system" )
  endif( NOT TAGLIB_FOUND )

  tde_save_and_set( CMAKE_REQUIRED_INCLUDES ${TAGLIB_INCLUDE_DIRS} )
  check_include_file_cxx( taglib/mpcfile.h HAVE_TAGLIB_MPC_H )
  tde_restore( CMAKE_REQUIRED_INCLUDES )

endif( BUILD_JUK OR WITH_TAGLIB )