diff --git a/CMakeLists.txt b/CMakeLists.txt index 5592576e59..5f4667f151 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,7 @@ cmake_minimum_required(VERSION 3.31) project(yuzu) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/find") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externals/cmake-modules") set(CPM_SOURCE_CACHE ${CMAKE_SOURCE_DIR}/.cache/cpm) diff --git a/CMakeModules/WindowsCopyFiles.cmake b/CMakeModules/WindowsCopyFiles.cmake deleted file mode 100644 index a4afeb77bf..0000000000 --- a/CMakeModules/WindowsCopyFiles.cmake +++ /dev/null @@ -1,39 +0,0 @@ -# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project -# SPDX-License-Identifier: GPL-3.0-or-later - -# SPDX-FileCopyrightText: 2018 yuzu Emulator Project -# SPDX-License-Identifier: GPL-2.0-or-later - -# This file provides the function windows_copy_files. -# This is only valid on Windows. - -# Include guard -if(__windows_copy_files) - return() -endif() -set(__windows_copy_files YES) - -# Any number of files to copy from SOURCE_DIR to DEST_DIR can be specified after DEST_DIR. -# This copying happens post-build. -if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") - function(windows_copy_files TARGET SOURCE_DIR DEST_DIR) - # windows commandline expects the / to be \ so switch them - string(REPLACE "/" "\\\\" SOURCE_DIR ${SOURCE_DIR}) - string(REPLACE "/" "\\\\" DEST_DIR ${DEST_DIR}) - - # /NJH /NJS /NDL /NFL /NC /NS /NP - Silence any output - # cmake adds an extra check for command success which doesn't work too well with robocopy - # so trick it into thinking the command was successful with the || cmd /c "exit /b 0" - add_custom_command(TARGET ${TARGET} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E make_directory ${DEST_DIR} - COMMAND robocopy ${SOURCE_DIR} ${DEST_DIR} ${ARGN} /NJH /NJS /NDL /NFL /NC /NS /NP || cmd /c "exit /b 0" - ) - endfunction() -else() - function(windows_copy_files TARGET SOURCE_DIR DEST_DIR) - add_custom_command(TARGET ${TARGET} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E make_directory ${DEST_DIR} - COMMAND cp -ra ${SOURCE_DIR}/. ${DEST_DIR} - ) - endfunction() -endif() diff --git a/CMakeModules/aqt_config.ini b/CMakeModules/aqt_config.ini deleted file mode 100644 index c87caf4988..0000000000 --- a/CMakeModules/aqt_config.ini +++ /dev/null @@ -1,30 +0,0 @@ -# SPDX-FileCopyrightText: 2024 kleidis - -[aqt] -concurrency: 2 - -[mirrors] -trusted_mirrors: - https://download.qt.io -blacklist: - https://qt.mirror.constant.com - https://mirrors.ocf.berkeley.edu - https://mirrors.ustc.edu.cn - https://mirrors.tuna.tsinghua.edu.cn - https://mirrors.geekpie.club - https://mirrors-wan.geekpie.club - https://mirrors.sjtug.sjtu.edu.cn -fallbacks: - https://qtproject.mirror.liquidtelecom.com/ - https://mirrors.aliyun.com/qt/ - https://ftp.jaist.ac.jp/pub/qtproject/ - https://ftp.yz.yamagata-u.ac.jp/pub/qtproject/ - https://qt-mirror.dannhauer.de/ - https://ftp.fau.de/qtproject/ - https://mirror.netcologne.de/qtproject/ - https://mirrors.dotsrc.org/qtproject/ - https://www.nic.funet.fi/pub/mirrors/download.qt-project.org/ - https://master.qt.io/ - https://mirrors.ukfast.co.uk/sites/qt.io/ - https://ftp2.nluug.nl/languages/qt/ - https://ftp1.nluug.nl/languages/qt/ diff --git a/CMakeModules/FindDiscordRPC.cmake b/CMakeModules/find/FindDiscordRPC.cmake similarity index 93% rename from CMakeModules/FindDiscordRPC.cmake rename to CMakeModules/find/FindDiscordRPC.cmake index 5ae9f4f999..a498cb0f26 100644 --- a/CMakeModules/FindDiscordRPC.cmake +++ b/CMakeModules/find/FindDiscordRPC.cmake @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later # SPDX-FileCopyrightText: 2022 Alexandre Bouvier diff --git a/CMakeModules/FindFFmpeg.cmake b/CMakeModules/find/FindFFmpeg.cmake similarity index 98% rename from CMakeModules/FindFFmpeg.cmake rename to CMakeModules/find/FindFFmpeg.cmake index edd0e0a882..11dd08acd5 100644 --- a/CMakeModules/FindFFmpeg.cmake +++ b/CMakeModules/find/FindFFmpeg.cmake @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later # SPDX-FileCopyrightText: 2019 Citra Emulator Project diff --git a/CMakeModules/FindLLVM.cmake b/CMakeModules/find/FindLLVM.cmake similarity index 100% rename from CMakeModules/FindLLVM.cmake rename to CMakeModules/find/FindLLVM.cmake diff --git a/CMakeModules/FindOpus.cmake b/CMakeModules/find/FindOpus.cmake similarity index 89% rename from CMakeModules/FindOpus.cmake rename to CMakeModules/find/FindOpus.cmake index 5557cd1baf..a4247f06db 100644 --- a/CMakeModules/FindOpus.cmake +++ b/CMakeModules/find/FindOpus.cmake @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later # SPDX-FileCopyrightText: 2022 yuzu Emulator Project diff --git a/CMakeModules/FindRenderDoc.cmake b/CMakeModules/find/FindRenderDoc.cmake similarity index 83% rename from CMakeModules/FindRenderDoc.cmake rename to CMakeModules/find/FindRenderDoc.cmake index 2678b936bc..8ac4271a36 100644 --- a/CMakeModules/FindRenderDoc.cmake +++ b/CMakeModules/find/FindRenderDoc.cmake @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +# SPDX-License-Identifier: GPL-3.0-or-later + # SPDX-FileCopyrightText: 2023 Alexandre Bouvier # # SPDX-License-Identifier: GPL-3.0-or-later diff --git a/CMakeModules/FindSimpleIni.cmake b/CMakeModules/find/FindSimpleIni.cmake similarity index 86% rename from CMakeModules/FindSimpleIni.cmake rename to CMakeModules/find/FindSimpleIni.cmake index 13426b25ba..1d2379fc82 100644 --- a/CMakeModules/FindSimpleIni.cmake +++ b/CMakeModules/find/FindSimpleIni.cmake @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +# SPDX-License-Identifier: GPL-3.0-or-later + # SPDX-FileCopyrightText: 2023 Alexandre Bouvier # # SPDX-License-Identifier: GPL-3.0-or-later diff --git a/CMakeModules/Findenet.cmake b/CMakeModules/find/Findenet.cmake similarity index 89% rename from CMakeModules/Findenet.cmake rename to CMakeModules/find/Findenet.cmake index d80e737ebb..2a2d1d807d 100644 --- a/CMakeModules/Findenet.cmake +++ b/CMakeModules/find/Findenet.cmake @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later # SPDX-FileCopyrightText: 2022 Alexandre Bouvier diff --git a/CMakeModules/Findgamemode.cmake b/CMakeModules/find/Findgamemode.cmake similarity index 81% rename from CMakeModules/Findgamemode.cmake rename to CMakeModules/find/Findgamemode.cmake index aa2f366832..3ec966c82d 100644 --- a/CMakeModules/Findgamemode.cmake +++ b/CMakeModules/find/Findgamemode.cmake @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +# SPDX-License-Identifier: GPL-3.0-or-later + # SPDX-FileCopyrightText: 2023 yuzu Emulator Project # SPDX-License-Identifier: GPL-2.0-or-later diff --git a/CMakeModules/Findhttplib.cmake b/CMakeModules/find/Findhttplib.cmake similarity index 90% rename from CMakeModules/Findhttplib.cmake rename to CMakeModules/find/Findhttplib.cmake index 48967add96..e92a9be63f 100644 --- a/CMakeModules/Findhttplib.cmake +++ b/CMakeModules/find/Findhttplib.cmake @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +# SPDX-License-Identifier: GPL-3.0-or-later + # SPDX-FileCopyrightText: 2022 Andrea Pappacoda # # SPDX-License-Identifier: GPL-2.0-or-later diff --git a/CMakeModules/Findlibiw.cmake b/CMakeModules/find/Findlibiw.cmake similarity index 92% rename from CMakeModules/Findlibiw.cmake rename to CMakeModules/find/Findlibiw.cmake index 1d13d7705a..3381db0f08 100644 --- a/CMakeModules/Findlibiw.cmake +++ b/CMakeModules/find/Findlibiw.cmake @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later find_package(PkgConfig QUIET) diff --git a/CMakeModules/Findlibusb.cmake b/CMakeModules/find/Findlibusb.cmake similarity index 90% rename from CMakeModules/Findlibusb.cmake rename to CMakeModules/find/Findlibusb.cmake index 87b174c5b4..dee8187d81 100644 --- a/CMakeModules/Findlibusb.cmake +++ b/CMakeModules/find/Findlibusb.cmake @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later # SPDX-FileCopyrightText: 2022 Alexandre Bouvier diff --git a/CMakeModules/Findlz4.cmake b/CMakeModules/find/Findlz4.cmake similarity index 93% rename from CMakeModules/Findlz4.cmake rename to CMakeModules/find/Findlz4.cmake index af230166eb..13235d7ac8 100644 --- a/CMakeModules/Findlz4.cmake +++ b/CMakeModules/find/Findlz4.cmake @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later # SPDX-FileCopyrightText: 2022 yuzu Emulator Project diff --git a/CMakeModules/Findstb.cmake b/CMakeModules/find/Findstb.cmake similarity index 89% rename from CMakeModules/Findstb.cmake rename to CMakeModules/find/Findstb.cmake index bff9985802..4808c45397 100644 --- a/CMakeModules/Findstb.cmake +++ b/CMakeModules/find/Findstb.cmake @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +# SPDX-License-Identifier: GPL-3.0-or-later + # SPDX-FileCopyrightText: 2023 Alexandre Bouvier # # SPDX-License-Identifier: GPL-3.0-or-later diff --git a/CMakeModules/Findzstd.cmake b/CMakeModules/find/Findzstd.cmake similarity index 95% rename from CMakeModules/Findzstd.cmake rename to CMakeModules/find/Findzstd.cmake index 8e44b7a892..58f0aa6117 100644 --- a/CMakeModules/Findzstd.cmake +++ b/CMakeModules/find/Findzstd.cmake @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project # SPDX-License-Identifier: GPL-3.0-or-later # SPDX-FileCopyrightText: 2022 yuzu Emulator Project diff --git a/CMakeModules/toolchains/GentooCross.cmake b/CMakeModules/toolchains/GentooCross.cmake new file mode 100644 index 0000000000..0bb78795fd --- /dev/null +++ b/CMakeModules/toolchains/GentooCross.cmake @@ -0,0 +1,39 @@ +# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +# SPDX-License-Identifier: GPL-3.0-or-later + +set(CROSS_TARGET "" CACHE STRING "Cross-compilation target (aarch64, etc)") +set(CROSS_PLATFORM "unknown-linux-gnu" CACHE STRING "Cross-compilation platform (e.g. unknown-linux-gnu)") +set(CROSS_COMPILER "gcc" CACHE STRING "Cross compiler type (gcc or clang)") + +if (NOT CROSS_TARGET) + message(FATAL_ERROR "GentooCross used without a valid CROSS_TARGET") +endif() + +set(prefix ${CROSS_TARGET}-${CROSS_PLATFORM}) + +set(CMAKE_SYSROOT /usr/${prefix}) + +if (CROSS_COMPILER STREQUAL "gcc") + set(CMAKE_C_COMPILER ${prefix}-gcc) + set(CMAKE_CXX_COMPILER ${prefix}-g++) +elseif (CROSS_COMPILER STREQUAL "clang") + set(CMAKE_C_COMPILER ${prefix}-clang) + set(CMAKE_CXX_COMPILER ${prefix}-clang++) +else() + message(FATAL_ERROR "Unsupported cross compiler type ${CROSS_COMPILER}") +endif() + +# search programs in the host environment +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + +# search headers and libraries in the target environment +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) + +# sanity checks +if (NOT IS_DIRECTORY ${CMAKE_SYSROOT}) + message(FATAL_ERROR "Invalid sysroot ${CMAKE_SYSROOT}." + "Double-check your CROSS_TARGET and CROSS_PLATFORM.") +endif() diff --git a/docs/CrossCompile.md b/docs/CrossCompile.md index 1f6ef447e6..06bac5d9db 100644 --- a/docs/CrossCompile.md +++ b/docs/CrossCompile.md @@ -10,3 +10,81 @@ A painless guide for cross compilation (or to test NCE) from a x86_64 system wit - Download Debian 13: `wget https://cdimage.debian.org/debian-cd/current/arm64/iso-cd/debian-13.0.0-arm64-netinst.iso` - Create a system disk: `qemu-img create -f qcow2 debian-13-arm64-ci.qcow2 30G` - Run the VM: `qemu-system-aarch64 -M virt -m 2G -cpu max -bios /usr/local/share/qemu/edk2-aarch64-code.fd -drive if=none,file=debian-13.0.0-arm64-netinst.iso,format=raw,id=cdrom -device scsi-cd,drive=cdrom -drive if=none,file=debian-13-arm64-ci.qcow2,id=hd0,format=qcow2 -device virtio-blk-device,drive=hd0 -device virtio-gpu-pci -device usb-ehci -device usb-kbd -device intel-hda -device hda-output -nic user,model=virtio-net-pci` + +## Gentoo + +Gentoo's cross-compilation setup is relatively easy, provided you're already familiar with portage. A [cross toolchain file](../CMakeModules/toolchains/GentooCross.cmake) is provided. Throughout this section, replace `aarch64` with whatever target architecture you desire. + +### Crossdev + +First, emerge crossdev via `sudo emerge -a sys-devel/crossdev`. + +Now, set up the environment depending on the target architecture; e.g. + +```sh +sudo crossdev aarch64 +``` + +### QEMU + +If you don't have a host Gentoo system of your target architecture, you should install a QEMU user setup for testing. To do so, enable the relevant USE flags for `app-emulation/qemu`: + +```txt +app-emulation/qemu static-user qemu_user_targets_aarch64 +``` + +To use cross-emerged shared libraries, you will also need to tell qemu where the sysroot is. You can do this with an alias: + +```sh +alias qemu-aarch64="qemu-aarch64 -L /usr/aarch64-unknown-linux-gnu" +``` + +### Dependencies + +Dependencies are the same [as normal Gentoo](./Deps.md#Commands); simply replace the `emerge` command with `emerge--unknown-linux-gnu` (e.g. `emerge-aarch64-unknown-linux-gnu`). However, there are a few caveats: + +#### Enabling GURU + +Since Crossdev sysroots are effectively isolated from the system w.r.t Portage, you must manually enable GURU in your sysroot. Run the following as root: + +```sh +mkdir -p /usr/aarch64-unknown-linux-gnu/etc/portage/repos.conf +cat << EOF > /usr/aarch64-unknown-linux-gnu/etc/portage/repos.conf/guru.conf +[guru] +location = /var/db/repos/guru +auto-sync = no +priority = 1 +EOF +``` + +#### Package Errata + +Crossdev is not perfect, and you may face some challenges with package that are not properly keyworded or have issues on specific architectures. These behaviors are, unfortunately, not well documented, and certain build systems such as Meson--and certain troublesome packages like GTK--are generally unfriendly towards cross-compilation. + +Thus, it may be desirable to emerge a minimal set of dependencies and allow Eden's build system to handle the rest for you. At a minimum, you *only* need standard system libraries (Crossdev does this for you) and Qt: + +```sh +sudo emerge-aarch64-unknown-linux-gnu dev-qt/qtbase:6 dev-qt/qtcharts:6 +``` + +From here, CPMUtil will take care of everything else. For extra insurance, you may want to set `-DCPMUTIL_FORCE_BUNDLED=ON` in your configure command. + +### Building + +From here, building is relatively standard. The [cross toolchain file](../CMakeModules/toolchains/GentooCross.cmake) contains a few additional configurations, but generally all you need to do is set `CROSS_TARGET` and `CMAKE_TOOLCHAIN_FILE`. Disabling OpenGL is strongly recommended as well. + +```sh +cmake -S . -B build/aarch64 -DCMAKE_TOOLCHAIN_FILE=CMakeModules/toolchains/GentooCross.cmake -GNinja -DCROSS_TARGET=aarch64 -DENABLE_OPENGL=OFF +``` + +With that done, you can build as normal: + +```sh +cmake --build build/aarch64 +``` + +And finally, run the compiled executable with QEMU! + +```sh +qemu-aarch64 build/aarch64/bin/eden +```