Cmake: Fixes for dependencies

- Sets dependencies for targets
  - Fixes not being able to build single targets, like `make vgmstream_cli`
  - Fixes not being able to build with multiple jobs, like `make -j 5`
- Compiles dependencies out of the source directory
- Fixes double lib suffix, renaming liblibvgmstream.a to libvgmstream.a
- Removes zlib dependency from static builds, previously required by ffmpeg
- If ARCHIVE_EXTRACT is not available in cmake, mpg123 will be downloaded through svn, then fall back to git if that is not available either
This commit is contained in:
KatieFrogs 2021-10-02 09:00:53 +03:00
parent fe316bb24c
commit bf89c3503d
10 changed files with 207 additions and 143 deletions

View File

@ -70,9 +70,6 @@ if(NOT WIN32)
set(ATRAC9_PATH CACHE PATH "Path to LibAtrac9") set(ATRAC9_PATH CACHE PATH "Path to LibAtrac9")
set(SPEEX_PATH CACHE PATH "Path to SPEEX") set(SPEEX_PATH CACHE PATH "Path to SPEEX")
set(LIBAO_PATH CACHE PATH "Path to libao") set(LIBAO_PATH CACHE PATH "Path to libao")
if(EMSCRIPTEN)
set(ZLIB_PATH CACHE PATH "Path to zlib")
endif()
endif() endif()
# Build choices # Build choices

View File

