Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
d36895e
CMake: Error out when switching sources for dependencies
JoshuaVandaele Dec 24, 2025
5dd7594
minizip-ng: Properly use libraries from Externals
JoshuaVandaele Dec 24, 2025
8f708c8
cURL: Actually disable ZLIB/ZSTD
JoshuaVandaele Jan 1, 2026
2ddfa18
LibUSB: Improve library detection
JoshuaVandaele Jan 3, 2026
e49a1f5
SDL: Use bundled LibUSB when desirable, update to bc68c1c
JoshuaVandaele Jan 2, 2026
f92da3f
UNDOME: Make WIL a submodule and update it
JoshuaVandaele Nov 26, 2025
8e8ecb4
UNDOME: Change ext-win-qt to local repo
JoshuaVandaele Oct 31, 2025
1a998c4
Remove Visual Studio Projects and Solutions in favor of CMake
JoshuaVandaele Oct 31, 2025
1d07116
CMake: Work around implot#565
JoshuaVandaele Dec 7, 2025
bd1b247
CMake: Remove license.txt
JoshuaVandaele Dec 11, 2025
e06f41a
CMake: PDBs outside of Binaries
JoshuaVandaele Dec 10, 2025
6209c21
CMake: Use rc and manifests on other targets to match VS Project
JoshuaVandaele Dec 11, 2025
5231571
CMake: Only copy build_info.txt if autoupdate is enabled
JoshuaVandaele Dec 11, 2025
3f7b59d
CMake: Unify translation directories
JoshuaVandaele Dec 11, 2025
fec5194
CMake: Unify sys directories
JoshuaVandaele Dec 11, 2025
87c2d06
CMake: Remove LINUX_LOCAL_DEV and symlink required files
JoshuaVandaele Dec 11, 2025
6b814c9
CMake: Unify output directory
JoshuaVandaele Dec 11, 2025
26bfc0c
CMake: Better architecture detection
JoshuaVandaele Dec 11, 2025
b999bab
CMake: Bump minimum requirement to 3.25
JoshuaVandaele Jan 20, 2026
07bee61
CMake: Introduce Presets, replacing Settings
JoshuaVandaele Dec 11, 2025
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ CMakeLists.txt.user
/.vscode/
# Ignore flatpak-builder's cache dir
.flatpak-builder
# Ignore CMake user presets
CMakeUserPresets.json
12 changes: 8 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
[submodule "Externals/Qt"]
path = Externals/Qt
url = https://github.com/dolphin-emu/ext-win-qt.git
shallow = true
[submodule "Externals/mGBA/mgba"]
path = Externals/mGBA/mgba
url = https://github.com/mgba-emu/mgba.git
Expand Down Expand Up @@ -130,3 +126,11 @@
path = Externals/imgui/imgui
url = https://github.com/ocornut/imgui.git
shallow = true
[submodule "Externals/wil"]
path = Externals/wil
url = https://github.com/microsoft/wil.git
shallow = true
[submodule "Externals/Qt"]
path = Externals/Qt
url = https://github.com/JoshuaVandaele/ext-win-qt.git
shallow = true
19 changes: 15 additions & 4 deletions CMake/DolphinLibraryTools.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ function(dolphin_add_bundled_library library use_system bundled_path)
add_subdirectory(${bundled_path} EXCLUDE_FROM_ALL)
endfunction()

function(dolphin_set_library_type library type)
if(DEFINED ${library}_TYPE AND NOT ${${library}_TYPE} STREQUAL "${type}")
message(FATAL_ERROR
"The selection for ${library} changed from '${${library}_TYPE}' to '${type}' after configuration.\n"
"Please delete the build directory (or at least CMakeCache.txt) and reconfigure."
)
endif()

set(${library}_TYPE "${type}" CACHE INTERNAL "")
endfunction()

function(dolphin_find_optional_system_library library bundled_path)
dolphin_optional_system_library(use_system ${library})
string(TOUPPER ${library} upperlib)
Expand Down Expand Up @@ -101,11 +112,11 @@ function(dolphin_find_optional_system_library library bundled_path)
endif()
endif()
if(${prefix}_FOUND)
dolphin_set_library_type(${library} "System")
message(STATUS "Using system ${library}")
set(${prefix}_TYPE "System" PARENT_SCOPE)
else()
dolphin_set_library_type(${library} "Bundled")
dolphin_add_bundled_library(${library} ${use_system} ${bundled_path})
set(${prefix}_TYPE "Bundled" PARENT_SCOPE)
endif()
endfunction()

