Add Atrac9 and Speex to cmake on Linux

This commit is contained in:
LoveEevee 2021-08-27 17:04:32 +03:00
parent 4cda04d025
commit 4bd621abac
3 changed files with 126 additions and 26 deletions

View File

@ -53,12 +53,15 @@ option(USE_G719 "Use libg719_decode for support ITU-T G.719" ON)
if(NOT WIN32)
set(G719_PATH CACHE PATH "Path to G.719 decoder")
endif()
option(USE_ATRAC9 "Use LibAtrac9 for support of ATRAC9" ON)
if(NOT WIN32)
set(ATRAC9_PATH CACHE PATH "Path to LibAtrac9")
endif()
if(WIN32)
# May need to see if it is possible to get these to work on non-Windows systems too
option(USE_ATRAC9 "Use LibAtrac9 for support of ATRAC9" ON)
option(USE_CELT "Use libcelt for support of FSB CELT versions 0.6.1 and 0.11.0" ON)
option(USE_SPEEX "Use libspeex for support of SPEEX" ON)
endif()
option(USE_SPEEX "Use libspeex for support of SPEEX" ON)
# Build choices
option(BUILD_CLI "Build vgmstream CLI" ON)
@ -224,30 +227,64 @@ if(USE_MAIATRAC3PLUS)
message(FATAL_ERROR "Path to MAIATRAC3+ must be set. (Use MAIATRAC3PLUS_PATH)")
endif()
endif()
if(NOT WIN32 AND USE_G719)
if(G719_PATH)
configure_file(
${VGM_SOURCE_DIR}/ext_libs/libg719_decode/CMakeLists.txt
${G719_PATH}/CMakeLists.txt
COPYONLY)
add_subdirectory(${G719_PATH})
else()
if(NOT WIN32)
find_package(Git QUIET)
if(Git_FOUND)
include(FetchContent)
endif()
if(USE_G719)
if(NOT G719_PATH)
if(Git_FOUND)
set(G719_PATH ${VGM_SOURCE_DIR}/dependencies/libg719_decode)
FetchContent_Populate(libg719_decode
GIT_REPOSITORY https://github.com/kode54/libg719_decode.git
SOURCE_DIR ${VGM_SOURCE_DIR}/dependencies/libg719_decode
GIT_REPOSITORY https://github.com/kode54/libg719_decode
SOURCE_DIR ${G719_PATH}
BINARY_DIR ${G719_PATH}-build
SUBBUILD_DIR ${G719_PATH}-subbuild
)
configure_file(
${VGM_SOURCE_DIR}/ext_libs/libg719_decode/CMakeLists.txt
${VGM_SOURCE_DIR}/dependencies/libg719_decode/CMakeLists.txt
COPYONLY)
add_subdirectory(${libg719_decode_SOURCE_DIR})
else()
set(USE_G719 OFF)
endif()
endif()
if(G719_PATH)
configure_file(
${VGM_SOURCE_DIR}/ext_libs/libg719_decode/CMakeLists.txt
${G719_PATH}/
COPYONLY)
add_subdirectory(${G719_PATH})
endif()
endif()
if(USE_ATRAC9)
if(NOT ATRAC9_PATH)
if(Git_FOUND)
set(ATRAC9_PATH ${VGM_SOURCE_DIR}/dependencies/LibAtrac9)
FetchContent_Populate(ATRAC9_FETCH
GIT_REPOSITORY https://github.com/Thealexbarney/LibAtrac9
SOURCE_DIR ${ATRAC9_PATH}
BINARY_DIR ${ATRAC9_PATH}-build
SUBBUILD_DIR ${ATRAC9_PATH}-subbuild
)
else()
set(USE_ATRAC9 OFF)
endif()
endif()
if(ATRAC9_PATH)
add_custom_target(ATRAC9_MAKE ALL
COMMAND make static CFLAGS="-fPIC"
WORKING_DIRECTORY ${ATRAC9_PATH}/C
)
add_library(atrac9 STATIC IMPORTED)
set_target_properties(atrac9 PROPERTIES
IMPORTED_LOCATION ${ATRAC9_PATH}/C/bin/libatrac9.a
)
endif()
endif()
if(USE_SPEEX)
find_package(Speex)
if(NOT Speex_FOUND)
set(USE_SPEEX OFF)
endif()
endif()
endif()
add_subdirectory(src)
if(WIN32)
@ -302,11 +339,11 @@ message(STATUS " FFmpeg: ${USE_FFMPEG}")
message(STATUS " MAIATRAC3+: ${USE_MAIATRAC3PLUS}")
message(STATUS " G.722.1: ${USE_G7221}")
message(STATUS " G.719: ${USE_G719}")
if(WIN32)
message(STATUS " ATRAC9: ${USE_ATRAC9}")
if(WIN32)
message(STATUS " FSB CELT: ${USE_CELT}")
message(STATUS " SPEEX: ${USE_SPEEX}")
endif()
message(STATUS " SPEEX: ${USE_SPEEX}")
message(STATUS "")
# Build Summary

