vgmstream/cmake/dependencies/mpg123.cmake

66 lines
1.8 KiB
CMake
Raw Normal View History

if(NOT WIN32 AND USE_MPEG)
if(NOT MPEG_PATH AND NOT BUILD_STATIC)
find_package(MPG123 QUIET)
if(MPG123_FOUND)
set(MPEG_SOURCE "(system)")
endif()
endif()
if(MPEG_PATH OR BUILD_STATIC OR NOT MPG123_FOUND)
FetchDependency(MPEG
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 mirror (default branch is not master), works too
GIT_REPOSITORY https://github.com/madebr/mpg123
GIT_TAG efedb989a4d300199f09757815409d3a89b8bc63
GIT_UNSHALLOW ON
)
2021-09-27 01:36:54 +02:00
if(MPEG_PATH)
set(MPEG_LINK_PATH ${MPEG_BIN}/src/libmpg123/.libs/libmpg123.a)
set(MPG123_INCLUDE_DIR ${MPEG_PATH}/src)
2021-09-27 01:36:54 +02:00
if(NOT EXISTS ${MPEG_PATH}/configure)
add_custom_target(MPEG_AUTORECONF
COMMAND autoreconf -iv
BYPRODUCTS ${MPEG_PATH}/configure
2021-09-27 01:36:54 +02:00
WORKING_DIRECTORY ${MPEG_PATH}
)
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}
)
2021-09-27 01:36:54 +02:00
add_library(mpg123 STATIC IMPORTED)
if(NOT EXISTS ${MPEG_LINK_PATH})
add_dependencies(mpg123 MPEG_MAKE)
endif()
2021-09-27 01:36:54 +02:00
set_target_properties(mpg123 PROPERTIES
IMPORTED_LOCATION ${MPEG_LINK_PATH}
)
endif()
endif()
endif()
if(NOT USE_MPEG)
unset(MPEG_SOURCE)
endif()