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

build: de-vendor xxHash dependency #2258

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ src/net/pcap/** linguist-vendored
src/sha1/** linguist-vendored
src/teakra/** linguist-vendored
src/tiny-AES-c/** linguist-vendored
src/xxhash/** linguist-vendored

# A handful of custom files embedded in the vendored dependencies

Expand Down
6 changes: 3 additions & 3 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
## Linux
1. Install dependencies:
* Ubuntu:
* All versions: `sudo apt install cmake extra-cmake-modules libcurl4-gnutls-dev libpcap0.8-dev libsdl2-dev libarchive-dev libenet-dev libzstd-dev`
* All versions: `sudo apt install cmake extra-cmake-modules libcurl4-gnutls-dev libpcap0.8-dev libsdl2-dev libarchive-dev libenet-dev libxxhash-dev libzstd-dev`
* 24.04: `sudo apt install qt6-{base,base-private,multimedia,svg}-dev`
* 22.04: `sudo apt install qtbase6-dev qtbase6-private-dev qtmultimedia6-dev libqt6svg6-dev`
* Older versions: `sudo apt install qtbase5-dev qtbase5-private-dev qtmultimedia5-dev libqt5svg5-dev`
Also add `-DUSE_QT6=OFF` to the first CMake command below.
* Fedora: `sudo dnf install gcc-c++ cmake extra-cmake-modules SDL2-devel libarchive-devel enet-devel libzstd-devel qt6-{qtbase,qtbase-private,qtmultimedia,qtsvg}-devel wayland-devel`
* Arch Linux: `sudo pacman -S base-devel cmake extra-cmake-modules git libpcap sdl2 qt6-{base,multimedia,svg} libarchive enet zstd`
* Fedora: `sudo dnf install gcc-c++ cmake extra-cmake-modules SDL2-devel libarchive-devel enet-devel libzstd-devel qt6-{qtbase,qtbase-private,qtmultimedia,qtsvg}-devel wayland-devel xxhash-devel`
* Arch Linux: `sudo pacman -S base-devel cmake extra-cmake-modules git libpcap sdl2 qt6-{base,multimedia,svg} libarchive enet xxhash zstd`
2. Download the melonDS repository and prepare:
```bash
git clone https://github.com/melonDS-emu/melonDS
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ endif()

option(BUILD_QT_SDL "Build Qt/SDL frontend" ON)

find_package(xxHash MODULE REQUIRED)

add_subdirectory(src)

if (BUILD_QT_SDL)
Expand Down
15 changes: 15 additions & 0 deletions cmake/FindxxHash.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# SPDX-FileCopyrightText: 2025 Andrea Pappacoda <[email protected]>
# SPDX-License-Identifier: GPL-2.0-or-later

find_package(PkgConfig QUIET)
pkg_search_module(XXHASH QUIET IMPORTED_TARGET libxxhash)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(xxHash
REQUIRED_VARS XXHASH_LINK_LIBRARIES
VERSION_VAR XXHASH_VERSION
)

if (xxHash_FOUND AND NOT TARGET xxHash::xxhash)
add_library(xxHash::xxhash ALIAS PkgConfig::XXHASH)
endif()
3 changes: 1 addition & 2 deletions src/ARMJIT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
#include <assert.h>
#include <unordered_map>

#define XXH_STATIC_LINKING_ONLY
#include "xxhash/xxhash.h"
#include <xxhash.h>

#include "Platform.h"

Expand Down
5 changes: 3 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ add_library(core STATIC
fatfs/ffconf.h

sha1/sha1.c
tiny-AES-c/aes.c
xxhash/xxhash.c)
tiny-AES-c/aes.c)

target_link_libraries(core PRIVATE xxHash::xxhash)

if (ENABLE_GDBSTUB)
message(NOTICE "Enabling GDB stub")
Expand Down
3 changes: 1 addition & 2 deletions src/GPU3D_Texcache.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
#include <unordered_map>
#include <vector>

#define XXH_STATIC_LINKING_ONLY
#include "xxhash/xxhash.h"
#include <xxhash.h>

namespace melonDS
{
Expand Down
3 changes: 1 addition & 2 deletions src/OpenGLSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@

#include <assert.h>

#define XXH_STATIC_LINKING_ONLY
#include "xxhash/xxhash.h"
#include <xxhash.h>

namespace melonDS
{
Expand Down
Loading