2021-08-30 06:50:54 +02:00
|
|
|
cmake_minimum_required(VERSION 3.6)
|
2019-03-17 19:36:55 +01:00
|
|
|
project(vgmstream C)
|
|
|
|
enable_language(CXX)
|
|
|
|
|
2021-08-08 18:37:52 +02:00
|
|
|
# TODO defautl out-of-source-builds not working properly?
|
|
|
|
# (like "cmake .." from ./build subdir creates makefiles on ./, unless using "cmake -S ..")
|
2020-03-08 03:25:31 +01:00
|
|
|
get_directory_property(hasParent PARENT_DIRECTORY)
|
|
|
|
if(hasParent)
|
|
|
|
set(VGM_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE)
|
|
|
|
set(VGM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
|
|
|
|
endif()
|
2020-01-11 17:34:51 +01:00
|
|
|
set(VGM_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
set(VGM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
2020-03-08 03:25:31 +01:00
|
|
|
set(CMAKE_MODULE_PATH ${VGM_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH})
|
2019-03-17 19:36:55 +01:00
|
|
|
include(vgmstream)
|
|
|
|
|
2021-08-08 18:37:52 +02:00
|
|
|
# Defaults for Windows, otherwise may be Program Files/vgmstream
|
|
|
|
if(WIN32)
|
|
|
|
IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
|
|
|
SET(CMAKE_INSTALL_PREFIX ${VGM_SOURCE_DIR} CACHE PATH "..." FORCE)
|
|
|
|
ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
|
|
|
endif()
|
|
|
|
|
2021-07-22 14:58:04 +02:00
|
|
|
function(set_mpeg onoff useForce)
|
|
|
|
if(useForce)
|
|
|
|
set(USE_FORCE_ FORCE)
|
|
|
|
endif()
|
|
|
|
set(USE_MPEG ${onoff} CACHE BOOL "Use libmpg123 for support of MPEG (MP1/MP2/MP3)" ${USE_FORCE_})
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(set_vorbis onoff useForce)
|
|
|
|
if(useForce)
|
|
|
|
set(USE_FORCE_ FORCE)
|
|
|
|
endif()
|
|
|
|
set(USE_VORBIS ${onoff} CACHE BOOL "Use libvorbis for support of Vorbis" ${USE_FORCE_})
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(set_ffmpeg onoff useForce)
|
|
|
|
if(useForce)
|
|
|
|
set(USE_FORCE_ FORCE)
|
|
|
|
endif()
|
|
|
|
set(USE_FFMPEG ${onoff} CACHE BOOL "Use FFmpeg for support of many codecs" ${USE_FORCE_})
|
|
|
|
endfunction()
|
|
|
|
|
2021-08-30 06:50:54 +02:00
|
|
|
function(add_library_path lib_name static lib_path)
|
|
|
|
if(static)
|
|
|
|
add_library(${lib_name} STATIC IMPORTED)
|
|
|
|
set_target_properties(${lib_name} PROPERTIES IMPORTED_LOCATION ${lib_path}.a)
|
|
|
|
else()
|
|
|
|
add_library(${lib_name} SHARED IMPORTED)
|
|
|
|
set_target_properties(${lib_name} PROPERTIES IMPORTED_LOCATION ${lib_path}.so)
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
2019-03-17 19:36:55 +01:00
|
|
|
# Options
|
2021-07-22 14:58:04 +02:00
|
|
|
set_mpeg(ON FALSE)
|
|
|
|
set_vorbis(ON FALSE)
|
|
|
|
set_ffmpeg(ON FALSE)
|
2019-03-17 19:36:55 +01:00
|
|
|
option(USE_MAIATRAC3PLUS "Use MAIATRAC3+ for support of ATRAC3+" OFF)
|
|
|
|
set(MAIATRAC3PLUS_PATH CACHE PATH "Path to MAIATRAC3+")
|
2020-01-12 12:33:37 +01:00
|
|
|
option(USE_G7221 "Use G7221 for support of ITU-T G.722.1 annex C" ON)
|
2021-08-25 17:50:20 +02:00
|
|
|
option(USE_G719 "Use libg719_decode for support ITU-T G.719" ON)
|
2021-08-27 16:04:32 +02:00
|
|
|
option(USE_ATRAC9 "Use LibAtrac9 for support of ATRAC9" ON)
|
2019-03-17 19:36:55 +01:00
|
|
|
if(WIN32)
|
|
|
|
# May need to see if it is possible to get these to work on non-Windows systems too
|
2021-08-27 16:04:32 +02:00
|
|
|
option(USE_CELT "Use libcelt for support of FSB CELT versions 0.6.1 and 0.11.0" ON)
|
2019-03-17 19:36:55 +01:00
|
|
|
endif()
|
2021-08-27 16:04:32 +02:00
|
|
|
option(USE_SPEEX "Use libspeex for support of SPEEX" ON)
|
2021-08-28 19:32:52 +02:00
|
|
|
if(NOT WIN32)
|
|
|
|
option(USE_JANSSON "Use jansson for JSON dumping" ON)
|
2021-08-30 06:50:54 +02:00
|
|
|
|
|
|
|
set(MPEG_PATH CACHE PATH "Path to mpg123")
|
|
|
|
set(FFMPEG_PATH CACHE PATH "Path to FFmpeg")
|
|
|
|
set(G719_PATH CACHE PATH "Path to G.719 decoder")
|
|
|
|
set(ATRAC9_PATH CACHE PATH "Path to LibAtrac9")
|
|
|
|
set(LIBAO_PATH CACHE PATH "Path to libao")
|
2021-08-28 19:32:52 +02:00
|
|
|
endif()
|
2019-03-17 19:36:55 +01:00
|
|
|
|
|
|
|
# Build choices
|
|
|
|
option(BUILD_CLI "Build vgmstream CLI" ON)
|
|
|
|
if(WIN32)
|
2021-08-08 18:37:52 +02:00
|
|
|
if(MSVC)
|
2021-08-07 13:01:55 +02:00
|
|
|
option(BUILD_FB2K "Build foobar2000 component" ON)
|
|
|
|
set(FB2K_SDK_PATH CACHE PATH "Path to foobar2000 SDK")
|
|
|
|
set(WTL_INCLUDE_PATH CACHE PATH "Path to WTL include directory")
|
|
|
|
set(FB2K_COMPONENT_INSTALL_PREFIX CACHE PATH "Path to foobar2000 component installation directory")
|
|
|
|
endif()
|
2019-03-17 19:36:55 +01:00
|
|
|
option(BUILD_WINAMP "Build Winamp plugin" ON)
|
2019-03-20 03:00:48 +01:00
|
|
|
set(WINAMP_INSTALL_PREFIX CACHE PATH "Path to Winamp installation directory")
|
2019-03-18 00:38:06 +01:00
|
|
|
option(BUILD_XMPLAY "Build XMPlay plugin" ON)
|
2019-03-20 03:00:48 +01:00
|
|
|
set(XMPLAY_INSTALL_PREFIX CACHE PATH "Path to XMPlay installation directory")
|
2019-03-18 05:17:08 +01:00
|
|
|
else()
|
2021-08-28 19:32:52 +02:00
|
|
|
option(BUILD_STATIC "Build statically linked binary" OFF)
|
2021-08-30 06:50:54 +02:00
|
|
|
if(BUILD_STATIC)
|
|
|
|
option(BUILD_V123 "Build vgmstream123 player" OFF)
|
|
|
|
else()
|
|
|
|
option(BUILD_V123 "Build vgmstream123 player" ON)
|
|
|
|
endif()
|
|
|
|
option(BUILD_AUDACIOUS "Build Audacious plugin" ON)
|
2021-08-28 19:32:52 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Static builds will link all libraries statically
|
|
|
|
if(BUILD_STATIC)
|
|
|
|
set(BUILD_SHARED_LIBS OFF)
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static")
|
|
|
|
|
2021-08-31 13:56:49 +02:00
|
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
pkg_check_modules(PC_OPUS REQUIRED opus>=1.1)
|
|
|
|
|
2021-08-30 06:50:54 +02:00
|
|
|
# Incompatible with static builds
|
2021-08-28 19:32:52 +02:00
|
|
|
set(BUILD_AUDACIOUS OFF)
|
2019-03-17 19:36:55 +01:00
|
|
|
endif()
|
|
|
|
|
2021-08-08 18:37:52 +02:00
|
|
|
# Autodetect some paths
|
|
|
|
if(MSVC AND NOT FB2K_SDK_PATH AND IS_DIRECTORY "${VGM_SOURCE_DIR}/dependencies/foobar/")
|
|
|
|
set(FB2K_SDK_PATH "${VGM_SOURCE_DIR}/dependencies/foobar/" CACHE PATH "..." FORCE)
|
|
|
|
endif()
|
|
|
|
if(MSVC AND NOT WTL_INCLUDE_PATH AND IS_DIRECTORY "${VGM_SOURCE_DIR}/dependencies/wtl/")
|
|
|
|
set(WTL_INCLUDE_PATH "${VGM_SOURCE_DIR}/dependencies/wtl/" CACHE PATH "..." FORCE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Set autogenerated version
|
|
|
|
if(MSVC)
|
|
|
|
set(VGM_VERSION_GENERATOR version-make.bat)
|
2021-08-12 20:02:32 +02:00
|
|
|
add_custom_command(OUTPUT ${VGM_SOURCE_DIR}/version_auto.h
|
|
|
|
COMMAND "${VGM_SOURCE_DIR}/${VGM_VERSION_GENERATOR}"
|
|
|
|
DEPENDS ${VGM_SOURCE_DIR}/${VGM_VERSION_GENERATOR})
|
2021-08-08 18:37:52 +02:00
|
|
|
else()
|
2021-08-12 20:02:32 +02:00
|
|
|
# linux uses 'sh' so git-less (src zip) builds can run without chmod -x (script)
|
2021-08-08 18:37:52 +02:00
|
|
|
set(VGM_VERSION_GENERATOR version-make.sh)
|
2021-08-12 20:02:32 +02:00
|
|
|
add_custom_command(OUTPUT ${VGM_SOURCE_DIR}/version_auto.h
|
|
|
|
COMMAND sh "${VGM_SOURCE_DIR}/${VGM_VERSION_GENERATOR}"
|
|
|
|
DEPENDS ${VGM_SOURCE_DIR}/${VGM_VERSION_GENERATOR})
|
2021-08-08 18:37:52 +02:00
|
|
|
endif()
|
2021-08-10 23:51:48 +02:00
|
|
|
add_custom_target(version_h ALL DEPENDS ${VGM_SOURCE_DIR}/version_auto.h)
|
2021-08-08 18:37:52 +02:00
|
|
|
|
2021-08-30 06:50:54 +02:00
|
|
|
if(NOT WIN32)
|
|
|
|
find_package(Git QUIET)
|
|
|
|
if(Git_FOUND)
|
|
|
|
include(FetchContent)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2021-08-08 18:37:52 +02:00
|
|
|
# FFmpeg detection
|
2021-07-17 18:37:49 +02:00
|
|
|
if(USE_FFMPEG)
|
2021-08-30 06:50:54 +02:00
|
|
|
if(NOT WIN32 AND BUILD_STATIC AND NOT FFMPEG_PATH)
|
|
|
|
if(Git_FOUND)
|
|
|
|
set(FFMPEG_PATH ${VGM_SOURCE_DIR}/dependencies/ffmpeg)
|
|
|
|
FetchContent_Declare(ffmpeg
|
|
|
|
GIT_REPOSITORY https://git.ffmpeg.org/ffmpeg.git
|
|
|
|
SOURCE_DIR ${FFMPEG_PATH}
|
|
|
|
BINARY_DIR ${FFMPEG_PATH}-build
|
|
|
|
SUBBUILD_DIR ${FFMPEG_PATH}-subbuild
|
|
|
|
GIT_TAG n4.4
|
|
|
|
GIT_SHALLOW ON
|
|
|
|
)
|
|
|
|
FetchContent_GetProperties(ffmpeg)
|
|
|
|
if(NOT ffmpeg_POPULATED)
|
|
|
|
FetchContent_Populate(ffmpeg)
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(USE_FFMPEG OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
if(NOT WIN32 AND FFMPEG_PATH)
|
|
|
|
if(BUILD_STATIC)
|
|
|
|
set(FF_SHARED --enable-static --disable-shared)
|
|
|
|
set(FF_EXTRA --extra-libs=-static --extra-cflags=--static --pkg-config-flags=--static)
|
|
|
|
set(LINK_EXT .a)
|
|
|
|
else()
|
|
|
|
set(FF_SHARED --disable-static --enable-shared)
|
|
|
|
unset(FF_EXTRA)
|
|
|
|
set(LINK_EXT .so)
|
|
|
|
endif()
|
|
|
|
set(FF_CONF_ARGS ${FF_SHARED} --enable-gpl --disable-doc --disable-ffplay --disable-ffprobe --disable-avdevice --disable-ffmpeg --disable-postproc --disable-avfilter --disable-swscale --disable-network --disable-swscale-alpha --disable-vdpau --disable-dxva2 --disable-amf --disable-cuda --disable-d3d11va --disable-ffnvcodec --disable-nvenc --disable-nvdec --disable-hwaccels --disable-sdl2 --disable-iconv --disable-everything --enable-hwaccels --enable-swresample --enable-libopus --enable-parser=ac3,mpegaudio,xma,vorbis,opus --enable-demuxer=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 --enable-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 --disable-parser=mpeg4video,h263 --disable-decoder=mpeg2video,h263,h264,mpeg1video,mpeg2video,mpeg4,hevc,vp9 --disable-cuvid --disable-version3 ${FF_EXTRA})
|
|
|
|
if(NOT EXISTS ${FFMPEG_PATH}/libavutil/libavutil${LINK_EXT})
|
|
|
|
add_custom_target(FF_MAKE ALL
|
|
|
|
COMMAND ./configure ${FF_CONF_ARGS} && make
|
|
|
|
WORKING_DIRECTORY ${FFMPEG_PATH}
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
add_library_path(avutil ${BUILD_STATIC} ${FFMPEG_PATH}/libavutil/libavutil)
|
|
|
|
add_library_path(avformat ${BUILD_STATIC} ${FFMPEG_PATH}/libavformat/libavformat)
|
|
|
|
add_library_path(swresample ${BUILD_STATIC} ${FFMPEG_PATH}/libswresample/libswresample)
|
|
|
|
add_library_path(avcodec ${BUILD_STATIC} ${FFMPEG_PATH}/libavcodec/libavcodec)
|
|
|
|
elseif(NOT BUILD_STATIC)
|
|
|
|
find_package(FFmpeg)
|
|
|
|
if(NOT FFMPEG_LIBRARIES)
|
2021-07-22 14:58:04 +02:00
|
|
|
set_ffmpeg(OFF TRUE)
|
2021-08-30 06:50:54 +02:00
|
|
|
else()
|
|
|
|
if(${AVCODEC_VERSION} VERSION_LESS 57)
|
|
|
|
set_ffmpeg(OFF TRUE)
|
|
|
|
message("libavcodec version mismatch ${AVCODEC_VERSION} expected >=57")
|
|
|
|
elseif(${AVUTIL_VERSION} VERSION_LESS 55)
|
|
|
|
set_ffmpeg(OFF TRUE)
|
|
|
|
message("libavutil version mismatch ${AVUTIL_VERSION} expected >=55")
|
|
|
|
elseif(${SWRESAMPLE_VERSION} VERSION_LESS 2)
|
|
|
|
set_ffmpeg(OFF TRUE)
|
|
|
|
message("libswresample version mismatch ${SWRESAMPLE_VERSION} expected >=2")
|
|
|
|
endif()
|
2021-07-17 18:37:49 +02:00
|
|
|
endif()
|
2021-08-30 06:50:54 +02:00
|
|
|
else()
|
|
|
|
set(USE_FFMPEG OFF)
|
2021-07-17 18:37:49 +02:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2019-03-17 19:36:55 +01:00
|
|
|
if(WIN32)
|
|
|
|
# Enable support for the resource compiler when using MinGW
|
|
|
|
if(MINGW)
|
|
|
|
enable_language(RC)
|
|
|
|
# Not 100% sure this is needed, but in the past, MinGW's command for compiling resources was incorrect
|
|
|
|
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
|
|
|
|
endif(MINGW)
|
|
|
|
|
|
|
|
set(CMAKE_EXECUTABLE_SUFFIX .exe)
|
2021-08-08 18:37:52 +02:00
|
|
|
|
2019-03-17 19:36:55 +01:00
|
|
|
else()
|
|
|
|
|
|
|
|
# Find the relevant packages
|
|
|
|
if(USE_MPEG)
|
2021-08-30 06:50:54 +02:00
|
|
|
if(NOT WIN32 AND BUILD_STATIC AND NOT MPEG_PATH)
|
|
|
|
set(MPEG_PATH ${VGM_SOURCE_DIR}/dependencies/mgp123)
|
|
|
|
set(MPEG_FILE ${MPEG_PATH}/mpg123-1.28.2.tar.bz2)
|
|
|
|
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()
|
|
|
|
if(NOT WIN32 AND MPEG_PATH)
|
|
|
|
if(BUILD_STATIC)
|
|
|
|
set(MPEG_CONF_ARGS --enable-static=yes --enable-shared=no)
|
|
|
|
set(LINK_EXT .a)
|
|
|
|
else()
|
|
|
|
set(MPEG_CONF_ARGS --enable-static=no --enable-shared=yes)
|
|
|
|
set(LINK_EXT .so)
|
|
|
|
endif()
|
|
|
|
if(NOT EXISTS ${MPEG_PATH}/src/libmpg123/.libs/libmpg123${LINK_EXT})
|
|
|
|
add_custom_target(MPEG_MAKE ALL
|
|
|
|
COMMAND ./configure ${MPEG_CONF_ARGS} && make
|
|
|
|
WORKING_DIRECTORY ${MPEG_PATH}
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
add_library_path(mpg123 ${BUILD_STATIC} ${MPEG_PATH}/src/libmpg123/.libs/libmpg123)
|
|
|
|
elseif(NOT BUILD_STATIC)
|
|
|
|
find_package(MPG123)
|
|
|
|
if(NOT MPG123_FOUND)
|
|
|
|
set_mpeg(OFF TRUE)
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(USE_MPEG OFF)
|
2019-03-17 19:36:55 +01:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
if(USE_VORBIS)
|
2019-03-21 03:23:47 +01:00
|
|
|
find_package(VorbisFile)
|
|
|
|
if(NOT VORBISFILE_FOUND)
|
2021-07-22 14:58:04 +02:00
|
|
|
set_vorbis(OFF TRUE)
|
2019-03-17 19:36:55 +01:00
|
|
|
endif()
|
|
|
|
endif()
|
2019-03-21 03:23:47 +01:00
|
|
|
|
|
|
|
# If building the CLI, we need to include AO as well
|
2021-08-28 19:32:52 +02:00
|
|
|
if(BUILD_V123)
|
2021-08-30 06:50:54 +02:00
|
|
|
if(LIBAO_PATH)
|
|
|
|
if(BUILD_STATIC)
|
|
|
|
set(LIBAO_CONF_ARGS --enable-static=yes --enable-shared=no)
|
|
|
|
set(LINK_EXT .a)
|
|
|
|
else()
|
|
|
|
set(LIBAO_CONF_ARGS --enable-static=no --enable-shared=yes)
|
|
|
|
set(LINK_EXT .so)
|
|
|
|
endif()
|
|
|
|
if(NOT EXISTS ${LIBAO_PATH}/src/.libs/libao${LINK_EXT})
|
|
|
|
add_custom_target(LIBAO_MAKE ALL
|
|
|
|
COMMAND ./autogen.sh && ./configure ${LIBAO_CONF_ARGS} && make
|
|
|
|
WORKING_DIRECTORY ${LIBAO_PATH}
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
add_library_path(ao ${BUILD_STATIC} ${LIBAO_PATH}/src/.libs/libao)
|
2021-08-30 11:30:24 +02:00
|
|
|
set(LIBAO_INCLUDE ${LIBAO_PATH}/include)
|
2021-08-08 18:37:52 +02:00
|
|
|
set(USE_V123 ON)
|
2021-08-30 06:50:54 +02:00
|
|
|
elseif(NOT BUILD_STATIC)
|
|
|
|
find_package(AO)
|
|
|
|
if(AO_FOUND)
|
|
|
|
set(LIBAO_INCLUDE ${AO_INCLUDE_DIR})
|
|
|
|
set(USE_V123 ON)
|
|
|
|
else()
|
|
|
|
set(USE_V123 OFF)
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Path to libao must be set. (Use LIBAO_PATH)")
|
2021-08-08 18:37:52 +02:00
|
|
|
set(USE_V123 OFF)
|
2019-03-17 19:36:55 +01:00
|
|
|
endif()
|
2021-08-28 19:32:52 +02:00
|
|
|
else()
|
|
|
|
set(USE_V123 OFF)
|
2019-03-17 19:36:55 +01:00
|
|
|
endif()
|
2019-03-18 05:17:08 +01:00
|
|
|
|
2021-07-17 17:01:40 +02:00
|
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
|
2020-09-29 04:10:23 +02:00
|
|
|
# Only build JSON dumping capabilities on Linux
|
2021-08-28 19:32:52 +02:00
|
|
|
if(USE_JANSSON)
|
|
|
|
pkg_check_modules(JANSSON jansson>=2.3)
|
|
|
|
if(JANSSON_FOUND)
|
|
|
|
set(JANSSON_PKG libjansson)
|
|
|
|
include_directories(${JANSSON_INCLUDE_DIRS})
|
|
|
|
link_directories(${JANSSON_LIBRARY_DIRS})
|
|
|
|
else()
|
|
|
|
set(USE_JANSSON OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
2020-09-29 04:10:23 +02:00
|
|
|
|
2019-03-18 05:17:08 +01:00
|
|
|
# If building Audacious, we need to make sure we can find its pkg-config module as well as GTK's
|
|
|
|
if(BUILD_AUDACIOUS)
|
|
|
|
pkg_search_module(AUDACIOUS REQUIRED audacious>=3.6)
|
2019-03-20 03:00:48 +01:00
|
|
|
pkg_get_variable(AUDACIOUS_PLUGIN_DIR audacious plugin_dir)
|
2019-03-18 05:17:08 +01:00
|
|
|
pkg_search_module(GTK REQUIRED gtk+-3.0 gtk+-2.0)
|
|
|
|
endif()
|
2019-03-17 19:36:55 +01:00
|
|
|
endif()
|
|
|
|
|
2020-09-29 04:10:23 +02:00
|
|
|
|
2019-03-17 19:36:55 +01:00
|
|
|
# Set compiler flags
|
|
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES Clang OR CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
|
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES Clang)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-parentheses-equality -Wno-header-guard -Wno-unused-function -Wno-shift-negative-value -Wno-deprecated-register")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-parentheses-equality -Wno-header-guard -Wno-unused-function -Wno-shift-negative-value -Wno-deprecated-register")
|
|
|
|
elseif()
|
|
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5.9)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-misleading-indentation")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-misleading-indentation")
|
|
|
|
endif()
|
|
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.0)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-attributes")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes")
|
|
|
|
endif()
|
|
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 2.99)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function")
|
|
|
|
endif()
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-format -Wno-sign-compare")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-format -Wno-sign-compare")
|
|
|
|
endif()
|
|
|
|
elseif(MSVC)
|
|
|
|
if(CMAKE_C_FLAGS MATCHES "/W[0-4]")
|
|
|
|
string(REGEX REPLACE "/W[0-4]" "/W3" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
|
|
|
else()
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3")
|
|
|
|
endif()
|
|
|
|
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
|
|
|
string(REGEX REPLACE "/W[0-4]" "/W3" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
|
|
else()
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3")
|
|
|
|
endif()
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4005 /wd4018 /wd4244 /wd4302 /wd4838")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4005 /wd4018 /wd4244 /wd4302 /wd4838")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Add other projects and subdirectories as needed
|
|
|
|
if(USE_MAIATRAC3PLUS)
|
|
|
|
if(MAIATRAC3PLUS_PATH)
|
2020-03-08 03:25:31 +01:00
|
|
|
add_subdirectory(${MAIATRAC3PLUS_PATH}/MaiAT3PlusDecoder ${VGM_BINARY_DIR}/maitrac3plus)
|
2019-03-17 19:36:55 +01:00
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Path to MAIATRAC3+ must be set. (Use MAIATRAC3PLUS_PATH)")
|
|
|
|
endif()
|
|
|
|
endif()
|
2021-08-27 16:04:32 +02:00
|
|
|
if(NOT WIN32)
|
|
|
|
if(USE_G719)
|
|
|
|
if(NOT G719_PATH)
|
|
|
|
if(Git_FOUND)
|
|
|
|
set(G719_PATH ${VGM_SOURCE_DIR}/dependencies/libg719_decode)
|
2021-08-30 06:50:54 +02:00
|
|
|
FetchContent_Declare(libg719_decode
|
2021-08-27 16:04:32 +02:00
|
|
|
GIT_REPOSITORY https://github.com/kode54/libg719_decode
|
|
|
|
SOURCE_DIR ${G719_PATH}
|
|
|
|
BINARY_DIR ${G719_PATH}-build
|
|
|
|
SUBBUILD_DIR ${G719_PATH}-subbuild
|
2021-08-30 06:50:54 +02:00
|
|
|
GIT_SHALLOW ON
|
2021-08-27 16:04:32 +02:00
|
|
|
)
|
2021-08-30 06:50:54 +02:00
|
|
|
FetchContent_GetProperties(libg719_decode)
|
|
|
|
if(NOT libg719_decode_POPULATED)
|
|
|
|
FetchContent_Populate(libg719_decode)
|
|
|
|
endif()
|
2021-08-27 16:04:32 +02:00
|
|
|
else()
|
|
|
|
set(USE_G719 OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
if(G719_PATH)
|
2021-08-26 11:01:17 +02:00
|
|
|
configure_file(
|
|
|
|
${VGM_SOURCE_DIR}/ext_libs/libg719_decode/CMakeLists.txt
|
2021-08-27 16:04:32 +02:00
|
|
|
${G719_PATH}/
|
2021-08-26 11:01:17 +02:00
|
|
|
COPYONLY)
|
2021-08-27 16:04:32 +02:00
|
|
|
add_subdirectory(${G719_PATH})
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
if(USE_ATRAC9)
|
|
|
|
if(NOT ATRAC9_PATH)
|
|
|
|
if(Git_FOUND)
|
|
|
|
set(ATRAC9_PATH ${VGM_SOURCE_DIR}/dependencies/LibAtrac9)
|
2021-08-30 06:50:54 +02:00
|
|
|
FetchContent_Declare(ATRAC9_FETCH
|
2021-08-27 16:04:32 +02:00
|
|
|
GIT_REPOSITORY https://github.com/Thealexbarney/LibAtrac9
|
|
|
|
SOURCE_DIR ${ATRAC9_PATH}
|
|
|
|
BINARY_DIR ${ATRAC9_PATH}-build
|
|
|
|
SUBBUILD_DIR ${ATRAC9_PATH}-subbuild
|
2021-08-30 06:50:54 +02:00
|
|
|
GIT_SHALLOW ON
|
2021-08-27 16:04:32 +02:00
|
|
|
)
|
2021-08-30 06:50:54 +02:00
|
|
|
FetchContent_GetProperties(ATRAC9_FETCH)
|
|
|
|
if(NOT ATRAC9_FETCH_POPULATED)
|
|
|
|
FetchContent_Populate(ATRAC9_FETCH)
|
|
|
|
endif()
|
2021-08-27 16:04:32 +02:00
|
|
|
else()
|
|
|
|
set(USE_ATRAC9 OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
if(ATRAC9_PATH)
|
2021-08-30 06:50:54 +02:00
|
|
|
if(NOT EXISTS ${ATRAC9_PATH}/C/bin/libatrac9.a)
|
|
|
|
add_custom_target(ATRAC9_MAKE ALL
|
|
|
|
COMMAND make static CFLAGS="-fPIC"
|
|
|
|
WORKING_DIRECTORY ${ATRAC9_PATH}/C
|
|
|
|
)
|
|
|
|
endif()
|
2021-08-27 16:04:32 +02:00
|
|
|
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)
|
2021-08-26 11:01:17 +02:00
|
|
|
endif()
|
2021-08-25 17:50:20 +02:00
|
|
|
endif()
|
|
|
|
endif()
|
2019-03-17 19:36:55 +01:00
|
|
|
add_subdirectory(src)
|
|
|
|
if(WIN32)
|
|
|
|
add_subdirectory(ext_libs)
|
|
|
|
if(BUILD_WINAMP)
|
2019-03-20 03:00:48 +01:00
|
|
|
if(NOT WINAMP_INSTALL_PREFIX)
|
2019-03-22 02:10:03 +01:00
|
|
|
set(WINAMP_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/winamp)
|
2019-03-20 03:00:48 +01:00
|
|
|
endif()
|
2019-03-17 19:36:55 +01:00
|
|
|
add_subdirectory(winamp)
|
|
|
|
endif()
|
|
|
|
if(BUILD_FB2K)
|
|
|
|
if(NOT FB2K_SDK_PATH)
|
|
|
|
message(FATAL_ERROR "The path to the foobar2000 SDK must be set. (Use FB2K_SDK_PATH)")
|
|
|
|
endif()
|
|
|
|
if(NOT WTL_INCLUDE_PATH)
|
|
|
|
message(FATAL_ERROR "The path to the WTL include directory must be set. (Use WTL_INCLUDE_PATH)")
|
|
|
|
endif()
|
2019-03-20 03:00:48 +01:00
|
|
|
if(NOT FB2K_COMPONENT_INSTALL_PREFIX)
|
2019-03-22 02:10:03 +01:00
|
|
|
set(FB2K_COMPONENT_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/fb2k)
|
2019-03-20 03:00:48 +01:00
|
|
|
endif()
|
2019-03-17 19:36:55 +01:00
|
|
|
include_external_msproject(fb2k_sdk ${FB2K_SDK_PATH}/foobar2000/SDK/foobar2000_SDK.vcxproj)
|
|
|
|
include_external_msproject(fb2k_sdk_helpers ${FB2K_SDK_PATH}/foobar2000/helpers/foobar2000_sdk_helpers.vcxproj)
|
|
|
|
include_external_msproject(fb2k_atl_helpers ${FB2K_SDK_PATH}/foobar2000/ATLHelpers/foobar2000_ATL_helpers.vcxproj)
|
|
|
|
include_external_msproject(fb2k_component_client ${FB2K_SDK_PATH}/foobar2000/foobar2000_component_client/foobar2000_component_client.vcxproj)
|
|
|
|
include_external_msproject(pfc ${FB2K_SDK_PATH}/pfc/pfc.vcxproj)
|
|
|
|
add_subdirectory(fb2k)
|
|
|
|
endif()
|
2019-03-18 00:38:06 +01:00
|
|
|
if(BUILD_XMPLAY)
|
2019-03-20 03:00:48 +01:00
|
|
|
if(NOT XMPLAY_INSTALL_PREFIX)
|
2019-03-22 02:10:03 +01:00
|
|
|
set(XMPLAY_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/xmplay)
|
2019-03-20 03:00:48 +01:00
|
|
|
endif()
|
2019-03-18 00:38:06 +01:00
|
|
|
add_subdirectory(xmplay)
|
|
|
|
endif()
|
2019-03-18 05:17:08 +01:00
|
|
|
else()
|
|
|
|
if(BUILD_AUDACIOUS)
|
|
|
|
add_subdirectory(audacious)
|
|
|
|
endif()
|
2019-03-17 19:36:55 +01:00
|
|
|
endif()
|
|
|
|
if(BUILD_CLI)
|
|
|
|
if(WIN32)
|
|
|
|
add_subdirectory(ext_libs/Getopt)
|
|
|
|
endif()
|
|
|
|
add_subdirectory(cli)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Option Summary
|
|
|
|
message(STATUS " Option Summary")
|
|
|
|
message(STATUS "=================")
|
|
|
|
message(STATUS " MPEG: ${USE_MPEG}")
|
|
|
|
message(STATUS " Vorbis: ${USE_VORBIS}")
|
|
|
|
message(STATUS " FFmpeg: ${USE_FFMPEG}")
|
|
|
|
message(STATUS " MAIATRAC3+: ${USE_MAIATRAC3PLUS}")
|
2020-01-12 12:33:37 +01:00
|
|
|
message(STATUS " G.722.1: ${USE_G7221}")
|
2021-08-25 17:50:20 +02:00
|
|
|
message(STATUS " G.719: ${USE_G719}")
|
2021-08-27 16:04:32 +02:00
|
|
|
message(STATUS " ATRAC9: ${USE_ATRAC9}")
|
2019-03-17 19:36:55 +01:00
|
|
|
if(WIN32)
|
2021-01-23 16:44:16 +01:00
|
|
|
message(STATUS " FSB CELT: ${USE_CELT}")
|
2019-03-17 19:36:55 +01:00
|
|
|
endif()
|
2021-08-27 16:04:32 +02:00
|
|
|
message(STATUS " SPEEX: ${USE_SPEEX}")
|
2019-03-17 19:36:55 +01:00
|
|
|
message(STATUS "")
|
|
|
|
|
|
|
|
# Build Summary
|
|
|
|
message(STATUS " Building")
|
|
|
|
message(STATUS "=========================")
|
|
|
|
if(WIN32)
|
2019-03-21 03:23:47 +01:00
|
|
|
message(STATUS " CLI: ${BUILD_CLI}")
|
2019-03-17 19:36:55 +01:00
|
|
|
message(STATUS "foobar2000 component: ${BUILD_FB2K}")
|
|
|
|
message(STATUS " Winamp plugin: ${BUILD_WINAMP}")
|
2019-03-18 00:38:06 +01:00
|
|
|
message(STATUS " XMPlay plugin: ${BUILD_XMPLAY}")
|
2019-03-18 05:17:08 +01:00
|
|
|
else()
|
2021-08-08 18:37:52 +02:00
|
|
|
message(STATUS " CLI: ${BUILD_CLI}")
|
|
|
|
message(STATUS " vgmstream123: ${USE_V123}")
|
2020-09-29 04:10:23 +02:00
|
|
|
message(STATUS " JSON dumping: ${USE_JANSSON}")
|
2019-03-21 03:23:47 +01:00
|
|
|
message(STATUS "Audacious plugin: ${BUILD_AUDACIOUS}")
|
2021-08-28 19:32:52 +02:00
|
|
|
message(STATUS " Static linking: ${BUILD_STATIC}")
|
2019-03-17 19:36:55 +01:00
|
|
|
endif()
|
|
|
|
message(STATUS "")
|
2019-03-20 03:00:48 +01:00
|
|
|
|
|
|
|
# Install Summary
|
|
|
|
message(STATUS " Install Paths")
|
|
|
|
message(STATUS "=========================")
|
|
|
|
if(WIN32)
|
2020-03-08 03:25:31 +01:00
|
|
|
if(BUILD_CLI)
|
|
|
|
message(STATUS " CLI: ${CMAKE_INSTALL_PREFIX}/bin")
|
|
|
|
endif()
|
|
|
|
if(BUILD_FB2K)
|
|
|
|
message(STATUS "foobar2000 component: ${FB2K_COMPONENT_INSTALL_PREFIX}")
|
|
|
|
endif()
|
|
|
|
if(BUILD_WINAMP)
|
|
|
|
message(STATUS " Winamp plugin: ${WINAMP_INSTALL_PREFIX}")
|
|
|
|
endif()
|
|
|
|
if(BUILD_XMPLAY)
|
|
|
|
message(STATUS " XMPlay plugin: ${XMPLAY_INSTALL_PREFIX}")
|
|
|
|
endif()
|
2019-03-20 03:00:48 +01:00
|
|
|
else()
|
2020-03-08 03:25:31 +01:00
|
|
|
if(BUILD_CLI)
|
|
|
|
message(STATUS "CLI/vgmstream123: ${CMAKE_INSTALL_PREFIX}/bin")
|
|
|
|
endif()
|
|
|
|
if(BUILD_AUDACIOUS)
|
|
|
|
message(STATUS "Audacious plugin: ${AUDACIOUS_PLUGIN_DIR}/Input")
|
|
|
|
endif()
|
2019-03-20 03:00:48 +01:00
|
|
|
endif()
|
|
|
|
message(STATUS "")
|