Use a better method to check for shared functions
[alure.git] / CMakeLists.txt
blob561cdd94c6c51b95284d93a15ee7bd895c0e993e
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(CheckSharedFunctionExists)
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_LIBRARY_EXISTS(stdc++ memset "" HAS_STDCXX)
57 IF(HAS_STDCXX)
58     SET(EXTRA_LIBS stdc++ ${EXTRA_LIBS})
59 ENDIF(HAS_STDCXX)
61 CHECK_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         # Force -fPIC for the static lib, because it causes problems when the
87         # static version is linked to a dynamic lib
88         SET(STATIC_CFLAGS "${STATIC_CFLAGS} -fPIC")
89     ENDIF(NOT WIN32)
91     CHECK_C_COMPILER_FLAG(-Wextra HAVE_WEXTRA)
92     IF(HAVE_WEXTRA)
93         ADD_DEFINITIONS(-Wextra)
94     ENDIF(HAVE_WEXTRA)
95     ADD_DEFINITIONS(-Wall)
97     CHECK_C_COMPILER_FLAG(-funswitch-loops HAVE_FUNSWITCH_LOOPS)
98     IF(HAVE_FUNSWITCH_LOOPS)
99         ADD_DEFINITIONS(-funswitch-loops)
100     ENDIF(HAVE_FUNSWITCH_LOOPS)
101 ENDIF(MSVC)
103 # Set visibility/export options if available
104 SET(EXPORT_DECL "")
105 IF(WIN32)
106     SET(EXPORT_DECL "__declspec(dllexport)")
107 ELSE(WIN32)
108     CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAVE_VISIBILITY_SWITCH)
109     CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"protected\")));
110                              int main() {return 0;}" HAVE_GCC_VISIBILITY)
111     IF(HAVE_VISIBILITY_SWITCH AND HAVE_GCC_VISIBILITY)
112         ADD_DEFINITIONS(-fvisibility=hidden)
113         SET(EXPORT_DECL "__attribute__((visibility(\"protected\")))")
114     ENDIF(HAVE_VISIBILITY_SWITCH AND HAVE_GCC_VISIBILITY)
115 ENDIF(WIN32)
118 CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H -D_WIN32_WINNT=0x0500)
119 IF(HAVE_WINDOWS_H)
120     CHECK_INCLUDE_FILE(ddk/ntddcdrm.h HAVE_DDK_NTDDCDRM_H)
121 ELSE(HAVE_WINDOWS_H)
122     CHECK_C_COMPILER_FLAG(-pthread HAVE_PTHREAD)
123     IF(HAVE_PTHREAD)
124         ADD_DEFINITIONS(-pthread)
125         SET(EXTRA_LIBS ${EXTRA_LIBS} -pthread)
126     ENDIF(HAVE_PTHREAD)
128     # We need pthreads outside of Windows
129     CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H)
130     IF(NOT HAVE_PTHREAD_H)
131         MESSAGE(FATAL_ERROR "PThreads is required for non-Windows builds!")
132     ENDIF()
133     # Some systems need pthread_np.h to get recursive mutexes
134     CHECK_INCLUDE_FILES("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H)
136     # _GNU_SOURCE is needed on some systems for extra attributes, and
137     # _REENTRANT is needed for libc thread-safety
138     ADD_DEFINITIONS(-D_GNU_SOURCE=1)
139     CHECK_FUNCTION_EXISTS(pthread_create HAS_PTHREAD_CREATE)
140     IF(NOT HAS_PTHREAD_CREATE)
141         CHECK_SHARED_FUNCTION_EXISTS(pthread_create "pthread.h" pthread "" HAVE_LIBPTHREAD)
142         IF(NOT HAVE_LIBPTHREAD)
143             MESSAGE(FATAL_ERROR "pthread_create not found on non-Windows target!")
144         ENDIF(NOT HAVE_LIBPTHREAD)
145         SET(EXTRA_LIBS pthread ${EXTRA_LIBS})
146     ENDIF(NOT HAS_PTHREAD_CREATE)
148     CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP)
149     IF(NOT HAVE_NANOSLEEP)
150         MESSAGE(FATAL_ERROR "No sleep function found!")
151     ENDIF(NOT HAVE_NANOSLEEP)
152 ENDIF(HAVE_WINDOWS_H)
154 CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H)
155 CHECK_INCLUDE_FILE(sys/wait.h HAVE_SYS_WAIT_H)
156 CHECK_INCLUDE_FILE(signal.h HAVE_SIGNAL_H)
157 CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H)
159 IF(HAVE_DLFCN_H)
160     CHECK_SHARED_FUNCTION_EXISTS(dlopen "dlfcn.h" dl "" HAVE_LIBDL)
161     IF(HAVE_LIBDL)
162         SET(EXTRA_LIBS dl ${EXTRA_LIBS})
163     ENDIF(HAVE_LIBDL)
164 ENDIF(HAVE_DLFCN_H)
166 OPTION(DYNLOAD    "Dynamically load support libs at run-time" ON)
167 OPTION(SNDFILE    "SoundFile support (for various formats)" ON)
168 OPTION(VORBIS     "VorbisFile support (for Ogg Vorbis)"  ON)
169 OPTION(FLAC       "FLAC support (for FLAC and Ogg FLAC)" ON)
170 OPTION(MPG123     "MPG123 support (for MP1/MP2/MP3)" ON)
171 OPTION(DUMB       "DUMB support (for IT/XM/S3M/MOD)" ON)
172 OPTION(MODPLUG    "ModPlug support (for IT/XM/S3M/MOD)" OFF)
173 OPTION(FLUIDSYNTH "FluidSynth support (for MID)" ON)
175 IF(WIN32)
176     ADD_DEFINITIONS(-D_WIN32)
177 ELSE(WIN32)
178     IF(NOT HAVE_DLFCN_H OR NOT HAVE_LIBDL)
179         SET(DYNLOAD OFF)
180     ENDIF(NOT HAVE_DLFCN_H OR NOT HAVE_LIBDL)
181     PKG_CHECK_MODULES(OPENAL openal)
182 ENDIF(WIN32)
184 IF(NOT OPENAL_FOUND)
185     FIND_PACKAGE(OpenAL)
186     IF(NOT OPENAL_FOUND)
187         MESSAGE(FATAL_ERROR "OpenAL not found!\nPlease try setting the OPENALDIR environment variable and try again.")
188     ENDIF(NOT OPENAL_FOUND)
190     MESSAGE(STATUS "OpenAL include: ${OPENAL_INCLUDE_DIR}")
191     MESSAGE(STATUS "OpenAL lib: ${OPENAL_LIBRARY}")
193     INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR})
194     SET(OPENAL_LIBRARIES ${OPENAL_LIBRARY})
195 ELSE(NOT OPENAL_FOUND)
196     INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIRS})
197     LINK_DIRECTORIES(${OPENAL_LIBRARY_DIRS})
198 ENDIF(NOT OPENAL_FOUND)
200 # Base source files
201 SET(ALURE_OBJS  src/alure.cpp
202                 src/buffer.cpp
203                 src/istream.cpp
204                 src/stream.cpp
205                 src/streamdec.cpp
206                 src/streamplay.cpp
207                 src/codec_wav.cpp
208                 src/codec_aiff.cpp
211 # SndFile support
212 IF(SNDFILE)
213     PKG_CHECK_MODULES(SNDFILE sndfile)
214     IF(SNDFILE_FOUND)
215         SET(HAS_SNDFILE 1)
216         LINK_DIRECTORIES(${SNDFILE_LIBRARY_DIRS})
217         SET_SOURCE_FILES_PROPERTIES(src/codec_sndfile.cpp PROPERTIES
218                                     COMPILE_FLAGS "${SNDFILE_CFLAGS}")
219     ELSE(SNDFILE_FOUND)
220         FIND_PACKAGE(SndFile)
221         IF(SNDFILE_FOUND)
222             SET(HAS_SNDFILE 1)
223             INCLUDE_DIRECTORIES(${SNDFILE_INCLUDE_DIRS})
224         ENDIF(SNDFILE_FOUND)
225     ENDIF(SNDFILE_FOUND)
226     IF(HAS_SNDFILE)
227         SET(ALURE_OBJS ${ALURE_OBJS} src/codec_sndfile.cpp)
228     ENDIF(HAS_SNDFILE)
229 ELSE(SNDFILE)
230     SET(SNDFILE_LIBRARIES "")
231 ENDIF(SNDFILE)
233 # Vorbis support
234 IF(VORBIS)
235     PKG_CHECK_MODULES(VORBISFILE vorbisfile)
236     IF(VORBISFILE_FOUND)
237         SET(HAS_VORBISFILE 1)
238         LINK_DIRECTORIES(${VORBISFILE_LIBRARY_DIRS})
239         SET_SOURCE_FILES_PROPERTIES(src/codec_vorbisfile.cpp PROPERTIES
240                                     COMPILE_FLAGS "${VORBISFILE_CFLAGS}")
241     ELSE(VORBISFILE_FOUND)
242         FIND_PACKAGE(OggVorbis)
243         IF(OGGVORBIS_FOUND)
244             SET(HAS_VORBISFILE 1)
245             INCLUDE_DIRECTORIES(${OGGVORBIS_INCLUDE_DIRS})
246             SET(VORBISFILE_LIBRARIES ${OGGVORBIS_LIBRARIES})
247         ENDIF(OGGVORBIS_FOUND)
248     ENDIF(VORBISFILE_FOUND)
249     IF(NOT HAS_VORBISFILE)
250         PKG_CHECK_MODULES(VORBISIDEC vorbisidec)
251         IF(NOT VORBISIDEC_FOUND)
252             CHECK_INCLUDE_FILE(tremor/ivorbisfile.h HAVE_TREMOR_IVORBISFILE_H)
253             IF(HAVE_TREMOR_IVORBISFILE_H)
254                 CHECK_SHARED_FUNCTION_EXISTS(ov_open "tremor/ivorbisfile.h" vorbisidec "" HAVE_LIBVORBISIDEC)
255                 IF(DYNLOAD OR HAVE_LIBVORBISIDEC)
256                     SET(HAS_VORBISFILE 1)
257                     IF(HAVE_LIBVORBISIDEC)
258                         SET(VORBISFILE_LIBRARIES "vorbisidec")
259                     ENDIF(HAVE_LIBVORBISIDEC)
260                     SET_SOURCE_FILES_PROPERTIES(src/codec_vorbisfile.cpp PROPERTIES
261                                                 COMPILE_FLAGS "-DHAS_VORBISIDEC")
262                 ENDIF(DYNLOAD OR HAVE_LIBVORBISIDEC)
263             ENDIF(HAVE_TREMOR_IVORBISFILE_H)
264         ELSE(NOT VORBISIDEC_FOUND)
265             SET(HAS_VORBISFILE 1)
266             LINK_DIRECTORIES(${VORBISIDEC_LIBRARY_DIRS})
267             SET_SOURCE_FILES_PROPERTIES(src/codec_vorbisfile.cpp PROPERTIES
268                                         COMPILE_FLAGS "${VORBISIDEC_CFLAGS} -DHAS_VORBISIDEC")
269         ENDIF(NOT VORBISIDEC_FOUND)
270     ENDIF(NOT HAS_VORBISFILE)
271     IF(HAS_VORBISFILE)
272         SET(ALURE_OBJS ${ALURE_OBJS} src/codec_vorbisfile.cpp)
273     ENDIF(HAS_VORBISFILE)
274 ELSE(VORBIS)
275     SET(VORBISFILE_LIBRARIES "")
276 ENDIF(VORBIS)
278 # FLAC support
279 IF(FLAC)
280     #PKG_CHECK_MODULES(LIBFLAC flac)
281     #IF(NOT LIBFLAC_FOUND)
282         CHECK_INCLUDE_FILE(FLAC/all.h HAVE_FLAC_ALL_H)
283         IF(HAVE_FLAC_ALL_H)
284             CHECK_SHARED_FUNCTION_EXISTS(FLAC__stream_decoder_new "FLAC/all.h" FLAC "" HAVE_LIBFLAC)
285             IF(DYNLOAD OR HAVE_LIBFLAC)
286                 SET(HAS_FLAC 1)
287                 IF(HAVE_LIBFLAC)
288                     SET(LIBFLAC_LIBRARIES "FLAC")
289                 ENDIF(HAVE_LIBFLAC)
290             ENDIF(DYNLOAD OR HAVE_LIBFLAC)
291         ENDIF(HAVE_FLAC_ALL_H)
292     #ELSE(NOT LIBFLAC_FOUND)
293     #    SET(HAS_FLAC 1)
294     #    INCLUDE_DIRECTORIES(${LIBFLAC_INCLUDE_DIRS})
295     #    LINK_DIRECTORIES(${LIBFLAC_LIBRARY_DIRS})
296     #ENDIF(NOT LIBFLAC_FOUND)
297     IF(HAS_FLAC)
298         SET(ALURE_OBJS ${ALURE_OBJS} src/codec_flac.cpp)
299     ENDIF(HAS_FLAC)
300 ELSE(FLAC)
301     SET(LIBFLAC_LIBRARIES "")
302 ENDIF(FLAC)
304 # MPG123 support
305 IF(MPG123)
306     PKG_CHECK_MODULES(MPG123 libmpg123)
307     IF(NOT MPG123_FOUND)
308         CHECK_INCLUDE_FILE(mpg123.h HAVE_MPG123_H)
309         IF(HAVE_MPG123_H)
310             CHECK_SHARED_FUNCTION_EXISTS(mpg123_init "mpg123.h" mpg123 "" HAVE_LIBMPG123)
311             IF(DYNLOAD OR HAVE_LIBMPG123)
312                 SET(HAS_MPG123 1)
313                 IF(HAVE_LIBMPG123)
314                     SET(MPG123_LIBRARIES "mpg123")
315                 ENDIF(HAVE_LIBMPG123)
316             ENDIF(DYNLOAD OR HAVE_LIBMPG123)
317         ENDIF(HAVE_MPG123_H)
318     ELSE(NOT MPG123_FOUND)
319         SET(HAS_MPG123 1)
320         LINK_DIRECTORIES(${MPG123_LIBRARY_DIRS})
321         SET_SOURCE_FILES_PROPERTIES(src/codec_mpg123.cpp PROPERTIES
322                                     COMPILE_FLAGS "${MPG123_CFLAGS}")
323     ENDIF(NOT MPG123_FOUND)
324     IF(HAS_MPG123)
325         SET(ALURE_OBJS ${ALURE_OBJS} src/codec_mpg123.cpp)
326     ENDIF(HAS_MPG123)
327 ELSE(MPG123)
328     SET(MPG123_LIBRARIES "")
329 ENDIF(MPG123)
331 # DUMB support
332 IF(DUMB)
333     CHECK_INCLUDE_FILE(dumb.h HAVE_DUMB_H)
334     IF(HAVE_DUMB_H)
335         IF(HAS_LIBM)
336             CHECK_LIBRARY_EXISTS("dumb;m" dumbfile_open_ex "" HAVE_LIBDUMB)
337         ELSE(HAS_LIBM)
338             CHECK_LIBRARY_EXISTS(dumb dumbfile_open_ex "" HAVE_LIBDUMB)
339         ENDIF(HAS_LIBM)
340         IF(DYNLOAD OR HAVE_LIBDUMB)
341             SET(HAS_DUMB 1)
342             IF(HAVE_LIBDUMB)
343                 SET(DUMB_LIBRARIES dumb)
344             ENDIF(HAVE_LIBDUMB)
345         ENDIF(DYNLOAD OR HAVE_LIBDUMB)
346     ENDIF(HAVE_DUMB_H)
347     IF(HAS_DUMB)
348         SET(ALURE_OBJS ${ALURE_OBJS} src/codec_dumb.cpp)
349     ENDIF(HAS_DUMB)
350 ELSE(DUMB)
351     SET(DUMB_LIBRARIES "")
352 ENDIF(DUMB)
354 # ModPlug support
355 IF(MODPLUG)
356     PKG_CHECK_MODULES(MODPLUG libmodplug)
357     IF(NOT MODPLUG_FOUND)
358         CHECK_INCLUDE_FILE(modplug.h HAVE_MODPLUG_H)
359         IF(HAVE_MODPLUG_H)
360             CHECK_SHARED_FUNCTION_EXISTS(ModPlug_Load "modplug.h" modplug "" HAVE_LIBMODPLUG)
361             IF(DYNLOAD OR HAVE_LIBMODPLUG)
362                 SET(HAS_MODPLUG 1)
363                 IF(HAVE_LIBMODPLUG)
364                     SET(MODPLUG_LIBRARIES "modplug")
365                 ENDIF(HAVE_LIBMODPLUG)
366             ENDIF(DYNLOAD OR HAVE_LIBMODPLUG)
367         ENDIF(HAVE_MODPLUG_H)
368     ELSE(NOT MODPLUG_FOUND)
369         SET(HAS_MODPLUG 1)
370         LINK_DIRECTORIES(${MODPLUG_LIBRARY_DIRS})
371         SET_SOURCE_FILES_PROPERTIES(src/codec_modplug.cpp PROPERTIES
372                                     COMPILE_FLAGS "${MODPLUG_CFLAGS}")
373     ENDIF(NOT MODPLUG_FOUND)
374     IF(HAS_MODPLUG)
375         SET(ALURE_OBJS ${ALURE_OBJS} src/codec_modplug.cpp)
376     ENDIF(HAS_MODPLUG)
377 ELSE(MODPLUG)
378     SET(MODPLUG_LIBRARIES "")
379 ENDIF(MODPLUG)
381 # FluidSynth support
382 IF(FLUIDSYNTH)
383     PKG_CHECK_MODULES(FLUIDSYNTH fluidsynth>=1.1.1)
384     IF(NOT FLUIDSYNTH_FOUND)
385         CHECK_INCLUDE_FILE(fluidsynth.h HAVE_FLUIDSYNTH_H)
386         IF(HAVE_FLUIDSYNTH_H)
387             CHECK_SHARED_FUNCTION_EXISTS(new_fluid_synth "fluidsynth.h" fluidsynth "" HAVE_LIBFLUIDSYNTH)
388             IF(DYNLOAD OR HAVE_LIBFLUIDSYNTH)
389                 SET(HAS_FLUIDSYNTH 1)
390                 IF(HAVE_LIBFLUIDSYNTH)
391                     SET(FLUIDSYNTH_LIBRARIES "fluidsynth")
392                 ENDIF(HAVE_LIBFLUIDSYNTH)
393             ENDIF(DYNLOAD OR HAVE_LIBFLUIDSYNTH)
394         ENDIF(HAVE_FLUIDSYNTH_H)
395     ELSE(NOT FLUIDSYNTH_FOUND)
396         SET(HAS_FLUIDSYNTH 1)
397         LINK_DIRECTORIES(${FLUIDSYNTH_LIBRARY_DIRS})
398         SET_SOURCE_FILES_PROPERTIES(src/codec_fluidsynth.cpp PROPERTIES
399                                     COMPILE_FLAGS "${FLUIDSYNTH_CFLAGS}")
400     ENDIF(NOT FLUIDSYNTH_FOUND)
401     IF(HAS_FLUIDSYNTH)
402         SET(ALURE_OBJS ${ALURE_OBJS} src/codec_fluidsynth.cpp)
403     ENDIF(HAS_FLUIDSYNTH)
404 ELSE(FLUIDSYNTH)
405     SET(FLUIDSYNTH_LIBRARIES "")
406 ENDIF(FLUIDSYNTH)
409 IF(NOT DYNLOAD)
410     SET(EXTRA_LIBS ${SNDFILE_LIBRARIES} ${VORBISFILE_LIBRARIES} ${LIBFLAC_LIBRARIES} ${MPG123_LIBRARIES} ${DUMB_LIBRARIES} ${MODPLUG_LIBRARIES} ${FLUIDSYNTH_LIBRARIES} ${EXTRA_LIBS})
411 ELSE(NOT DYNLOAD)
412     ADD_DEFINITIONS(-DDYNLOAD=1)
413 ENDIF(NOT DYNLOAD)
415 # For alure.pc.in
416 SET(prefix ${CMAKE_INSTALL_PREFIX})
417 SET(exec_prefix "\${prefix}")
418 SET(libdir "\${exec_prefix}/lib${LIB_SUFFIX}")
419 SET(bindir "\${exec_prefix}/bin")
420 SET(includedir "\${prefix}/include")
421 SET(PKG_CONFIG_REQUIRES openal)
422 SET(PACKAGE_VERSION "${LIB_VERSION}")
424 # End configuration
425 CONFIGURE_FILE(
426     "${ALURE_SOURCE_DIR}/config.h.in"
427     "${ALURE_BINARY_DIR}/config.h")
428 IF(BUILD_SHARED)
429     CONFIGURE_FILE(
430         "${ALURE_SOURCE_DIR}/alure.pc.in"
431         "${ALURE_BINARY_DIR}/alure.pc"
432         @ONLY)
433 ENDIF(BUILD_SHARED)
434 IF(BUILD_STATIC)
435     CONFIGURE_FILE(
436         "${ALURE_SOURCE_DIR}/alure-static.pc.in"
437         "${ALURE_BINARY_DIR}/alure-static.pc"
438         @ONLY)
439 ENDIF(BUILD_STATIC)
441 ADD_DEFINITIONS(-DHAVE_CONFIG_H)
444 IF(BUILD_SHARED)
445     #build a shared library
446     ADD_LIBRARY(${LIBNAME} SHARED ${ALURE_OBJS})
447     SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES DEFINE_SYMBOL ALURE_BUILD_LIBRARY
448                                                 VERSION ${LIB_VERSION}.0
449                                                 SOVERSION ${LIB_MAJOR_VERSION})
450     IF(WIN32)
451         SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES PREFIX "")
452     ELSE(WIN32)
453         SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES LINK_FLAGS "-Wl,--version-script=${ALURE_SOURCE_DIR}/libalure.map")
454     ENDIF(WIN32)
455     TARGET_LINK_LIBRARIES(${LIBNAME} ${OPENAL_LIBRARIES} ${EXTRA_LIBS})
457     INSTALL(TARGETS ${LIBNAME}
458             RUNTIME DESTINATION bin
459             LIBRARY DESTINATION lib${LIB_SUFFIX}
460             ARCHIVE DESTINATION lib${LIB_SUFFIX}
462 ENDIF(BUILD_SHARED)
463 IF(BUILD_STATIC)
464     #build a static library
465     ADD_LIBRARY(${LIBNAME}-static STATIC ${ALURE_OBJS})
466     SET_TARGET_PROPERTIES(${LIBNAME}-static PROPERTIES DEFINE_SYMBOL ALURE_BUILD_LIBRARY
467                                                        COMPILE_FLAGS ${STATIC_CFLAGS}
468                                                        VERSION ${LIB_VERSION}.0)
469     INSTALL(TARGETS ${LIBNAME}-static
470             RUNTIME DESTINATION bin
471             LIBRARY DESTINATION lib${LIB_SUFFIX}
472             ARCHIVE DESTINATION lib${LIB_SUFFIX}
474 ENDIF(BUILD_STATIC)
477 IF(HAVE_DDK_NTDDCDRM_H)
478     SET_SOURCE_FILES_PROPERTIES(examples/alurecdplay.c PROPERTIES
479                                 COMPILE_FLAGS "-DHAVE_DDK_NTDDCDRM_H")
480 ENDIF(HAVE_DDK_NTDDCDRM_H)
481 ADD_EXECUTABLE(alureplay examples/alureplay.c)
482 ADD_EXECUTABLE(alurecdplay examples/alurecdplay.c)
483 ADD_EXECUTABLE(alurestream examples/alurestream.c)
484 IF(BUILD_SHARED)
485     TARGET_LINK_LIBRARIES(alureplay ${LIBNAME} ${OPENAL_LIBRARIES} ${EXTRA_LIBS})
486     TARGET_LINK_LIBRARIES(alurecdplay ${LIBNAME} ${OPENAL_LIBRARIES} ${EXTRA_LIBS})
487     TARGET_LINK_LIBRARIES(alurestream ${LIBNAME} ${OPENAL_LIBRARIES} ${EXTRA_LIBS})
488 ELSE(BUILD_SHARED)
489     SET_TARGET_PROPERTIES(alureplay PROPERTIES COMPILE_FLAGS -DALURE_STATIC_LIBRARY)
490     SET_TARGET_PROPERTIES(alurecdplay PROPERTIES COMPILE_FLAGS -DALURE_STATIC_LIBRARY)
491     SET_TARGET_PROPERTIES(alurestream PROPERTIES COMPILE_FLAGS -DALURE_STATIC_LIBRARY)
492     TARGET_LINK_LIBRARIES(alureplay ${LIBNAME}-static ${OPENAL_LIBRARIES} ${EXTRA_LIBS})
493     TARGET_LINK_LIBRARIES(alurecdplay ${LIBNAME}-static ${OPENAL_LIBRARIES} ${EXTRA_LIBS})
494     TARGET_LINK_LIBRARIES(alurestream ${LIBNAME}-static ${OPENAL_LIBRARIES} ${EXTRA_LIBS})
495 ENDIF(BUILD_SHARED)
498 FIND_PROGRAM(NATDOCS_BIN NaturalDocs)
499 IF(NATDOCS_BIN)
500     ADD_CUSTOM_TARGET(docs
501                       "${NATDOCS_BIN}" -i "${ALURE_SOURCE_DIR}/src" -o HTML "${ALURE_SOURCE_DIR}/docs/html" -p "${ALURE_SOURCE_DIR}/docs/naturaldocs" -s Default CustomStyle
502                       COMMENT "Building NaturalDocs documentation..." VERBATIM)
503 ELSE(NATDOCS_BIN)
504     MESSAGE(STATUS "\nNaturalDocs not found; building documentation is disabled")
505 ENDIF(NATDOCS_BIN)
508 #add an install target here
509 IF(APPLE)
510     SET(INCPATH OpenAL)
511 ELSE(APPLE)
512     SET(INCPATH AL)
513 ENDIF(APPLE)
515 INSTALL(DIRECTORY "${ALURE_SOURCE_DIR}/docs/html"
516         DESTINATION share/doc/alure
518 INSTALL(FILES include/AL/alure.h
519         DESTINATION "include/${INCPATH}"
521 IF(BUILD_SHARED)
522     INSTALL(FILES "${ALURE_BINARY_DIR}/alure.pc"
523             DESTINATION "lib${LIB_SUFFIX}/pkgconfig"
524     )
525 ENDIF(BUILD_SHARED)
526 IF(BUILD_STATIC)
527     INSTALL(FILES "${ALURE_BINARY_DIR}/alure-static.pc"
528             DESTINATION "lib${LIB_SUFFIX}/pkgconfig"
529     )
530 ENDIF(BUILD_STATIC)
533 MESSAGE(STATUS "\n********************** Configured options **********************")
534 IF(BUILD_SHARED AND BUILD_STATIC)
535     MESSAGE(STATUS "Building shared, static library")
536 ELSEIF(BUILD_SHARED)
537     MESSAGE(STATUS "Building shared library")
538 ELSE(BUILD_SHARED AND BUILD_STATIC)
539     MESSAGE(STATUS "Building static library")
540 ENDIF(BUILD_SHARED AND BUILD_STATIC)
541 MESSAGE(STATUS "")
542 IF(HAS_SNDFILE)
543     MESSAGE(STATUS "SndFile support: enabled")
544 ELSE(HAS_SNDFILE)
545     MESSAGE(STATUS "SndFile support: disabled")
546 ENDIF(HAS_SNDFILE)
547 IF(HAS_VORBISFILE)
548     MESSAGE(STATUS "VorbisFile support: enabled")
549 ELSE(HAS_VORBISFILE)
550     MESSAGE(STATUS "VorbisFile support: disabled")
551 ENDIF(HAS_VORBISFILE)
552 IF(HAS_FLAC)
553     MESSAGE(STATUS "FLAC support: enabled")
554 ELSE(HAS_FLAC)
555     MESSAGE(STATUS "FLAC support: disabled")
556 ENDIF(HAS_FLAC)
557 IF(HAS_MPG123)
558     MESSAGE(STATUS "MPG123 support: enabled")
559 ELSE(HAS_MPG123)
560     MESSAGE(STATUS "MPG123 support: disabled")
561 ENDIF(HAS_MPG123)
562 IF(HAS_DUMB)
563     MESSAGE(STATUS "DUMB support: enabled")
564 ELSE(HAS_DUMB)
565     MESSAGE(STATUS "DUMB support: disabled")
566 ENDIF(HAS_DUMB)
567 IF(HAS_MODPLUG)
568     MESSAGE(STATUS "ModPlug support: enabled")
569 ELSE(HAS_MODPLUG)
570     MESSAGE(STATUS "ModPlug support: disabled")
571 ENDIF(HAS_MODPLUG)
572 IF(HAS_FLUIDSYNTH)
573     MESSAGE(STATUS "FluidSynth support: enabled")
574 ELSE(HAS_FLUIDSYNTH)
575     MESSAGE(STATUS "FluidSynth support: disabled")
576 ENDIF(HAS_FLUIDSYNTH)
577 MESSAGE(STATUS "")