@ -1,17 +1,36 @@
if(NOT WIN32) if(NOT WIN32)
find_package(Git QUIET) find_package(Git QUIET)
if(Git_FOUND) find_package(Subversion QUIET)
if(Git_FOUND OR Subversion_FOUND)
include(FetchContent) include(FetchContent)
endif() endif()
endif() endif()
function(FetchDependency name) function(FetchDependency name)
set(value_args DIR GIT_REPOSITORY GIT_TAG DOWNLOAD SUBDIR) set(value_args
cmake_parse_arguments(ARGS "" "${value_args}" "" ${ARGN}) DIR
GIT_REPOSITORY
GIT_TAG
GIT_UNSHALLOW
SVN_REPOSITORY
SVN_REVISION
FILE_DOWNLOAD
FILE_SUBDIR
)
set(multi_value_args
FETCH_PRIORITY
)
cmake_parse_arguments(ARGS "" "${value_args}" "${multi_value_args}" ${ARGN})
if(NOT ARGS_DIR) if(NOT ARGS_DIR)
set(ARGS_DIR ${name}) set(ARGS_DIR ${name})
endif() endif()
if(NOT ARGS_FETCH_PRIORITY)
set(ARGS_FETCH_PRIORITY git svn file)
endif()
set(${name}_BIN ${VGM_BINARY_DIR}/dependencies/${ARGS_DIR}) set(${name}_BIN ${VGM_BINARY_DIR}/dependencies/${ARGS_DIR})
set(${name}_BIN ${${name}_BIN} PARENT_SCOPE) set(${name}_BIN ${${name}_BIN} PARENT_SCOPE)
@ -22,31 +41,55 @@ function(FetchDependency name)
else() else()
message(FATAL_ERROR "The provided path to ${ARGS_DIR} does not exist (Use ${name}_PATH)") message(FATAL_ERROR "The provided path to ${ARGS_DIR} does not exist (Use ${name}_PATH)")
endif() endif()
elseif(Git_FOUND AND ARGS_GIT_REPOSITORY OR ARGS_DOWNLOAD) elseif((Subversion_FOUND AND ARGS_SVN_REPOSITORY) OR (Git_FOUND AND ARGS_GIT_REPOSITORY) OR (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.18.0" AND ARGS_FILE_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) foreach(CURRENT_FETCH ${ARGS_FETCH_PRIORITY})
if(CURRENT_FETCH STREQUAL "git" AND Git_FOUND AND ARGS_GIT_REPOSITORY)
if(ARGS_GIT_UNSHALLOW)
set(shallow OFF)
else()
set(shallow ON)
endif()
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}
BINARY_DIR ${${name}_BIN} BINARY_DIR ${${name}_BIN}
SUBBUILD_DIR ${${name}_BIN}-sub SUBBUILD_DIR ${${name}_BIN}-sub
GIT_TAG ${ARGS_GIT_TAG} GIT_TAG ${ARGS_GIT_TAG}
GIT_SHALLOW ON GIT_SHALLOW ${shallow}
) )
FetchContent_GetProperties(${name}_FETCH) FetchContent_GetProperties(${name}_FETCH)
if(NOT ${name}_FETCH_POPULATED) if(NOT ${name}_FETCH_POPULATED)
message("Downloading ${ARGS_DIR}...") message("Downloading ${ARGS_DIR} (git)...")
FetchContent_Populate(${name}_FETCH) FetchContent_Populate(${name}_FETCH)
endif() endif()
else() break()
string(REGEX REPLACE ".*/" "" FILE ${ARGS_DOWNLOAD})
elseif(CURRENT_FETCH STREQUAL "svn" AND Subversion_FOUND AND ARGS_SVN_REPOSITORY)
FetchContent_Declare(${name}_FETCH
SVN_REPOSITORY ${ARGS_SVN_REPOSITORY}
SOURCE_DIR ${${name}_PATH}
BINARY_DIR ${${name}_BIN}
SUBBUILD_DIR ${${name}_BIN}-sub
SVN_REVISION ${ARGS_SVN_REVISION}
)
FetchContent_GetProperties(${name}_FETCH)
if(NOT ${name}_FETCH_POPULATED)
message("Downloading ${ARGS_DIR} (svn)...")
FetchContent_Populate(${name}_FETCH)
endif()
break()
elseif(CURRENT_FETCH STREQUAL "file" AND ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.18.0" AND ARGS_FILE_DOWNLOAD)
# no ARCHIVE_EXTRACT until 3.18
string(REGEX REPLACE ".*/" "" FILE ${ARGS_FILE_DOWNLOAD})
if(NOT EXISTS ${${name}_PATH}/${FILE}) if(NOT EXISTS ${${name}_PATH}/${FILE})
message("Downloading ${ARGS_DIR}...") message("Downloading ${ARGS_DIR} (file)...")
file(DOWNLOAD file(DOWNLOAD
${ARGS_DOWNLOAD} ${ARGS_FILE_DOWNLOAD}
${${name}_PATH}/${FILE} ${${name}_PATH}/${FILE}
) )
file(ARCHIVE_EXTRACT file(ARCHIVE_EXTRACT
@ -54,10 +97,12 @@ function(FetchDependency name)
DESTINATION ${${name}_PATH} DESTINATION ${${name}_PATH}
) )
endif() endif()
if(ARGS_SUBDIR) if(ARGS_FILE_SUBDIR)
set(${name}_PATH ${${name}_PATH}/${ARGS_SUBDIR} PARENT_SCOPE) set(${name}_PATH ${${name}_PATH}/${ARGS_FILE_SUBDIR} PARENT_SCOPE)
endif() endif()
break()
endif() endif()
endforeach()
else() else()
set(${name}_PATH "" PARENT_SCOPE) set(${name}_PATH "" PARENT_SCOPE)
set(USE_${name} OFF PARENT_SCOPE) set(USE_${name} OFF PARENT_SCOPE)

View File

@ -6,26 +6,18 @@ if(NOT WIN32 AND USE_ATRAC9)
) )
if(ATRAC9_PATH) if(ATRAC9_PATH)
if(EMSCRIPTEN)
set(ATRAC9_LINK_PATH ${ATRAC9_BIN}/embin/libatrac9.a)
else()
set(ATRAC9_LINK_PATH ${ATRAC9_BIN}/bin/libatrac9.a) set(ATRAC9_LINK_PATH ${ATRAC9_BIN}/bin/libatrac9.a)
endif()
if(NOT EXISTS ${ATRAC9_LINK_PATH}) add_custom_target(ATRAC9_MAKE
if(EMSCRIPTEN) COMMAND make static CFLAGS="-fPIC" OBJDIR="${ATRAC9_BIN}/obj" BINDIR="${ATRAC9_BIN}/bin" CC="${CMAKE_C_COMPILER}" AR="${CMAKE_AR}"
add_custom_target(ATRAC9_MAKE ALL
COMMAND emmake make static CFLAGS="-fPIC" CC=emcc AR=emar BINDIR="${ATRAC9_BIN}/embin" && make clean
WORKING_DIRECTORY ${ATRAC9_PATH}/C WORKING_DIRECTORY ${ATRAC9_PATH}/C
BYPRODUCTS ${ATRAC9_LINK_PATH} ${ATRAC9_BIN}
) )
else()
add_custom_target(ATRAC9_MAKE ALL
COMMAND make static CFLAGS="-fPIC" BINDIR="${ATRAC9_BIN}/bin" && make clean
WORKING_DIRECTORY ${ATRAC9_PATH}/C
)
endif()
endif()
add_library(atrac9 STATIC IMPORTED) add_library(atrac9 STATIC IMPORTED)
if(NOT EXISTS ${ATRAC9_LINK_PATH})
add_dependencies(atrac9 ATRAC9_MAKE)
endif()
set_target_properties(atrac9 PROPERTIES set_target_properties(atrac9 PROPERTIES
IMPORTED_LOCATION ${ATRAC9_LINK_PATH} IMPORTED_LOCATION ${ATRAC9_LINK_PATH}
) )

