Skip to content

Commit

Permalink
build(sdl2): use SDL2 vars in cmake
Browse files Browse the repository at this point in the history
In Ubuntu Jammy (22.04LTS) and some other Linux OS, FindSDL2_mixer cmake
is not provided. However, the pkg-config file is present.

Ref fofix#21
  • Loading branch information
Linkid committed Dec 31, 2022
1 parent 8cf0af1 commit d080177
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ if (WIN32 AND USE_WIN_DEP)
# gthread
find_path(GTHREAD2_INCLUDE_DIRS NAMES glib/gthread.h PATHS "${DEPENDENCY_FOLDER}/include/glib-2.0")
find_library(GTHREAD2_LINK_LIBRARIES NAMES gthread-2.0 PATHS "${DEPENDENCY_FOLDER}/lib")
# sdl_mixer
find_package(FindSDL_mixer)
# sdl2_mixer
find_package(FindSDL2_mixer)
# soundtouch
find_path(SOUNDTOUCH_INCLUDE_DIRS NAMES SoundTouch.h SoundTouchDLL.h PATHS "${DEPENDENCY_FOLDER}/include/soundtouch")
find_library(SOUNDTOUCH_LINK_LIBRARIES NAMES libsoundtouch soundtouch soundtouchdll_x64 soundtouchdll_x86 soundtouchdll soundtouch-c PATHS "${DEPENDENCY_FOLDER}/lib")
Expand All @@ -54,7 +54,8 @@ else()
pkg_search_module(GTHREAD2 REQUIRED gthread-2.0 IMPORTED_TARGET)
pkg_search_module(SOUNDTOUCH REQUIRED soundtouch soundtouch-1.0 soundtouch-1.4 IMPORTED_TARGET)
pkg_search_module(VORBISFILE REQUIRED vorbisfile IMPORTED_TARGET)
find_package(SDL_mixer REQUIRED)
pkg_search_module(SDL2_MIXER REQUIRED SDL2_mixer IMPORTED_TARGET)
#find_package(SDL_mixer REQUIRED)
endif()


Expand Down
6 changes: 3 additions & 3 deletions mixstream/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ target_include_directories(_MixStream
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${GLIB2_INCLUDE_DIRS}
PRIVATE ${GTHREAD2_INCLUDE_DIRS} # for osx
PRIVATE ${SDL_MIXER_INCLUDE_DIRS}
PRIVATE ${SDL2_MIXER_INCLUDE_DIRS}
PRIVATE ${SOUNDTOUCH_INCLUDE_DIRS}
PRIVATE ${VORBISFILE_INCLUDE_DIRS} # for osx
)
target_link_libraries(_MixStream
${GLIB2_LINK_LIBRARIES}
${GTHREAD2_LINK_LIBRARIES} # for osx
${SDL_MIXER_LIBRARIES}
${SDL2_MIXER_LIBRARIES}
${SOUNDTOUCH_LINK_LIBRARIES}
${VORBISFILE_LINK_LIBRARIES}
)
Expand All @@ -37,7 +37,7 @@ if (WIN32)
list(APPEND DEPENDENCIES_DLL ${DEPENDENCY_FOLDER}/bin/SoundTouchDll_x64.dll)
list(APPEND DEPENDENCIES_DLL ${DEPENDENCY_FOLDER}/bin/SoundTouchDll_x84.dll)
list(APPEND DEPENDENCIES_DLL ${DEPENDENCY_FOLDER}/bin/libSoundTouch-0.dll)
list(APPEND DEPENDENCIES_DLL ${DEPENDENCY_FOLDER}/bin/SDL_mixer.dll)
list(APPEND DEPENDENCIES_DLL ${DEPENDENCY_FOLDER}/bin/SDL2_mixer.dll)
foreach(DEP IN LISTS ${DEPENDENCIES_DLL})
if (EXISTS ${DEP})
install(FILES ${DEP}
Expand Down

0 comments on commit d080177

Please sign in to comment.