Support loading Zstandard-compressed ROMs

This is different from the archive support in that the compressed ROMs
are standalone files, rather than archives, making it possible to use
them exactly as if they were regular ROMs, while saving a bunch of space
on disk. This is supported both for DS and GBA ROMs, though given GBA
ROMs' generally small size it's mostly useful for the former.
This commit is contained in:
Nadia Holmquist Pedersen
2023-04-15 21:51:34 +02:00
parent 3ada5b9bc8
commit e7d2edd203
4 changed files with 133 additions and 15 deletions

View File

@ -83,6 +83,9 @@ pkg_check_modules(SDL2 REQUIRED IMPORTED_TARGET sdl2)
pkg_check_modules(Slirp REQUIRED IMPORTED_TARGET slirp)
pkg_check_modules(LibArchive REQUIRED IMPORTED_TARGET libarchive)
find_package(zstd CONFIG)
cmake_dependent_option(ENABLE_ZSTD "Enable support for Zstandard-compressed ROMs" ON "zstd_FOUND" OFF)
fix_interface_includes(PkgConfig::SDL2 PkgConfig::Slirp PkgConfig::LibArchive)
add_compile_definitions(ARCHIVE_SUPPORT_ENABLED)
@ -157,6 +160,15 @@ target_link_libraries(melonDS PRIVATE core)
target_link_libraries(melonDS PRIVATE PkgConfig::SDL2 PkgConfig::Slirp PkgConfig::LibArchive)
target_link_libraries(melonDS PRIVATE ${QT_LINK_LIBS} ${CMAKE_DL_LIBS})
if (ENABLE_ZSTD)
target_compile_definitions(melonDS PRIVATE ZSTD_ENABLED)
if (BUILD_STATIC)
target_link_libraries(melonDS PRIVATE zstd::libzstd_static)
else()
target_link_libraries(melonDS PRIVATE zstd::libzstd_shared)
endif()
endif()
if (UNIX)
option(PORTABLE "Make a portable build that looks for its configuration in the current directory" OFF)
elseif (WIN32)