View File

@ -1,6 +1,7 @@
if(NOT WIN32 AND BUILD_AUDACIOUS) if(NOT WIN32 AND BUILD_AUDACIOUS)
set(AUDACIOUS_SOURCE "(system)") set(AUDACIOUS_SOURCE "(system)")
find_package(PkgConfig REQUIRED)
pkg_search_module(AUDACIOUS REQUIRED audacious>=3.6) pkg_search_module(AUDACIOUS REQUIRED audacious>=3.6)
pkg_get_variable(AUDACIOUS_PLUGIN_DIR audacious plugin_dir) pkg_get_variable(AUDACIOUS_PLUGIN_DIR audacious plugin_dir)
pkg_search_module(GTK REQUIRED gtk+-3.0 gtk+-2.0) pkg_search_module(GTK REQUIRED gtk+-3.0 gtk+-2.0)

View File

@ -59,6 +59,8 @@ if(USE_FFMPEG)
) )
if(FFMPEG_PATH) if(FFMPEG_PATH)
set(FFMPEG_COMPILE YES)
set(FFMPEG_CONF_PARSER set(FFMPEG_CONF_PARSER
ac3 mpegaudio xma vorbis opus ac3 mpegaudio xma vorbis opus
) )
@ -119,6 +121,7 @@ if(USE_FFMPEG)
--disable-decoder=${FFMPEG_CONF_DISABLE_DECODER} --disable-decoder=${FFMPEG_CONF_DISABLE_DECODER}
--disable-cuvid --disable-cuvid
--disable-version3 --disable-version3
--disable-zlib
--extra-libs=-static --extra-libs=-static
--extra-cflags=--static --extra-cflags=--static
--pkg-config-flags=--static --pkg-config-flags=--static
@ -130,8 +133,8 @@ if(USE_FFMPEG)
endif() endif()
if(EMSCRIPTEN) if(EMSCRIPTEN)
list(APPEND FFMPEG_CONF_ARGS list(APPEND FFMPEG_CONF_ARGS
--cc=emcc --cc=${CMAKE_C_COMPILER}
--ranlib=emranlib --ranlib=${CMAKE_RANLIB}
--enable-cross-compile --enable-cross-compile
--target-os=none --target-os=none
--arch=x86 --arch=x86
@ -150,47 +153,28 @@ if(USE_FFMPEG)
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) set(FFMPEG_INCLUDE_DIRS ${FFMPEG_BIN}/bin/usr/local/include)
if(NOT EXISTS ${FFMPEG_LINK_PATH}/libavutil.a) file(MAKE_DIRECTORY ${FFMPEG_BIN})
if(EMSCRIPTEN) add_custom_target(FFMPEG_CONFIGURE
add_custom_target(FFMPEG_MAKE ALL COMMAND "${FFMPEG_PATH}/configure" ${FFMPEG_CONF_ARGS}
COMMAND emconfigure ./configure ${FFMPEG_CONF_ARGS} && emmake make && make install DESTDIR="${FFMPEG_BIN}/bin" && make clean BYPRODUCTS ${FFMPEG_BIN}/Makefile
WORKING_DIRECTORY ${FFMPEG_PATH} WORKING_DIRECTORY ${FFMPEG_BIN}
) )
else() add_custom_target(FFMPEG_MAKE
add_custom_target(FFMPEG_MAKE ALL COMMAND make && make install DESTDIR="${FFMPEG_BIN}/bin"
COMMAND ./configure ${FFMPEG_CONF_ARGS} && make && make install DESTDIR="${FFMPEG_BIN}/bin" && make clean DEPENDS ${FFMPEG_BIN}/Makefile
WORKING_DIRECTORY ${FFMPEG_PATH} BYPRODUCTS ${FFMPEG_BIN}
WORKING_DIRECTORY ${FFMPEG_BIN}
) )
endif()
endif()
foreach(LIB avutil avformat swresample avcodec) foreach(LIB avutil avformat swresample avcodec)
add_library(${LIB} STATIC IMPORTED) add_library(${LIB} STATIC IMPORTED)
if(NOT EXISTS ${FFMPEG_LINK_PATH}/lib${LIB}.a)
add_dependencies(${LIB} FFMPEG_MAKE)
endif()
set_target_properties(${LIB} PROPERTIES set_target_properties(${LIB} PROPERTIES
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
)
if(ZLIB_PATH)
add_subdirectory(${ZLIB_PATH} ${ZLIB_BIN})
set_target_properties(zlib example minigzip example64 minigzip64 PROPERTIES
EXCLUDE_FROM_ALL TRUE
EXCLUDE_FROM_DEFAULT_BUILD TRUE
)
add_library(z STATIC IMPORTED)
set_target_properties(z PROPERTIES
IMPORTED_LOCATION ${ZLIB_BIN}/libz.a
)
endif()
endif()
endif() endif()
endif() endif()
endif() endif()

View File

@ -15,32 +15,50 @@ if(NOT WIN32 AND BUILD_V123)
if(LIBAO_PATH) if(LIBAO_PATH)
if(BUILD_STATIC) if(BUILD_STATIC)
set(LIBAO_CONF_ARGS --enable-static=yes --enable-shared=no) set(LIBAO_CONF_ARGS --enable-static --disable-shared)
set(LINK_EXT .a) set(LINK_EXT .a)
else() else()
set(LIBAO_CONF_ARGS --enable-static=no --enable-shared=yes) set(LIBAO_CONF_ARGS --disable-static --enable-shared)
set(LINK_EXT .so) set(LINK_EXT .so)
endif() endif()
set(LIBAO_LINK_PATH ${LIBAO_BIN}/bin/usr/local/lib/libao${LINK_EXT}) set(LIBAO_LINK_PATH ${LIBAO_BIN}/bin/usr/local/lib/libao${LINK_EXT})
set(LIBAO_INCLUDE ${LIBAO_BIN}/bin/usr/local/include) set(LIBAO_INCLUDE ${LIBAO_BIN}/bin/usr/local/include)
if(NOT EXISTS ${LIBAO_LINK_PATH}) if(NOT EXISTS ${LIBAO_PATH}/configure)
add_custom_target(LIBAO_MAKE ALL add_custom_target(LIBAO_AUTORECONF
COMMAND ./autogen.sh && ./configure ${LIBAO_CONF_ARGS} && make clean && make && make install DESTDIR=${LIBAO_BIN}/bin COMMAND ./autogen.sh
BYPRODUCTS ${LIBAO_PATH}/configure
WORKING_DIRECTORY ${LIBAO_PATH} WORKING_DIRECTORY ${LIBAO_PATH}
) )
endif() endif()
file(MAKE_DIRECTORY ${LIBAO_BIN})
add_custom_target(LIBAO_CONFIGURE
COMMAND "${LIBAO_PATH}/configure" ${LIBAO_CONF_ARGS} CC="${CMAKE_C_COMPILER}" AR="${CMAKE_AR}"
DEPENDS ${LIBAO_PATH}/configure
BYPRODUCTS ${LIBAO_BIN}/Makefile
WORKING_DIRECTORY ${LIBAO_BIN}
)
add_custom_target(LIBAO_MAKE
COMMAND make && make install DESTDIR=${LIBAO_BIN}/bin
DEPENDS ${LIBAO_BIN}/Makefile
BYPRODUCTS ${LIBAO_LINK_PATH} ${LIBAO_BIN}
WORKING_DIRECTORY ${LIBAO_BIN}
)
if(BUILD_STATIC) if(BUILD_STATIC)
add_library(ao STATIC IMPORTED) add_library(ao STATIC IMPORTED)
else() else()
add_library(ao SHARED IMPORTED) add_library(ao SHARED IMPORTED)
endif() endif()
if(NOT EXISTS ${LIBAO_LINK_PATH})
add_dependencies(ao LIBAO_MAKE)
endif()
set_target_properties(ao PROPERTIES set_target_properties(ao PROPERTIES
IMPORTED_LOCATION ${LIBAO_LINK_PATH} IMPORTED_LOCATION ${LIBAO_LINK_PATH}
) )
elseif(BUILD_STATIC) elseif(BUILD_STATIC)
message(FATAL_ERROR "Path to libao must be set. (Use LIBAO_PATH)") message(FATAL_ERROR "Path to libao must be set. (Use LIBAO_PATH or turn off BUILD_V123)")
else() else()
set(BUILD_V123 OFF) set(BUILD_V123 OFF)
endif() endif()

View File

@ -7,39 +7,53 @@ 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)
if(${CMAKE_VERSION} VERSION_LESS "3.18.0")
# no ARCHIVE_EXTRACT until 3.18
FetchDependency(MPEG FetchDependency(MPEG
DIR mpg123 DIR mpg123
FETCH_PRIORITY file svn git
FILE_DOWNLOAD https://downloads.sourceforge.net/mpg123/mpg123-1.28.2.tar.bz2
FILE_SUBDIR mpg123-1.28.2
SVN_REPOSITORY svn://scm.orgis.org/mpg123/trunk
SVN_REVISION -r4968
# "official" git repo: https://www.mpg123.de/trunk/.git/ but *very* slow (HTTP emulation) # "official" git repo: https://www.mpg123.de/trunk/.git/ but *very* slow (HTTP emulation)
# (original is svn://scm.orgis.org/mpg123/trunk, FetchDependency would need SVN_REPOSITORY and stuff)
# "official" git mirror (default branch is not master), works too # "official" git mirror (default branch is not master), works too
# not sure how to set branch + commit fedb989a4d300199f09757815409d3a89b8bc63 (v1.28.2)
GIT_REPOSITORY https://github.com/madebr/mpg123 GIT_REPOSITORY https://github.com/madebr/mpg123
GIT_TAG master GIT_TAG efedb989a4d300199f09757815409d3a89b8bc63
GIT_UNSHALLOW ON
) )
set(MPEG_BUILD_COMMAND autoreconf -iv && ./configure --enable-static=yes --enable-shared=no && make && make install DESTDIR="${MPEG_BIN}/bin" && make clean)
else()
FetchDependency(MPEG
DIR mpg123
DOWNLOAD https://downloads.sourceforge.net/mpg123/mpg123-1.28.2.tar.bz2
SUBDIR mpg123-1.28.2
)
set(MPEG_BUILD_COMMAND ./configure --enable-static=yes --enable-shared=no && make && make install DESTDIR="${MPEG_BIN}/bin" && make clean)
endif()
if(MPEG_PATH) if(MPEG_PATH)
set(MPEG_LINK_PATH ${MPEG_BIN}/bin/usr/local/lib/libmpg123.a) set(MPEG_LINK_PATH ${MPEG_BIN}/src/libmpg123/.libs/libmpg123.a)
set(MPG123_INCLUDE_DIR ${MPEG_BIN}/bin/usr/local/include) set(MPG123_INCLUDE_DIR ${MPEG_PATH}/src)
if(NOT EXISTS ${MPEG_LINK_PATH}) if(NOT EXISTS ${MPEG_PATH}/configure)
add_custom_target(MPEG_MAKE ALL add_custom_target(MPEG_AUTORECONF
COMMAND ${MPEG_BUILD_COMMAND} COMMAND autoreconf -iv
BYPRODUCTS ${MPEG_PATH}/configure
WORKING_DIRECTORY ${MPEG_PATH} WORKING_DIRECTORY ${MPEG_PATH}
) )
endif() endif()
file(MAKE_DIRECTORY ${MPEG_BIN})
add_custom_target(MPEG_CONFIGURE
COMMAND "${MPEG_PATH}/configure" --enable-static --disable-shared CC="${CMAKE_C_COMPILER}" AR="${CMAKE_AR}"
DEPENDS ${MPEG_PATH}/configure
BYPRODUCTS ${MPEG_BIN}/Makefile
WORKING_DIRECTORY ${MPEG_BIN}
)
add_custom_target(MPEG_MAKE
COMMAND make src/libmpg123/libmpg123.la
DEPENDS ${MPEG_BIN}/Makefile
BYPRODUCTS ${MPEG_LINK_PATH} ${MPEG_BIN}
WORKING_DIRECTORY ${MPEG_BIN}
)
add_library(mpg123 STATIC IMPORTED) add_library(mpg123 STATIC IMPORTED)
if(NOT EXISTS ${MPEG_LINK_PATH})
add_dependencies(mpg123 MPEG_MAKE)
endif()
set_target_properties(mpg123 PROPERTIES set_target_properties(mpg123 PROPERTIES
IMPORTED_LOCATION ${MPEG_LINK_PATH} IMPORTED_LOCATION ${MPEG_LINK_PATH}
) )

View File

@ -14,26 +14,34 @@ if(NOT WIN32 AND USE_SPEEX)
) )
if(SPEEX_PATH) if(SPEEX_PATH)
if(EMSCRIPTEN) set(SPEEX_LINK_PATH ${SPEEX_BIN}/libspeex/.libs/libspeex.a)
set(SPEEX_LINK_PATH ${SPEEX_BIN}/embin/usr/local/lib/libspeex.a)
else() if(NOT EXISTS ${SPEEX_PATH}/configure)
set(SPEEX_LINK_PATH ${SPEEX_BIN}/bin/usr/local/lib/libspeex.a) add_custom_target(SPEEX_AUTORECONF
endif() COMMAND ./autogen.sh
if(NOT EXISTS ${SPEEX_LINK_PATH}) BYPRODUCTS ${SPEEX_PATH}/configure
if(EMSCRIPTEN)
add_custom_target(SPEEX_MAKE ALL
COMMAND emconfigure ./autogen.sh && emconfigure ./configure --enable-static=yes --enable-shared=no && emmake make && make install DESTDIR="${SPEEX_BIN}/embin" && make clean
WORKING_DIRECTORY ${SPEEX_PATH} WORKING_DIRECTORY ${SPEEX_PATH}
) )
else()
add_custom_target(SPEEX_MAKE ALL
COMMAND ./autogen.sh && ./configure --enable-static=yes --enable-shared=no && make && make install DESTDIR="${SPEEX_BIN}/bin" && make clean
WORKING_DIRECTORY ${SPEEX_PATH}
)
endif()
endif() endif()
file(MAKE_DIRECTORY ${SPEEX_BIN})
add_custom_target(SPEEX_CONFIGURE
COMMAND "${SPEEX_PATH}/configure" --enable-static --disable-shared --disable-binaries CC="${CMAKE_C_COMPILER}" AR="${CMAKE_AR}"
DEPENDS ${SPEEX_PATH}/configure
BYPRODUCTS ${SPEEX_BIN}/Makefile
WORKING_DIRECTORY ${SPEEX_BIN}
)
add_custom_target(SPEEX_MAKE
COMMAND make
DEPENDS ${SPEEX_BIN}/Makefile
BYPRODUCTS ${SPEEX_LINK_PATH} ${SPEEX_BIN}
WORKING_DIRECTORY ${SPEEX_BIN}
)
add_library(speex STATIC IMPORTED) add_library(speex STATIC IMPORTED)
if(NOT EXISTS ${SPEEX_LINK_PATH})
add_dependencies(speex SPEEX_MAKE)
endif()
set_target_properties(speex PROPERTIES set_target_properties(speex PROPERTIES
IMPORTED_LOCATION ${SPEEX_LINK_PATH} IMPORTED_LOCATION ${SPEEX_LINK_PATH}
) )

