summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmake/FindSndFile.cmake8
-rw-r--r--cmake/Findopusfile.cmake67
-rw-r--r--src/CMakeLists.txt8
3 files changed, 78 insertions, 5 deletions
diff --git a/cmake/FindSndFile.cmake b/cmake/FindSndFile.cmake
index 05ef0510..f0e2883e 100644
--- a/cmake/FindSndFile.cmake
+++ b/cmake/FindSndFile.cmake
@@ -8,7 +8,7 @@
# SNDFILE_INCLUDE_DIRS - the libsndfile include directory
# SNDFILE_LIBRARIES - Link these to use libsndfile
# SNDFILE_CFLAGS - Compile options to use libsndfile
-# SndFile::SNdFile - Imported library of libsndfile
+# SndFile::SndFile - Imported library of libsndfile
#
# Copyright (C) 2006 Wengo
#
@@ -48,15 +48,15 @@ find_library(SNDFILE_LIBRARY
set(SNDFILE_CFLAGS "${PKG_SNDFILE_CFLAGS_OTHER}" CACHE STRING "CFLAGS of libsndfile")
-set(SNDFILE_INCLUDE_DIRS ${SNDFILE_INCLUDE_DIR})
-set(SNDFILE_LIBRARIES ${SNDFILE_LIBRARY})
+set(SNDFILE_INCLUDE_DIRS "${SNDFILE_INCLUDE_DIR}")
+set(SNDFILE_LIBRARIES "${SNDFILE_LIBRARY}")
if (SNDFILE_INCLUDE_DIRS AND SNDFILE_LIBRARIES)
set(SNDFILE_FOUND TRUE)
endif (SNDFILE_INCLUDE_DIRS AND SNDFILE_LIBRARIES)
-# handle the QUIETLY and REQUIRED arguments and set SNdFile_FOUND to TRUE if
+# handle the QUIETLY and REQUIRED arguments and set SndFile_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SndFile DEFAULT_MSG SNDFILE_INCLUDE_DIRS SNDFILE_LIBRARIES)
diff --git a/cmake/Findopusfile.cmake b/cmake/Findopusfile.cmake
new file mode 100644
index 00000000..43d285eb
--- /dev/null
+++ b/cmake/Findopusfile.cmake
@@ -0,0 +1,67 @@
+# - Try to find opusfile
+#
+# Once done this will define
+#
+# OPUSFILE_FOUND - system has opusfile
+# OPUSFILE_INCLUDE_DIRS - the opusfile include directories
+# OPUSFILE_LIBRARIES - Link these to use opusfile
+# OPUSFILE_CFLAGS - Compile options to use opusfile
+# opusfile::opusfile - Imported library of opusfile
+#
+
+# FIXME: opusfile does not ship an official opusfile cmake script,
+# rename this file/variables/target when/if it has.
+
+find_package(PkgConfig QUIET)
+if(PKG_CONFIG_FOUND)
+ pkg_search_module(PKG_OPUSFILE "opusfile")
+endif()
+
+find_path(OPUSFILE_INCLUDE_DIR
+ NAMES
+ opusfile.h
+ PATH_SUFFIXES
+ opusfile
+ HINTS
+ ${PKG_OPUSFILE_INCLUDE_DIRS}
+ PATHS
+ /usr/include
+ /usr/local/include
+ /opt/local/include
+ /sw/include
+ )
+
+find_library(OPUSFILE_LIBRARY
+ NAMES
+ opusfile
+ HINTS
+ ${PKG_OPUSFILE_LIBRARIES}
+ PATHS
+ /usr/lib
+ /usr/local/lib
+ /opt/local/lib
+ /sw/lib
+)
+
+set(OPUSFILE_CFLAGS "${PKG_OPUSFILE_CFLAGS_OTHER}" CACHE STRING "CFLAGS of opusfile")
+
+set(OPUSFILE_INCLUDE_DIRS "${OPUSFILE_INCLUDE_DIR}")
+set(OPUSFILE_LIBRARIES "${OPUSFILE_LIBRARY}")
+
+if (OPUSFILE_INCLUDE_DIRS AND OPUSFILE_LIBRARIES)
+set(OPUSFILE_FOUND TRUE)
+endif (OPUSFILE_INCLUDE_DIRS AND OPUSFILE_LIBRARIES)
+
+
+# handle the QUIETLY and REQUIRED arguments and set Opusfile_FOUND to TRUE if
+# all listed variables are TRUE
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(opusfile DEFAULT_MSG OPUSFILE_INCLUDE_DIRS OPUSFILE_LIBRARIES)
+
+if(NOT TARGET opusfile::opusfile)
+ add_library(__opusfile INTERFACE)
+ target_compile_options(__opusfile INTERFACE ${OPUSFILE_CFLAGS})
+ target_include_directories(__opusfile INTERFACE ${OPUSFILE_INCLUDE_DIRS})
+ target_link_libraries(__opusfile INTERFACE ${OPUSFILE_LIBRARIES})
+ add_library(opusfile::opusfile ALIAS __opusfile)
+endif()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 502255df..e943b908 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -40,19 +40,25 @@ if(RE3_AUDIO STREQUAL "OAL")
find_package(OpenAL REQUIRED)
target_include_directories(re3 PRIVATE ${OPENAL_INCLUDE_DIR})
target_link_libraries(re3 PRIVATE ${OPENAL_LIBRARY})
+ target_compile_definitions(re3 PRIVATE ${OPENAL_DEFINITIONS})
target_compile_definitions(re3 PRIVATE AUDIO_OAL)
elseif(RE3_AUDIO STREQUAL "MSS")
target_compile_definitions(re3 PRIVATE AUDIO_MSS)
endif()
if(RE3_WITH_OPUS)
+ find_package(opusfile REQUIRED)
+ target_link_libraries(re3 PRIVATE
+ opusfile::opusfile
+ )
+ target_compile_definitions(re3 PRIVATE AUDIO_OPUS)
+else()
find_package(mpg123 REQUIRED)
find_package(SndFile REQUIRED)
target_link_libraries(re3 PRIVATE
MPG123::libmpg123
SndFile::SndFile
)
- target_compile_definitions(re3 PRIVATE AUDIO_OPUS)
endif()
target_compile_definitions(re3 PRIVATE )