@@ -6,6 +6,7 @@ if(WIN32)
6
6
endif ()
7
7
option (WANT_VORBIS "Enable Ogg Vorbis support using libvorbis" on )
8
8
option (WANT_TREMOR "Enable Ogg Vorbis support using Tremor" off )
9
+ option (WANT_OPUS "Enable Opus support using libopus" on )
9
10
option (WANT_MODAUDIO "Enable MOD Audio support" on )
10
11
option (WANT_ACODEC_DYNAMIC_LOAD "Enable DLL loading in acodec (Windows)" off )
11
12
@@ -268,6 +269,63 @@ if(SUPPORT_VORBIS)
268
269
endif ()
269
270
endif (SUPPORT_VORBIS)
270
271
272
+ #
273
+ # Opus
274
+ #
275
+
276
+ if (WANT_OPUS)
277
+ find_package (Opus)
278
+ if (OPUS_FOUND)
279
+ set (CMAKE_REQUIRED_INCLUDES ${OGG_INCLUDE_DIR} ${OPUS_INCLUDE_DIR} )
280
+ if (COMPILER_GCC_OR_CLANG)
281
+ # libm is required when linking statically.
282
+ set (CMAKE_REQUIRED_LIBRARIES "${OPUS_LIBRARIES} ;m" )
283
+ else ()
284
+ set (CMAKE_REQUIRED_LIBRARIES "${OPUS_LIBRARIES} " )
285
+ endif (COMPILER_GCC_OR_CLANG)
286
+ run_c_compile_test("
287
+ #include <opus/opusfile.h>
288
+ int main(void)
289
+ {
290
+ OggOpusFile *f;
291
+ OpusHead *v = 0;
292
+ (void)v;
293
+ op_free(f);
294
+ return 0;
295
+ }"
296
+ OPUS_COMPILES)
297
+ set (CMAKE_REQUIRED_INCLUDES)
298
+ set (CMAKE_REQUIRED_LIBRARIES)
299
+ if (OPUS_COMPILES)
300
+ set (SUPPORT_OPUS 1)
301
+ endif ()
302
+ endif (OPUS_FOUND)
303
+ if (NOT SUPPORT_OPUS)
304
+ message ("WARNING: libopus not found or compile test failed, disabling support." )
305
+ endif (NOT SUPPORT_OPUS)
306
+ endif ()
307
+
308
+ if (SUPPORT_OPUS)
309
+ include_directories (SYSTEM ${OGG_INCLUDE_DIR} ${OPUS_INCLUDE_DIR} )
310
+ set (ALLEGRO_CFG_ACODEC_OPUS 1)
311
+ list (APPEND ACODEC_SOURCES opus.c)
312
+
313
+ list (APPEND ACODEC_INCLUDE_DIRECTORIES ${OGG_INCLUDE_DIR} ${OPUS_INCLUDE_DIR} )
314
+
315
+ if (WIN32 AND WANT_ACODEC_DYNAMIC_LOAD)
316
+ if (OPUSFILE_LIBRARY MATCHES "${WIN32_STATIC_LIB_REGEX} " )
317
+ message ("WARNING: Dynamic loading will be disabled for Opus"
318
+ " as static library was found: ${OPUSFILE_LIBRARY} " )
319
+ else ()
320
+ get_dll_name(${OPUSFILE_LIBRARY} ALLEGRO_CFG_ACODEC_OPUSFILE_DLL)
321
+ endif ()
322
+ endif ()
323
+
324
+ if (NOT ALLEGRO_CFG_ACODEC_OPUSFILE_DLL)
325
+ list (APPEND ACODEC_LIBRARIES ${OPUS_LIBRARIES} )
326
+ endif ()
327
+ endif (SUPPORT_OPUS)
328
+
271
329
configure_file (
272
330
allegro5/internal /aintern_acodec_cfg.h.cmake
273
331
${PROJECT_BINARY_DIR} /include /allegro5/internal /aintern_acodec_cfg.h
0 commit comments