mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-28 00:20:47 +01:00
Cmake: Build FFmpeg for wasm target
This commit is contained in:
parent
b84f820b54
commit
60cb90c4a0
@ -47,6 +47,7 @@ set_mpeg(ON FALSE)
|
|||||||
set_vorbis(ON FALSE)
|
set_vorbis(ON FALSE)
|
||||||
set_ffmpeg(ON FALSE)
|
set_ffmpeg(ON FALSE)
|
||||||
|
|
||||||
|
option(USE_MAIATRAC3PLUS "Use MAIATRAC3+ for support of ATRAC3+" OFF)
|
||||||
option(USE_G7221 "Use G7221 for support of ITU-T G.722.1 annex C" ON)
|
option(USE_G7221 "Use G7221 for support of ITU-T G.722.1 annex C" ON)
|
||||||
option(USE_G719 "Use libg719_decode for support ITU-T G.719" ON)
|
option(USE_G719 "Use libg719_decode for support ITU-T G.719" ON)
|
||||||
option(USE_ATRAC9 "Use LibAtrac9 for support of ATRAC9" ON)
|
option(USE_ATRAC9 "Use LibAtrac9 for support of ATRAC9" ON)
|
||||||
@ -100,7 +101,6 @@ endif()
|
|||||||
|
|
||||||
if(EMSCRIPTEN)
|
if(EMSCRIPTEN)
|
||||||
set(USE_MPEG OFF)
|
set(USE_MPEG OFF)
|
||||||
set(USE_FFMPEG OFF)
|
|
||||||
set(USE_JANSSON OFF)
|
set(USE_JANSSON OFF)
|
||||||
set(BUILD_V123 OFF)
|
set(BUILD_V123 OFF)
|
||||||
set(BUILD_AUDACIOUS OFF)
|
set(BUILD_AUDACIOUS OFF)
|
||||||
@ -141,13 +141,6 @@ add_custom_target(version_h ALL DEPENDS ${VGM_SOURCE_DIR}/version_auto.h)
|
|||||||
include(FetchDependency)
|
include(FetchDependency)
|
||||||
|
|
||||||
include(dependencies/ffmpeg)
|
include(dependencies/ffmpeg)
|
||||||
|
|
||||||
if(USE_FFMPEG)
|
|
||||||
option(USE_MAIATRAC3PLUS "Use MAIATRAC3+ for support of ATRAC3+" OFF)
|
|
||||||
else()
|
|
||||||
option(USE_MAIATRAC3PLUS "Use MAIATRAC3+ for support of ATRAC3+" ON)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include(dependencies/mpg123)
|
include(dependencies/mpg123)
|
||||||
include(dependencies/vorbis)
|
include(dependencies/vorbis)
|
||||||
include(dependencies/libao)
|
include(dependencies/libao)
|
||||||
|
@ -6,7 +6,7 @@ if(NOT WIN32)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
function(FetchDependency name)
|
function(FetchDependency name)
|
||||||
set(value_args DIR GIT_REPOSITORY GIT_TAG)
|
set(value_args DIR GIT_REPOSITORY GIT_TAG DOWNLOAD SUBDIR)
|
||||||
cmake_parse_arguments(ARGS "" "${value_args}" "" ${ARGN})
|
cmake_parse_arguments(ARGS "" "${value_args}" "" ${ARGN})
|
||||||
|
|
||||||
if(NOT ARGS_DIR)
|
if(NOT ARGS_DIR)
|
||||||
@ -18,11 +18,12 @@ function(FetchDependency name)
|
|||||||
|
|
||||||
if(${name}_PATH AND IS_DIRECTORY "${${name}_PATH}")
|
if(${name}_PATH AND IS_DIRECTORY "${${name}_PATH}")
|
||||||
set(${name}_SOURCE "(local path)" PARENT_SCOPE)
|
set(${name}_SOURCE "(local path)" PARENT_SCOPE)
|
||||||
elseif(Git_FOUND AND ARGS_GIT_REPOSITORY)
|
elseif(Git_FOUND AND ARGS_GIT_REPOSITORY OR ARGS_DOWNLOAD)
|
||||||
set(${name}_PATH ${VGM_SOURCE_DIR}/dependencies/${ARGS_DIR})
|
set(${name}_PATH ${VGM_SOURCE_DIR}/dependencies/${ARGS_DIR})
|
||||||
set(${name}_PATH ${${name}_PATH} PARENT_SCOPE)
|
set(${name}_PATH ${${name}_PATH} PARENT_SCOPE)
|
||||||
set(${name}_SOURCE "(download)" PARENT_SCOPE)
|
set(${name}_SOURCE "(download)" PARENT_SCOPE)
|
||||||
|
|
||||||
|
if(Git_FOUND AND ARGS_GIT_REPOSITORY)
|
||||||
FetchContent_Declare(${name}_FETCH
|
FetchContent_Declare(${name}_FETCH
|
||||||
GIT_REPOSITORY ${ARGS_GIT_REPOSITORY}
|
GIT_REPOSITORY ${ARGS_GIT_REPOSITORY}
|
||||||
SOURCE_DIR ${${name}_PATH}
|
SOURCE_DIR ${${name}_PATH}
|
||||||
@ -36,6 +37,23 @@ function(FetchDependency name)
|
|||||||
message("Downloading ${ARGS_DIR}...")
|
message("Downloading ${ARGS_DIR}...")
|
||||||
FetchContent_Populate(${name}_FETCH)
|
FetchContent_Populate(${name}_FETCH)
|
||||||
endif()
|
endif()
|
||||||
|
else()
|
||||||
|
string(REGEX REPLACE ".*/" "" FILE ${ARGS_DOWNLOAD})
|
||||||
|
if(NOT EXISTS ${${name}_PATH}/${FILE})
|
||||||
|
message("Downloading ${ARGS_DIR}...")
|
||||||
|
file(DOWNLOAD
|
||||||
|
${ARGS_DOWNLOAD}
|
||||||
|
${${name}_PATH}/${FILE}
|
||||||
|
)
|
||||||
|
file(ARCHIVE_EXTRACT
|
||||||
|
INPUT ${${name}_PATH}/${FILE}
|
||||||
|
DESTINATION ${${name}_PATH}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
if(ARGS_SUBDIR)
|
||||||
|
set(${name}_PATH ${${name}_PATH}/${ARGS_SUBDIR} PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
set(${name}_PATH "" PARENT_SCOPE)
|
set(${name}_PATH "" PARENT_SCOPE)
|
||||||
set(USE_${name} OFF PARENT_SCOPE)
|
set(USE_${name} OFF PARENT_SCOPE)
|
||||||
|
@ -43,8 +43,14 @@ if(USE_FFMPEG)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if(USE_FFMPEG AND NOT WIN32 AND (NOT FFmpeg_FOUND OR FFMPEG_PATH OR BUILD_STATIC))
|
if(USE_FFMPEG AND NOT WIN32 AND (NOT FFmpeg_FOUND OR FFMPEG_PATH OR BUILD_STATIC))
|
||||||
|
set(USE_FFMPEG_LIBOPUS OFF)
|
||||||
|
if(NOT EMSCRIPTEN)
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
pkg_check_modules(PC_OPUS REQUIRED opus>=1.1)
|
pkg_check_modules(PC_OPUS QUIET opus>=1.1)
|
||||||
|
if(PC_OPUS_FOUND)
|
||||||
|
set(USE_FFMPEG_LIBOPUS ON)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
FetchDependency(FFMPEG
|
FetchDependency(FFMPEG
|
||||||
DIR ffmpeg
|
DIR ffmpeg
|
||||||
@ -60,8 +66,13 @@ if(USE_FFMPEG)
|
|||||||
ac3 asf xwma mov oma ogg tak dsf wav aac dts dtshd mp3 bink flac msf xmv caf ape smacker pcm_s8 spdif mpc mpc8
|
ac3 asf xwma mov oma ogg tak dsf wav aac dts dtshd mp3 bink flac msf xmv caf ape smacker pcm_s8 spdif mpc mpc8
|
||||||
)
|
)
|
||||||
set(FFMPEG_CONF_DECODER
|
set(FFMPEG_CONF_DECODER
|
||||||
ac3 wmapro wmav1 wmav2 wmavoice wmalossless xma1 xma2 dca tak dsd_lsbf dsd_lsbf_planar dsd_mbf dsd_msbf_planar aac atrac3 atrac3p mp1float mp2float mp3float binkaudio_dct binkaudio_rdft flac pcm_s16be pcm_s16be_planar pcm_s16le pcm_s16le_planar vorbis ape adpcm_ima_qt smackaud libopus pcm_s8 pcm_s8_planar mpc7 mpc8 alac adpcm_ima_dk3 adpcm_ima_dk4
|
ac3 wmapro wmav1 wmav2 wmavoice wmalossless xma1 xma2 dca tak dsd_lsbf dsd_lsbf_planar dsd_mbf dsd_msbf_planar aac atrac3 atrac3p mp1float mp2float mp3float binkaudio_dct binkaudio_rdft flac pcm_s16be pcm_s16be_planar pcm_s16le pcm_s16le_planar vorbis ape adpcm_ima_qt smackaud pcm_s8 pcm_s8_planar mpc7 mpc8 alac adpcm_ima_dk3 adpcm_ima_dk4
|
||||||
)
|
)
|
||||||
|
if(USE_FFMPEG_LIBOPUS)
|
||||||
|
list(APPEND FFMPEG_CONF_DECODER libopus)
|
||||||
|
else()
|
||||||
|
list(APPEND FFMPEG_CONF_DECODER opus)
|
||||||
|
endif()
|
||||||
set(FFMPEG_CONF_DISABLE_PARSER
|
set(FFMPEG_CONF_DISABLE_PARSER
|
||||||
mpeg4video h263
|
mpeg4video h263
|
||||||
)
|
)
|
||||||
@ -101,7 +112,6 @@ if(USE_FFMPEG)
|
|||||||
--disable-everything
|
--disable-everything
|
||||||
--enable-hwaccels
|
--enable-hwaccels
|
||||||
--enable-swresample
|
--enable-swresample
|
||||||
--enable-libopus
|
|
||||||
--enable-parser=${FFMPEG_CONF_PARSER}
|
--enable-parser=${FFMPEG_CONF_PARSER}
|
||||||
--enable-demuxer=${FFMPEG_CONF_DEMUXER}
|
--enable-demuxer=${FFMPEG_CONF_DEMUXER}
|
||||||
--enable-decoder=${FFMPEG_CONF_DECODER}
|
--enable-decoder=${FFMPEG_CONF_DECODER}
|
||||||
@ -113,15 +123,46 @@ if(USE_FFMPEG)
|
|||||||
--extra-cflags=--static
|
--extra-cflags=--static
|
||||||
--pkg-config-flags=--static
|
--pkg-config-flags=--static
|
||||||
)
|
)
|
||||||
|
if(USE_FFMPEG_LIBOPUS)
|
||||||
|
list(APPEND FFMPEG_CONF_ARGS
|
||||||
|
--enable-libopus
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
if(EMSCRIPTEN)
|
||||||
|
list(APPEND FFMPEG_CONF_ARGS
|
||||||
|
--cc=emcc
|
||||||
|
--ranlib=emranlib
|
||||||
|
--enable-cross-compile
|
||||||
|
--target-os=none
|
||||||
|
--arch=x86
|
||||||
|
--disable-runtime-cpudetect
|
||||||
|
--disable-asm
|
||||||
|
--disable-fast-unaligned
|
||||||
|
--disable-pthreads
|
||||||
|
--disable-w32threads
|
||||||
|
--disable-os2threads
|
||||||
|
--disable-debug
|
||||||
|
--disable-stripping
|
||||||
|
--disable-safe-bitstream-reader
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(FFMPEG_LINK_PATH ${FFMPEG_BIN}/bin/usr/local/lib)
|
set(FFMPEG_LINK_PATH ${FFMPEG_BIN}/bin/usr/local/lib)
|
||||||
|
set(FFMPEG_INCLUDE_DIRS ${FFMPEG_BIN}/bin/usr/local/include)
|
||||||
|
|
||||||
if(NOT EXISTS ${FFMPEG_LINK_PATH}/libavutil.a)
|
if(NOT EXISTS ${FFMPEG_LINK_PATH}/libavutil.a)
|
||||||
|
if(EMSCRIPTEN)
|
||||||
|
add_custom_target(FFMPEG_MAKE ALL
|
||||||
|
COMMAND emconfigure ./configure ${FFMPEG_CONF_ARGS} && emmake make && make install DESTDIR="${FFMPEG_BIN}/bin" && make clean
|
||||||
|
WORKING_DIRECTORY ${FFMPEG_PATH}
|
||||||
|
)
|
||||||
|
else()
|
||||||
add_custom_target(FFMPEG_MAKE ALL
|
add_custom_target(FFMPEG_MAKE ALL
|
||||||
COMMAND ./configure ${FFMPEG_CONF_ARGS} && make && make install DESTDIR="${FFMPEG_BIN}/bin" && make clean
|
COMMAND ./configure ${FFMPEG_CONF_ARGS} && make && make install DESTDIR="${FFMPEG_BIN}/bin" && make clean
|
||||||
WORKING_DIRECTORY ${FFMPEG_PATH}
|
WORKING_DIRECTORY ${FFMPEG_PATH}
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
foreach(LIB avutil avformat swresample avcodec)
|
foreach(LIB avutil avformat swresample avcodec)
|
||||||
add_library(${LIB} STATIC IMPORTED)
|
add_library(${LIB} STATIC IMPORTED)
|
||||||
@ -129,6 +170,25 @@ if(USE_FFMPEG)
|
|||||||
IMPORTED_LOCATION ${FFMPEG_LINK_PATH}/lib${LIB}.a
|
IMPORTED_LOCATION ${FFMPEG_LINK_PATH}/lib${LIB}.a
|
||||||
)
|
)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
if(EMSCRIPTEN)
|
||||||
|
FetchDependency(ZLIB
|
||||||
|
DIR zlib
|
||||||
|
DOWNLOAD https://zlib.net/zlib-1.2.11.tar.xz
|
||||||
|
SUBDIR zlib-1.2.11
|
||||||
|
)
|
||||||
|
|
||||||
|
add_subdirectory(${ZLIB_PATH} ${ZLIB_BIN})
|
||||||
|
target_include_directories(example PRIVATE ${ZLIB_PATH})
|
||||||
|
target_include_directories(minigzip PRIVATE ${ZLIB_PATH})
|
||||||
|
target_include_directories(example64 PRIVATE ${ZLIB_PATH})
|
||||||
|
target_include_directories(minigzip64 PRIVATE ${ZLIB_PATH})
|
||||||
|
|
||||||
|
add_library(z STATIC IMPORTED)
|
||||||
|
set_target_properties(z PROPERTIES
|
||||||
|
IMPORTED_LOCATION ${ZLIB_BIN}/libz.a
|
||||||
|
)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
if(USE_MAIATRAC3PLUS)
|
if(USE_MAIATRAC3PLUS)
|
||||||
FetchDependency(MAIATRAC3PLUS
|
FetchDependency(MAIATRAC3PLUS
|
||||||
DIR maiatrac3plus
|
DIR maiatrac3plus
|
||||||
GIT_REPOSITORY https://github.com/emulibraries/maiatrac3plus
|
|
||||||
GIT_TAG 95c34f2651b0988a8ed762692925eb22700e9b42
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if(MAIATRAC3PLUS_PATH)
|
if(MAIATRAC3PLUS_PATH)
|
||||||
@ -19,6 +17,8 @@ if(USE_MAIATRAC3PLUS)
|
|||||||
${MAIATRAC3PLUS_PATH}/MaiAT3PlusDecoder/src/base/Mai_Mem.cc
|
${MAIATRAC3PLUS_PATH}/MaiAT3PlusDecoder/src/base/Mai_Mem.cc
|
||||||
COPYONLY)
|
COPYONLY)
|
||||||
add_subdirectory(${MAIATRAC3PLUS_PATH}/MaiAT3PlusDecoder ${MAIATRAC3PLUS_BIN})
|
add_subdirectory(${MAIATRAC3PLUS_PATH}/MaiAT3PlusDecoder ${MAIATRAC3PLUS_BIN})
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Path to MAIATRAC3+ must be set. (Use MAIATRAC3PLUS_PATH)")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if(NOT USE_MAIATRAC3PLUS)
|
if(NOT USE_MAIATRAC3PLUS)
|
||||||
|
@ -7,29 +7,11 @@ if(NOT WIN32 AND USE_MPEG)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if(MPEG_PATH OR BUILD_STATIC OR NOT MPG123_FOUND)
|
if(MPEG_PATH OR BUILD_STATIC OR NOT MPG123_FOUND)
|
||||||
set(MPEG_BIN ${VGM_BINARY_DIR}/dependencies/mpg123)
|
FetchDependency(MPEG
|
||||||
|
DIR mpg123
|
||||||
if(MPEG_PATH)
|
DOWNLOAD https://downloads.sourceforge.net/mpg123/mpg123-1.28.2.tar.bz2
|
||||||
set(MPEG_SOURCE "(local path)")
|
SUBDIR mpg123-1.28.2
|
||||||
else()
|
|
||||||
set(MPEG_PATH ${VGM_SOURCE_DIR}/dependencies/mgp123)
|
|
||||||
set(MPEG_FILE ${MPEG_PATH}/mpg123-1.28.2.tar.bz2)
|
|
||||||
set(MPEG_SOURCE "(download)")
|
|
||||||
|
|
||||||
if(NOT EXISTS ${MPEG_FILE})
|
|
||||||
|
|
||||||
file(DOWNLOAD
|
|
||||||
https://downloads.sourceforge.net/mpg123/mpg123-1.28.2.tar.bz2
|
|
||||||
${MPEG_FILE}
|
|
||||||
)
|
)
|
||||||
file(ARCHIVE_EXTRACT
|
|
||||||
INPUT ${MPEG_FILE}
|
|
||||||
DESTINATION ${MPEG_PATH}
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(MPEG_PATH ${MPEG_PATH}/mpg123-1.28.2)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(MPEG_LINK_PATH ${MPEG_BIN}/bin/usr/local/lib/libmpg123.a)
|
set(MPEG_LINK_PATH ${MPEG_BIN}/bin/usr/local/lib/libmpg123.a)
|
||||||
|
|
||||||
|
@ -73,7 +73,11 @@ macro(setup_target TARGET)
|
|||||||
target_include_directories(${TARGET} PRIVATE ${FFMPEG_INCLUDE_DIRS})
|
target_include_directories(${TARGET} PRIVATE ${FFMPEG_INCLUDE_DIRS})
|
||||||
if(LINK)
|
if(LINK)
|
||||||
if(BUILD_STATIC)
|
if(BUILD_STATIC)
|
||||||
|
if(USE_FFMPEG_LIBOPUS)
|
||||||
target_link_libraries(${TARGET} avformat avcodec avutil swresample opus pthread m z)
|
target_link_libraries(${TARGET} avformat avcodec avutil swresample opus pthread m z)
|
||||||
|
else()
|
||||||
|
target_link_libraries(${TARGET} avformat avcodec avutil swresample pthread m z)
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
target_link_libraries(${TARGET} ${FFMPEG_LIBRARIES})
|
target_link_libraries(${TARGET} ${FFMPEG_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
Loading…
Reference in New Issue
Block a user