Skip to content

Commit

Permalink
Fix compressed format support on GME when using miniz
Browse files Browse the repository at this point in the history
  • Loading branch information
Cacodemon345 authored and coelckers committed Sep 24, 2023
1 parent 33de9d9 commit 26c8890
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
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

0 comments on commit 26c8890

Please sign in to comment.