2019-02-16 23:42:47 +01:00
|
|
|
cmake_minimum_required(VERSION 3.1)
|
2017-04-10 11:00:52 +02:00
|
|
|
project(SDL2_MIXER C)
|
|
|
|
|
|
|
|
find_path(SDL_INCLUDE_DIR SDL.h PATH_SUFFIXES SDL2)
|
2019-05-01 16:36:57 -04:00
|
|
|
find_package(SDL2 CONFIG REQUIRED)
|
2017-04-10 11:00:52 +02:00
|
|
|
set(SDL_MIXER_INCLUDES ${SDL_INCLUDE_DIR})
|
2019-05-01 16:36:57 -04:00
|
|
|
|
|
|
|
set(SDL_MIXER_LIBRARIES SDL2::SDL2)
|
2017-04-10 11:00:52 +02:00
|
|
|
|
|
|
|
# builtin formats
|
2019-02-16 23:42:47 +01:00
|
|
|
set(SDL_MIXER_DEFINES MUSIC_WAV)
|
2017-04-10 11:00:52 +02:00
|
|
|
|
2019-09-24 04:49:38 +08:00
|
|
|
# MP3 support
|
|
|
|
if(SDL_MIXER_ENABLE_MP3)
|
2021-12-07 12:35:19 +08:00
|
|
|
find_package(mpg123 CONFIG REQUIRED)
|
|
|
|
set(MPG123_LIBRARY MPG123::libmpg123)
|
2019-09-24 04:49:38 +08:00
|
|
|
list(APPEND SDL_MIXER_DEFINES MUSIC_MP3_MPG123)
|
2021-03-19 04:17:59 +08:00
|
|
|
list(APPEND SDL_MIXER_LIBRARIES ${MPG123_LIBRARY})
|
2020-01-28 06:21:09 +08:00
|
|
|
if (SDL_DYNAMIC_LOAD)
|
|
|
|
get_filename_component(MPG123_LIBRARY_NAME "${MPG123_LIBRARY}" NAME_WE)
|
|
|
|
list(APPEND SDL_MIXER_LOAD_DEFINES -DMPG123_DYNAMIC="${MPG123_LIBRARY_NAME}${LIBRARY_SUFFIX}")
|
|
|
|
endif()
|
2019-09-24 04:49:38 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# FLAC support
|
|
|
|
if(SDL_MIXER_ENABLE_FLAC)
|
2021-12-07 12:35:19 +08:00
|
|
|
find_package(flac CONFIG REQUIRED)
|
|
|
|
set(FLAC_LIBRARY FLAC::FLAC)
|
2019-09-24 04:49:38 +08:00
|
|
|
list(APPEND SDL_MIXER_DEFINES MUSIC_FLAC)
|
2021-03-19 04:17:59 +08:00
|
|
|
list(APPEND SDL_MIXER_LIBRARIES ${FLAC_LIBRARY})
|
2020-01-28 06:21:09 +08:00
|
|
|
if (SDL_DYNAMIC_LOAD)
|
|
|
|
get_filename_component(FLAC_LIBRARY_NAME "${FLAC_LIBRARY}" NAME_WE)
|
|
|
|
list(APPEND SDL_MIXER_LOAD_DEFINES -DFLAC_DYNAMIC="${FLAC_LIBRARY_NAME}${LIBRARY_SUFFIX}")
|
|
|
|
endif()
|
2019-09-24 04:49:38 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# MOD support
|
|
|
|
if(SDL_MIXER_ENABLE_MOD)
|
|
|
|
find_path(MODPLUG_INCLUDE_DIR libmodplug/modplug.h)
|
2019-09-25 23:27:32 +08:00
|
|
|
find_library(MODPLUG_LIBRARY modplug)
|
2019-09-24 04:49:38 +08:00
|
|
|
list(APPEND SDL_MIXER_INCLUDES ${MODPLUG_INCLUDE_DIR})
|
|
|
|
list(APPEND SDL_MIXER_DEFINES MUSIC_MOD_MODPLUG)
|
2021-03-19 04:17:59 +08:00
|
|
|
list(APPEND SDL_MIXER_LIBRARIES ${MODPLUG_LIBRARY})
|
2020-01-28 06:21:09 +08:00
|
|
|
if (SDL_DYNAMIC_LOAD)
|
|
|
|
get_filename_component(MODPLUG_LIBRARY_NAME "${MODPLUG_LIBRARY}" NAME_WE)
|
|
|
|
list(APPEND SDL_MIXER_LOAD_DEFINES -DMODPLUG_DYNAMIC="${MODPLUG_LIBRARY_NAME}${LIBRARY_SUFFIX}")
|
|
|
|
endif()
|
2019-09-24 04:49:38 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Ogg-Vorbis support
|
|
|
|
if(SDL_MIXER_ENABLE_OGGVORBIS)
|
|
|
|
find_path(VORBIS_INCLUDE_DIR vorbis/codec.h)
|
2019-09-25 23:27:32 +08:00
|
|
|
find_library(VORBISFILE_LIBRARY vorbisfile)
|
2019-09-24 04:49:38 +08:00
|
|
|
list(APPEND SDL_MIXER_INCLUDES ${VORBIS_INCLUDE_DIR})
|
|
|
|
list(APPEND SDL_MIXER_DEFINES MUSIC_OGG)
|
2021-09-14 11:25:53 +08:00
|
|
|
list(APPEND SDL_MIXER_LIBRARIES ${VORBISFILE_LIBRARY})
|
2020-01-28 06:21:09 +08:00
|
|
|
if (SDL_DYNAMIC_LOAD)
|
|
|
|
get_filename_component(VORBISFILE_LIBRARY_NAME "${VORBISFILE_LIBRARY}" NAME_WE)
|
|
|
|
list(APPEND SDL_MIXER_LOAD_DEFINES -DOGG_DYNAMIC="${VORBISFILE_LIBRARY_NAME}${LIBRARY_SUFFIX}")
|
|
|
|
endif()
|
2019-09-24 04:49:38 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Opus support
|
|
|
|
if(SDL_MIXER_ENABLE_OPUS)
|
|
|
|
find_path(OPUS_INCLUDE_DIR opus/opusfile.h)
|
2019-09-25 23:27:32 +08:00
|
|
|
find_library(OPUSFILE_LIBRARY opusfile)
|
2019-09-24 04:49:38 +08:00
|
|
|
list(APPEND SDL_MIXER_INCLUDES ${OPUS_INCLUDE_DIR})
|
|
|
|
list(APPEND SDL_MIXER_DEFINES MUSIC_OPUS)
|
2021-03-19 04:17:59 +08:00
|
|
|
list(APPEND SDL_MIXER_LIBRARIES ${OPUSFILE_LIBRARY})
|
2020-01-28 06:21:09 +08:00
|
|
|
if (SDL_DYNAMIC_LOAD)
|
|
|
|
get_filename_component(OPUSFILE_LIBRARY_NAME "${OPUSFILE_LIBRARY}" NAME_WE)
|
|
|
|
list(APPEND SDL_MIXER_LOAD_DEFINES -DOPUS_DYNAMIC="${OPUSFILE_LIBRARY_NAME}${LIBRARY_SUFFIX}")
|
|
|
|
endif()
|
2019-09-24 04:49:38 +08:00
|
|
|
endif()
|
|
|
|
|
2021-07-06 16:38:46 -04:00
|
|
|
# Fluidsynth support
|
|
|
|
if(SDL_MIXER_ENABLE_FLUIDSYNTH)
|
|
|
|
find_path(FLUIDSYNTH_INCLUDE_DIR fluidsynth.h)
|
|
|
|
find_library(FLUIDSYNTH_LIBRARY fluidsynth)
|
|
|
|
list(APPEND SDL_MIXER_INCLUDES ${FLUIDSYNTH_INCLUDE_DIR})
|
|
|
|
list(APPEND SDL_MIXER_DEFINES MUSIC_MID_FLUIDSYNTH)
|
2021-09-14 11:25:53 +08:00
|
|
|
list(APPEND SDL_MIXER_LIBRARIES ${FLUIDSYNTH_LIBRARY})
|
2021-07-06 16:38:46 -04:00
|
|
|
if (SDL_DYNAMIC_LOAD)
|
|
|
|
get_filename_component(FLUIDSYNTH_LIBRARY_NAME "${FLUIDSYNTH_LIBRARY}" NAME_WE)
|
|
|
|
list(APPEND SDL_MIXER_LOAD_DEFINES -DFLUIDSYNTH_DYNAMIC="${FLUIDSYNTH_LIBRARY_NAME}${LIBRARY_SUFFIX}")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2018-05-18 23:15:52 +08:00
|
|
|
add_library(SDL2_mixer
|
2017-04-10 11:00:52 +02:00
|
|
|
effect_position.c
|
|
|
|
effect_stereoreverse.c
|
|
|
|
effects_internal.c
|
|
|
|
load_aiff.c
|
|
|
|
load_voc.c
|
|
|
|
mixer.c
|
|
|
|
music.c
|
|
|
|
music_cmd.c
|
|
|
|
music_flac.c
|
2017-11-13 21:55:33 -05:00
|
|
|
music_fluidsynth.c
|
2017-04-10 11:00:52 +02:00
|
|
|
music_mad.c
|
2017-11-13 21:55:33 -05:00
|
|
|
music_mikmod.c
|
2017-04-10 11:00:52 +02:00
|
|
|
music_modplug.c
|
2017-11-13 21:55:33 -05:00
|
|
|
music_mpg123.c
|
2017-04-10 11:00:52 +02:00
|
|
|
music_ogg.c
|
2019-03-11 20:15:08 +00:00
|
|
|
music_opus.c
|
2017-11-13 21:55:33 -05:00
|
|
|
music_timidity.c
|
|
|
|
music_wav.c
|
2018-01-09 23:44:37 +03:00
|
|
|
version.rc)
|
2017-04-10 11:00:52 +02:00
|
|
|
|
2020-07-31 14:23:27 -04:00
|
|
|
if((WIN32 OR APPLE) AND SDL_MIXER_ENABLE_NATIVEMIDI)
|
2019-02-16 23:42:47 +01:00
|
|
|
list(APPEND SDL_MIXER_DEFINES MUSIC_MID_NATIVE)
|
2020-02-29 05:42:47 +00:00
|
|
|
target_sources(SDL2_mixer PRIVATE music_nativemidi.c native_midi/native_midi_common.c)
|
|
|
|
target_link_libraries(SDL2_mixer ${SDL_MIXER_LIBRARIES})
|
|
|
|
if(WIN32)
|
|
|
|
target_sources(SDL2_mixer PRIVATE native_midi/native_midi_win32.c)
|
|
|
|
target_link_libraries(SDL2_mixer Winmm)
|
|
|
|
elseif(APPLE)
|
|
|
|
target_sources(SDL2_mixer PRIVATE native_midi/native_midi_macosx.c)
|
|
|
|
endif()
|
2019-02-16 23:42:47 +01:00
|
|
|
endif()
|
|
|
|
|
2021-01-05 21:33:13 +01:00
|
|
|
set_target_properties(SDL2_mixer PROPERTIES DEFINE_SYMBOL DLL_EXPORT)
|
2019-09-25 23:27:32 +08:00
|
|
|
target_compile_definitions(SDL2_mixer PRIVATE ${SDL_MIXER_DEFINES} ${SDL_MIXER_LOAD_DEFINES})
|
2017-04-10 11:00:52 +02:00
|
|
|
target_include_directories(SDL2_mixer PRIVATE ${SDL_MIXER_INCLUDES} ./native_midi)
|
|
|
|
|
|
|
|
install(TARGETS SDL2_mixer
|
2019-03-26 17:57:16 +01:00
|
|
|
EXPORT SDL2_mixer
|
2017-04-10 11:00:52 +02:00
|
|
|
RUNTIME DESTINATION bin
|
|
|
|
ARCHIVE DESTINATION lib
|
|
|
|
LIBRARY DESTINATION lib)
|
|
|
|
|
2019-03-26 17:57:16 +01:00
|
|
|
install(EXPORT SDL2_mixer
|
|
|
|
DESTINATION share/sdl2-mixer/
|
|
|
|
FILE sdl2-mixer-config.cmake
|
|
|
|
NAMESPACE SDL2::
|
|
|
|
)
|
|
|
|
|
2021-12-01 00:29:54 +01:00
|
|
|
set(prefix "")
|
|
|
|
set(exec_prefix [[${prefix}]])
|
|
|
|
set(libdir [[${prefix}/lib]])
|
|
|
|
set(includedir [[${prefix}/include]])
|
|
|
|
set(PACKAGE "SDL2_mixer")
|
|
|
|
file(READ "SDL_mixer.h" header_contents)
|
|
|
|
# #define SDL_MIXER_MAJOR_VERSION 2
|
|
|
|
# #define SDL_MIXER_MINOR_VERSION 0
|
|
|
|
# #define SDL_MIXER_PATCHLEVEL 5
|
|
|
|
string(REGEX MATCH "define *SDL_MIXER_MAJOR_VERSION *([0-9]+)" _ "${header_contents}")
|
|
|
|
set(VERSION ${CMAKE_MATCH_1})
|
|
|
|
string(REGEX MATCH "define *SDL_MIXER_MINOR_VERSION *([0-9]+)" _ "${header_contents}")
|
|
|
|
string(APPEND VERSION ".${CMAKE_MATCH_1}")
|
|
|
|
string(REGEX MATCH "define *SDL_MIXER_PATCHLEVEL *([0-9]+)" _ "${header_contents}")
|
|
|
|
string(APPEND VERSION ".${CMAKE_MATCH_1}")
|
|
|
|
set(SDL_VERSION 0.0)
|
|
|
|
configure_file(SDL2_mixer.pc.in "${CMAKE_CURRENT_BINARY_DIR}/SDL2_mixer.pc" @ONLY)
|
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/SDL2_mixer.pc DESTINATION lib/pkgconfig)
|
|
|
|
|
2017-04-10 11:00:52 +02:00
|
|
|
if(NOT SDL_MIXER_SKIP_HEADERS)
|
|
|
|
install(FILES SDL_mixer.h DESTINATION include/SDL2)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
message(STATUS "Link-time dependencies:")
|
|
|
|
foreach(LIBRARY ${SDL_MIXER_LIBRARIES})
|
|
|
|
message(STATUS " " ${LIBRARY})
|
|
|
|
endforeach()
|