mirror of
https://github.com/GTAmodding/re3.git
synced 2024-11-15 02:09:02 +00:00
cmake: use openal/opusfile/mpg123/libsndfile correctly
This commit is contained in:
parent
9707eeb8cb
commit
8d0b4ede68
3 changed files with 78 additions and 5 deletions
|
@ -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)
|
||||
|
|
67
cmake/Findopusfile.cmake
Normal file
67
cmake/Findopusfile.cmake
Normal file
|
@ -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()
|
|
@ -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 )
|
||||
|
|
Loading…
Reference in a new issue