Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/openal-0.0.8/CMakeLists.txt @ 52

Last change on this file since 52 was 17, checked in by landauf, 17 years ago

added openal

File size: 24.3 KB
Line 
1# cmake project file by Prakash Punnoor
2CMAKE_MINIMUM_REQUIRED(VERSION 2.0)
3
4SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/admin/CMakeModules")
5PROJECT(OpenAL C)
6SET(PACKAGE "openal")
7SET(PACKAGE_TARNAME "openal")
8SET(PACKAGE_NAME "openal")
9SET(PACKAGE_MAJOR_VERSION "0")
10SET(PACKAGE_MINOR_VERSION "0")
11SET(PACKAGE_BUILD_VERSION "8")
12SET(PACKAGE_VERSION "${PACKAGE_MAJOR_VERSION}.${PACKAGE_MINOR_VERSION}.${PACKAGE_BUILD_VERSION}")
13
14SET(PACKAGE_STRING "openal")
15SET(PACKAGE_BUGREPORT "openal-devel@opensource.creative.com")
16SET(OPERATING_SYSTEM "${CMAKE_SYSTEM_NAME}")
17
18FIND_PACKAGE(ConfigHelper)
19
20MACRO(MACRO_TEST ARG VAR)
21CHECK_C_SOURCE_COMPILES(
22"#ifndef ${ARG}
23#error ${ARG} macro not defined
24#endif
25int main(){}
26" ${VAR})
27ENDMACRO(MACRO_TEST ARG VAR)
28
29
30ADD_DEFINE("PACKAGE_VERSION \"${PACKAGE_VERSION}\"")
31
32# We need ISO C99 features (e.g. snprintf) and POSIX IEEE Std 1003.1b-1993
33# features (e.g. struct timespec, used in <alsa/asoundlib.h>)
34ADD_DEFINITIONS(-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=199309)
35
36ADD_DEFINE("SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P}")
37
38INCLUDE(${CMAKE_ROOT}/Modules/CheckCSourceCompiles.cmake)
39INCLUDE(${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
40INCLUDE(${CMAKE_ROOT}/Modules/CheckLibraryExists.cmake)
41INCLUDE(${CMAKE_ROOT}/Modules/TestBigEndian.cmake)
42
43INCLUDE_DIRECTORIES(${OpenAL_SOURCE_DIR}/common/include)
44INCLUDE_DIRECTORIES(${OpenAL_SOURCE_DIR}/include)
45INCLUDE_DIRECTORIES(${OpenAL_SOURCE_DIR}/src)
46INCLUDE_DIRECTORIES(${OpenAL_SOURCE_DIR}/src/arch)
47
48
49SET(AL_OBJS              src/al_bpool.c
50                         src/al_buffer.c
51                         src/al_config.c
52                         src/al_debug.c
53                         src/al_distance.c
54                         src/al_error.c
55                         src/al_ext.c
56                         src/al_filter.c
57                         src/al_listen.c
58                         src/al_main.c
59                         src/al_mixer.c
60                         src/al_mixfunc.c
61                         src/al_mixmanager.c
62                         src/al_mspool.c
63                         src/al_mutexlib.c
64                         src/al_queue.c
65                         src/al_rctree.c
66                         src/al_rcvar.c
67                         src/al_source.c
68                         src/al_spool.c
69                         src/al_state.c
70                         src/al_threadlib.c
71                         src/al_vector.c
72                         src/al_matrix.c
73                         src/mixaudio16.c
74                         src/backends/alc_backend.c)
75
76SET(ALC_OBJS             src/alc/alc_context.c
77                         src/alc/alc_speaker.c
78                         src/alc/alc_error.c
79                         src/alc/alc_device.c)
80
81SET(AC_OBJS              src/audioconvert/ac_misc.c
82                         src/audioconvert/ac_freq.c
83                         src/audioconvert/ac_bits.c
84                         src/audioconvert/ac_channels.c
85                         src/audioconvert/ac_helper.c
86                         src/audioconvert/ac_adpcm.c
87                         src/audioconvert/ac_endian.c)
88
89SET(EXT_OBJS             src/extensions/al_ext_loki.c
90                         src/extensions/al_ext_capture.c)
91
92SET(MP3_OBJS             src/extensions/al_ext_mp3.c)
93SET(VORBIS_OBJS          src/extensions/al_ext_vorbis.c)
94
95SET(BSD_OBJS             src/backends/alc_backend_bsd.c)
96SET(DARWIN_OBJS          src/backends/alc_backend_darwin.c)
97SET(DMEDIA_OBJS          src/backends/alc_backend_irix.c)
98SET(LINUX_OBJS           src/backends/alc_backend_linux.c)
99SET(MORPHOS_OBJS         src/backends/alc_backend_morphos.c)
100SET(SOLARIS_OBJS         src/backends/alc_backend_solaris.c)
101SET(WINDOWS_OBJS         src/backends/alc_backend_windows.c)
102SET(ALSA_OBJS            src/backends/alc_backend_alsa.c)
103SET(ARTS_OBJS            src/backends/alc_backend_arts.c)
104SET(ESD_OBJS             src/backends/alc_backend_esd.c)
105SET(NULL_OBJS            src/backends/alc_backend_null.c)
106SET(SDL_OBJS             src/backends/alc_backend_sdl.c)
107SET(WAVEOUT_OBJS         src/backends/alc_backend_wave.c)
108
109SET(x86_OBJS             src/arch/i386/x86_floatmul.c
110                         src/arch/i386/x86_cpu_caps_prk.c)
111SET(x86_MMX_OBJS         src/arch/i386/mixaudio16_mmx_prk.c)
112SET(x86_NASM_OBJS        src/arch/i386/x86_cpu_caps_detect_prk.nasm)
113SET(x86_MMX_NASM_OBJS    src/arch/i386/memcpy_mmx_prk.nasm)
114
115SET(PORTABLE_OBJS        src/arch/portable/floatmul.c
116                         src/arch/portable/cpu_caps.c)
117
118
119SET(ADD_CFLAGS "")
120SET(ADD_LIBS "")
121SET(ADD_LDFLAGS "")
122SET(ADD_WFLAGS "")
123
124IF(CMAKE_UNAME)
125  EXEC_PROGRAM(uname ARGS -m OUTPUT_VARIABLE CMAKE_SYSTEM_MACHINE)
126ELSE(CMAKE_UNAME)
127  MESSAGE("Could not detect machine type")
128ENDIF(CMAKE_UNAME)
129
130IF(CMAKE_SYSTEM MATCHES CYGWIN OR CMAKE_SYSTEM MATCHES MINGW)
131  SET(CMAKE_SYSTEM Windows)
132  IF(CMAKE_SYSTEM MATCHES CYGWIN)
133    SET(CYGWIN ON)
134  ELSE(CMAKE_SYSTEM MATCHES CYGWIN)
135    SET(MINGW ON)
136  ENDIF(CMAKE_SYSTEM MATCHES CYGWIN)
137ENDIF(CMAKE_SYSTEM MATCHES CYGWIN OR CMAKE_SYSTEM MATCHES MINGW)
138
139
140TEST_BIG_ENDIAN(CMAKE_WORDS_BIGENDIAN)
141
142IF(CMAKE_WORDS_BIGENDIAN)
143  ADD_DEFINE(WORDS_BIGENDIAN)
144ENDIF(CMAKE_WORDS_BIGENDIAN)
145
146
147OPTION(BUILD_STATIC "build static library too" ON)
148OPTION(BUILD_TESTS  "build the test-suite"     OFF)
149OPTION(PROFILE      "enable profile"           OFF)
150OPTION(OPTIMIZATION "enable optimization"      ON)
151OPTION(DEBUG        "enable debug"             OFF)
152OPTION(WARNINGS     "enable warnings"          ON)
153
154# sound backends
155IF(CMAKE_SYSTEM MATCHES "Linux")
156  OPTION(ALSA        "alsa back-end"         ON)
157  OPTION(ALSA_DLOPEN "alsa dynamic loading"  ON)
158ENDIF(CMAKE_SYSTEM MATCHES "Linux")
159
160#IF(WIN32)
161#  OPTION(DSOUND      "directsound back-end"  OFF)
162#ENDIF(WIN32)
163
164OPTION(NATIVE      "native/oss back-end"  ON)
165OPTION(ARTS        "arts back-end"        ON)
166OPTION(ARTS_DLOPEN "arts dynamic loading" ON)
167OPTION(DMEDIA      "DMedia/Irix back-end" ON)
168OPTION(ESD         "esd back-end"         ON)
169OPTION(ESD_DLOPEN  "esd dynamic loading"  ON)
170OPTION(SDL         "sdl back-end"         ON)
171OPTION(SDL_DLOPEN  "sdl dynamic loading"  ON)
172OPTION(WAVEOUT     "wave out back-end"    ON)
173OPTION(NULLOUT     "null out back-end"    ON)
174
175# additional codecs
176OPTION(VORBIS         "vorbis support"          ON)
177OPTION(VORBIS_DLOPEN  "vorbis dynamic loading"  ON)
178OPTION(MP3            "mp3 support"             ON)
179OPTION(MP3_DLOPEN     "mp3 dynamic loading"     ON)
180
181IF(DEBUG)
182  ADD_DEFINE(DEBUG)
183  IF(WARNINGS)
184    OPTION(MORE_WARNINGS "enable more warnings"         OFF)
185    OPTION(USE_WERROR    "enable fail on all warning"   OFF)
186  ENDIF(WARNINGS)
187
188  OPTION(EFENCE          "enable efence support"        OFF)
189  OPTION(DEBUG_MAXIMUS   "enable all debugging"         OFF)
190  OPTION(DEBUG_STUB      "enable stub debugging"        OFF)
191  OPTION(DEBUG_LOOP      "enable looping debugging"     OFF)
192  OPTION(DEBUG_CONVERT   "enable convertion debugging"  OFF)
193  OPTION(DEBUG_CONFIG    "enable config file debugging" OFF)
194  OPTION(DEBUG_LOCK      "enable lock debugging"        OFF)
195  OPTION(DEBUG_EXT       "enable extension debugging"   OFF)
196  OPTION(DEBUG_BUFFER    "enable buffer debugging"      OFF)
197  OPTION(DEBUG_SOURCE    "enable source debugging"      OFF)
198  OPTION(DEBUG_MIXER     "enable mixer debugging"       OFF)
199  OPTION(DEBUG_STREAMING "enable streaming debugging"   OFF)
200  OPTION(DEBUG_MATH      "enable math debugging"        OFF)
201  OPTION(DEBUG_MEM       "enable mem debugging"         OFF)
202  OPTION(DEBUG_CONTEXT   "enable context debugging"     OFF)
203  OPTION(DEBUG_QUEUE     "enable queue debugging"       OFF)
204  OPTION(DEBUG_FILTER    "enable filter debugging"      OFF)
205
206  IF(EFENCE)
207    FIND_LIBRARY(EFENCE_LIB NAMES efence PATHS /usr/lib /usr/local/lib)
208    IF(EFENCE_LIB MATCHES "NOTFOUND")
209      MESSAGE("Electric Fence not installed - disabled.")
210      SET(EFENCE OFF CACHE BOOL "" FORCE)
211    ELSE(EFENCE_LIB MATCHES "NOTFOUND")
212
213      SET(ADD_LIBS ${ADD_LIBS} ${EFENCE_LIB})
214    ENDIF(EFENCE_LIB MATCHES "NOTFOUND")
215  ENDIF(EFENCE)
216
217  MACRO(CHECK_DEBUG DEBUG_OPTION)
218  IF(${DEBUG_OPTION})
219    ADD_DEFINE(${DEBUG_OPTION})
220  ENDIF(${DEBUG_OPTION})
221  ENDMACRO(CHECK_DEBUG)
222
223  CHECK_DEBUG(DEBUG_MAXIMUS)
224  CHECK_DEBUG(DEBUG_STUB)
225  CHECK_DEBUG(DEBUG_LOOP)
226  CHECK_DEBUG(DEBUG_CONVERT)
227  CHECK_DEBUG(DEBUG_CONFIG)
228  CHECK_DEBUG(DEBUG_LOCK)
229  CHECK_DEBUG(DEBUG_EXT)
230  CHECK_DEBUG(DEBUG_BUFFER)
231  CHECK_DEBUG(DEBUG_SOURC)
232  CHECK_DEBUG(DEBUG_MIXER)
233  CHECK_DEBUG(DEBUG_STREAMING)
234  CHECK_DEBUG(DEBUG_MATH)
235  CHECK_DEBUG(DEBUG_MEM)
236  CHECK_DEBUG(DEBUG_CONTEXT)
237  CHECK_DEBUG(DEBUG_QUEUE)
238  CHECK_DEBUG(DEBUG_FILTER)
239ELSE(DEBUG)
240
241  ADD_DEFINITIONS(-DNDEBUG)
242ENDIF(DEBUG)
243
244
245# library stuff
246CHECK_LIBRARY_EXISTS("m" "sin" "" HAVE_LIB_M)
247IF(HAVE_LIB_M)
248  SET(ADD_LIBS ${ADD_LIBS} m)
249ELSE(HAVE_LIB_M)
250
251  IF(NOT CMAKE_SYSTEM MATCHES "Darwin")
252    MESSAGE(FATAL_ERROR "libm not found.")
253  ENDIF(NOT CMAKE_SYSTEM MATCHES "Darwin")
254ENDIF(HAVE_LIB_M)
255
256
257CHECK_INCLUDE_FILE("dlfcn.h" HAVE_DL)
258IF(HAVE_DL)
259  CHECK_LIBRARY_EXISTS("dl" "dlopen" "" HAVE_LIB_DL)
260  IF(HAVE_LIB_DL)
261    SET(ADD_LIBS ${ADD_LIBS} dl)
262  ENDIF(HAVE_LIB_DL)
263ELSE(HAVE_DL)
264
265  ADD_DEFINE(NODLOPEN)
266  MESSAGE("Dynamic loading of libraries is not available.")
267ENDIF(HAVE_DL)
268
269
270# Special OS objs for target systems
271IF(NATIVE)
272IF(CMAKE_SYSTEM MATCHES "Linux")
273  ADD_DEFINE(USE_BACKEND_NATIVE_IRIX)
274  SET(OS_OBJS ${LINUX_OBJS})
275ELSE(CMAKE_SYSTEM MATCHES "Linux")
276
277IF(CMAKE_SYSTEM MATCHES "BSD")
278  ADD_DEFINE(USE_BACKEND_NATIVE_BSD)
279  SET(OS_OBJS ${BSD_OBJS})
280ELSE(CMAKE_SYSTEM MATCHES "BSD")
281
282IF(CMAKE_SYSTEM MATCHES "SunOS")
283  ADD_DEFINE(USE_BACKEND_NATIVE_SOLARIS)
284  SET(OS_OBJS ${SOLARIS_OBJS})
285ELSE(CMAKE_SYSTEM MATCHES "SunOS")
286
287IF(CMAKE_SYSTEM MATCHES "Windows")
288  ADD_DEFINE(USE_BACKEND_NATIVE_WINDOWS)
289  SET(OS_OBJS ${WINDOWS_OBJS})
290  # need winmm library for waveOutOpen etc.
291  SET(ADD_LIBS ${ADD_LIBS} winmm)
292ELSE(CMAKE_SYSTEM MATCHES "Windows")
293
294IF(CMAKE_SYSTEM MATCHES "Darwin")
295  ADD_DEFINE(USE_BACKEND_NATIVE_DARWIN)
296  SET(OS_OBJS ${DARWIN_OBJS})
297  #FIXME
298  SET(ADD_LDFLAGS "${ADD_LDFLAGS} -I/System/Library/Frameworks/CoreAudio.framework/Headers/ -framework CoreAudio")
299ELSE(CMAKE_SYSTEM MATCHES "Darwin")
300
301IF(CMAKE_SYSTEM MATCHES "morphos")
302  ADD_DEFINE(USE_BACKEND_NATIVE_MORPHOS)
303  SET(OS_OBJS ${MORPHOS_OBJS})
304ELSE(CMAKE_SYSTEM MATCHES "morphos")
305
306  MESSAGE("unknown System")
307  SET(OS_OBJS ${LINUX_OBJS})
308ENDIF(CMAKE_SYSTEM MATCHES "morphos")
309ENDIF(CMAKE_SYSTEM MATCHES "Darwin")
310ENDIF(CMAKE_SYSTEM MATCHES "Windows")
311ENDIF(CMAKE_SYSTEM MATCHES "SunOS")
312ENDIF(CMAKE_SYSTEM MATCHES "BSD")
313ENDIF(CMAKE_SYSTEM MATCHES "Linux")
314ENDIF(NATIVE)
315
316# threads handling
317IF(CMAKE_SYSTEM MATCHES "morphos")
318  CHECK_INCLUDE_FILE(dlfcn.h MOSTHREAD_AVAILABLE)
319ENDIF(CMAKE_SYSTEM MATCHES "morphos")
320
321IF(MOSTHREAD_AVAILABLE)
322  ADD_DEFINE(USE_MORPHOSTHREADING)
323ELSE(MOSTHREAD_AVAILABLE)
324
325  FIND_PACKAGE(Threads)
326  IF(CMAKE_USE_WIN32_THREADS_INIT)
327    ADD_DEFINE(USE_WINDOWSTHREADING)
328  ELSE(CMAKE_USE_WIN32_THREADS_INIT)
329
330  IF(CMAKE_USE_PTHREADS_INIT)
331    ADD_DEFINE(USE_POSIXTHREADING)
332    SET(ADD_LIBS ${ADD_LIBS} ${CMAKE_THREAD_LIBS_INIT})
333  ELSE(CMAKE_USE_PTHREADS_INIT)
334
335    ADD_DEFINE(NO_THREADING)
336  ENDIF(CMAKE_USE_PTHREADS_INIT)
337  ENDIF(CMAKE_USE_WIN32_THREADS_INIT)
338ENDIF(MOSTHREAD_AVAILABLE)
339
340# sound backends
341FIND_PACKAGE(PkgConfig)
342
343MACRO(CHECK_BACKEND BACKEND_OPTION BACKEND_NAME BACKEND_LIB BACKEND_HEADER BACKEND_TEST_FUNC)
344IF(${BACKEND_OPTION} AND NOT ${BACKEND_OPTION}_FOUND MATCHES "1${${BACKEND_OPTION}_DLOPEN}")
345  IF(CMAKE_PKGCONFIG_EXECUTABLE AND NOT ${BACKEND_NAME} MATCHES "^$")
346    PKGCONFIG(${BACKEND_NAME}
347              BACKEND_HAVE
348              BACKEND_INCLUDE_DIRS
349              BACKEND_DEFINES
350              BACKEND_LINK_DIRS
351              BACKEND_LIBS)
352
353    SET(${BACKEND_OPTION}_HAVE          ${BACKEND_HAVE}          CACHE INTERNAL "")
354    SET(${BACKEND_OPTION}_INCLUDE_DIRS "${BACKEND_INCLUDE_DIRS}" CACHE INTERNAL "")
355    SET(${BACKEND_OPTION}_DEFINES      "${BACKEND_DEFINES}"      CACHE INTERNAL "")
356    SET(${BACKEND_OPTION}_LINK_DIRS    "${BACKEND_LINK_DIRS}"    CACHE INTERNAL "")
357    SET(${BACKEND_OPTION}_LIBS         "${BACKEND_LIBS}"         CACHE INTERNAL "")
358
359    #MESSAGE("have ${${BACKEND_OPTION}_HAVE} inc ${${BACKEND_OPTION}_INCLUDE_DIRS} def ${${BACKEND_OPTION}_DEFINES} linkdirs ${${BACKEND_OPTION}_LINK_DIRS} libs ${${BACKEND_OPTION}_LIBS}")
360  ENDIF(CMAKE_PKGCONFIG_EXECUTABLE AND NOT ${BACKEND_NAME} MATCHES "^$")
361
362  SET(SOURCE
363"#include <${BACKEND_HEADER}>
364int main(){return 0;}
365")
366  # CHECK_INCLUDE_FILE() doesn't handle include dir, so check by hand
367  FILE(WRITE "${CMAKE_BINARY_DIR}/CMakeTmp/src.c" "${SOURCE}")
368
369  TRY_COMPILE(HAVE_BACKEND_HEADER
370              ${CMAKE_BINARY_DIR}
371              ${CMAKE_BINARY_DIR}/CMakeTmp/src.c
372              CMAKE_FLAGS
373              "-DINCLUDE_DIRECTORIES:STRING=${${BACKEND_OPTION}_INCLUDE_DIRS}"
374              "-DCOMPILE_DEFINITIONS:STRING=${${BACKEND_OPTION}_DEFINES}"
375              OUTPUT_VARIABLE OUTPUT)
376
377   WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeOutput.log
378              "Performing manual C SOURCE FILE Test HAVE_BACKEND_HEADER for ${BACKEND_OPTION} with the following output:\n"
379              "${OUTPUT}\n"
380              "Source file was:\n${SOURCE}\n" APPEND)
381
382  IF(HAVE_BACKEND_HEADER)
383    IF(HAVE_DL AND ${BACKEND_OPTION}_DLOPEN)
384      SET(${BACKEND_OPTION}_FOUND "1${${BACKEND_OPTION}_DLOPEN}" CACHE INTERNAL "")
385    ELSE(HAVE_DL AND ${BACKEND_OPTION}_DLOPEN)
386
387      IF(${BACKEND_OPTION}_LIBS MATCHES "^$")
388        FIND_LIBRARY(${BACKEND_OPTION}_LIBS NAMES ${BACKEND_LIB} PATHS /usr/lib /usr/local/lib)
389      ENDIF(${BACKEND_OPTION}_LIBS MATCHES "^$")
390
391      IF(${BACKEND_OPTION}_LIBS MATCHES "NOTFOUND")
392        MESSAGE(STATUS "${BACKEND_OPTION} library ${BACKEND_LIB} not found.")
393      ELSE(${BACKEND_OPTION}_LIBS MATCHES "NOTFOUND")
394
395        # check whether back-end is link-able
396        SET(SOURCE
397"int main(){${BACKEND_TEST_FUNC}();return 0;}
398")
399        FILE(WRITE "${CMAKE_BINARY_DIR}/CMakeTmp/src.c" "${SOURCE}")
400
401        TRY_COMPILE(BACKEND_LINKS
402          ${CMAKE_BINARY_DIR}
403          ${CMAKE_BINARY_DIR}/CMakeTmp/src.c
404          CMAKE_FLAGS
405          "-DINCLUDE_DIRECTORIES:STRING=${${BACKEND_OPTION}_INCLUDE_DIRS}"
406          "-DLINK_DIRECTORIES:STRING=${${BACKEND_OPTION}_LINK_DIRS}"
407          "-DLINK_LIBRARIES:STRING=${${BACKEND_OPTION}_LIBS}"
408          "-DCOMPILE_DEFINITIONS:STRING=${${BACKEND_OPTION}_DEFINES}"
409          OUTPUT_VARIABLE OUTPUT)
410
411        WRITE_FILE(${CMAKE_BINARY_DIR}/CMakeOutput.log
412                   "Performing manual C SOURCE FILE Test BACKEND_LINKS for ${BACKEND_OPTION} with the following output:\n"
413                   "${OUTPUT}\n"
414                   "Source file was:\n${SOURCE}\n" APPEND)
415
416        IF(BACKEND_LINKS)
417          SET(${BACKEND_OPTION}_FOUND "1${${BACKEND_OPTION}_DLOPEN}" CACHE INTERNAL "")
418        ELSE(BACKEND_LINKS)
419
420          MESSAGE(STATUS "${BACKEND_OPTION} doesn't link.")
421        ENDIF(BACKEND_LINKS)
422      ENDIF(${BACKEND_OPTION}_LIBS MATCHES "NOTFOUND")
423    ENDIF(HAVE_DL AND ${BACKEND_OPTION}_DLOPEN)
424  ELSE(HAVE_BACKEND_HEADER)
425
426    MESSAGE(STATUS "${BACKEND_OPTION} header ${BACKEND_HEADER} not found.")
427  ENDIF(HAVE_BACKEND_HEADER)
428ENDIF(${BACKEND_OPTION} AND NOT ${BACKEND_OPTION}_FOUND MATCHES "1${${BACKEND_OPTION}_DLOPEN}")
429
430IF(${BACKEND_OPTION} AND ${BACKEND_OPTION}_FOUND MATCHES "1${${BACKEND_OPTION}_DLOPEN}")
431  SET(OS_OBJS ${OS_OBJS} ${${BACKEND_OPTION}_OBJS})
432  # kinda hack, but won't hurt
433  ADD_DEFINE(USE_BACKEND_${BACKEND_OPTION})
434  ADD_DEFINE(ENABLE_EXTENSION_AL_EXT_${BACKEND_OPTION})
435  INCLUDE_DIRECTORIES(${${BACKEND_OPTION}_INCLUDE_DIRS})
436
437  ADD_DEFINITIONS(${${BACKEND_OPTION}_DEFINES})
438
439  IF(HAVE_DL AND ${BACKEND_OPTION}_DLOPEN)
440    ADD_DEFINE(OPENAL_DLOPEN_${BACKEND_OPTION})
441    MESSAGE(STATUS "${BACKEND_OPTION} support - dynamic")
442  ELSE(HAVE_DL AND ${BACKEND_OPTION}_DLOPEN)
443
444    SET(ADD_LIBS ${ADD_LIBS} ${${BACKEND_OPTION}_LIBS})
445    LINK_DIRECTORIES(${${BACKEND_OPTION}_LINK_DIRS})
446    MESSAGE(STATUS "${BACKEND_OPTION} support - static")
447  ENDIF(HAVE_DL AND ${BACKEND_OPTION}_DLOPEN)
448ELSE(${BACKEND_OPTION} AND ${BACKEND_OPTION}_FOUND MATCHES "1${${BACKEND_OPTION}_DLOPEN}")
449
450  MESSAGE(STATUS "${BACKEND_OPTION} support - disabled")
451  SET(${BACKEND_OPTION} OFF CACHE BOOL "" FORCE)
452ENDIF(${BACKEND_OPTION} AND ${BACKEND_OPTION}_FOUND MATCHES "1${${BACKEND_OPTION}_DLOPEN}")
453ENDMACRO(CHECK_BACKEND)
454
455#             OPT    PKG-NAME   LIB        HEADER              TEST-FUNCTION
456CHECK_BACKEND(ALSA   alsa       asound     alsa/asoundlib.h    snd_pcm_info_sizeof)
457CHECK_BACKEND(ARTS   artsc      artsc      artsc.h             arts_free)
458CHECK_BACKEND(DMEDIA ""         audio      dmedia/audio.h      alGetResourceByName)
459CHECK_BACKEND(ESD    esd        esd        esd.h               esd_audio_open)
460CHECK_BACKEND(SDL    sdl        sdl        SDL.h               SDL_LockAudio)
461#IF(WIN32)
462#  CHECK_BACKEND(DSOUND ""       dsound     dsound.h     ???)
463#ENDIF(WIN32)
464
465CHECK_BACKEND(MP3    smpeg      smpeg      smpeg.h             SMPEG_play)
466CHECK_BACKEND(VORBIS vorbisfile vorbisfile vorbis/vorbisfile.h ov_clear)
467
468IF(WAVEOUT)
469  SET(OS_OBJS ${OS_OBJS} ${WAVEOUT_OBJS})
470  ADD_DEFINE(USE_BACKEND_WAVEOUT)
471ENDIF(WAVEOUT)
472
473IF(NULLOUT)
474  SET(OS_OBJS ${OS_OBJS} ${NULL_OBJS})
475  ADD_DEFINE(USE_BACKEND_NULL)
476ENDIF(NULLOUT)
477
478
479# Special objs for architectures
480IF(CMAKE_SYSTEM_MACHINE MATCHES "i.86" OR CMAKE_SYSTEM_MACHINE MATCHES "x86_64")
481  INCLUDE_DIRECTORIES(${OpenAL_SOURCE_DIR}/src/arch/i386)
482  SET(ARCH_OBJS ${x86_OBJS})
483
484  MACRO_TEST(__MMX__ HAVE_MMX)
485  IF(HAVE_MMX)
486    SET(ARCH_OBJS ${ARCH_OBJS} ${x86_MMX_OBJS})
487 
488
489  IF(CMAKE_SYSTEM_MACHINE MATCHES "i.86")
490    # nasm stuff
491    FIND_PROGRAM(HAVE_NASM NAMES nasm)
492
493    IF(NOT HAVE_NASM MATCHES "NOTFOUND")
494      PROJECT(OpenAL ASM)
495      MESSAGE(STATUS "Using NASM")
496      ADD_DEFINE(HAVE_CPU_CAPS_DETECTION)
497      SET(ARCH_OBJS ${ARCH_OBJS} ${x86_NASM_OBJS})
498
499      IF(HAVE_MMX)
500        SET(ARCH_OBJS ${ARCH_OBJS} ${x86_MMX_NASM_OBJS})
501        ADD_DEFINE(HAVE_MMX_MEMCPY)
502      ENDIF(HAVE_MMX)
503    ELSE(NOT HAVE_NASM MATCHES "NOTFOUND")
504
505      IF(HAVE_MMX)
506        MESSAGE("Warning: MMX capability found, but NASM not found. Without NASM no SIMD detection (MMX enabled by default) and no MMX memcopy is built.")
507      ENDIF(HAVE_MMX)
508    ENDIF(NOT HAVE_NASM MATCHES "NOTFOUND")
509  ENDIF(CMAKE_SYSTEM_MACHINE MATCHES "i.86")
510
511  IF(CMAKE_SYSTEM_MACHINE MATCHES "i686" OR CMAKE_SYSTEM_MACHINE MATCHES "x86_64")
512    OPTION(OPTIM_GENERIC "enable full generic mixing despite MMX optimized routines" OFF)
513  ELSE(CMAKE_SYSTEM_MACHINE MATCHES "i686" OR CMAKE_SYSTEM_MACHINE MATCHES "x86_64")
514
515    OPTION(OPTIM_GENERIC "enable full generic mixing" ON)
516  ENDIF(CMAKE_SYSTEM_MACHINE MATCHES "i686" OR CMAKE_SYSTEM_MACHINE MATCHES "x86_64")
517
518  IF(NOT OPTIM_GENERIC)
519    ADD_DEFINE(USE_LIGHT_GEN_MIXING)
520  ENDIF(NOT OPTIM_GENERIC)
521  ENDIF(HAVE_MMX)
522ELSE(CMAKE_SYSTEM_MACHINE MATCHES "i.86" OR CMAKE_SYSTEM_MACHINE MATCHES "x86_64")
523
524  SET(ARCH_OBJS ${PORTABLE_OBJS})
525ENDIF(CMAKE_SYSTEM_MACHINE MATCHES "i.86" OR CMAKE_SYSTEM_MACHINE MATCHES "x86_64")
526
527
528# compiler specific settings
529FIND_PACKAGE(CompilerAttribute)
530FIND_PACKAGE(CompilerVisibility)
531FIND_PACKAGE(CompilerFlagsSet)
532
533ADD_DEFINE(AL_SUPPORT_BYTE_LOKI_SOURCE_ATTR_)
534ADD_DEFINITIONS(-DAL_BUILD_LIBRARY)
535
536
537GENERATE_CONFIG_H()
538
539SET(CMAKE_C_FLAGS "${ADD_WFLAGS} ${ADD_CFLAGS} ${CMAKE_C_FLAGS}")
540SET(CMAKE_CXX_FLAGS "${ADD_CFLAGS} ${CMAKE_CXX_FLAGS}")
541SET(CMAKE_SHARED_LINKER_FLAGS "${ADD_LDFLAGS} ${CMAKE_SHARED_LINKER_FLAGS}")
542SET(CMAKE_MODULE_LINKER_FLAGS "${ADD_LDFLAGS} ${CMAKE_MODULE_LINKER_FLAGS}")
543
544SET(OPENAL_OBJS ${AL_OBJS}
545                ${OS_OBJS}
546                ${ARCH_OBJS}
547                ${ALC_OBJS}
548                ${AC_OBJS}
549                ${EXT_OBJS})
550
551IF(BUILD_STATIC)
552  # we can't create a static library with the same name
553  # as the shared one, so we copy it over after creation
554  ADD_LIBRARY(openal-static STATIC ${OPENAL_OBJS})
555  #SET_TARGET_PROPERTIES(openal-static PROPERTIES OUTPUT_NAME openal)
556  SET_TARGET_PROPERTIES(openal-static PROPERTIES LINKER_LANGUAGE C)
557  TARGET_LINK_LIBRARIES(openal-static ${ADD_LIBS})
558  ADD_CUSTOM_COMMAND(
559    TARGET openal-static
560    POST_BUILD
561    COMMAND ${CMAKE_COMMAND}
562    ARGS -E copy
563      ${CMAKE_BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}openal-static${CMAKE_STATIC_LIBRARY_SUFFIX}
564      ${CMAKE_BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}openal${CMAKE_STATIC_LIBRARY_SUFFIX})
565  INSTALL_FILES(/lib FILES ${CMAKE_STATIC_LIBRARY_PREFIX}openal${CMAKE_STATIC_LIBRARY_SUFFIX})
566ENDIF(BUILD_STATIC)
567
568ADD_LIBRARY(openal SHARED ${OPENAL_OBJS})
569SET_TARGET_PROPERTIES(openal PROPERTIES LINKER_LANGUAGE C)
570SET_TARGET_PROPERTIES(openal PROPERTIES VERSION ${PACKAGE_VERSION} SOVERSION ${PACKAGE_MAJOR_VERSION})
571TARGET_LINK_LIBRARIES(openal ${ADD_LIBS})
572INSTALL_TARGETS(/lib openal)
573INSTALL_FILES(/include/AL FILES common/include/AL/al.h
574                                common/include/AL/alc.h
575                                include/AL/alext.h)
576
577# build test-suite
578IF(BUILD_TESTS)
579  # need CXX for testcpp only
580  PROJECT(OpenAL CXX)
581  FIND_LIBRARY(ALUT_LIB NAMES alut PATHS /usr/lib /usr/local/lib)
582  IF(ALUT_LIB MATCHES "NOTFOUND")
583    MESSAGE("alut not installed, cannot build tests")
584  ELSE(ALUT_LIB MATCHES "NOTFOUND")
585
586    ADD_LIBRARY(testlib test/testlib.c)
587    TARGET_LINK_LIBRARIES(testlib ${ADD_LIBS} openal ${ALUT_LIB})
588
589    SET(TESTS rotatesound
590              reverb
591              da
592              multi
593              multinothread
594              alut
595              time
596              multialut
597              alinitexit
598              single
599              nothread
600              pitch
601              pitch2
602              pitch3
603              pitch4
604              doppler
605              sourcestop
606              ext
607              stream
608              callback
609              orient
610              relative
611              channel
612              channel2
613              pause
614              pitchnothread
615              pitchnothread2
616              gain
617              loop
618              listener
619              listener2
620              listener3
621              listener4
622              bufferuniq
623              sourceuniq
624              gendelbuffer_error
625              gendelsource_error
626              multichannel
627              mp3
628              mp32
629              vorbis
630              gainlinear
631              multimp3
632              queue
633              queue2
634              queue3
635              capture
636              capture2
637              leak
638              multicontext
639              strings
640              attributes)
641
642    FOREACH(TEST ${TESTS})
643      SET(TEST_SRC test/test${TEST}.c)
644      # gets added at the beginning thus having no effect
645      SET_SOURCE_FILES_PROPERTIES(${TEST_SRC} PROPERTIES COMPILE_FLAGS "-Wno-unused")
646      ADD_EXECUTABLE(test${TEST} ${TEST_SRC})
647      TARGET_LINK_LIBRARIES(test${TEST} testlib openal ${ALUT_LIB})
648    ENDFOREACH(TEST)
649
650    SET_SOURCE_FILES_PROPERTIES(test/testcpp.cc PROPERTIES COMPILE_FLAGS "-Wno-unused")
651    ADD_EXECUTABLE(testcpp test/testcpp.cc)
652    TARGET_LINK_LIBRARIES(testcpp testlib openal ${ALUT_LIB})
653
654    # copy over testdata, so test-suite can be used in binary dir
655    SET(TESTDATA boom.mp3
656                 boom.ogg
657                 boom.wav
658                 fire2.wav
659                 multiboom.wav
660                 multisample.wav
661                 sample.wav)
662
663    FOREACH(TESTDATUM ${TESTDATA})
664      CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/test/${TESTDATUM} ${CMAKE_BINARY_DIR}/${TESTDATUM} COPYONLY)
665    ENDFOREACH(TESTDATUM)
666  ENDIF(ALUT_LIB MATCHES "NOTFOUND")
667ENDIF(BUILD_TESTS)
668
669
670# needed for openal.pc.in and openal-config.in
671SET(prefix ${CMAKE_INSTALL_PREFIX})
672SET(exec_prefix "\${prefix}")
673SET(libdir "\${exec_prefix}/lib")
674SET(bindir "\${exec_prefix}/bin")
675SET(includedir "\${prefix}/include")
676SET(requirements "")
677SET(PTHREAD_LIBS ${CMAKE_THREAD_LIBS_INIT})
678
679CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/admin/pkgconfig/openal.pc.in ${CMAKE_BINARY_DIR}/admin/pkgconfig/openal.pc @ONLY)
680CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/admin/pkgconfig/openal-config.in ${CMAKE_BINARY_DIR}/admin/pkgconfig/openal-config @ONLY)
681INSTALL_PROGRAMS(/bin FILES admin/pkgconfig/openal-config)
682INSTALL_FILES(/lib/pkgconfig FILES admin/pkgconfig/openal.pc)
683
684
685# info file
686IF(UNIX)
687  FIND_PROGRAM(MAKEINFO_PRG NAMES makeinfo)
688  IF(NOT MAKEINFO_PRG MATCHES "NOTFOUND")
689    IF(NOT EXISTS ${CMAKE_BINARY_DIR}/doc)
690      MAKE_DIRECTORY(${CMAKE_BINARY_DIR}/doc)
691    ENDIF(NOT EXISTS ${CMAKE_BINARY_DIR}/doc)
692
693    ADD_CUSTOM_COMMAND(
694      OUTPUT    ${CMAKE_BINARY_DIR}/doc/openal.info
695      DEPENDS   ${CMAKE_SOURCE_DIR}/doc/openal.texi
696      COMMAND   cd ${CMAKE_BINARY_DIR}/doc && ${MAKEINFO_PRG}
697      ARGS      ${CMAKE_SOURCE_DIR}/doc/openal.texi)
698
699    ADD_CUSTOM_TARGET(InfoFile ALL echo DEPENDS ${CMAKE_BINARY_DIR}/doc/openal.info)
700    INSTALL_FILES(/share/info FILES doc/openal.info)
701  ENDIF(NOT MAKEINFO_PRG MATCHES "NOTFOUND")
702ENDIF(UNIX)
703
Note: See TracBrowser for help on using the repository browser.