Don't require libs to enable a decoder when run-time loading is used
[alure.git] / CMakeLists.txt
blob826f55f348f03721cc9f78899cfdc38cc45cfd8e
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 "0")
31 SET(LIB_BUILD_VERSION "72")
32 SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_BUILD_VERSION}")
33 IF(NOT DEFINED LIB_INSTALL_DIR)
34     SET(LIB_INSTALL_DIR "lib${LIB_SUFFIX}")
35 ENDIF(NOT DEFINED LIB_INSTALL_DIR)
38 INCLUDE_DIRECTORIES(include "${ALURE_BINARY_DIR}")
41 OPTION(NO_SHARED "Build a static library instead of shared" OFF)
43 IF(NOT CMAKE_BUILD_TYPE)
44     SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
45         "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
46         FORCE)
47 ENDIF(NOT CMAKE_BUILD_TYPE)
48 IF(NOT DEFINED CMAKE_DEBUG_POSTFIX)
49     SET(CMAKE_DEBUG_POSTFIX "" CACHE STRING
50         "Library postfix for debug builds. Normally left blank."
51         FORCE)
52 ENDIF(NOT DEFINED CMAKE_DEBUG_POSTFIX)
55 ADD_DEFINITIONS(-DALURE_BUILD_LIBRARY -DHAVE_CONFIG_H)
57 CHECK_SHARED_LIBRARY_EXISTS(stdc++ memset "" HAS_STDCXX)
58 IF(HAS_STDCXX)
59     SET(EXTRA_LIBS stdc++ ${EXTRA_LIBS})
60 ENDIF(HAS_STDCXX)
62 CHECK_SHARED_LIBRARY_EXISTS(m pow "" HAS_LIBM)
63 IF(HAS_LIBM)
64     SET(EXTRA_LIBS m ${EXTRA_LIBS})
65 ENDIF(HAS_LIBM)
67 CHECK_FILE_OFFSET_BITS()
68 IF(_FILE_OFFSET_BITS)
69     ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=${_FILE_OFFSET_BITS})
70     SET(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_FILE_OFFSET_BITS=${_FILE_OFFSET_BITS})
71 ENDIF(_FILE_OFFSET_BITS)
73 CHECK_FUNCTION_EXISTS(fseeko HAVE_FSEEKO)
75 IF(MSVC)
76     # ???
77 ELSE(MSVC)
78     IF(NOT WIN32)
79         CHECK_C_SOURCE_COMPILES("int foo() __attribute__((constructor));
80                                  int main() {return 0;}" HAVE_GCC_CONSTRUCTOR)
82         CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAVE_GCC_VISIBILITY)
83         IF(HAVE_GCC_VISIBILITY)
84             ADD_DEFINITIONS(-fvisibility=hidden)
85         ENDIF(HAVE_GCC_VISIBILITY)
86     ENDIF(NOT WIN32)
88     CHECK_C_COMPILER_FLAG(-Wextra HAVE_WEXTRA)
89     IF(HAVE_WEXTRA)
90         ADD_DEFINITIONS(-Wextra)
91     ENDIF(HAVE_WEXTRA)
92     ADD_DEFINITIONS(-Wall)
94     CHECK_C_COMPILER_FLAG(-funswitch-loops HAVE_FUNSWITCH_LOOPS)
95     IF(HAVE_FUNSWITCH_LOOPS)
96         ADD_DEFINITIONS(-funswitch-loops)
97     ENDIF(HAVE_FUNSWITCH_LOOPS)
98 ENDIF(MSVC)
101 CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H -D_WIN32_WINNT=0x0500)
102 IF(NOT HAVE_WINDOWS_H)
103     CHECK_C_COMPILER_FLAG(-pthread HAVE_PTHREAD)
104     IF(HAVE_PTHREAD)
105         ADD_DEFINITIONS(-pthread)
106         SET(EXTRA_LIBS ${EXTRA_LIBS} -pthread)
107     ENDIF(HAVE_PTHREAD)
109     # We need pthreads outside of Windows
110     CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
111     IF(NOT HAVE_PTHREAD_H)
112         MESSAGE(FATAL_ERROR "PThreads is required for non-Windows builds!")
113     ENDIF()
114     # Some systems need pthread_np.h to get recursive mutexes
115     CHECK_INCLUDE_FILES("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H)
117     # _GNU_SOURCE is needed on some systems for extra attributes, and
118     # _REENTRANT is needed for libc thread-safety
119     ADD_DEFINITIONS(-D_GNU_SOURCE=1)
120     CHECK_FUNCTION_EXISTS(pthread_create HAS_PTHREAD_CREATE)
121     IF(NOT HAS_PTHREAD_CREATE)
122         CHECK_SHARED_LIBRARY_EXISTS(pthread pthread_create "" HAVE_LIBPTHREAD)
123         IF(NOT HAVE_LIBPTHREAD)
124             MESSAGE(FATAL_ERROR "pthread_create not found on non-Windows target!")
125         ENDIF(NOT HAVE_LIBPTHREAD)
126         SET(EXTRA_LIBS pthread ${EXTRA_LIBS})
127     ENDIF(NOT HAS_PTHREAD_CREATE)
129     CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP)
130     IF(NOT HAVE_NANOSLEEP)
131         MESSAGE(FATAL_ERROR "No sleep function found!")
132     ENDIF(NOT HAVE_NANOSLEEP)
133 ENDIF(NOT HAVE_WINDOWS_H)
135 CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H)
136 CHECK_INCLUDE_FILE(sys/wait.h HAVE_SYS_WAIT_H)
137 CHECK_INCLUDE_FILE(signal.h HAVE_SIGNAL_H)
138 CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H)
140 IF(HAVE_DLFCN_H)
141     CHECK_SHARED_LIBRARY_EXISTS(dl dlopen "" HAVE_LIBDL)
142     IF(HAVE_LIBDL)
143         SET(EXTRA_LIBS dl ${EXTRA_LIBS})
144     ENDIF(HAVE_LIBDL)
145 ENDIF(HAVE_DLFCN_H)
147 OPTION(DYNLOAD   "Dynamically load support libs at run-time" ON)
148 OPTION(SNDFILE   "SoundFile support (for various formats)" ON)
149 OPTION(VORBIS    "VorbisFile support (for Ogg Vorbis)"  ON)
150 OPTION(FLAC      "FLAC support (for FLAC and Ogg FLAC)" ON)
151 OPTION(MPG123    "MPG123 support (for MP1/MP2/MP3)" ON)
152 OPTION(DUMB      "DUMB support (for IT/XM/S3M/MOD)" ON)
153 OPTION(TIMIDITY  "Timidity support (for MIDI/MUS)" ON)
154 OPTION(GSTREAMER "GStreamer support" OFF)
156 IF(WIN32)
157     ADD_DEFINITIONS(-D_WIN32)
159     IF(CMAKE_SIZEOF_VOID_P MATCHES "8")
160         SET(WIN_TYPE Win64)
161         SET(XBITS x64)
162     ELSE(CMAKE_SIZEOF_VOID_P MATCHES "8")
163         SET(WIN_TYPE Win32)
164         SET(XBITS x86)
165     ENDIF(CMAKE_SIZEOF_VOID_P MATCHES "8")
167     SET(OPENAL_SEARCH_PATHS
168         ENV ALSDK_DIR
169         ENV MINGDIR
170         "C:/Program Files/OpenAL 1.1 SDK"
171         "C:/Program Files (x86)/OpenAL 1.1 SDK"
172         "E:/Programs/Dev/OpenAL"
173         "E:/Program Files (x86)/OpenAL 1.1 SDK" )
175     FIND_PATH(OPENAL_INCLUDE_DIR al.h
176               PATHS ${OPENAL_SEARCH_PATHS}
177               PATH_SUFFIXES include include/AL )
178     IF(OPENAL_INCLUDE_DIR)
179         INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR})
180         FIND_LIBRARY(OPENAL_LIBRARIES OpenAL32
181                      PATHS ${OPENAL_SEARCH_PATHS}
182                      PATH_SUFFIXES lib libs/${WIN_TYPE} )
183     ENDIF(OPENAL_INCLUDE_DIR)
185     IF(NOT OPENAL_LIBRARIES)
186         MESSAGE(FATAL_ERROR "OpenAL not found!\nPlease try setting the ALSDK_DIR environment variable and try again.")
187     ENDIF(NOT OPENAL_LIBRARIES)
189     MESSAGE(STATUS "OpenAL include: ${OPENAL_INCLUDE_DIR}")
190     MESSAGE(STATUS "OpenAL lib: ${OPENAL_LIBRARIES}")
191 ELSE(WIN32)
192     IF(NOT HAVE_DLFCN_H OR NOT HAVE_LIBDL)
193         SET(DYNLOAD OFF)
194     ENDIF(NOT HAVE_DLFCN_H OR NOT HAVE_LIBDL)
196     PKG_CHECK_MODULES(OPENAL openal)
197     IF(NOT OPENAL_FOUND)
198         IF(APPLE)
199             CHECK_INCLUDE_FILE(OpenAL/al.h HAVE_OPENAL_AL_H)
200             IF(HAVE_OPENAL_AL_H)
201                 SET(OPENAL_LIBRARIES "-framework OpenAL")
202                 SET(HAS_OPENAL 1)
203             ENDIF(HAVE_OPENAL_AL_H)
204         ELSE(APPLE)
205             CHECK_INCLUDE_FILE(AL/al.h HAVE_AL_AL_H)
206             IF(HAVE_AL_AL_H)
207                 CHECK_SHARED_LIBRARY_EXISTS(openal alcOpenDevice "" HAS_OPENAL)
208                 IF(HAS_OPENAL)
209                     SET(OPENAL_LIBRARIES openal)
210                 ENDIF(HAS_OPENAL)
211             ENDIF(HAVE_AL_AL_H)
212         ENDIF(APPLE)
213         IF(NOT HAS_OPENAL)
214             MESSAGE(FATAL_ERROR "OpenAL not found!")
215         ENDIF(NOT HAS_OPENAL)
216     ELSE(NOT OPENAL_FOUND)
217         INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIRS})
218         LINK_DIRECTORIES(${OPENAL_LIBRARY_DIRS})
219     ENDIF(NOT OPENAL_FOUND)
220 ENDIF(WIN32)
222 # SndFile support
223 IF(SNDFILE)
224     PKG_CHECK_MODULES(SNDFILE sndfile)
225     IF(NOT SNDFILE_FOUND)
226         CHECK_INCLUDE_FILE(sndfile.h HAVE_SNDFILE_H)
227         IF(HAVE_SNDFILE_H)
228             CHECK_SHARED_LIBRARY_EXISTS(sndfile sf_open "" HAVE_LIBSNDFILE)
229             CHECK_SHARED_LIBRARY_EXISTS(libsndfile-1 sf_open "" HAVE_LIBSNDFILE1)
230             IF(DYNLOAD OR HAVE_LIBSNDFILE OR HAVE_LIBSNDFILE1)
231                 SET(HAS_SNDFILE 1)
232                 IF(HAVE_LIBSNDFILE)
233                     SET(SNDFILE_LIBRARIES "sndfile")
234                 ELSEIF(HAVE_LIBSNDFILE1)
235                     SET(SNDFILE_LIBRARIES "libsndfile-1")
236                 ENDIF(HAVE_LIBSNDFILE)
237             ENDIF(DYNLOAD OR HAVE_LIBSNDFILE OR HAVE_LIBSNDFILE1)
238         ENDIF(HAVE_SNDFILE_H)
239     ELSE(NOT SNDFILE_FOUND)
240         SET(HAS_SNDFILE 1)
241         INCLUDE_DIRECTORIES(${SNDFILE_INCLUDE_DIRS})
242         LINK_DIRECTORIES(${SNDFILE_LIBRARY_DIRS})
243     ENDIF(NOT SNDFILE_FOUND)
244 ELSE(SNDFILE)
245     SET(SNDFILE_LIBRARIES "")
246 ENDIF(SNDFILE)
248 # Vorbis support
249 IF(VORBIS)
250     PKG_CHECK_MODULES(VORBISFILE vorbisfile)
251     IF(NOT VORBISFILE_FOUND)
252         CHECK_INCLUDE_FILE(vorbis/vorbisfile.h HAVE_VORBIS_VORBISFILE_H)
253         IF(HAVE_VORBIS_VORBISFILE_H)
254             CHECK_SHARED_LIBRARY_EXISTS(vorbisfile ov_open "" HAVE_LIBVORBISFILE)
255             IF(DYNLOAD OR HAVE_LIBVORBISFILE)
256                 SET(HAS_VORBISFILE 1)
257                 IF(HAVE_LIBVORBISFILE)
258                     SET(VORBISFILE_LIBRARIES "vorbisfile")
259                 ENDIF(HAVE_LIBVORBISFILE)
260             ENDIF(DYNLOAD OR HAVE_LIBVORBISFILE)
261         ENDIF(HAVE_VORBIS_VORBISFILE_H)
262     ELSE(NOT VORBISFILE_FOUND)
263         SET(HAS_VORBISFILE 1)
264         INCLUDE_DIRECTORIES(${VORBISFILE_INCLUDE_DIRS})
265         LINK_DIRECTORIES(${VORBISFILE_LIBRARY_DIRS})
266     ENDIF(NOT VORBISFILE_FOUND)
267 ELSE(VORBIS)
268     SET(VORBISFILE_LIBRARIES "")
269 ENDIF(VORBIS)
271 # FLAC support
272 IF(FLAC)
273     #PKG_CHECK_MODULES(LIBFLAC flac)
274     #IF(NOT LIBFLAC_FOUND)
275         CHECK_INCLUDE_FILE(FLAC/all.h HAVE_FLAC_ALL_H)
276         IF(HAVE_FLAC_ALL_H)
277             CHECK_SHARED_LIBRARY_EXISTS(FLAC FLAC__stream_decoder_new "" HAVE_LIBFLAC)
278             IF(DYNLOAD OR HAVE_LIBFLAC)
279                 SET(HAS_FLAC 1)
280                 IF(HAVE_LIBFLAC)
281                     SET(LIBFLAC_LIBRARIES "FLAC")
282                 ENDIF(HAVE_LIBFLAC)
283             ENDIF(DYNLOAD OR HAVE_LIBFLAC)
284         ENDIF(HAVE_FLAC_ALL_H)
285     #ELSE(NOT LIBFLAC)
286     #    SET(HAS_FLAC 1)
287     #    INCLUDE_DIRECTORIES(${LIBFLAC_INCLUDE_DIRS})
288     #    LINK_DIRECTORIES(${LIBFLAC_LIBRARY_DIRS})
289     #ENDIF(NOT LIBFLAC_FOUND)
290 ELSE(FLAC)
291     SET(LIBFLAC_LIBRARIES "")
292 ENDIF(FLAC)
294 # MPG123 support
295 IF(MPG123)
296     PKG_CHECK_MODULES(MPG123 libmpg123)
297     IF(NOT MPG123_FOUND)
298         CHECK_INCLUDE_FILE(mpg123.h HAVE_MPG123_H)
299         IF(HAVE_MPG123_H)
300             CHECK_SHARED_LIBRARY_EXISTS(mpg123 mpg123_init "" HAVE_LIBMPG123)
301             IF(DYNLOAD OR HAVE_LIBMPG123)
302                 SET(HAS_MPG123 1)
303                 IF(HAVE_LIBMPG123)
304                     SET(MPG123_LIBRARIES "mpg123")
305                 ENDIF(HAVE_LIBMPG123)
306             ENDIF(DYNLOAD OR HAVE_LIBMPG123)
307         ENDIF(HAVE_MPG123_H)
308     ELSE(NOT MPG123_FOUND)
309         SET(HAS_MPG123 1)
310         INCLUDE_DIRECTORIES(${MPG123_INCLUDE_DIRS})
311         LINK_DIRECTORIES(${MPG123_LIBRARY_DIRS})
312     ENDIF(NOT MPG123_FOUND)
313 ELSE(MPG123)
314     SET(MPG123_LIBRARIES "")
315 ENDIF(MPG123)
317 # DUMB support
318 IF(DUMB)
319     CHECK_INCLUDE_FILE(dumb.h HAVE_DUMB_H)
320     IF(HAVE_DUMB_H)
321         IF(HAS_LIBM)
322             CHECK_SHARED_LIBRARY_EXISTS("dumb;m" dumbfile_open_ex "" HAVE_LIBDUMB)
323         ELSE(HAS_LIBM)
324             CHECK_SHARED_LIBRARY_EXISTS(dumb dumbfile_open_ex "" HAVE_LIBDUMB)
325         ENDIF(HAS_LIBM)
326         IF(DYNLOAD OR HAVE_LIBDUMB)
327             SET(HAS_DUMB 1)
328             IF(HAVE_LIBDUMB)
329                 SET(DUMB_LIBRARIES dumb)
330             ENDIF(HAVE_LIBDUMB)
331         ENDIF(DYNLOAD OR HAVE_LIBDUMB)
332     ENDIF(HAVE_DUMB_H)
333 ELSE(DUMB)
334     SET(DUMB_LIBRARIES "")
335 ENDIF(DUMB)
337 IF(TIMIDITY)
338     CHECK_FUNCTION_EXISTS(fork HAVE_FORK)
339     CHECK_FUNCTION_EXISTS(pipe HAVE_PIPE)
340     CHECK_FUNCTION_EXISTS(kill HAVE_KILL)
341     CHECK_FUNCTION_EXISTS(open HAVE_OPEN)
342     IF(WIN32 OR (HAVE_OPEN AND HAVE_KILL AND HAVE_PIPE AND HAVE_FORK))
343         SET(HAS_TIMIDITY 1)
344     ELSE(WIN32 OR (HAVE_OPEN AND HAVE_KILL AND HAVE_PIPE AND HAVE_FORK))
345         SET(HAS_TIMIDITY 0)
346     ENDIF(WIN32 OR (HAVE_OPEN AND HAVE_KILL AND HAVE_PIPE AND HAVE_FORK))
347 ENDIF(TIMIDITY)
349 # GStreamer support
350 IF(GSTREAMER)
351     PKG_CHECK_MODULES(GST gstreamer-0.10;gstreamer-plugins-base-0.10)
352     IF(GST_FOUND)
353         CHECK_SHARED_LIBRARY_EXISTS(gstapp-0.10 gst_app_sink_pull_buffer "" HAS_GSTAPP)
354         IF(HAS_GSTAPP)
355             SET(HAS_GSTREAMER 1)
356             INCLUDE_DIRECTORIES(${GST_INCLUDE_DIRS})
357             LINK_DIRECTORIES(${GST_LIBRARY_DIRS})
358             SET(EXTRA_LIBS gstapp-0.10 ${EXTRA_LIBS})
359         ENDIF(HAS_GSTAPP)
360     ELSE(GST_FOUND)
361         SET(GST_SEARCH_PATHS
362             ENV GSTSDK_DIR
363             ENV MINGDIR
364             "C:/Program Files/gstreamer"
365             "C:/gstreamer" )
367         MESSAGE(STATUS "Looking for glib.h")
368         FIND_PATH(GLIB_INCLUDE_DIR glib.h
369                   PATHS ${GST_SEARCH_PATHS}
370                   PATH_SUFFIXES include include/glib-2.0)
371         IF(GLIB_INCLUDE_DIR)
372             MESSAGE(STATUS "Looking for glib.h - found: ${GLIB_INCLUDE_DIR}")
373         ELSE(GLIB_INCLUDE_DIR)
374             MESSAGE(STATUS "Looking for glib.h - not found")
375         ENDIF(GLIB_INCLUDE_DIR)
377         MESSAGE(STATUS "Looking for gst/gst.h")
378         FIND_PATH(GST_INCLUDE_DIR gst/gst.h
379                   PATHS ${GST_SEARCH_PATHS}
380                   PATH_SUFFIXES include include/gstreamer-0.10)
381         IF(GST_INCLUDE_DIR)
382             MESSAGE(STATUS "Looking for gst/gst.h - found: ${GST_INCLUDE_DIR}")
383         ELSE(GST_INCLUDE_DIR)
384             MESSAGE(STATUS "Looking for gst/gst.h - not found")
385         ENDIF(GST_INCLUDE_DIR)
387         IF(GLIB_INCLUDE_DIR AND GST_INCLUDE_DIR)
388             INCLUDE_DIRECTORIES("${GLIB_INCLUDE_DIR}" "${GST_INCLUDE_DIR}")
389             FIND_LIBRARY(GST_LIBRARY1 NAMES gstapp-0.10
390                          PATHS ${GST_SEARCH_PATHS} PATH_SUFFIXES lib )
391             FIND_LIBRARY(GST_LIBRARY2 NAMES gstreamer-0.10
392                          PATHS ${GST_SEARCH_PATHS} PATH_SUFFIXES lib )
393             FIND_LIBRARY(GST_LIBRARY3 NAMES gthread-2.0
394                          PATHS ${GST_SEARCH_PATHS} PATH_SUFFIXES lib )
395             FIND_LIBRARY(GST_LIBRARY4 NAMES gmodule-2.0
396                          PATHS ${GST_SEARCH_PATHS} PATH_SUFFIXES lib )
397             FIND_LIBRARY(GST_LIBRARY5 NAMES gobject-2.0
398                          PATHS ${GST_SEARCH_PATHS} PATH_SUFFIXES lib )
399             FIND_LIBRARY(GST_LIBRARY6 NAMES glib-2.0
400                          PATHS ${GST_SEARCH_PATHS} PATH_SUFFIXES lib )
401             IF(GST_LIBRARY1 AND GST_LIBRARY2 AND GST_LIBRARY3 AND GST_LIBRARY4 AND GST_LIBRARY5 AND GST_LIBRARY6)
402                 SET(GST_LIBRARIES "${GST_LIBRARY1}" "${GST_LIBRARY2}" "${GST_LIBRARY3}" "${GST_LIBRARY4}" "${GST_LIBRARY5}" "${GST_LIBRARY6}")
403                 MESSAGE(STATUS "GStreamer libs: ${GST_LIBRARIES}")
404                 SET(HAS_GSTREAMER 1)
405             ENDIF(GST_LIBRARY1 AND GST_LIBRARY2 AND GST_LIBRARY3 AND GST_LIBRARY4 AND GST_LIBRARY5 AND GST_LIBRARY6)
406         ENDIF(GLIB_INCLUDE_DIR AND GST_INCLUDE_DIR)
407     ENDIF(GST_FOUND)
408 ELSE(GSTREAMER)
409     SET(GST_LIBRARIES "")
410 ENDIF(GSTREAMER)
413 IF(NOT DYNLOAD)
414     SET(EXTRA_LIBS ${SNDFILE_LIBRARIES} ${VORBISFILE_LIBRARIES} ${LIBFLAC_LIBRARIES} ${MPG123_LIBRARIES} ${DUMB_LIBRARIES} ${EXTRA_LIBS})
415 ELSE(NOT DYNLOAD)
416     ADD_DEFINITIONS(-DDYNLOAD=1)
417 ENDIF(NOT DYNLOAD)
419 # For alure.pc.in
420 SET(prefix ${CMAKE_INSTALL_PREFIX})
421 SET(exec_prefix "\${prefix}")
422 SET(libdir "\${exec_prefix}/${LIB_INSTALL_DIR}")
423 SET(bindir "\${exec_prefix}/bin")
424 SET(includedir "\${prefix}/include")
425 SET(PKG_CONFIG_REQUIRES openal)
426 SET(PACKAGE_VERSION "${LIB_VERSION}")
428 # End configuration
429 CONFIGURE_FILE(
430     "${ALURE_SOURCE_DIR}/config.h.in"
431     "${ALURE_BINARY_DIR}/config.h")
432 CONFIGURE_FILE(
433     "${ALURE_SOURCE_DIR}/alure.pc.in"
434     "${ALURE_BINARY_DIR}/alure.pc"
435     @ONLY)
438 SET(ALURE_OBJS  src/alure.cpp
439                 src/buffer.cpp
440                 src/istream.cpp
441                 src/stream.cpp
442                 src/streamdec.cpp
443                 src/streamplay.cpp
446 IF(NOT NO_SHARED)
447     #build a shared library
448     ADD_LIBRARY(${LIBNAME} SHARED ${ALURE_OBJS})
449     SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES VERSION ${LIB_VERSION}
450                                                 SOVERSION ${LIB_MAJOR_VERSION})
451     IF(WIN32)
452         SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES PREFIX "")
453     ENDIF(WIN32)
454     TARGET_LINK_LIBRARIES(${LIBNAME} ${OPENAL_LIBRARIES} ${GST_LIBRARIES} ${EXTRA_LIBS})
455 ELSE(NOT NO_SHARED)
456     #build a static library
457     ADD_LIBRARY(${LIBNAME} STATIC ${ALURE_OBJS})
458     SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES VERSION ${LIB_VERSION})
459 ENDIF(NOT NO_SHARED)
462 ADD_EXECUTABLE(alureplay examples/alureplay.c)
463 TARGET_LINK_LIBRARIES(alureplay ${LIBNAME} ${OPENAL_LIBRARIES} ${GST_LIBRARIES} ${EXTRA_LIBS})
465 ADD_EXECUTABLE(alurestream examples/alurestream.c)
466 TARGET_LINK_LIBRARIES(alurestream ${LIBNAME} ${OPENAL_LIBRARIES} ${GST_LIBRARIES} ${EXTRA_LIBS})
469 FIND_PROGRAM(NATDOCS_BIN NaturalDocs)
470 IF(NATDOCS_BIN)
471     ADD_CUSTOM_TARGET(docs
472                       "${NATDOCS_BIN}" -i "${ALURE_SOURCE_DIR}/src" -o HTML "${ALURE_SOURCE_DIR}/docs/html" -p "${ALURE_SOURCE_DIR}/docs/naturaldocs" -s Default CustomStyle
473                       COMMENT "Building NaturalDocs documentation..." VERBATIM)
474 ELSE(NATDOCS_BIN)
475     MESSAGE(STATUS "\nNaturalDocs not found; building documentation is disabled")
476 ENDIF(NATDOCS_BIN)
479 #add an install target here
480 IF(APPLE)
481     SET(INCPATH OpenAL)
482 ELSE(APPLE)
483     SET(INCPATH AL)
484 ENDIF(APPLE)
486 INSTALL(DIRECTORY "${ALURE_SOURCE_DIR}/docs/html"
487         DESTINATION share/doc/alure
489 INSTALL(TARGETS ${LIBNAME}
490         RUNTIME DESTINATION bin
491         LIBRARY DESTINATION ${LIB_INSTALL_DIR}
492         ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
494 INSTALL(FILES include/AL/alure.h
495         DESTINATION "include/${INCPATH}"
497 INSTALL(FILES "${ALURE_BINARY_DIR}/alure.pc"
498         DESTINATION "${LIB_INSTALL_DIR}/pkgconfig"
502 MESSAGE(STATUS "\n********************** Configured options **********************")
503 IF(NO_SHARED)
504     MESSAGE(STATUS "Building static library")
505 ELSE(NO_SHARED)
506     MESSAGE(STATUS "Building shared library")
507 ENDIF(NO_SHARED)
508 MESSAGE(STATUS "")
509 IF(HAS_SNDFILE)
510     MESSAGE(STATUS "SndFile support: enabled")
511 ELSE(HAS_SNDFILE)
512     MESSAGE(STATUS "SndFile support: disabled")
513 ENDIF(HAS_SNDFILE)
514 IF(HAS_VORBISFILE)
515     MESSAGE(STATUS "VorbisFile support: enabled")
516 ELSE(HAS_VORBISFILE)
517     MESSAGE(STATUS "VorbisFile support: disabled")
518 ENDIF(HAS_VORBISFILE)
519 IF(HAS_FLAC)
520     MESSAGE(STATUS "FLAC support: enabled")
521 ELSE(HAS_FLAC)
522     MESSAGE(STATUS "FLAC support: disabled")
523 ENDIF(HAS_FLAC)
524 IF(HAS_MPG123)
525     MESSAGE(STATUS "MPG123 support: enabled")
526 ELSE(HAS_MPG123)
527     MESSAGE(STATUS "MPG123 support: disabled")
528 ENDIF(HAS_MPG123)
529 IF(HAS_DUMB)
530     MESSAGE(STATUS "DUMB support: enabled")
531 ELSE(HAS_DUMB)
532     MESSAGE(STATUS "DUMB support: disabled")
533 ENDIF(HAS_DUMB)
534 IF(HAS_TIMIDITY)
535     MESSAGE(STATUS "Timidity support: enabled")
536 ELSE(HAS_TIMIDTY)
537     MESSAGE(STATUS "Timidity support: disabled")
538 ENDIF(HAS_TIMIDITY)
539 IF(HAS_GSTREAMER)
540     MESSAGE(STATUS "GStreamer support: enabled")
541 ELSE(HAS_GSTREAMER)
542     MESSAGE(STATUS "GStreamer support: disabled")
543 ENDIF(HAS_GSTREAMER)
544 MESSAGE(STATUS "")