[sdl2-mixer]Use dynamic library suffix when building dynamic library.

This commit is contained in:
JackBoosY 2019-10-08 01:52:25 -07:00
parent df09093358
commit df484b0e5a
2 changed files with 17 additions and 11 deletions

View File

@ -16,9 +16,8 @@ if(SDL_MIXER_ENABLE_MP3)
find_library(MPG123_LIBRARY NAMES libmpg123 mpg123)
list(APPEND SDL_MIXER_INCLUDES ${MPG123_INCLUDE_DIR})
list(APPEND SDL_MIXER_DEFINES MUSIC_MP3_MPG123)
get_filename_component(MPG123_LIBRARY_NAME "${MPG123_LIBRARY}" NAME)
message("MPG123_LIBRARY_NAME: ${MPG123_LIBRARY_NAME}")
list(APPEND SDL_MIXER_LOAD_DEFINES -DMPG123_DYNAMIC="${MPG123_LIBRARY_NAME}")
get_filename_component(MPG123_LIBRARY_NAME "${MPG123_LIBRARY}" NAME_WE)
list(APPEND SDL_MIXER_LOAD_DEFINES -DMPG123_DYNAMIC="${MPG123_LIBRARY_NAME}${LIBRARY_SUFFIX}")
endif()
# FLAC support
@ -27,8 +26,8 @@ if(SDL_MIXER_ENABLE_FLAC)
find_library(FLAC_LIBRARY FLAC)
list(APPEND SDL_MIXER_INCLUDES ${FLAC_INCLUDE_DIR})
list(APPEND SDL_MIXER_DEFINES MUSIC_FLAC)
get_filename_component(FLAC_LIBRARY_NAME "${FLAC_LIBRARY}" NAME)
list(APPEND SDL_MIXER_LOAD_DEFINES -DFLAC_DYNAMIC="${FLAC_LIBRARY_NAME}")
get_filename_component(FLAC_LIBRARY_NAME "${FLAC_LIBRARY}" NAME_WE)
list(APPEND SDL_MIXER_LOAD_DEFINES -DFLAC_DYNAMIC="${FLAC_LIBRARY_NAME}${LIBRARY_SUFFIX}")
endif()
# MOD support
@ -37,8 +36,8 @@ if(SDL_MIXER_ENABLE_MOD)
find_library(MODPLUG_LIBRARY modplug)
list(APPEND SDL_MIXER_INCLUDES ${MODPLUG_INCLUDE_DIR})
list(APPEND SDL_MIXER_DEFINES MUSIC_MOD_MODPLUG)
get_filename_component(MODPLUG_LIBRARY_NAME "${MODPLUG_LIBRARY}" NAME)
list(APPEND SDL_MIXER_LOAD_DEFINES -DMODPLUG_DYNAMIC="${MODPLUG_LIBRARY_NAME}")
get_filename_component(MODPLUG_LIBRARY_NAME "${MODPLUG_LIBRARY}" NAME_WE)
list(APPEND SDL_MIXER_LOAD_DEFINES -DMODPLUG_DYNAMIC="${MODPLUG_LIBRARY_NAME}${LIBRARY_SUFFIX}")
endif()
# Ogg-Vorbis support
@ -47,8 +46,8 @@ if(SDL_MIXER_ENABLE_OGGVORBIS)
find_library(VORBISFILE_LIBRARY vorbisfile)
list(APPEND SDL_MIXER_INCLUDES ${VORBIS_INCLUDE_DIR})
list(APPEND SDL_MIXER_DEFINES MUSIC_OGG)
get_filename_component(VORBISFILE_LIBRARY_NAME "${VORBISFILE_LIBRARY}" NAME)
list(APPEND SDL_MIXER_LOAD_DEFINES -DOGG_DYNAMIC="${VORBISFILE_LIBRARY_NAME}")
get_filename_component(VORBISFILE_LIBRARY_NAME "${VORBISFILE_LIBRARY}" NAME_WE)
list(APPEND SDL_MIXER_LOAD_DEFINES -DOGG_DYNAMIC="${VORBISFILE_LIBRARY_NAME}${LIBRARY_SUFFIX}")
endif()
# Opus support
@ -57,8 +56,8 @@ if(SDL_MIXER_ENABLE_OPUS)
find_library(OPUSFILE_LIBRARY opusfile)
list(APPEND SDL_MIXER_INCLUDES ${OPUS_INCLUDE_DIR})
list(APPEND SDL_MIXER_DEFINES MUSIC_OPUS)
get_filename_component(OPUSFILE_LIBRARY_NAME "${OPUSFILE_LIBRARY}" NAME)
list(APPEND SDL_MIXER_LOAD_DEFINES -DOPUS_DYNAMIC="${OPUSFILE_LIBRARY_NAME}")
get_filename_component(OPUSFILE_LIBRARY_NAME "${OPUSFILE_LIBRARY}" NAME_WE)
list(APPEND SDL_MIXER_LOAD_DEFINES -DOPUS_DYNAMIC="${OPUSFILE_LIBRARY_NAME}${LIBRARY_SUFFIX}")
endif()
add_library(SDL2_mixer

View File

@ -13,6 +13,12 @@ vcpkg_extract_source_archive_ex(
)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
set(LIBRARY_SUFFIX ${VCPKG_TARGET_SHARED_LIBRARY_SUFFIX})
else()
set(LIBRARY_SUFFIX ${VCPKG_TARGET_STATIC_LIBRARY_SUFFIX})
endif()
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
mpg123 SDL_MIXER_ENABLE_MP3
libflac SDL_MIXER_ENABLE_FLAC
@ -26,6 +32,7 @@ vcpkg_configure_cmake(
PREFER_NINJA
OPTIONS
${FEATURE_OPTIONS}
-DLIBRARY_SUFFIX=${LIBRARY_SUFFIX}
OPTIONS_DEBUG
-DSDL_MIXER_SKIP_HEADERS=ON
)