Expand All @@ -119,11 +130,11 @@ function(dolphin_find_optional_system_library_pkgconfig library search alias bun
endif()
endif()
if(${library}_FOUND)
dolphin_set_library_type(${library} "System")
message(STATUS "Using system ${library}")
dolphin_alias_library(${alias} PkgConfig::${library})
set(${library}_TYPE "System" PARENT_SCOPE)
else()
dolphin_set_library_type(${library} "Bundled")
dolphin_add_bundled_library(${library} ${use_system} ${bundled_path})
set(${library}_TYPE "Bundled" PARENT_SCOPE)
endif()
endfunction()
50 changes: 50 additions & 0 deletions CMake/DolphinToolchain.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
set(ARCH "generic" CACHE STRING "Target architecture")

set(VALID_ARCHS x86_64 arm64 generic)
if(NOT ARCH IN_LIST VALID_ARCHS)
message(FATAL_ERROR "Invalid ARCH='${ARCH}'. Valid: ${VALID_ARCHS}")
endif()

if(ARCH STREQUAL "generic")
set(ENABLE_GENERIC "ON")
else()
set(CMAKE_SYSTEM_PROCESSOR "${ARCH}")
endif()

if (NOT DEFINED CMAKE_SYSTEM_NAME)
if(EXISTS "${CMAKE_SYSROOT}/usr/include/linux")
set(CMAKE_SYSTEM_NAME Linux)
elseif(EXISTS "${CMAKE_SYSROOT}/Windows/System32")
set(CMAKE_SYSTEM_NAME Windows)
elseif(EXISTS "${CMAKE_SYSROOT}/System/Library")
set(CMAKE_SYSTEM_NAME Darwin)
elseif(EXISTS "${CMAKE_SYSROOT}/usr/include/osreldate.h")
set(CMAKE_SYSTEM_NAME FreeBSD)
elseif(EXISTS "${CMAKE_SYSROOT}/usr/include/c++/v1/__locale_dir/locale_base_api/openbsd.h")
set(CMAKE_SYSTEM_NAME OpenBSD)
elseif(EXISTS "${CMAKE_SYSROOT}/usr/include/dev/dm/netbsd-dm.h")
set(CMAKE_SYSTEM_NAME NetBSD)
elseif(EXISTS "${CMAKE_SYSROOT}/boot/system/develop")
set(CMAKE_SYSTEM_NAME Haiku)
else()
message(WARNING "Cannot detect OS from sysroot '${CMAKE_SYSROOT}/'. Cross-compilation has been disabled.")
endif()
endif()

set(CMAKE_FIND_ROOT_PATH "${CMAKE_SYSROOT}")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

if(NOT QT_HOST_PATH)
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
if (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "AMD64")
set(QT_HOST_PATH "${CMAKE_SOURCE_DIR}/Externals/Qt/Qt6.5.1/x64")
else()
set(QT_HOST_PATH "${CMAKE_SOURCE_DIR}/Externals/Qt/Qt6.5.1/ARM64")
endif()
else()
set(QT_HOST_PATH "/usr")
endif()
endif()
31 changes: 18 additions & 13 deletions CMake/FindLibUSB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@
if(ANDROID)
set(LIBUSB_FOUND FALSE CACHE INTERNAL "libusb-1.0 found")
message(STATUS "libusb-1.0 not found.")
elseif (NOT LIBUSB_FOUND)
pkg_check_modules (LIBUSB_PKG libusb-1.0)
return()
endif()

if(TARGET LibUSB::LibUSB)
return()
endif()

if(NOT LIBUSB_FOUND)
pkg_check_modules(LIBUSB_PKG libusb-1.0)

find_path(LIBUSB_INCLUDE_DIR NAMES libusb.h
PATHS
Expand All @@ -30,21 +37,19 @@ elseif (NOT LIBUSB_FOUND)
/usr/local/lib
)

if(LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)
set(LIBUSB_FOUND TRUE CACHE INTERNAL "libusb-1.0 found")
message(STATUS "Found libusb-1.0: ${LIBUSB_INCLUDE_DIR}, ${LIBUSB_LIBRARIES}")
else(LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)
set(LIBUSB_FOUND FALSE CACHE INTERNAL "libusb-1.0 found")
message(STATUS "libusb-1.0 not found.")
endif(LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)

mark_as_advanced(LIBUSB_INCLUDE_DIR LIBUSB_LIBRARIES)
endif ()
if(LIBUSB_FOUND AND NOT TARGET LibUSB::LibUSB)
endif()


if(LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)
add_library(LibUSB::LibUSB UNKNOWN IMPORTED)
set_target_properties(LibUSB::LibUSB PROPERTIES
IMPORTED_LOCATION "${LIBUSB_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${LIBUSB_INCLUDE_DIR}"
)
set(LIBUSB_FOUND TRUE CACHE INTERNAL "libusb-1.0 found")
message(STATUS "Found libusb-1.0: ${LIBUSB_INCLUDE_DIR}, ${LIBUSB_LIBRARIES}")
else()
set(LIBUSB_FOUND FALSE CACHE INTERNAL "libusb-1.0 found")
message(STATUS "libusb-1.0 not found.")
endif()

82 changes: 29 additions & 53 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
########################################
# General setup
#
cmake_minimum_required(VERSION 3.20...4.2.1)
cmake_minimum_required(VERSION 3.25...4.2.1)

cmake_policy(SET CMP0080 OLD) # allow using BundleUtilities at configure time

Expand All @@ -23,10 +23,6 @@ set(CMAKE_CXX_SCAN_FOR_MODULES OFF)

project(dolphin-emu)

if (CMAKE_VERSION VERSION_LESS "3.25" AND CMAKE_SYSTEM_NAME MATCHES "Linux")
set(LINUX TRUE)
endif()

if (MSVC)
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 23)
Expand Down Expand Up @@ -146,12 +142,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
endif()
endif()

