diff --git a/aedi/target/library_tier2.py b/aedi/target/library_tier2.py index a98fbe20..ceec8197 100644 --- a/aedi/target/library_tier2.py +++ b/aedi/target/library_tier2.py @@ -287,7 +287,11 @@ class Sdl2MixerTarget(base.CMakeStaticDependencyTarget): base_url = 'https://github.com/libsdl-org/SDL_mixer/releases/download' state.download_source( f'{base_url}/release-{self.version}/SDL2_mixer-{self.version}.tar.gz', - '7a6ba86a478648ce617e3a5e9277181bc67f7ce9876605eea6affd4a0d6eea8f') + '7a6ba86a478648ce617e3a5e9277181bc67f7ce9876605eea6affd4a0d6eea8f', + patches='sdl2_mixer-fix-opusfile') + + os.unlink(state.source / 'cmake/Findopusfile.cmake') + shutil.copy2(state.patch_path / 'FindOpusFile.cmake', state.source / 'cmake/FindOpusFile.cmake') def configure(self, state: BuildState): opts = state.options diff --git a/deps/sdl2_mixer/lib/cmake/SDL2_mixer/Findopusfile.cmake b/deps/sdl2_mixer/lib/cmake/SDL2_mixer/Findopusfile.cmake index 40648d3b..835390d4 100644 --- a/deps/sdl2_mixer/lib/cmake/SDL2_mixer/Findopusfile.cmake +++ b/deps/sdl2_mixer/lib/cmake/SDL2_mixer/Findopusfile.cmake @@ -1,37 +1,37 @@ include(FindPackageHandleStandardArgs) -find_library(opusfile_LIBRARY +find_library(OpusFile_LIBRARY NAMES opusfile ) -set(opusfile_COMPILE_OPTIONS "" CACHE STRING "Extra compile options of opusfile") +set(OpusFile_COMPILE_OPTIONS "" CACHE STRING "Extra compile options of opusfile") -set(opusfile_LINK_LIBRARIES "" CACHE STRING "Extra link libraries of opusfile") +set(OpusFile_LINK_LIBRARIES "" CACHE STRING "Extra link libraries of opusfile") -set(opusfile_LINK_FLAGS "" CACHE STRING "Extra link flags of opusfile") +set(OpusFile_LINK_FLAGS "" CACHE STRING "Extra link flags of opusfile") -find_path(opusfile_INCLUDE_PATH +find_path(OpusFile_INCLUDE_PATH NAMES opusfile.h PATH_SUFFIXES opus ) -find_package_handle_standard_args(opusfile - REQUIRED_VARS opusfile_LIBRARY opusfile_INCLUDE_PATH +find_package_handle_standard_args(OpusFile + REQUIRED_VARS OpusFile_LIBRARY OpusFile_INCLUDE_PATH ) -if (opusfile_FOUND) - set(opusfile_dirs ${opusfile_INCLUDE_PATH}) - if(EXISTS "${opusfile_INCLUDE_PATH}/opus") - list(APPEND opusfile_dirs "${opusfile_INCLUDE_PATH}/opus") +if (OpusFile_FOUND) + set(OpusFile_dirs ${OpusFile_INCLUDE_PATH}) + if(EXISTS "${OpusFile_INCLUDE_PATH}/opus") + list(APPEND OpusFile_dirs "${OpusFile_INCLUDE_PATH}/opus") endif() - if (NOT TARGET opusfile::opusfile) - add_library(opusfile::opusfile UNKNOWN IMPORTED) - set_target_properties(opusfile::opusfile PROPERTIES - IMPORTED_LOCATION "${opusfile_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${opusfile_dirs}" - INTERFACE_COMPILE_OPTIONS "${opusfile_COMPILE_OPTIONS}" - INTERFACE_LINK_LIBRARIES "${opusfile_LINK_LIBRARIES}" - INTERFACE_LINK_FLAGS "${opusfile_LINK_FLAGS}" + if (NOT TARGET OpusFile::opusfile) + add_library(OpusFile::opusfile UNKNOWN IMPORTED) + set_target_properties(OpusFile::opusfile PROPERTIES + IMPORTED_LOCATION "${OpusFile_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${OpusFile_dirs}" + INTERFACE_COMPILE_OPTIONS "${OpusFile_COMPILE_OPTIONS}" + INTERFACE_LINK_LIBRARIES "${OpusFile_LINK_LIBRARIES}" + INTERFACE_LINK_FLAGS "${OpusFile_LINK_FLAGS}" ) endif() endif() diff --git a/deps/sdl2_mixer/lib/cmake/SDL2_mixer/SDL2_mixer-static-targets.cmake b/deps/sdl2_mixer/lib/cmake/SDL2_mixer/SDL2_mixer-static-targets.cmake index 64fd3ba0..7da5c279 100644 --- a/deps/sdl2_mixer/lib/cmake/SDL2_mixer/SDL2_mixer-static-targets.cmake +++ b/deps/sdl2_mixer/lib/cmake/SDL2_mixer/SDL2_mixer-static-targets.cmake @@ -60,7 +60,7 @@ add_library(SDL2_mixer::SDL2_mixer-static STATIC IMPORTED) set_target_properties(SDL2_mixer::SDL2_mixer-static PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include/SDL2" - INTERFACE_LINK_LIBRARIES "\$;\$;\$;\$;\$;\$;\$;\$" + INTERFACE_LINK_LIBRARIES "\$;\$;\$;\$;\$;\$;\$;\$" ) if(CMAKE_VERSION VERSION_LESS 2.8.12) diff --git a/deps/sdl2_mixer/lib/cmake/SDL2_mixer/SDL2_mixerConfig.cmake b/deps/sdl2_mixer/lib/cmake/SDL2_mixer/SDL2_mixerConfig.cmake index d0d7ad49..ee49d8d3 100644 --- a/deps/sdl2_mixer/lib/cmake/SDL2_mixer/SDL2_mixerConfig.cmake +++ b/deps/sdl2_mixer/lib/cmake/SDL2_mixer/SDL2_mixerConfig.cmake @@ -85,6 +85,10 @@ include(CMakeFindDependencyMacro) find_dependency(vorbisfile) endif() + if(SDL2MIXER_OPUS AND NOT SDL2MIXER_VENDORED AND NOT TARGET opusfile::opusfile) + find_dependency(OpusFile) + endif() + if((NOT SDL2MIXER_VENDORED AND SDL2MIXER_MOD_MODPLUG) OR (HAIKU AND SDL2MIXER_MIDI_NATIVE)) include(CheckLanguage) check_language(CXX) diff --git a/patch/FindOpusFile.cmake b/patch/FindOpusFile.cmake new file mode 100644 index 00000000..835390d4 --- /dev/null +++ b/patch/FindOpusFile.cmake @@ -0,0 +1,37 @@ +include(FindPackageHandleStandardArgs) + +find_library(OpusFile_LIBRARY + NAMES opusfile +) + +set(OpusFile_COMPILE_OPTIONS "" CACHE STRING "Extra compile options of opusfile") + +set(OpusFile_LINK_LIBRARIES "" CACHE STRING "Extra link libraries of opusfile") + +set(OpusFile_LINK_FLAGS "" CACHE STRING "Extra link flags of opusfile") + +find_path(OpusFile_INCLUDE_PATH + NAMES opusfile.h + PATH_SUFFIXES opus +) + +find_package_handle_standard_args(OpusFile + REQUIRED_VARS OpusFile_LIBRARY OpusFile_INCLUDE_PATH +) + +if (OpusFile_FOUND) + set(OpusFile_dirs ${OpusFile_INCLUDE_PATH}) + if(EXISTS "${OpusFile_INCLUDE_PATH}/opus") + list(APPEND OpusFile_dirs "${OpusFile_INCLUDE_PATH}/opus") + endif() + if (NOT TARGET OpusFile::opusfile) + add_library(OpusFile::opusfile UNKNOWN IMPORTED) + set_target_properties(OpusFile::opusfile PROPERTIES + IMPORTED_LOCATION "${OpusFile_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${OpusFile_dirs}" + INTERFACE_COMPILE_OPTIONS "${OpusFile_COMPILE_OPTIONS}" + INTERFACE_LINK_LIBRARIES "${OpusFile_LINK_LIBRARIES}" + INTERFACE_LINK_FLAGS "${OpusFile_LINK_FLAGS}" + ) + endif() +endif() diff --git a/patch/sdl2_mixer-fix-opusfile.diff b/patch/sdl2_mixer-fix-opusfile.diff new file mode 100644 index 00000000..79231ef2 --- /dev/null +++ b/patch/sdl2_mixer-fix-opusfile.diff @@ -0,0 +1,68 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -369,8 +369,8 @@ + ) + target_include_directories(SDL2_mixer PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") + +- if(NOT TARGET opusfile::opusfile) +- add_library(opusfile::opusfile ALIAS opusfile) ++ if(NOT TARGET OpusFile::opusfile) ++ add_library(OpusFile::opusfile ALIAS opusfile) + endif() + if(SDL2MIXER_OPUS_SHARED OR NOT SDL2MIXER_BUILD_SHARED_LIBS) + list(APPEND INSTALL_EXTRA_TARGETS opus opusfile) +@@ -380,25 +380,25 @@ + endif() + else() + message(STATUS "Using system opusfile") +- find_package(opusfile REQUIRED) ++ find_package(OpusFile REQUIRED) + if(NOT SDL2MIXER_OPUS_SHARED) + list(APPEND PC_REQUIRES opusfile) + endif() + endif() + if(SDL2MIXER_OPUS_SHARED) + target_include_directories(SDL2_mixer PRIVATE +- $ +- $ +- $ ++ $ ++ $ ++ $ + ) +- target_get_dynamic_library(dynamic_opusfile opusfile::opusfile) ++ target_get_dynamic_library(dynamic_opusfile OpusFile::opusfile) + message(STATUS "Dynamic opus (opusfile): ${dynamic_opusfile}") + target_compile_definitions(SDL2_mixer PRIVATE "OPUS_DYNAMIC=\"${dynamic_opusfile}\"") + if(SDL2MIXER_VENDORED) +- add_dependencies(SDL2_mixer opusfile::opusfile) ++ add_dependencies(SDL2_mixer OpusFile::opusfile) + endif() + else() +- target_link_libraries(SDL2_mixer PRIVATE opusfile::opusfile) ++ target_link_libraries(SDL2_mixer PRIVATE OpusFile::opusfile) + endif() + endif() + +@@ -851,7 +851,7 @@ + cmake/Findlibxmp.cmake + cmake/Findlibxmp-lite.cmake + cmake/Findmodplug.cmake +- cmake/Findopusfile.cmake ++ cmake/FindOpusFile.cmake + cmake/FindMPG123.cmake + cmake/FindVorbis.cmake + cmake/Findtremor.cmake +--- a/SDL2_mixerConfig.cmake.in ++++ b/SDL2_mixerConfig.cmake.in +@@ -85,6 +85,10 @@ + find_dependency(vorbisfile) + endif() + ++ if(SDL2MIXER_OPUS AND NOT SDL2MIXER_VENDORED AND NOT TARGET opusfile::opusfile) ++ find_dependency(OpusFile) ++ endif() ++ + if((NOT SDL2MIXER_VENDORED AND SDL2MIXER_MOD_MODPLUG) OR (HAIKU AND SDL2MIXER_MIDI_NATIVE)) + include(CheckLanguage) + check_language(CXX)