57
cmake/FindSpeex.cmake Normal file
View File

@ -0,0 +1,57 @@
# - Find Speex
# Find the native Speex includes and libraries
#
# SPEEX_INCLUDE_DIRS - where to find speex.h, etc.
# SPEEX_LIBRARIES - List of libraries when using Speex.
# SPEEX_FOUND - True if Speex found.
# Comes from https://github.com/libsndfile/libsndfile/blob/master/cmake/FindSpeex.cmake
if (SPEEX_INCLUDE_DIR)
set (SPEEX_FIND_QUIETLY TRUE)
endif ()
find_package (PkgConfig QUIET)
pkg_check_modules (PC_SPEEX QUIET speex)
set (SPEEX_VERSION ${PC_SPEEX_VERSION})
find_path (SPEEX_INCLUDE_DIR speex/speex.h
HINTS
${PC_SPEEX_INCLUDEDIR}
${PC_SPEEX_INCLUDE_DIRS}
${SPEEX_ROOT}
)
find_library (SPEEX_LIBRARY
NAMES
speex
libspeex
HINTS
${PC_SPEEX_LIBDIR}
${PC_SPEEX_LIBRARY_DIRS}
${SPEEX_ROOT}
)
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (Speex
REQUIRED_VARS
SPEEX_LIBRARY
SPEEX_INCLUDE_DIR
VERSION_VAR
SPEEX_VERSION
)
if (SPEEX_FOUND)
set (SPEEX_LIBRARIES ${SPEEX_LIBRARY})
set (SPEEX_INCLUDE_DIRS ${SPEEX_INCLUDE_DIR})
if (NOT TARGET Speex::Speex)
add_library (Speex::Speex UNKNOWN IMPORTED)
set_target_properties (Speex::Speex PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${SPEEX_INCLUDE_DIRS}"
IMPORTED_LOCATION "${SPEEX_LIBRARIES}"
)
endif ()
endif ()
mark_as_advanced (SPEEX_INCLUDE_DIR SPEEX_LIBRARY)

View File

@ -100,10 +100,13 @@ macro(setup_target TARGET)
if(USE_ATRAC9)
target_compile_definitions(${TARGET} PRIVATE VGM_USE_ATRAC9)
if(LINK)
if(WIN32 AND LINK)
add_dependencies(${TARGET} libatrac9)
target_link_libraries(${TARGET} ${VGM_BINARY_DIR}/ext_libs/libatrac9.lib)
endif()
if(NOT WIN32 AND LINK)
target_link_libraries(${TARGET} atrac9)
endif()
endif()
if(USE_CELT)
@ -118,10 +121,13 @@ macro(setup_target TARGET)
if(USE_SPEEX)
target_compile_definitions(${TARGET} PRIVATE VGM_USE_SPEEX)
if(LINK)
if(WIN32 AND LINK)
add_dependencies(${TARGET} libspeex)
target_link_libraries(${TARGET} ${VGM_BINARY_DIR}/ext_libs/libspeex/libspeex.lib)
endif()
if(NOT WIN32 AND LINK)
target_link_libraries(${TARGET} speex)
endif()
endif()
endmacro()