if(UNIX)
# Builds a relocatable binary on Linux.
# The Sys folder will need to be copied to the Binaries folder.
option(LINUX_LOCAL_DEV "Enable relocatable binary" OFF)
endif()

list(APPEND CMAKE_MODULE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/CMake
)
Expand Down Expand Up @@ -179,20 +169,15 @@ if(CMAKE_SYSROOT)
set(ENV{PKG_CONFIG_SYSROOT_DIR} "${CMAKE_SYSROOT}")
endif()

# Set where the binary files will be built. The program will not execute from
# here. You must run "make install" to install these to the proper location
# as defined above.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Binaries)

if (WIN32)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/Binary)
# Output directory for the Dolphin binary
# We need to use a generator expression here to ensure that multi-config generators
# (like Visual Studio) put the binaries in the right place.
# See https://cmake.org/cmake/help/v4.2/prop_tgt/RUNTIME_OUTPUT_DIRECTORY.html
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_BINARY_DIR}/Binaries>)

if (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64")
string(APPEND CMAKE_RUNTIME_OUTPUT_DIRECTORY /x64)
elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
string(APPEND CMAKE_RUNTIME_OUTPUT_DIRECTORY /ARM64)
endif()
endif()
# Output directory for PDB files. PDBs are only generated on Windows with MSVC.
# We set a common directory for all PDBs to avoid littering the Binaries/ directory.
set(CMAKE_PDB_OUTPUT_DIRECTORY $<1:${CMAKE_BINARY_DIR}/pdb>)

# setup CCache
include(CCache)
Expand All @@ -216,11 +201,11 @@ if(ENABLE_GENERIC)
message(STATUS "Warning! Building generic build!")
set(_M_GENERIC 1)
add_definitions(-D_M_GENERIC=1)
elseif(_ARCH_64 AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64")
elseif(_ARCH_64 AND CMAKE_SYSTEM_PROCESSOR MATCHES "x64|x86_64|amd64|AMD64")
set(_M_X86_64 1)
add_definitions(-D_M_X86_64=1)
check_and_add_flag(HAVE_SSE2 -msse2)
elseif(_ARCH_64 AND CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|arm64")
elseif(_ARCH_64 AND CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|arm64|ARM64")
set(_M_ARM_64 1)
add_definitions(-D_M_ARM_64=1)
# CRC instruction set is used in the CRC32 hash function
Expand Down Expand Up @@ -350,7 +335,7 @@ if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(CMAKE_XCODE_ATTRIBUTE_GCC_STRICT_ALIASING NO)

# Specify target CPUs.
if(_ARCH_64 AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64")
if(_ARCH_64 AND _M_X86_64)
check_and_add_flag(HAVE_MSSSE3 -mssse3)
check_and_add_flag(HAVE_ARCH_CORE2 -march=core2)
endif()
Expand Down Expand Up @@ -389,12 +374,6 @@ if(ENABLE_LTO)
endif()
endif()

if(UNIX)
if(LINUX_LOCAL_DEV)
add_definitions(-DLINUX_LOCAL_DEV)
endif()
endif()

# BSDs put packages in /usr/local instead of /usr, so we need to
# force CMake to look in those directories by default, too.
# All commands and submodule commands also need to see these
Expand Down Expand Up @@ -584,10 +563,6 @@ if(UNIX)
add_definitions(-DUSE_MEMORYWATCHER=1)
endif()

if(ENABLE_SDL)
dolphin_find_optional_system_library(SDL3 Externals/SDL 3.2.0)
endif()

if(ENABLE_ANALYTICS)
message(STATUS "Enabling analytics collection (subject to end-user opt-in)")
add_definitions(-DUSE_ANALYTICS=1)
Expand Down Expand Up @@ -655,11 +630,18 @@ if(ENABLE_VULKAN)
endif()
endif()

if(NOT WIN32 OR (NOT (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")))
if(NOT (WIN32 AND _M_ARM_64))
# OpenGL is available on all platforms except windows-arm64
add_definitions(-DHAS_OPENGL)
endif()

if(NOT WIN32)
if(ANDROID)
set(USE_SYSTEM_Iconv OFF)
endif()
dolphin_find_optional_system_library(Iconv Externals/libiconv 1.14)
endif()

dolphin_find_optional_system_library(pugixml Externals/pugixml)

dolphin_find_optional_system_library_pkgconfig(ENET libenet>=1.3.18 enet::enet Externals/enet)
Expand Down Expand Up @@ -703,12 +685,14 @@ if(ENABLE_CUBEB)
endif()

if(NOT ANDROID)
dolphin_find_optional_system_library_pkgconfig(
LibUSB libusb-1.0 LibUSB::LibUSB Externals/libusb
)
dolphin_find_optional_system_library(LibUSB Externals/libusb)
add_definitions(-D__LIBUSB__)
endif()

if(ENABLE_SDL)
dolphin_find_optional_system_library(SDL3 Externals/SDL 3.2.0)
endif()

dolphin_find_optional_system_library(SFML Externals/SFML 3.0 COMPONENTS Network System)

if(USE_UPNP)
Expand All @@ -720,15 +704,6 @@ dolphin_find_optional_system_library(MBEDTLS Externals/mbedtls 2.28)

dolphin_find_optional_system_library(CURL Externals/curl)

if(NOT WIN32)
if(NOT ANDROID)
dolphin_find_optional_system_library(Iconv Externals/libiconv 1.14)
else()
message(STATUS "Using static iconv from Externals")
add_subdirectory(Externals/libiconv EXCLUDE_FROM_ALL)
endif()
endif()

if(NOT ANDROID)
dolphin_find_optional_system_library(HIDAPI Externals/hidapi)
endif()
Expand All @@ -755,7 +730,7 @@ else()
endif()

if (WIN32)
include_directories(Externals/WIL/include)
include_directories(Externals/wil/include)
include_directories(Externals/OpenAL/include)
endif()

Expand Down Expand Up @@ -848,10 +823,11 @@ add_subdirectory(Source)
# Install shared data files
#
if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin|Windows")
install(DIRECTORY Data/Sys/ DESTINATION ${datadir}/sys PATTERN)
install(DIRECTORY Data/Sys/ DESTINATION ${datadir}/Sys PATTERN)
endif()
if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux|FreeBSD|OpenBSD|Darwin")
install(FILES Data/license.txt DESTINATION ${datadir})
install(FILES COPYING DESTINATION ${datadir})
install(DIRECTORY LICENSES DESTINATION ${datadir}/LICENSES PATTERN)
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Linux|FreeBSD|OpenBSD")
# Install the application icon and menu item
Expand Down
Loading