Set default cmake flags for emscripten, support atrac9

This commit is contained in:
LoveEevee 2021-09-13 00:17:00 +03:00
parent 95aada74c6
commit 854896cf34
2 changed files with 40 additions and 17 deletions

View File

@ -90,24 +90,35 @@ if(WIN32)
option(BUILD_XMPLAY "Build XMPlay plugin" ON) option(BUILD_XMPLAY "Build XMPlay plugin" ON)
set(XMPLAY_INSTALL_PREFIX CACHE PATH "Path to XMPlay installation directory") set(XMPLAY_INSTALL_PREFIX CACHE PATH "Path to XMPlay installation directory")
else() else()
option(BUILD_STATIC "Build statically linked binary" OFF) if(EMSCRIPTEN)
if(BUILD_STATIC) set(BUILD_STATIC ON)
option(BUILD_V123 "Build vgmstream123 player" OFF)
else() else()
option(BUILD_V123 "Build vgmstream123 player" ON) option(BUILD_STATIC "Build statically linked binary" OFF)
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)
endif() endif()
option(BUILD_AUDACIOUS "Build Audacious plugin" ON) endif()
if(EMSCRIPTEN)
set(USE_MPEG OFF)
set(USE_FFMPEG OFF)
set(USE_JANSSON OFF)
endif() endif()
# Static builds will link all libraries statically # Static builds will link all libraries statically
if(BUILD_STATIC) if(BUILD_STATIC)
set(BUILD_SHARED_LIBS OFF) set(BUILD_SHARED_LIBS OFF)
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static") set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static")
# it is already kind of obvious when you do not have it, and just prevents you from building without ffmpeg if(USE_FFMPEG)
#find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
#pkg_check_modules(PC_OPUS REQUIRED opus>=1.1) pkg_check_modules(PC_OPUS REQUIRED opus>=1.1)
endif()
# Incompatible with static builds # Incompatible with static builds
set(BUILD_AUDACIOUS OFF) set(BUILD_AUDACIOUS OFF)
endif() endif()
@ -417,15 +428,27 @@ if(NOT WIN32)
endif() endif()
endif() endif()
if(ATRAC9_PATH) if(ATRAC9_PATH)
if(NOT EXISTS ${ATRAC9_PATH}/C/bin/libatrac9.a) if(EMSCRIPTEN)
add_custom_target(ATRAC9_MAKE ALL set(ATRAC9_LINK_PATH ${ATRAC9_PATH}/C/embin/libatrac9.a)
COMMAND make static CFLAGS="-fPIC" else()
WORKING_DIRECTORY ${ATRAC9_PATH}/C set(ATRAC9_LINK_PATH ${ATRAC9_PATH}/C/bin/libatrac9.a)
) endif()
if(NOT EXISTS ${ATRAC9_LINK_PATH})
if(EMSCRIPTEN)
add_custom_target(ATRAC9_MAKE ALL
COMMAND emmake make static CFLAGS="-fPIC" CC=emcc AR=emar BINDIR=embin
WORKING_DIRECTORY ${ATRAC9_PATH}/C
)
else()
add_custom_target(ATRAC9_MAKE ALL
COMMAND make static CFLAGS="-fPIC"
WORKING_DIRECTORY ${ATRAC9_PATH}/C
)
endif()
endif() endif()
add_library(atrac9 STATIC IMPORTED) add_library(atrac9 STATIC IMPORTED)
set_target_properties(atrac9 PROPERTIES set_target_properties(atrac9 PROPERTIES
IMPORTED_LOCATION ${ATRAC9_PATH}/C/bin/libatrac9.a IMPORTED_LOCATION ${ATRAC9_LINK_PATH}
) )
endif() endif()
endif() endif()

View File

@ -17,7 +17,7 @@ endif()
target_link_libraries(vgmstream_cli libvgmstream) target_link_libraries(vgmstream_cli libvgmstream)
# Link to Jansson, if we have it # Link to Jansson, if we have it
if (JANSSON_FOUND) if (USE_JANSSON AND JANSSON_FOUND)
target_compile_definitions(vgmstream_cli PRIVATE HAVE_JSON) target_compile_definitions(vgmstream_cli PRIVATE HAVE_JSON)
target_link_libraries(vgmstream_cli jansson) target_link_libraries(vgmstream_cli jansson)
endif() endif()