Skip to content
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
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
8 changes: 4 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 @@ -134,3 +130,7 @@
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
20 changes: 20 additions & 0 deletions CMake/DolphinSymlinkOrCopy.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
if(NOT DEFINED target OR NOT DEFINED link)
message(FATAL_ERROR "`target` and `link` must be defined")
endif()

file(CREATE_LINK "${target}" "${link}" RESULT result SYMBOLIC)
if(result EQUAL 0)
return()
endif()

if(WIN32)
set(hint "On Windows, enable Developer Mode to allow symlinks (https://learn.microsoft.com/windows/advanced-settings/developer-mode).")
endif()
message(WARNING "Symlink failed (${result}). Falling back to copying. ${hint}")

file(REMOVE_RECURSE "${link}")
if(IS_DIRECTORY "${target}")
file(COPY "${target}/." DESTINATION "${link}")
else()
file(COPY_FILE "${target}" "${link}" ONLY_IF_DIFFERENT)
endif()
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()
44 changes: 13 additions & 31 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)
# 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 (WIN32)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/Binary)

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 @@ -213,6 +198,9 @@ else()
endif()

if(ENABLE_GENERIC)
if(WIN32)
message(FATAL_ERROR "Generic builds are not supported on Windows!")
endif()
message(STATUS "Warning! Building generic build!")
set(_M_GENERIC 1)
add_definitions(-D_M_GENERIC=1)
Expand Down Expand Up @@ -387,12 +375,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 @@ -840,7 +822,7 @@ 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 COPYING DESTINATION ${datadir})
Expand Down
Loading