Avoid calling function pointers for vorbisfile directly
[alure.git] / CMakeLists.txt
blob98801becc78d28a7bb710637aa0ae202befde5cc
1 # CMakeLists.txt for ALURE
2 CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
4 IF(COMMAND CMAKE_POLICY)
5     CMAKE_POLICY(SET CMP0003 NEW)
6 ENDIF(COMMAND CMAKE_POLICY)
8 SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
10 INCLUDE(CheckCCompilerFlag)
11 INCLUDE(CheckCSourceCompiles)
12 INCLUDE(CheckFunctionExists)
13 INCLUDE(CheckIncludeFile)
14 INCLUDE(CheckIncludeFiles)
15 INCLUDE(CheckLibraryExists)
16 INCLUDE(CheckSharedLibraryExists)
17 INCLUDE(FindPkgConfig)
18 INCLUDE(UsePkgConfig)
19 INCLUDE(CheckFileOffsetBits)
21 PROJECT(ALURE)
23 IF(WIN32)
24     SET(LIBNAME ALURE32)
25 ELSE(WIN32)
26     SET(LIBNAME alure)
27 ENDIF(WIN32)
29 SET(LIB_MAJOR_VERSION "1")
30 SET(LIB_MINOR_VERSION "1")
31 SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}")
34 INCLUDE_DIRECTORIES(include "${ALURE_BINARY_DIR}")
37 OPTION(BUILD_SHARED "Build the shared version of the library" ON)
38 OPTION(BUILD_STATIC "Build the static version of the library" ON)
40 IF(NOT BUILD_SHARED AND NOT BUILD_STATIC)
41     MESSAGE(FATAL_ERROR "No libtype being built!")
42 ENDIF(NOT BUILD_SHARED AND NOT BUILD_STATIC)
44 IF(NOT CMAKE_BUILD_TYPE)
45     SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
46         "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
47         FORCE)
48 ENDIF(NOT CMAKE_BUILD_TYPE)
49 IF(NOT DEFINED CMAKE_DEBUG_POSTFIX)
50     SET(CMAKE_DEBUG_POSTFIX "" CACHE STRING
51         "Library postfix for debug builds. Normally left blank."
52         FORCE)
53 ENDIF(NOT DEFINED CMAKE_DEBUG_POSTFIX)
56 CHECK_SHARED_LIBRARY_EXISTS(stdc++ memset "" HAS_STDCXX)
57 IF(HAS_STDCXX)
58     SET(EXTRA_LIBS stdc++ ${EXTRA_LIBS})
59 ENDIF(HAS_STDCXX)
61 CHECK_SHARED_LIBRARY_EXISTS(m pow "" HAS_LIBM)
62 IF(HAS_LIBM)
63     SET(EXTRA_LIBS m ${EXTRA_LIBS})
64 ENDIF(HAS_LIBM)
66 CHECK_FILE_OFFSET_BITS()
67 IF(_FILE_OFFSET_BITS)
68     ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=${_FILE_OFFSET_BITS})
69     SET(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_FILE_OFFSET_BITS=${_FILE_OFFSET_BITS})
70 ENDIF(_FILE_OFFSET_BITS)
72 CHECK_FUNCTION_EXISTS(fseeko HAVE_FSEEKO)
73 IF(NOT HAVE_FSEEKO)
74     CHECK_FUNCTION_EXISTS(_fseeki64 HAVE__FSEEKI64)
75 ENDIF(NOT HAVE_FSEEKO)
77 SET(STATIC_CFLAGS "${STATIC_CFLAGS} -DALURE_STATIC_LIBRARY")
79 IF(MSVC)
80     # ???
81 ELSE(MSVC)
82     IF(NOT WIN32)
83         CHECK_C_SOURCE_COMPILES("int foo() __attribute__((constructor));
84                                  int main() {return 0;}" HAVE_GCC_CONSTRUCTOR)
86         CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAVE_GCC_VISIBILITY)
87         IF(HAVE_GCC_VISIBILITY)
88             ADD_DEFINITIONS(-fvisibility=hidden)
89         ENDIF(HAVE_GCC_VISIBILITY)
91         # Force -fPIC for the static lib, because it causes problems when the
92         # static version is linked to a dynamic lib
93         SET(STATIC_CFLAGS "${STATIC_CFLAGS} -fPIC")
94     ENDIF(NOT WIN32)
96     CHECK_C_COMPILER_FLAG(-Wextra HAVE_WEXTRA)
97     IF(HAVE_WEXTRA)
98         ADD_DEFINITIONS(-Wextra)
99     ENDIF(HAVE_WEXTRA)
100     ADD_DEFINITIONS(-Wall)
102     CHECK_C_COMPILER_FLAG(-funswitch-loops HAVE_FUNSWITCH_LOOPS)
103     IF(HAVE_FUNSWITCH_LOOPS)
104         ADD_DEFINITIONS(-funswitch-loops)
105     ENDIF(HAVE_FUNSWITCH_LOOPS)
106 ENDIF(MSVC)
109 CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H -D_WIN32_WINNT=0x0500)
110 IF(NOT HAVE_WINDOWS_H)
111     CHECK_C_COMPILER_FLAG(-pthread HAVE_PTHREAD)
112     IF(HAVE_PTHREAD)
113         ADD_DEFINITIONS(-pthread)
114         SET(EXTRA_LIBS ${EXTRA_LIBS} -pthread)
115     ENDIF(HAVE_PTHREAD)
117     # We need pthreads outside of Windows
118     CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
119     IF(NOT HAVE_PTHREAD_H)
120         MESSAGE(FATAL_ERROR "PThreads is required for non-Windows builds!")
121     ENDIF()
122     # Some systems need pthread_np.h to get recursive mutexes
123     CHECK_INCLUDE_FILES("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H)
125     # _GNU_SOURCE is needed on some systems for extra attributes, and
126     # _REENTRANT is needed for libc thread-safety
127     ADD_DEFINITIONS(-D_GNU_SOURCE=1)
128     CHECK_FUNCTION_EXISTS(pthread_create HAS_PTHREAD_CREATE)
129     IF(NOT HAS_PTHREAD_CREATE)
130         CHECK_SHARED_LIBRARY_EXISTS(pthread pthread_create "" HAVE_LIBPTHREAD)
131         IF(NOT HAVE_LIBPTHREAD)
132             MESSAGE(FATAL_ERROR "pthread_create not found on non-Windows target!")
133         ENDIF(NOT HAVE_LIBPTHREAD)
134         SET(EXTRA_LIBS pthread ${EXTRA_LIBS})
135     ENDIF(NOT HAS_PTHREAD_CREATE)
137     CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP)
138     IF(NOT HAVE_NANOSLEEP)
139         MESSAGE(FATAL_ERROR "No sleep function found!")
140     ENDIF(NOT HAVE_NANOSLEEP)
141 ENDIF(NOT HAVE_WINDOWS_H)
143 CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H)
144 CHECK_INCLUDE_FILE(sys/wait.h HAVE_SYS_WAIT_H)
145 CHECK_INCLUDE_FILE(signal.h HAVE_SIGNAL_H)
146 CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H)
148 IF(HAVE_DLFCN_H)
149     CHECK_SHARED_LIBRARY_EXISTS(dl dlopen "" HAVE_LIBDL)
150     IF(HAVE_LIBDL)
151         SET(EXTRA_LIBS dl ${EXTRA_LIBS})
152     ENDIF(HAVE_LIBDL)
153 ENDIF(HAVE_DLFCN_H)
155 OPTION(DYNLOAD    "Dynamically load support libs at run-time" ON)
156 OPTION(SNDFILE    "SoundFile support (for various formats)" ON)
157 OPTION(VORBIS     "VorbisFile support (for Ogg Vorbis)"  ON)
158 OPTION(FLAC       "FLAC support (for FLAC and Ogg FLAC)" ON)
159 OPTION(MPG123     "MPG123 support (for MP1/MP2/MP3)" ON)
160 OPTION(DUMB       "DUMB support (for IT/XM/S3M/MOD)" ON)
161 OPTION(MODPLUG    "ModPlug support (for IT/XM/S3M/MOD)" OFF)
162 OPTION(FLUIDSYNTH "FluidSynth support (for MID)" ON)
164 IF(WIN32)
165     ADD_DEFINITIONS(-D_WIN32)
167     IF(CMAKE_SIZEOF_VOID_P MATCHES "8")
168         SET(WIN_TYPE Win64)
169         SET(XBITS x64)
170     ELSE(CMAKE_SIZEOF_VOID_P MATCHES "8")
171         SET(WIN_TYPE Win32)
172         SET(XBITS x86)
173     ENDIF(CMAKE_SIZEOF_VOID_P MATCHES "8")
175     SET(OPENAL_SEARCH_PATHS
176         ENV ALSDK_DIR
177         ENV MINGDIR
178         "C:/Program Files/OpenAL 1.1 SDK"
179         "C:/Program Files (x86)/OpenAL 1.1 SDK"
180         "E:/Programs/Dev/OpenAL"
181         "E:/Program Files (x86)/OpenAL 1.1 SDK" )
183     FIND_PATH(OPENAL_INCLUDE_DIR al.h
184               PATHS ${OPENAL_SEARCH_PATHS}
185               PATH_SUFFIXES include include/AL )
186     IF(OPENAL_INCLUDE_DIR)
187         INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR})
188         FIND_LIBRARY(OPENAL_LIBRARIES OpenAL32
189                      PATHS ${OPENAL_SEARCH_PATHS}
190                      PATH_SUFFIXES lib libs/${WIN_TYPE} )
191     ENDIF(OPENAL_INCLUDE_DIR)
193     IF(NOT OPENAL_LIBRARIES)
194         MESSAGE(FATAL_ERROR "OpenAL not found!\nPlease try setting the ALSDK_DIR environment variable and try again.")
195     ENDIF(NOT OPENAL_LIBRARIES)
197     MESSAGE(STATUS "OpenAL include: ${OPENAL_INCLUDE_DIR}")
198     MESSAGE(STATUS "OpenAL lib: ${OPENAL_LIBRARIES}")
199 ELSE(WIN32)
200     IF(NOT HAVE_DLFCN_H OR NOT HAVE_LIBDL)
201         SET(DYNLOAD OFF)
202     ENDIF(NOT HAVE_DLFCN_H OR NOT HAVE_LIBDL)
204     PKG_CHECK_MODULES(OPENAL openal)
205     IF(NOT OPENAL_FOUND)
206         IF(APPLE)
207             CHECK_INCLUDE_FILE(OpenAL/al.h HAVE_OPENAL_AL_H)
208             IF(HAVE_OPENAL_AL_H)
209                 SET(OPENAL_LIBRARIES "-framework OpenAL")
210                 SET(HAS_OPENAL 1)
211             ENDIF(HAVE_OPENAL_AL_H)
212         ELSE(APPLE)
213             CHECK_INCLUDE_FILE(AL/al.h HAVE_AL_AL_H)
214             IF(HAVE_AL_AL_H)
215                 CHECK_SHARED_LIBRARY_EXISTS(openal alcOpenDevice "" HAS_OPENAL)
216                 IF(HAS_OPENAL)
217                     SET(OPENAL_LIBRARIES openal)
218                 ENDIF(HAS_OPENAL)
219             ENDIF(HAVE_AL_AL_H)
220         ENDIF(APPLE)
221         IF(NOT HAS_OPENAL)
222             MESSAGE(FATAL_ERROR "OpenAL not found!")
223         ENDIF(NOT HAS_OPENAL)
224     ELSE(NOT OPENAL_FOUND)
225         INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIRS})
226         LINK_DIRECTORIES(${OPENAL_LIBRARY_DIRS})
227     ENDIF(NOT OPENAL_FOUND)
228 ENDIF(WIN32)
230 # Base source files
231 SET(ALURE_OBJS  src/alure.cpp
232                 src/buffer.cpp
233                 src/istream.cpp
234                 src/stream.cpp
235                 src/streamdec.cpp
236                 src/streamplay.cpp
237                 src/codec_wav.cpp
238                 src/codec_aiff.cpp
241 # SndFile support
242 IF(SNDFILE)
243     PKG_CHECK_MODULES(SNDFILE sndfile)
244     IF(NOT SNDFILE_FOUND)
245         CHECK_INCLUDE_FILE(sndfile.h HAVE_SNDFILE_H)
246         IF(HAVE_SNDFILE_H)
247             CHECK_SHARED_LIBRARY_EXISTS(sndfile sf_open "" HAVE_LIBSNDFILE)
248             CHECK_SHARED_LIBRARY_EXISTS(libsndfile-1 sf_open "" HAVE_LIBSNDFILE1)
249             IF(DYNLOAD OR HAVE_LIBSNDFILE OR HAVE_LIBSNDFILE1)
250                 SET(HAS_SNDFILE 1)
251                 IF(HAVE_LIBSNDFILE)
252                     SET(SNDFILE_LIBRARIES "sndfile")
253                 ELSEIF(HAVE_LIBSNDFILE1)
254                     SET(SNDFILE_LIBRARIES "libsndfile-1")
255                 ENDIF(HAVE_LIBSNDFILE)
256             ENDIF(DYNLOAD OR HAVE_LIBSNDFILE OR HAVE_LIBSNDFILE1)
257         ENDIF(HAVE_SNDFILE_H)
258     ELSE(NOT SNDFILE_FOUND)
259         SET(HAS_SNDFILE 1)
260         LINK_DIRECTORIES(${SNDFILE_LIBRARY_DIRS})
261         SET_SOURCE_FILES_PROPERTIES(src/codec_sndfile.cpp PROPERTIES
262                                     COMPILE_FLAGS "${SNDFILE_CFLAGS}")
263     ENDIF(NOT SNDFILE_FOUND)
264     IF(HAS_SNDFILE)
265         SET(ALURE_OBJS ${ALURE_OBJS} src/codec_sndfile.cpp)
266     ENDIF(HAS_SNDFILE)
267 ELSE(SNDFILE)
268     SET(SNDFILE_LIBRARIES "")
269 ENDIF(SNDFILE)
271 # Vorbis support
272 IF(VORBIS)
273     PKG_CHECK_MODULES(VORBISFILE vorbisfile)
274     IF(NOT VORBISFILE_FOUND)
275         CHECK_INCLUDE_FILE(vorbis/vorbisfile.h HAVE_VORBIS_VORBISFILE_H)
276         IF(HAVE_VORBIS_VORBISFILE_H)
277             CHECK_SHARED_LIBRARY_EXISTS(vorbisfile ov_open "" HAVE_LIBVORBISFILE)
278             IF(DYNLOAD OR HAVE_LIBVORBISFILE)
279                 SET(HAS_VORBISFILE 1)
280                 IF(HAVE_LIBVORBISFILE)
281                     SET(VORBISFILE_LIBRARIES "vorbisfile")
282                 ENDIF(HAVE_LIBVORBISFILE)
283             ENDIF(DYNLOAD OR HAVE_LIBVORBISFILE)
284         ENDIF(HAVE_VORBIS_VORBISFILE_H)
285     ELSE(NOT VORBISFILE_FOUND)
286         SET(HAS_VORBISFILE 1)
287         LINK_DIRECTORIES(${VORBISFILE_LIBRARY_DIRS})
288         SET_SOURCE_FILES_PROPERTIES(src/codec_vorbisfile.cpp PROPERTIES
289                                     COMPILE_FLAGS "${VORBISFILE_CFLAGS}")
290     ENDIF(NOT VORBISFILE_FOUND)
291     IF(HAS_VORBISFILE)
292         SET(ALURE_OBJS ${ALURE_OBJS} src/codec_vorbisfile.cpp)
293     ENDIF(HAS_VORBISFILE)
294 ELSE(VORBIS)
295     SET(VORBISFILE_LIBRARIES "")
296 ENDIF(VORBIS)
298 # FLAC support
299 IF(FLAC)
300     #PKG_CHECK_MODULES(LIBFLAC flac)
301     #IF(NOT LIBFLAC_FOUND)
302         CHECK_INCLUDE_FILE(FLAC/all.h HAVE_FLAC_ALL_H)
303         IF(HAVE_FLAC_ALL_H)
304             CHECK_SHARED_LIBRARY_EXISTS(FLAC FLAC__stream_decoder_new "" HAVE_LIBFLAC)
305             IF(DYNLOAD OR HAVE_LIBFLAC)
306                 SET(HAS_FLAC 1)
307                 IF(HAVE_LIBFLAC)
308                     SET(LIBFLAC_LIBRARIES "FLAC")
309                 ENDIF(HAVE_LIBFLAC)
310             ENDIF(DYNLOAD OR HAVE_LIBFLAC)
311         ENDIF(HAVE_FLAC_ALL_H)
312     #ELSE(NOT LIBFLAC_FOUND)
313     #    SET(HAS_FLAC 1)
314     #    INCLUDE_DIRECTORIES(${LIBFLAC_INCLUDE_DIRS})
315     #    LINK_DIRECTORIES(${LIBFLAC_LIBRARY_DIRS})
316     #ENDIF(NOT LIBFLAC_FOUND)
317     IF(HAS_FLAC)
318         SET(ALURE_OBJS ${ALURE_OBJS} src/codec_flac.cpp)
319     ENDIF(HAS_FLAC)
320 ELSE(FLAC)
321     SET(LIBFLAC_LIBRARIES "")
322 ENDIF(FLAC)
324 # MPG123 support
325 IF(MPG123)
326     PKG_CHECK_MODULES(MPG123 libmpg123)
327     IF(NOT MPG123_FOUND)
328         CHECK_INCLUDE_FILE(mpg123.h HAVE_MPG123_H)
329         IF(HAVE_MPG123_H)
330             CHECK_SHARED_LIBRARY_EXISTS(mpg123 mpg123_init "" HAVE_LIBMPG123)
331             IF(DYNLOAD OR HAVE_LIBMPG123)
332                 SET(HAS_MPG123 1)
333                 IF(HAVE_LIBMPG123)
334                     SET(MPG123_LIBRARIES "mpg123")
335                 ENDIF(HAVE_LIBMPG123)
336             ENDIF(DYNLOAD OR HAVE_LIBMPG123)
337         ENDIF(HAVE_MPG123_H)
338     ELSE(NOT MPG123_FOUND)
339         SET(HAS_MPG123 1)
340         LINK_DIRECTORIES(${MPG123_LIBRARY_DIRS})
341         SET_SOURCE_FILES_PROPERTIES(src/codec_mpg123.cpp PROPERTIES
342                                     COMPILE_FLAGS "${MPG123_CFLAGS}")
343     ENDIF(NOT MPG123_FOUND)
344     IF(HAS_MPG123)
345         SET(ALURE_OBJS ${ALURE_OBJS} src/codec_mpg123.cpp)
346     ENDIF(HAS_MPG123)
347 ELSE(MPG123)
348     SET(MPG123_LIBRARIES "")
349 ENDIF(MPG123)
351 # DUMB support
352 IF(DUMB)
353     CHECK_INCLUDE_FILE(dumb.h HAVE_DUMB_H)
354     IF(HAVE_DUMB_H)
355         IF(HAS_LIBM)
356             CHECK_LIBRARY_EXISTS("dumb;m" dumbfile_open_ex "" HAVE_LIBDUMB)
357         ELSE(HAS_LIBM)
358             CHECK_LIBRARY_EXISTS(dumb dumbfile_open_ex "" HAVE_LIBDUMB)
359         ENDIF(HAS_LIBM)
360         IF(DYNLOAD OR HAVE_LIBDUMB)
361             SET(HAS_DUMB 1)
362             IF(HAVE_LIBDUMB)
363                 SET(DUMB_LIBRARIES dumb)
364             ENDIF(HAVE_LIBDUMB)
365         ENDIF(DYNLOAD OR HAVE_LIBDUMB)
366     ENDIF(HAVE_DUMB_H)
367     IF(HAS_DUMB)
368         SET(ALURE_OBJS ${ALURE_OBJS} src/codec_dumb.cpp)
369     ENDIF(HAS_DUMB)
370 ELSE(DUMB)
371     SET(DUMB_LIBRARIES "")
372 ENDIF(DUMB)
374 # ModPlug support
375 IF(MODPLUG)
376     PKG_CHECK_MODULES(MODPLUG libmodplug)
377     IF(NOT MODPLUG_FOUND)
378         CHECK_INCLUDE_FILE(modplug.h HAVE_MODPLUG_H)
379         IF(HAVE_MODPLUG_H)
380             CHECK_SHARED_LIBRARY_EXISTS(modplug ModPlug_Load "" HAVE_LIBMODPLUG)
381             IF(DYNLOAD OR HAVE_LIBMODPLUG)
382                 SET(HAS_MODPLUG 1)
383                 IF(HAVE_LIBMODPLUG)
384                     SET(MODPLUG_LIBRARIES "modplug")
385                 ENDIF(HAVE_LIBMODPLUG)
386             ENDIF(DYNLOAD OR HAVE_LIBMODPLUG)
387         ENDIF(HAVE_MODPLUG_H)
388     ELSE(NOT MODPLUG_FOUND)
389         SET(HAS_MODPLUG 1)
390         LINK_DIRECTORIES(${MODPLUG_LIBRARY_DIRS})
391         SET_SOURCE_FILES_PROPERTIES(src/codec_modplug.cpp PROPERTIES
392                                     COMPILE_FLAGS "${MODPLUG_CFLAGS}")
393     ENDIF(NOT MODPLUG_FOUND)
394     IF(HAS_MODPLUG)
395         SET(ALURE_OBJS ${ALURE_OBJS} src/codec_modplug.cpp)
396     ENDIF(HAS_MODPLUG)
397 ELSE(MODPLUG)
398     SET(MODPLUG_LIBRARIES "")
399 ENDIF(MODPLUG)
401 # FluidSynth support
402 IF(FLUIDSYNTH)
403     PKG_CHECK_MODULES(FLUIDSYNTH fluidsynth>=1.1.1)
404     IF(NOT FLUIDSYNTH_FOUND)
405         CHECK_INCLUDE_FILE(fluidsynth.h HAVE_FLUIDSYNTH_H)
406         IF(HAVE_FLUIDSYNTH_H)
407             CHECK_SHARED_LIBRARY_EXISTS(fluidsynth new_fluid_synth "" HAVE_LIBFLUIDSYNTH)
408             IF(DYNLOAD OR HAVE_LIBFLUIDSYNTH)
409                 SET(HAS_FLUIDSYNTH 1)
410                 IF(HAVE_LIBFLUIDSYNTH)
411                     SET(FLUIDSYNTH_LIBRARIES "fluidsynth")
412                 ENDIF(HAVE_LIBFLUIDSYNTH)
413             ENDIF(DYNLOAD OR HAVE_LIBFLUIDSYNTH)
414         ENDIF(HAVE_FLUIDSYNTH_H)
415     ELSE(NOT FLUIDSYNTH_FOUND)
416         SET(HAS_FLUIDSYNTH 1)
417         LINK_DIRECTORIES(${FLUIDSYNTH_LIBRARY_DIRS})
418         SET_SOURCE_FILES_PROPERTIES(src/codec_fluidsynth.cpp PROPERTIES
419                                     COMPILE_FLAGS "${FLUIDSYNTH_CFLAGS}")
420     ENDIF(NOT FLUIDSYNTH_FOUND)
421     IF(HAS_FLUIDSYNTH)
422         SET(ALURE_OBJS ${ALURE_OBJS} src/codec_fluidsynth.cpp)
423     ENDIF(HAS_FLUIDSYNTH)
424 ELSE(FLUIDSYNTH)
425     SET(FLUIDSYNTH_LIBRARIES "")
426 ENDIF(FLUIDSYNTH)
429 IF(NOT DYNLOAD)
430     SET(EXTRA_LIBS ${SNDFILE_LIBRARIES} ${VORBISFILE_LIBRARIES} ${LIBFLAC_LIBRARIES} ${MPG123_LIBRARIES} ${DUMB_LIBRARIES} ${MODPLUG_LIBRARIES} ${FLUIDSYNTH_LIBRARIES} ${EXTRA_LIBS})
431 ELSE(NOT DYNLOAD)
432     ADD_DEFINITIONS(-DDYNLOAD=1)
433 ENDIF(NOT DYNLOAD)
435 # For alure.pc.in
436 SET(prefix ${CMAKE_INSTALL_PREFIX})
437 SET(exec_prefix "\${prefix}")
438 SET(libdir "\${exec_prefix}/lib${LIB_SUFFIX}")
439 SET(bindir "\${exec_prefix}/bin")
440 SET(includedir "\${prefix}/include")
441 SET(PKG_CONFIG_REQUIRES openal)
442 SET(PACKAGE_VERSION "${LIB_VERSION}")
444 # End configuration
445 CONFIGURE_FILE(
446     "${ALURE_SOURCE_DIR}/config.h.in"
447     "${ALURE_BINARY_DIR}/config.h")
448 IF(BUILD_SHARED)
449     CONFIGURE_FILE(
450         "${ALURE_SOURCE_DIR}/alure.pc.in"
451         "${ALURE_BINARY_DIR}/alure.pc"
452         @ONLY)
453 ENDIF(BUILD_SHARED)
454 IF(BUILD_STATIC)
455     CONFIGURE_FILE(
456         "${ALURE_SOURCE_DIR}/alure-static.pc.in"
457         "${ALURE_BINARY_DIR}/alure-static.pc"
458         @ONLY)
459 ENDIF(BUILD_STATIC)
461 ADD_DEFINITIONS(-DHAVE_CONFIG_H)
464 IF(BUILD_SHARED)
465     #build a shared library
466     ADD_LIBRARY(${LIBNAME} SHARED ${ALURE_OBJS})
467     SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES DEFINE_SYMBOL ALURE_BUILD_LIBRARY
468                                                 VERSION ${LIB_VERSION}.0
469                                                 SOVERSION ${LIB_MAJOR_VERSION})
470     IF(WIN32)
471         SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES PREFIX "")
472     ELSE(WIN32)
473         SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES LINK_FLAGS "-Wl,--version-script=${ALURE_SOURCE_DIR}/libalure.map")
474     ENDIF(WIN32)
475     TARGET_LINK_LIBRARIES(${LIBNAME} ${OPENAL_LIBRARIES} ${EXTRA_LIBS})
477     INSTALL(TARGETS ${LIBNAME}
478             RUNTIME DESTINATION bin
479             LIBRARY DESTINATION lib${LIB_SUFFIX}
480             ARCHIVE DESTINATION lib${LIB_SUFFIX}
482 ENDIF(BUILD_SHARED)
483 IF(BUILD_STATIC)
484     #build a static library
485     ADD_LIBRARY(${LIBNAME}-static STATIC ${ALURE_OBJS})
486     SET_TARGET_PROPERTIES(${LIBNAME}-static PROPERTIES DEFINE_SYMBOL ALURE_BUILD_LIBRARY
487                                                        COMPILE_FLAGS ${STATIC_CFLAGS}
488                                                        VERSION ${LIB_VERSION}.0)
489     INSTALL(TARGETS ${LIBNAME}-static
490             RUNTIME DESTINATION bin
491             LIBRARY DESTINATION lib${LIB_SUFFIX}
492             ARCHIVE DESTINATION lib${LIB_SUFFIX}
494 ENDIF(BUILD_STATIC)
497 ADD_EXECUTABLE(alureplay examples/alureplay.c)
498 ADD_EXECUTABLE(alurecdplay examples/alurecdplay.c)
499 ADD_EXECUTABLE(alurestream examples/alurestream.c)
500 IF(BUILD_SHARED)
501     TARGET_LINK_LIBRARIES(alureplay ${LIBNAME} ${OPENAL_LIBRARIES} ${EXTRA_LIBS})
502     TARGET_LINK_LIBRARIES(alurecdplay ${LIBNAME} ${OPENAL_LIBRARIES} ${EXTRA_LIBS})
503     TARGET_LINK_LIBRARIES(alurestream ${LIBNAME} ${OPENAL_LIBRARIES} ${EXTRA_LIBS})
504 ELSE(BUILD_SHARED)
505     SET_TARGET_PROPERTIES(alureplay PROPERTIES COMPILE_FLAGS -DALURE_STATIC_LIBRARY)
506     SET_TARGET_PROPERTIES(alurecdplay PROPERTIES COMPILE_FLAGS -DALURE_STATIC_LIBRARY)
507     SET_TARGET_PROPERTIES(alurestream PROPERTIES COMPILE_FLAGS -DALURE_STATIC_LIBRARY)
508     TARGET_LINK_LIBRARIES(alureplay ${LIBNAME}-static ${OPENAL_LIBRARIES} ${EXTRA_LIBS})
509     TARGET_LINK_LIBRARIES(alurecdplay ${LIBNAME}-static ${OPENAL_LIBRARIES} ${EXTRA_LIBS})
510     TARGET_LINK_LIBRARIES(alurestream ${LIBNAME}-static ${OPENAL_LIBRARIES} ${EXTRA_LIBS})
511 ENDIF(BUILD_SHARED)
514 FIND_PROGRAM(NATDOCS_BIN NaturalDocs)
515 IF(NATDOCS_BIN)
516     ADD_CUSTOM_TARGET(docs
517                       "${NATDOCS_BIN}" -i "${ALURE_SOURCE_DIR}/src" -o HTML "${ALURE_SOURCE_DIR}/docs/html" -p "${ALURE_SOURCE_DIR}/docs/naturaldocs" -s Default CustomStyle
518                       COMMENT "Building NaturalDocs documentation..." VERBATIM)
519 ELSE(NATDOCS_BIN)
520     MESSAGE(STATUS "\nNaturalDocs not found; building documentation is disabled")
521 ENDIF(NATDOCS_BIN)
524 #add an install target here
525 IF(APPLE)
526     SET(INCPATH OpenAL)
527 ELSE(APPLE)
528     SET(INCPATH AL)
529 ENDIF(APPLE)
531 INSTALL(DIRECTORY "${ALURE_SOURCE_DIR}/docs/html"
532         DESTINATION share/doc/alure
534 INSTALL(FILES include/AL/alure.h
535         DESTINATION "include/${INCPATH}"
537 IF(BUILD_SHARED)
538     INSTALL(FILES "${ALURE_BINARY_DIR}/alure.pc"
539             DESTINATION "lib${LIB_SUFFIX}/pkgconfig"
540     )
541 ENDIF(BUILD_SHARED)
542 IF(BUILD_STATIC)
543     INSTALL(FILES "${ALURE_BINARY_DIR}/alure-static.pc"
544             DESTINATION "lib${LIB_SUFFIX}/pkgconfig"
545     )
546 ENDIF(BUILD_STATIC)
549 MESSAGE(STATUS "\n********************** Configured options **********************")
550 IF(BUILD_SHARED AND BUILD_STATIC)
551     MESSAGE(STATUS "Building shared, static library")
552 ELSEIF(BUILD_SHARED)
553     MESSAGE(STATUS "Building shared library")
554 ELSE(BUILD_SHARED AND BUILD_STATIC)
555     MESSAGE(STATUS "Building static library")
556 ENDIF(BUILD_SHARED AND BUILD_STATIC)
557 MESSAGE(STATUS "")
558 IF(HAS_SNDFILE)
559     MESSAGE(STATUS "SndFile support: enabled")
560 ELSE(HAS_SNDFILE)
561     MESSAGE(STATUS "SndFile support: disabled")
562 ENDIF(HAS_SNDFILE)
563 IF(HAS_VORBISFILE)
564     MESSAGE(STATUS "VorbisFile support: enabled")
565 ELSE(HAS_VORBISFILE)
566     MESSAGE(STATUS "VorbisFile support: disabled")
567 ENDIF(HAS_VORBISFILE)
568 IF(HAS_FLAC)
569     MESSAGE(STATUS "FLAC support: enabled")
570 ELSE(HAS_FLAC)
571     MESSAGE(STATUS "FLAC support: disabled")
572 ENDIF(HAS_FLAC)
573 IF(HAS_MPG123)
574     MESSAGE(STATUS "MPG123 support: enabled")
575 ELSE(HAS_MPG123)
576     MESSAGE(STATUS "MPG123 support: disabled")
577 ENDIF(HAS_MPG123)
578 IF(HAS_DUMB)
579     MESSAGE(STATUS "DUMB support: enabled")
580 ELSE(HAS_DUMB)
581     MESSAGE(STATUS "DUMB support: disabled")
582 ENDIF(HAS_DUMB)
583 IF(HAS_MODPLUG)
584     MESSAGE(STATUS "ModPlug support: enabled")
585 ELSE(HAS_MODPLUG)
586     MESSAGE(STATUS "ModPlug support: disabled")
587 ENDIF(HAS_MODPLUG)
588 IF(HAS_FLUIDSYNTH)
589     MESSAGE(STATUS "FluidSynth support: enabled")
590 ELSE(HAS_FLUIDSYNTH)
591     MESSAGE(STATUS "FluidSynth support: disabled")
592 ENDIF(HAS_FLUIDSYNTH)
593 MESSAGE(STATUS "")