minimp3's sliding-window frame confirmation could spuriously discard real frames near the tail of a not-yet-full window, losing ~5.5% of a real VBR file's content even at a tuned 256KB window (~0.3% residual) - audible as the whole track finishing early with stutters at each drop. libmad's mad_stream/mad_frame/mad_synth API reports "need more data" (MAD_ERROR_BUFLEN) and "genuinely bad data" separately rather than overloading one return value, which was the actual ambiguity minimp3 couldn't resolve. Verified against the same real file with a 32KB window (vs minimp3's 256KB): frame count and duration match the Xing header exactly. Confirmed building for Linux, GameCube, and Wii (the latter two via the project's real devkitPPC/libogc Docker toolchain) - libmad ships inside libogc itself on Dolphin, no separate fetch needed there. libmad is GPL-licensed, unlike the rest of this MIT project - a deliberate tradeoff, noted at each site that pulls it in. Co-Authored-By: Claude Sonnet 5 <[email protected]>
82 lines
2.9 KiB
CMake
82 lines
2.9 KiB
CMake
# Build type: DOL (SD/USB via libfat) or ISO (DVD disc via libogc DVD driver)
|
|
set(DUSK_DOLPHIN_BUILD_TYPE "DOL" CACHE STRING "Dolphin asset source: DOL (SD/USB) or ISO (DVD disc)")
|
|
set_property(CACHE DUSK_DOLPHIN_BUILD_TYPE PROPERTY STRINGS "DOL" "ISO")
|
|
|
|
# Numeric tokens so #if DUSK_DOLPHIN_BUILD_TYPE == DOL works in C.
|
|
# DUSK_DOLPHIN_BUILD_TYPE is passed without quotes so it expands to the identifier.
|
|
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
|
DUSK_DOLPHIN
|
|
DUSK_INPUT_GAMEPAD
|
|
# DUSK_DISPLAY_WIDTH=640
|
|
# DUSK_DISPLAY_HEIGHT=480
|
|
DUSK_DISPLAY_WIDTH=320
|
|
DUSK_DISPLAY_HEIGHT=240
|
|
DUSK_DISPLAY_OVERSCAN=16
|
|
DUSK_THREAD_PTHREAD
|
|
DOL=1
|
|
ISO=2
|
|
DUSK_DOLPHIN_BUILD_TYPE=${DUSK_DOLPHIN_BUILD_TYPE}
|
|
# GameCube/Wii PowerPC is always big-endian; declare it at compile time
|
|
# like every other target instead of relying on endian.h's runtime probe.
|
|
DUSK_PLATFORM_ENDIAN_BIG
|
|
)
|
|
|
|
# Custom compiler flags
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions")
|
|
|
|
# Disable all warnings
|
|
target_compile_options(${DUSK_LIBRARY_TARGET_NAME} PRIVATE -w)
|
|
|
|
# cglm: fetched at source level via Findcglm.cmake (FetchContent, headers only)
|
|
find_package(cglm REQUIRED)
|
|
|
|
# Pre-create ZLIB::ZLIB so any downstream cmake module that resolves it
|
|
# (FindZLIB, pkg-config IMPORTED_TARGET Requires processing) gets plain -lz
|
|
# rather than an unresolvable IMPORTED target that the PPC linker rejects.
|
|
if(NOT TARGET ZLIB::ZLIB)
|
|
add_library(ZLIB::ZLIB INTERFACE IMPORTED GLOBAL)
|
|
set_target_properties(ZLIB::ZLIB PROPERTIES INTERFACE_LINK_LIBRARIES "z")
|
|
endif()
|
|
|
|
# Mark libzip as found so src/dusk/CMakeLists.txt skips Findlibzip.cmake.
|
|
# Findlibzip.cmake calls find_package(ZLIB) which can recreate a broken
|
|
# ZLIB::ZLIB IMPORTED target, bypassing the shim above.
|
|
set(libzip_FOUND TRUE CACHE BOOL "libzip found (devkitpro portlibs)" FORCE)
|
|
|
|
# Locate zip.h in the devkitpro sysroot (respects CMAKE_FIND_ROOT_PATH).
|
|
find_path(_dusk_zip_inc NAMES zip.h)
|
|
if(_dusk_zip_inc)
|
|
target_include_directories(${DUSK_LIBRARY_TARGET_NAME} PRIVATE "${_dusk_zip_inc}")
|
|
endif()
|
|
|
|
# Link libraries.
|
|
# zip/z/lzma use target_link_options (raw flags) to bypass cmake target
|
|
# resolution - pkg-config-generated targets for these carry ZLIB::ZLIB in
|
|
# INTERFACE_LINK_LIBRARIES which breaks the PPC link step.
|
|
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PRIVATE
|
|
cglm
|
|
m
|
|
zip
|
|
bz2
|
|
zstd
|
|
z
|
|
lzma
|
|
ansnd
|
|
mad
|
|
)
|
|
|
|
if(DUSK_DOLPHIN_BUILD_TYPE STREQUAL "ISO")
|
|
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC DUSK_DOLPHIN_BUILD_ISO)
|
|
else()
|
|
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PRIVATE fat)
|
|
endif()
|
|
|
|
# Postbuild: ELF -> DOL
|
|
set(DUSK_BINARY_TARGET_NAME_DOL "${DUSK_BUILD_DIR}/Dusk.dol")
|
|
add_custom_command(TARGET ${DUSK_BINARY_TARGET_NAME} POST_BUILD
|
|
COMMAND elf2dol
|
|
"$<TARGET_FILE:${DUSK_BINARY_TARGET_NAME}>"
|
|
"${DUSK_BINARY_TARGET_NAME_DOL}"
|
|
COMMENT "Generating ${DUSK_BINARY_TARGET_NAME_DOL} from ${DUSK_BINARY_TARGET_NAME}"
|
|
)
|