Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compressed format support on GME when using miniz #52

Merged
merged 1 commit into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion thirdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
add_subdirectory(miniz)
# GME is not currently released in a way that's conducive to using as a system
# library. Nevertheless at least one person tried, and so the ability to use a
# system copy exists soley to placate people following distro guidelines to the
Expand All @@ -19,7 +20,6 @@
add_subdirectory(game-music-emu)
#endif()

add_subdirectory(miniz)
add_subdirectory(dumb)
add_subdirectory(adlmidi)
add_subdirectory(opnmidi)
Expand Down
20 changes: 12 additions & 8 deletions thirdparty/game-music-emu/gme/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ if(NOT BUILD_SHARED_LIBS)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
endif()

find_package(ZLIB QUIET)
# [ZMusic] We use miniz now.
# find_package(ZLIB QUIET)

# Ay_Apu is very popular around here
if (USE_GME_AY OR USE_GME_KSS)
Expand Down Expand Up @@ -165,17 +166,20 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})
# Add library to be compiled.
add_library(gme OBJECT ${libgme_SRCS})

if(ZLIB_FOUND)
message(" ** ZLib library located, compressed file formats will be supported")
# Commented our since we use miniz
#if(ZLIB_FOUND)
# message(" ** ZLib library located, compressed file formats will be supported")
target_compile_definitions(gme PRIVATE -DHAVE_ZLIB_H)
target_link_libraries(gme PRIVATE miniz)

# [ZMusic] Switch to modern target for better transitive handling.
target_link_libraries(gme PRIVATE ZLIB::ZLIB)
# target_link_libraries(gme PRIVATE ZLIB::ZLIB)
# Is not to be installed though

set(PKG_CONFIG_ZLIB -lz) # evaluated in libgme.pc.in
else()
message("ZLib library not found, disabling support for compressed formats such as VGZ")
endif()
# set(PKG_CONFIG_ZLIB -lz) # evaluated in libgme.pc.in
#else()
# message("ZLib library not found, disabling support for compressed formats such as VGZ")
#endif()

# [ZMusic] Interface include directories
target_include_directories(gme INTERFACE ..)
Expand Down
3 changes: 2 additions & 1 deletion thirdparty/game-music-emu/gme/Data_Reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
#include "blargg_source.h"

#ifdef HAVE_ZLIB_H
#include <zlib.h>
// [ZMusic] Use miniz.
#include <miniz.h>
#include <stdlib.h>
#include <errno.h>
static const unsigned char gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */
Expand Down
3 changes: 2 additions & 1 deletion thirdparty/game-music-emu/gme/Data_Reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
#include "blargg_common.h"

#ifdef HAVE_ZLIB_H
#include <zlib.h>
// [ZMusic] Use miniz.
#include <miniz.h>
#endif

// Supports reading and finding out how many bytes are remaining
Expand Down