vgmstream/cmake/dependencies/celt.cmake

170 lines
4.0 KiB
CMake
Raw Normal View History

2021-10-22 06:51:04 +02:00
if(NOT WIN32 AND USE_CELT)
FetchDependency(CELT_0061
DIR celt-0061
GIT_REPOSITORY https://gitlab.xiph.org/xiph/celt
GIT_TAG 8ccf148573277b983692e15d5f0753081f806bea
)
FetchDependency(CELT_0110
DIR celt-0110
GIT_REPOSITORY https://gitlab.xiph.org/xiph/celt
GIT_TAG 0b405d1170122c859faab435405666506d52fa2e
)
2021-10-22 09:09:33 +02:00
if(CELT_0061_PATH AND CELT_0110_PATH AND (OGG_PATH OR OGG_FOUND))
2021-10-22 06:51:04 +02:00
set(CELT_0061_LINK_PATH ${CELT_0061_BIN}/libcelt/.libs/libcelt.a)
set(CELT_0110_LINK_PATH ${CELT_0110_BIN}/libcelt/.libs/libcelt0.a)
2021-10-22 09:09:33 +02:00
configure_file(
${VGM_SOURCE_DIR}/ext_libs/celt-0110/ecintrin.h
${CELT_0110_PATH}/libcelt/ecintrin.h
COPYONLY)
set(CELT_CFLAGS
2021-10-22 06:51:04 +02:00
alg_quant
alg_unquant
celt_decode
celt_decoder_create
celt_decoder_create_custom
celt_decoder_destroy
celt_mode_create
celt_mode_destroy
celt_mode_info
celt_encoder_destroy
celt_encoder_create
celt_encode
celt_encode_float
celt_encoder_ctl
celt_decode_float
celt_decoder_ctl
compute_allocation
compute_band_energies
denormalise_bands
ec_dec_init
ec_decode
ec_decode_bin
ec_dec_update
ec_dec_uint
ec_dec_bits
ec_enc_init
ec_encode
ec_encode_bin
ec_enc_uint
ec_enc_bits
ec_enc_done
normalise_bands
renormalise_vector
quant_coarse_energy
quant_fine_energy
quant_energy_finalise
unquant_coarse_energy
unquant_energy_finalise
unquant_fine_energy
2021-10-22 07:19:11 +02:00
eMeans
encode_pulses
decode_pulses
ec_laplace_encode
ec_laplace_decode
celt_decoder_get_size
celt_decoder_init
ec_dec_bit_logp
ec_dec_icdf
ec_enc_bit_logp
ec_enc_icdf
ec_enc_shrink
_celt_lpc
_celt_autocorr
amp2Log2
stereo_itheta
anti_collapse
spreading_decision
haar1
quant_all_bands
log2_frac
icwrs
get_required_bits
2021-10-22 09:09:33 +02:00
ec_ilog
mdct_forward
mdct_backward
mdct_init
mdct_clear
2021-10-22 06:51:04 +02:00
)
foreach(ver 0061 0110)
2021-10-22 09:09:33 +02:00
foreach(source ${CELT_CFLAGS})
2021-10-22 06:51:04 +02:00
string(REGEX REPLACE "^([^_]+)" "\\1_${ver}" target ${source})
2021-10-22 07:19:11 +02:00
if(source STREQUAL ${target})
set(target "${source}_${ver}")
endif()
2021-10-22 09:09:33 +02:00
list(APPEND CELT_${ver}_CFLAGS "-D${source}=${target}")
2021-10-22 06:51:04 +02:00
endforeach()
if(ver STREQUAL "0110")
2021-10-22 09:09:33 +02:00
list(APPEND CELT_${ver}_CFLAGS "-DCUSTOM_MODES=1")
endif()
list(APPEND CELT_${ver}_CFLAGS "-fPIC")
set(CELT_${ver}_CONF
--enable-static
--disable-shared
CC="${CMAKE_C_COMPILER}"
AR="${CMAKE_AR}"
CFLAGS="${CELT_${ver}_CFLAGS}"
)
set(CELT_${ver}_CONFIGURE_DEPENDS
${CELT_${ver}_PATH}/configure
)
if(OGG_PATH)
foreach(ogg_include ${OGG_INCLUDE_DIR})
list(APPEND OGG_INCLUDES -I${ogg_include})
endforeach()
list(APPEND CELT_${ver}_CONF
LDFLAGS="-L${OGG_BIN}"
CPPFLAGS="${OGG_INCLUDES}"
)
list(APPEND CELT_${ver}_CONFIGURE_DEPENDS
${OGG_BIN}/libogg.a
)
2021-10-22 06:51:04 +02:00
endif()
if(NOT EXISTS ${CELT_${ver}_PATH}/configure)
add_custom_target(CELT_${ver}_AUTOGEN
COMMAND ./autogen.sh
BYPRODUCTS ${CELT_${ver}_PATH}/configure
WORKING_DIRECTORY ${CELT_${ver}_PATH}
)
endif()
file(MAKE_DIRECTORY ${CELT_${ver}_BIN})
add_custom_target(CELT_${ver}_CONFIGURE
2021-10-22 09:09:33 +02:00
COMMAND "${CELT_${ver}_PATH}/configure" ${CELT_${ver}_CONF}
DEPENDS ${CELT_${ver}_CONFIGURE_DEPENDS}
2021-10-22 06:51:04 +02:00
BYPRODUCTS ${CELT_${ver}_BIN}/Makefile
WORKING_DIRECTORY ${CELT_${ver}_BIN}
)
add_custom_target(CELT_${ver}_MAKE
COMMAND make
DEPENDS ${CELT_${ver}_BIN}/Makefile
BYPRODUCTS ${CELT_${ver}_LINK_PATH} ${CELT_${ver}_BIN}
WORKING_DIRECTORY ${CELT_${ver}_BIN}
)
add_library(celt${ver} STATIC IMPORTED)
if(NOT EXISTS ${CELT_${ver}_LINK_PATH})
add_dependencies(celt${ver} CELT_${ver}_MAKE)
endif()
set_target_properties(celt${ver} PROPERTIES
IMPORTED_LOCATION ${CELT_${ver}_LINK_PATH}
)
endforeach()
else()
set(USE_CELT OFF)
endif()
endif()
if(USE_CELT)
if(CELT_0061_SOURCE STREQUAL "${CELT_0110_SOURCE}")
set(CELT_SOURCE ${CELT_0061_SOURCE})
else()
set(CELT_SOURCE "v0.6.1: ${CELT_0061_SOURCE}, v0.11.0: ${CELT_0110_SOURCE}")
endif()
else()
unset(CELT_SOURCE)
endif()