2019-03-17 19:36:55 +01:00
|
|
|
# Setup a target to have the proper preprocessor definitions, include directories, dependencies and link libraries
|
|
|
|
# Can take either 1 argument, the target, or 2 arguments, the target and a boolean that, if set to TRUE, will add the link libraries
|
|
|
|
macro(setup_target TARGET)
|
|
|
|
set(LINK FALSE)
|
|
|
|
if(${ARGC} GREATER 1)
|
|
|
|
if(${ARGV1})
|
|
|
|
set(LINK TRUE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Common preprocessor definitions and include directories
|
|
|
|
if(WIN32)
|
|
|
|
target_compile_definitions(${TARGET} PRIVATE
|
|
|
|
_WIN32_WINNT=0x501
|
|
|
|
_CRT_SECURE_NO_WARNINGS)
|
|
|
|
endif()
|
2020-01-11 17:34:51 +01:00
|
|
|
target_include_directories(${TARGET} PRIVATE ${VGM_SOURCE_DIR}/src)
|
|
|
|
target_include_directories(${TARGET} PRIVATE ${VGM_SOURCE_DIR}/ext_includes)
|
2019-03-18 05:17:08 +01:00
|
|
|
# Set up position-independent code for all targets
|
2021-08-28 19:32:52 +02:00
|
|
|
set_target_properties(${TARGET} PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
|
|
|
|
if(BUILD_STATIC)
|
|
|
|
set_target_properties(${TARGET} PROPERTIES LINK_SEARCH_END_STATIC 1)
|
|
|
|
endif()
|
2019-03-23 17:47:06 +01:00
|
|
|
if(NOT WIN32 AND LINK)
|
|
|
|
# Include libm on non-Windows systems
|
|
|
|
target_link_libraries(${TARGET} m)
|
|
|
|
endif()
|
2019-03-17 19:36:55 +01:00
|
|
|
|
2021-08-26 18:43:17 +02:00
|
|
|
target_compile_definitions(${TARGET} PRIVATE VGM_LOG_OUTPUT)
|
|
|
|
|
2019-03-17 19:36:55 +01:00
|
|
|
if(USE_MPEG)
|
|
|
|
target_compile_definitions(${TARGET} PRIVATE VGM_USE_MPEG)
|
|
|
|
if(WIN32)
|
|
|
|
if(LINK)
|
|
|
|
add_dependencies(${TARGET} libmpg123)
|
2020-01-11 17:34:51 +01:00
|
|
|
target_link_libraries(${TARGET} ${VGM_BINARY_DIR}/ext_libs/libmpg123-0.lib)
|
2019-03-17 19:36:55 +01:00
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
target_include_directories(${TARGET} PRIVATE ${MPG123_INCLUDE_DIR})
|
|
|
|
if(LINK)
|
2021-09-27 01:36:54 +02:00
|
|
|
target_link_libraries(${TARGET} mpg123 m)
|
2019-03-17 19:36:55 +01:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(USE_VORBIS)
|
|
|
|
target_compile_definitions(${TARGET} PRIVATE VGM_USE_VORBIS)
|
|
|
|
if(WIN32)
|
|
|
|
if(LINK)
|
|
|
|
add_dependencies(${TARGET} libvorbis)
|
2020-01-11 17:34:51 +01:00
|
|
|
target_link_libraries(${TARGET} ${VGM_BINARY_DIR}/ext_libs/libvorbis.lib)
|
2019-03-17 19:36:55 +01:00
|
|
|
endif()
|
|
|
|
else()
|
2019-03-21 03:23:47 +01:00
|
|
|
target_include_directories(${TARGET} PRIVATE ${VORBISFILE_INCLUDE_DIRS})
|
2019-03-17 19:36:55 +01:00
|
|
|
if(LINK)
|
2021-08-28 19:32:52 +02:00
|
|
|
target_link_libraries(${TARGET} vorbisfile vorbis ogg m)
|
2019-03-17 19:36:55 +01:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(USE_FFMPEG)
|
|
|
|
target_compile_definitions(${TARGET} PRIVATE VGM_USE_FFMPEG)
|
2021-07-17 18:37:49 +02:00
|
|
|
if(WIN32 AND NOT FFMPEG_LIBRARIES)
|
2021-07-17 17:01:10 +02:00
|
|
|
target_include_directories(${TARGET} PRIVATE ${VGM_SOURCE_DIR}/ext_includes/ffmpeg)
|
2019-03-17 19:36:55 +01:00
|
|
|
if(LINK)
|
|
|
|
add_dependencies(${TARGET} ffmpeg)
|
|
|
|
target_link_libraries(${TARGET}
|
2020-01-11 17:34:51 +01:00
|
|
|
${VGM_BINARY_DIR}/ext_libs/avcodec.lib
|
|
|
|
${VGM_BINARY_DIR}/ext_libs/avformat.lib
|
|
|
|
${VGM_BINARY_DIR}/ext_libs/avutil.lib)
|
2019-03-17 19:36:55 +01:00
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
target_include_directories(${TARGET} PRIVATE ${FFMPEG_INCLUDE_DIRS})
|
|
|
|
if(LINK)
|
2021-10-02 08:00:53 +02:00
|
|
|
if(FFMPEG_COMPILE)
|
2021-09-19 19:00:39 +02:00
|
|
|
if(USE_FFMPEG_LIBOPUS)
|
2021-10-02 08:00:53 +02:00
|
|
|
target_link_libraries(${TARGET} avformat avcodec avutil swresample opus pthread m)
|
2021-09-19 19:00:39 +02:00
|
|
|
else()
|
2021-10-02 08:00:53 +02:00
|
|
|
target_link_libraries(${TARGET} avformat avcodec avutil swresample pthread m)
|
2021-09-19 19:00:39 +02:00
|
|
|
endif()
|
2021-08-30 07:07:37 +02:00
|
|
|
else()
|
|
|
|
target_link_libraries(${TARGET} ${FFMPEG_LIBRARIES})
|
|
|
|
endif()
|
2019-03-17 19:36:55 +01:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(USE_G7221)
|
|
|
|
target_compile_definitions(${TARGET} PRIVATE VGM_USE_G7221)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(USE_G719)
|
|
|
|
target_compile_definitions(${TARGET} PRIVATE VGM_USE_G719)
|
2021-08-25 17:50:20 +02:00
|
|
|
if(WIN32 AND LINK)
|
2019-03-17 19:36:55 +01:00
|
|
|
add_dependencies(${TARGET} libg719_decode)
|
2020-01-11 17:34:51 +01:00
|
|
|
target_link_libraries(${TARGET} ${VGM_BINARY_DIR}/ext_libs/libg719_decode.lib)
|
2019-03-17 19:36:55 +01:00
|
|
|
endif()
|
2021-08-25 17:50:20 +02:00
|
|
|
if(NOT WIN32 AND LINK)
|
|
|
|
target_link_libraries(${TARGET} g719_decode)
|
|
|
|
endif()
|
2019-03-17 19:36:55 +01:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(USE_ATRAC9)
|
|
|
|
target_compile_definitions(${TARGET} PRIVATE VGM_USE_ATRAC9)
|
2021-08-27 16:04:32 +02:00
|
|
|
if(WIN32 AND LINK)
|
2019-03-17 19:36:55 +01:00
|
|
|
add_dependencies(${TARGET} libatrac9)
|
2020-01-11 17:34:51 +01:00
|
|
|
target_link_libraries(${TARGET} ${VGM_BINARY_DIR}/ext_libs/libatrac9.lib)
|
2019-03-17 19:36:55 +01:00
|
|
|
endif()
|
2021-08-27 16:04:32 +02:00
|
|
|
if(NOT WIN32 AND LINK)
|
2021-10-02 08:00:53 +02:00
|
|
|
target_link_libraries(${TARGET} atrac9 m)
|
2021-08-27 16:04:32 +02:00
|
|
|
endif()
|
2019-03-17 19:36:55 +01:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(USE_CELT)
|
|
|
|
target_compile_definitions(${TARGET} PRIVATE VGM_USE_CELT)
|
2021-10-22 06:51:04 +02:00
|
|
|
if(WIN32 AND LINK)
|
2019-03-17 19:36:55 +01:00
|
|
|
add_dependencies(${TARGET} libcelt)
|
|
|
|
target_link_libraries(${TARGET}
|
2020-01-11 17:34:51 +01:00
|
|
|
${VGM_BINARY_DIR}/ext_libs/libcelt-0061.lib
|
|
|
|
${VGM_BINARY_DIR}/ext_libs/libcelt-0110.lib)
|
2019-03-17 19:36:55 +01:00
|
|
|
endif()
|
2021-10-22 06:51:04 +02:00
|
|
|
if(NOT WIN32 AND LINK)
|
|
|
|
target_link_libraries(${TARGET} celt0061 celt0110 m)
|
|
|
|
endif()
|
2019-03-17 19:36:55 +01:00
|
|
|
endif()
|
2021-01-23 16:44:16 +01:00
|
|
|
|
|
|
|
if(USE_SPEEX)
|
|
|
|
target_compile_definitions(${TARGET} PRIVATE VGM_USE_SPEEX)
|
2021-08-27 16:04:32 +02:00
|
|
|
if(WIN32 AND LINK)
|
2021-01-23 16:44:16 +01:00
|
|
|
add_dependencies(${TARGET} libspeex)
|
2023-01-15 19:13:33 +01:00
|
|
|
target_link_libraries(${TARGET} ${VGM_BINARY_DIR}/ext_libs/libspeex-1.lib)
|
2021-01-23 16:44:16 +01:00
|
|
|
endif()
|
2021-08-27 16:04:32 +02:00
|
|
|
if(NOT WIN32 AND LINK)
|
2021-08-30 06:50:54 +02:00
|
|
|
target_link_libraries(${TARGET} speex m)
|
2021-08-27 16:04:32 +02:00
|
|
|
endif()
|
2021-01-23 16:44:16 +01:00
|
|
|
endif()
|
2019-03-17 19:36:55 +01:00
|
|
|
endmacro()
|
2019-03-20 03:00:48 +01:00
|
|
|
|
|
|
|
# Installs the DLLs to the given install prefix
|
|
|
|
macro(install_dlls INSTALL_PREFIX)
|
|
|
|
# Paths to the DLLs
|
2020-01-11 17:34:51 +01:00
|
|
|
set(MPEG_DLL ${VGM_SOURCE_DIR}/ext_libs/libmpg123-0.dll)
|
|
|
|
set(VORBIS_DLL ${VGM_SOURCE_DIR}/ext_libs/libvorbis.dll)
|
|
|
|
set(G719_DLL ${VGM_SOURCE_DIR}/ext_libs/libg719_decode.dll)
|
2019-03-20 03:00:48 +01:00
|
|
|
set(FFMPEG_DLL
|
2023-01-15 17:39:01 +01:00
|
|
|
${VGM_SOURCE_DIR}/ext_libs/avcodec-vgmstream-59.dll
|
|
|
|
${VGM_SOURCE_DIR}/ext_libs/avformat-vgmstream-59.dll
|
|
|
|
${VGM_SOURCE_DIR}/ext_libs/avutil-vgmstream-57.dll
|
|
|
|
${VGM_SOURCE_DIR}/ext_libs/swresample-vgmstream-4.dll)
|
2020-01-11 17:34:51 +01:00
|
|
|
set(ATRAC9_DLL ${VGM_SOURCE_DIR}/ext_libs/libatrac9.dll)
|
2019-03-20 03:00:48 +01:00
|
|
|
set(CELT_DLL
|
2020-01-11 17:34:51 +01:00
|
|
|
${VGM_SOURCE_DIR}/ext_libs/libcelt-0061.dll
|
|
|
|
${VGM_SOURCE_DIR}/ext_libs/libcelt-0110.dll)
|
2023-01-15 19:13:33 +01:00
|
|
|
set(SPEEX_DLL ${VGM_SOURCE_DIR}/ext_libs/libspeex-1.dll)
|
2019-03-20 03:00:48 +01:00
|
|
|
|
|
|
|
# List of DLLs to check for install
|
|
|
|
set(DLLS
|
|
|
|
MPEG
|
|
|
|
VORBIS
|
|
|
|
G7221
|
|
|
|
G719
|
|
|
|
FFMPEG
|
|
|
|
ATRAC9
|
2021-01-23 16:44:16 +01:00
|
|
|
CELT
|
|
|
|
SPEEX)
|
2019-03-20 03:00:48 +01:00
|
|
|
|
|
|
|
# Loop over DLLs and only install if the USE_* is set for that DLL
|
|
|
|
foreach(DLL ${DLLS})
|
|
|
|
if(${USE_${DLL}})
|
|
|
|
install(FILES ${${DLL}_DLL}
|
|
|
|
DESTINATION ${INSTALL_PREFIX})
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
endmacro()
|