View File

@ -72,11 +72,11 @@ macro(setup_target TARGET)
else() else()
target_include_directories(${TARGET} PRIVATE ${FFMPEG_INCLUDE_DIRS}) target_include_directories(${TARGET} PRIVATE ${FFMPEG_INCLUDE_DIRS})
if(LINK) if(LINK)
if(BUILD_STATIC) if(FFMPEG_COMPILE)
if(USE_FFMPEG_LIBOPUS) 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)
else() else()
target_link_libraries(${TARGET} avformat avcodec avutil swresample pthread m z) target_link_libraries(${TARGET} avformat avcodec avutil swresample pthread m)
endif() endif()
else() else()
target_link_libraries(${TARGET} ${FFMPEG_LIBRARIES}) target_link_libraries(${TARGET} ${FFMPEG_LIBRARIES})
@ -115,7 +115,7 @@ macro(setup_target TARGET)
target_link_libraries(${TARGET} ${VGM_BINARY_DIR}/ext_libs/libatrac9.lib) target_link_libraries(${TARGET} ${VGM_BINARY_DIR}/ext_libs/libatrac9.lib)
endif() endif()
if(NOT WIN32 AND LINK) if(NOT WIN32 AND LINK)
target_link_libraries(${TARGET} atrac9) target_link_libraries(${TARGET} atrac9 m)
endif() endif()
endif() endif()

View File

@ -37,6 +37,11 @@ add_library(libvgmstream STATIC
${EXT_HEADERS} ${EXT_HEADERS}
${MAIN_HEADERS} ${MAIN_HEADERS}
${MAIN_SOURCES}) ${MAIN_SOURCES})
set_target_properties(libvgmstream PROPERTIES PREFIX "")
if(USE_FFMPEG)
add_dependencies(libvgmstream avcodec)
endif()
setup_target(libvgmstream) setup_target(libvgmstream)