2010-11-01 15:47:02 +00:00
########################################
# General setup
#
2022-07-24 05:10:10 +00:00
cmake_minimum_required ( VERSION 3.13 )
cmake_policy ( SET CMP0079 NEW ) # let target_link_libraries() link to a target defined in a different directory
cmake_policy ( SET CMP0080 OLD ) # allow using BundleUtilities at configure time
2021-01-13 14:23:57 +00:00
2023-03-31 02:03:16 +00:00
if ( POLICY CMP0099 )
cmake_policy ( SET CMP0099 NEW ) # Propagate INTERFACE_LINK_OPTIONS from private dependencies, used by MacOS framework builds of SDL
endif ( )
2022-05-21 12:26:39 +00:00
# Weird chicken-and-egg problem: We can't check the compiler before the project() call, but we have to set the policies before it.
# So we do this in two steps: Set the policies if they exist, then error out afterwards if we end up being MSVC and they don't exist.
if ( POLICY CMP0117 )
cmake_policy ( SET CMP0091 NEW ) # MSVC runtime library flags are selected by an abstraction.
cmake_policy ( SET CMP0092 NEW ) # MSVC warning flags are not in CMAKE_{C,CXX}_FLAGS by default.
cmake_policy ( SET CMP0117 NEW ) # MSVC RTTI flag will not be added by default.
endif ( )
2023-01-29 09:10:03 +00:00
if ( POLICY CMP0141 )
cmake_policy ( SET CMP0141 NEW ) # MSVC debug information format flags are selected by an abstraction.
endif ( )
2017-01-24 07:45:54 +00:00
# Minimum OS X version.
# This is inserted into the Info.plist as well.
2022-12-22 09:02:10 +00:00
set ( CMAKE_OSX_DEPLOYMENT_TARGET "10.15.0" CACHE STRING "" )
2012-03-14 00:14:00 +00:00
2024-02-16 17:40:45 +00:00
set ( CMAKE_USER_MAKE_RULES_OVERRIDE "${CMAKE_CURRENT_SOURCE_DIR}/CMake/FlagsOverride.cmake" )
2017-06-15 16:24:41 +00:00
2017-01-24 07:44:15 +00:00
project ( dolphin-emu )
2018-04-05 12:16:08 +00:00
2022-05-21 01:31:41 +00:00
if ( MSVC )
2022-05-21 12:26:39 +00:00
if ( POLICY CMP0117 )
# cmake is a weird language. You can't do if(not POLICY)
else ( )
message ( FATAL_ERROR "Please update to CMake 3.20 or higher." )
endif ( )
2022-05-21 01:31:41 +00:00
set ( CMAKE_C_STANDARD 99 )
2022-05-21 02:40:13 +00:00
set ( CMAKE_CXX_STANDARD 23 )
2022-05-21 01:31:41 +00:00
set ( CMAKE_CXX_STANDARD_REQUIRED ON )
endif ( )
2022-08-10 02:50:29 +00:00
set ( COMPILER ${ CMAKE_CXX_COMPILER_ID } )
if ( COMPILER STREQUAL "GNU" )
set ( COMPILER "GCC" ) # perfer printing GCC instead of GNU
endif ( )
2024-05-21 05:13:43 +00:00
# Enforce minimum compiler versions that support the c++20 features we use
set ( GCC_min_version 11 )
set ( Clang_min_version 14 )
set ( AppleClang_min_version 14.0.3 )
set ( min_xcode_version "14.0" ) # corresponding xcode version for AppleClang_min_version
2022-08-10 02:50:29 +00:00
set ( MSVC_min_version 14.32 )
2024-05-21 05:13:43 +00:00
set ( min_vs_version "2022 17.2.3" ) # corresponding Visual Studio version for MSVC_min_version
2022-08-10 02:50:29 +00:00
message ( STATUS "Using ${COMPILER} ${CMAKE_CXX_COMPILER_VERSION}" )
if ( "-" STREQUAL "${${COMPILER}_min_version}-" )
message ( WARNING "Unknown compiler ${COMPILER}, assuming it is new enough" )
else ( )
if ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${ ${COMPILER } _min_version} )
message ( FATAL_ERROR "Requires GCC ${GCC_min_version}, Clang ${Clang_min_version},"
" A p p l e C l a n g $ { A p p l e C l a n g _ m i n _ v e r s i o n } ( X c o d e $ { m i n _ x c o d e _ v e r s i o n } ) , "
" o r MSVC $ { M S V C _ m i n _ v e r s i o n } ( V i s u a l S t u d i o $ { m i n _ v s _ v e r s i o n } ) o r h i g h e r " )
endif ( )
endif ( )
2018-04-05 12:16:08 +00:00
# Name of the Dolphin distributor. If you redistribute Dolphin builds (forks,
# unofficial builds) please consider identifying your distribution with a
# unique name here.
set ( DISTRIBUTOR "None" CACHE STRING "Name of the distributor." )
2021-04-17 17:45:43 +00:00
set ( DOLPHIN_DEFAULT_UPDATE_TRACK "" CACHE STRING "Name of the default update track. If empty, disables auto-update." )
2018-10-03 13:03:36 +00:00
if ( UNIX AND NOT APPLE AND NOT ANDROID )
option ( ENABLE_X11 "Enables X11 Support" ON )
endif ( )
2020-12-12 20:25:51 +00:00
if ( NOT WIN32 AND NOT APPLE AND NOT HAIKU )
2018-10-03 13:03:36 +00:00
option ( ENABLE_EGL "Enables EGL OpenGL Interface" ON )
endif ( )
2021-12-03 21:40:19 +00:00
if ( NOT ANDROID )
option ( ENABLE_CLI_TOOL "Enable dolphin-tool, a CLI-based utility for functions such as managing disc images" ON )
endif ( )
2023-04-16 07:46:42 +00:00
set ( USE_SYSTEM_LIBS "AUTO" CACHE STRING "Use system libraries instead of bundled libraries. ON - Always use system and fail if unavailable, OFF - Always use bundled, AUTO - Use system if available, otherwise use bundled. Default is AUTO" )
if ( APPROVED_VENDORED_DEPENDENCIES )
message ( WARNING "APPROVED_VENDORED_DEPENDENCIES is deprecated. Please migrate to setting USE_SYSTEM_LIBS to ON and setting USE_SYSTEM_<dependency> to either AUTO or OFF to allow bundled libs." )
endif ( )
2013-07-09 00:13:02 +00:00
option ( USE_UPNP "Enables UPnP port mapping support" ON )
2018-10-24 08:14:50 +00:00
option ( ENABLE_NOGUI "Enable NoGUI frontend" ON )
2018-07-06 22:40:15 +00:00
option ( ENABLE_QT "Enable Qt (Default)" ON )
2014-04-23 09:15:25 +00:00
option ( ENABLE_LTO "Enables Link Time Optimization" OFF )
2014-05-26 01:52:52 +00:00
option ( ENABLE_GENERIC "Enables generic build that should run on any little-endian host" OFF )
2016-01-26 13:35:17 +00:00
option ( ENABLE_HEADLESS "Enables running Dolphin as a headless variant" OFF )
2016-12-03 18:36:34 +00:00
option ( ENABLE_ALSA "Enables ALSA sound backend" ON )
option ( ENABLE_PULSEAUDIO "Enables PulseAudio sound backend" ON )
2016-12-03 18:37:02 +00:00
option ( ENABLE_LLVM "Enables LLVM support, for disassembly" ON )
2018-12-08 22:06:23 +00:00
option ( ENABLE_TESTS "Enables building the unit tests" ON )
2018-09-03 16:09:23 +00:00
option ( ENABLE_VULKAN "Enables vulkan video backend" ON )
2018-06-08 20:56:11 +00:00
option ( USE_DISCORD_PRESENCE "Enables Discord Rich Presence, show the current game on Discord" ON )
2021-07-04 10:41:46 +00:00
option ( USE_MGBA "Enables GBA controllers emulation using libmgba" ON )
2022-03-15 22:40:13 +00:00
option ( ENABLE_AUTOUPDATE "Enables support for automatic updates" ON )
2022-06-08 14:44:14 +00:00
option ( STEAM "Creates a build for Steam" OFF )
2023-03-18 16:22:17 +00:00
option ( USE_RETRO_ACHIEVEMENTS "Enables integration with retroachievements.org" ON )
2015-06-29 01:09:24 +00:00
2016-06-17 00:28:34 +00:00
# Maintainers: if you consider blanket disabling this for your users, please
# consider the following points:
# * No data is being sent without explicit user approval (pop up box at first
# launch).
# * The Dolphin team relies on the data in order to understand the behavior
# of our software in the wild.
option ( ENABLE_ANALYTICS "Enables opt-in Analytics collection" ON )
2018-04-05 12:16:08 +00:00
option ( ENCODE_FRAMEDUMPS "Encode framedumps in AVI format" ON )
option ( ENABLE_GPROF "Enable gprof profiling (must be using Debug build)" OFF )
option ( FASTLOG "Enable all logs" OFF )
option ( OPROFILING "Enable profiling" OFF )
# TODO: Add DSPSpy
option ( DSPTOOL "Build dsptool" OFF )
2016-06-17 22:13:37 +00:00
2024-01-02 10:24:13 +00:00
# Enable SDL by default on operating systems that aren't Android.
if ( NOT ANDROID )
2015-06-29 01:09:24 +00:00
option ( ENABLE_SDL "Enables SDL as a generic controller backend" ON )
else ( )
option ( ENABLE_SDL "Enables SDL as a generic controller backend" OFF )
endif ( )
2014-10-29 04:11:57 +00:00
if ( APPLE )
2021-01-17 04:31:48 +00:00
option ( MACOS_USE_DEFAULT_SEARCH_PATH "Don't prioritize system library paths" OFF )
2022-04-28 17:20:16 +00:00
option ( SKIP_POSTPROCESS_BUNDLE "Skip postprocessing bundle for redistributability" OFF )
2021-01-17 04:31:48 +00:00
# Enable adhoc code signing by default (otherwise makefile builds on ARM will not work)
option ( MACOS_CODE_SIGNING "Enable codesigning" ON )
2022-05-31 01:01:24 +00:00
option ( USE_BUNDLED_MOLTENVK "Build MoltenVK from Externals with Dolphin-specific patches" ON )
2021-01-17 04:31:48 +00:00
set ( MACOS_CODE_SIGNING_IDENTITY "-" CACHE STRING "The identity used for codesigning." )
set ( MACOS_CODE_SIGNING_IDENTITY_UPDATER "-" CACHE STRING "The identity used for codesigning, for the updater." )
2014-10-29 04:11:57 +00:00
endif ( )
2013-01-25 19:55:05 +00:00
2018-07-02 17:01:16 +00:00
if ( CMAKE_SYSTEM_NAME STREQUAL "Linux" )
2018-04-21 16:37:17 +00:00
option ( ENABLE_VTUNE "Enable Intel VTune integration for JIT code." OFF )
2018-04-05 12:16:08 +00:00
if ( NOT ANDROID )
option ( ENABLE_EVDEV "Enables the evdev controller backend" ON )
endif ( )
2015-02-12 00:36:29 +00:00
endif ( )
2014-11-06 01:53:34 +00:00
2018-04-05 12:16:08 +00:00
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 )
2014-11-06 01:53:34 +00:00
endif ( )
2013-01-25 19:55:05 +00:00
2017-01-25 00:48:16 +00:00
list ( APPEND CMAKE_MODULE_PATH
2024-02-20 13:09:06 +00:00
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / C M a k e
2017-01-25 00:48:16 +00:00
)
# Support functions
include ( CheckAndAddFlag )
2017-01-25 04:23:06 +00:00
include ( CheckCCompilerFlag )
2017-01-25 15:20:03 +00:00
include ( DolphinCompileDefinitions )
2022-05-21 13:09:05 +00:00
include ( DolphinDisableWarningsMSVC )
2022-08-01 22:35:22 +00:00
include ( DolphinLibraryTools )
2022-10-11 18:44:04 +00:00
include ( GNUInstallDirs )
2022-05-21 12:26:39 +00:00
include ( RemoveCompileFlag )
2017-01-25 00:48:16 +00:00
2017-02-03 03:19:23 +00:00
# Enable folders for IDE
set_property ( GLOBAL PROPERTY USE_FOLDERS ON )
2010-11-04 13:47:17 +00:00
# Set up paths
2022-10-11 18:44:04 +00:00
set ( datadir ${ CMAKE_INSTALL_FULL_DATADIR } /dolphin-emu CACHE PATH "datadir" )
2017-02-05 19:16:27 +00:00
add_definitions ( -DDATA_DIR= "${datadir}/" )
2010-11-04 13:47:17 +00:00
2017-01-17 20:34:18 +00:00
if ( CMAKE_SYSROOT )
# If we should use a sysroot, tell pkg-config to search for packages in there, not on the host
set ( ENV{PKG_CONFIG_LIBDIR} "${CMAKE_SYSROOT}/usr/lib/pkgconfig:${CMAKE_SYSROOT}/usr/share/pkgconfig" )
set ( ENV{PKG_CONFIG_SYSROOT_DIR} "${CMAKE_SYSROOT}" )
endif ( )
2011-02-11 02:38:23 +00:00
# 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.
2010-11-04 13:47:17 +00:00
set ( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${ CMAKE_BINARY_DIR } /Binaries )
2010-11-01 15:47:02 +00:00
2019-05-15 07:59:55 +00:00
if ( WIN32 )
set ( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${ CMAKE_SOURCE_DIR } /Binary )
2020-02-11 23:07:56 +00:00
2021-04-17 19:33:07 +00:00
if ( CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64" )
string ( APPEND CMAKE_RUNTIME_OUTPUT_DIRECTORY /x64 )
elseif ( CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" )
2020-10-23 21:48:37 +00:00
string ( APPEND CMAKE_RUNTIME_OUTPUT_DIRECTORY /ARM64 )
2020-02-11 23:07:56 +00:00
endif ( )
2019-05-08 21:57:47 +00:00
endif ( )
2017-01-17 21:38:02 +00:00
# setup CCache
include ( CCache )
2014-03-02 11:21:50 +00:00
# Architecture detection and arch specific settings
2017-01-17 20:47:24 +00:00
message ( STATUS "Detected architecture: ${CMAKE_SYSTEM_PROCESSOR}" )
2014-03-02 11:21:50 +00:00
# Detect 64bit or 32bit
# CMake doesn't provide a simple way to determine 32bit or 64bit
# If we ever support a architecture that is 64bit with 32bit pointers then this'll break
# Of course the chances of that are slim(x32?) so who cares
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set ( _ARCH_64 1 )
add_definitions ( -D_ARCH_64=1 )
else ( )
set ( _ARCH_32 1 )
add_definitions ( -D_ARCH_32=1 )
endif ( )
2014-05-26 01:52:52 +00:00
if ( ENABLE_GENERIC )
2017-01-17 20:47:24 +00:00
message ( STATUS "Warning! Building generic build!" )
2014-03-02 11:21:50 +00:00
set ( _M_GENERIC 1 )
add_definitions ( -D_M_GENERIC=1 )
2017-01-27 08:56:38 +00:00
elseif ( _ARCH_64 AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64" )
2016-06-08 17:49:46 +00:00
set ( _M_X86_64 1 )
2017-01-25 05:02:01 +00:00
add_definitions ( -D_M_X86_64=1 )
check_and_add_flag ( HAVE_SSE2 -msse2 )
2020-12-23 07:26:53 +00:00
elseif ( _ARCH_64 AND CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|arm64" )
2016-06-08 17:49:46 +00:00
set ( _M_ARM_64 1 )
2017-01-25 05:02:01 +00:00
add_definitions ( -D_M_ARM_64=1 )
# CRC instruction set is used in the CRC32 hash function
check_and_add_flag ( HAVE_ARCH_ARMV8 -march=armv8-a+crc )
2016-06-08 17:49:46 +00:00
else ( )
2017-01-27 08:56:38 +00:00
message ( FATAL_ERROR "You're building on an unsupported platform: "
" ' $ { C M A K E _ S Y S T E M _ P R O C E S S O R } ' w i t h $ { C M A K E _ S I Z E O F _ V O I D _ P } - b y t e p o i n t e r s . "
" E n a b l e g e n e r i c b u i l d i f y o u r e a l l y w a n t a J I T - l e s s b i n a r y . " )
2013-02-26 19:49:00 +00:00
endif ( )
2011-01-09 16:36:19 +00:00
2017-04-12 00:49:35 +00:00
if ( CMAKE_GENERATOR MATCHES "Ninja" )
check_and_add_flag ( DIAGNOSTICS_COLOR -fdiagnostics-color )
elseif ( CMAKE_GENERATOR MATCHES "Visual Studio" )
# Only MSBuild needs this, other generators will compile one file at a time
add_compile_options ( "/MP" )
endif ( )
2022-04-28 17:20:16 +00:00
if ( MSVC )
2017-01-25 05:06:25 +00:00
check_and_add_flag ( EXCEPTIONS /EHsc )
2017-03-08 05:31:02 +00:00
dolphin_compile_definitions ( _DEBUG DEBUG_ONLY )
2017-03-01 12:43:43 +00:00
2022-05-21 02:37:28 +00:00
# Disable RTTI
2022-05-21 12:26:39 +00:00
add_compile_options ( /GR- )
2022-05-21 02:37:28 +00:00
# Set warning level 4 (the highest)
add_compile_options ( /W4 )
# Treat all warnings as errors
add_compile_options ( /WX )
# Disable some warnings
add_compile_options (
/ w d 4 2 0 1 # nonstandard extension used : nameless struct/union
/ w d 4 1 2 7 # conditional expression is constant
/ w d 4 1 0 0 # 'identifier' : unreferenced formal parameter
/ w d 4 2 0 0 # InputCommon fix temp.
/ w d 4 2 4 4 # 'conversion' conversion from 'type1' to 'type2', possible loss of data
/ w d 4 1 2 1 # 'symbol' : alignment of a member was sensitive to packing
/ w d 4 3 2 4 # Padding was added at the end of a structure because you specified a __declspec(align) value.
/ w d 4 7 1 4 # function 'function' marked as __forceinline not inlined
/ w d 4 3 5 1 # new behavior: elements of array 'array' will be default initialized
# TODO: Enable this warning once possible
/ w d 4 2 4 5 # conversion from 'type1' to 'type2', signed/unsigned mismatch
# Currently jits use some annoying code patterns which makes this common
)
# Additional warnings
add_compile_options (
/ w 4 4 2 6 3 # Non-virtual member function hides base class virtual function
/ w 4 4 2 6 5 # Class has virtual functions, but destructor is not virtual
/ w 4 4 9 4 6 # Reinterpret cast between related types
)
# All files are encoded as UTF-8
add_compile_options ( /utf-8 )
# Ignore warnings in external headers
add_compile_options ( /external:anglebrackets )
add_compile_options ( /external:W0 )
add_compile_options ( /external:templates- )
# Request deterministic builds
add_compile_options ( /experimental:deterministic )
add_link_options ( /experimental:deterministic )
2021-04-25 17:00:32 +00:00
# Enable function-level linking
add_compile_options ( /Gy )
# Generate intrinsic functions
add_compile_options ( /Oi )
2022-05-21 02:37:28 +00:00
# Enable buffer security check on Debug, disable otherwise
add_compile_options ( $< IF:$<CONFIG:Debug > ,/GS,/GS-> )
2017-06-06 06:22:01 +00:00
# Remove unreferenced inline functions/data to reduce link time and catch bugs
2023-01-13 09:55:42 +00:00
# Note: In msbuild build, this gets set by msbuild by default
2017-06-06 06:22:01 +00:00
add_compile_options ( /Zc:inline )
2023-01-13 09:55:42 +00:00
# Fix various other non-conformant behaviors
2023-02-22 21:22:08 +00:00
add_compile_options ( /Zc:__cplusplus,enumTypes,externConstexpr,preprocessor,templateScope,throwingNew )
2017-06-06 06:22:01 +00:00
# Enforce strict volatile semantics as per ISO C++
add_compile_options ( /volatile:iso )
2022-05-21 02:37:28 +00:00
# Use 'precise' floating point model
add_compile_options ( /fp:precise )
2017-02-03 03:42:52 +00:00
string ( APPEND CMAKE_EXE_LINKER_FLAGS " /NXCOMPAT" )
2021-04-25 17:00:32 +00:00
# Generate debug data
string ( APPEND CMAKE_EXE_LINKER_FLAGS " /DEBUG" )
# Eliminate dead code and data
string ( APPEND CMAKE_EXE_LINKER_FLAGS " /OPT:REF /OPT:ICF" )
2017-01-25 05:06:25 +00:00
else ( )
2016-06-16 20:31:51 +00:00
add_definitions ( -D_DEFAULT_SOURCE )
2017-03-01 12:43:43 +00:00
2017-01-25 04:33:36 +00:00
# gcc uses some optimizations which might break stuff without this flag
check_and_add_flag ( NO_STRICT_ALIASING -fno-strict-aliasing )
check_and_add_flag ( NO_EXCEPTIONS -fno-exceptions )
2017-03-01 12:43:43 +00:00
2017-01-25 04:33:36 +00:00
check_and_add_flag ( VISIBILITY_INLINES_HIDDEN -fvisibility-inlines-hidden )
check_and_add_flag ( VISIBILITY_HIDDEN -fvisibility=hidden )
2017-03-01 12:43:43 +00:00
2022-06-25 04:01:25 +00:00
check_and_add_flag ( FOMIT_FRAME_POINTER -fomit-frame-pointer NO_DEBINFO_ONLY )
2017-03-01 12:43:43 +00:00
2017-01-25 15:20:03 +00:00
dolphin_compile_definitions ( _DEBUG DEBUG_ONLY )
2017-01-25 15:19:35 +00:00
check_and_add_flag ( GGDB -ggdb DEBUG_ONLY )
2018-06-30 15:46:46 +00:00
if ( CMAKE_SYSTEM_NAME STREQUAL "Linux" )
# GNU ar: Create thin archive files.
# Requires binutils-2.19 or later.
set ( CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> qcTP <TARGET> <LINK_FLAGS> <OBJECTS>" )
set ( CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> qTP <TARGET> <LINK_FLAGS> <OBJECTS>" )
set ( CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> qcTP <TARGET> <LINK_FLAGS> <OBJECTS>" )
set ( CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> qTP <TARGET> <LINK_FLAGS> <OBJECTS>" )
endif ( )
2017-01-25 05:06:25 +00:00
endif ( )
2010-11-01 15:47:02 +00:00
2017-01-27 08:58:21 +00:00
if ( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
2021-01-17 04:31:48 +00:00
if ( NOT MACOS_USE_DEFAULT_SEARCH_PATH )
2014-10-29 04:11:57 +00:00
# Hack up the path to prioritize the path to built-in OS libraries to
# increase the chance of not depending on a bunch of copies of them
# installed by MacPorts, Fink, Homebrew, etc, and ending up copying
# them into the bundle. Since we optionally depend on libraries which
2016-09-28 17:32:07 +00:00
# are not part of OS X (ffmpeg, etc.), however, don't remove the default
# path entirely as was done in a previous version of this file. This is
# still kinda evil, since it defeats the user's path settings...
2014-10-29 04:11:57 +00:00
# See http://www.cmake.org/cmake/help/v3.0/command/find_program.html
2017-01-25 05:03:44 +00:00
list ( APPEND CMAKE_PREFIX_PATH "/usr" )
2014-10-29 04:11:57 +00:00
endif ( )
2017-03-01 12:43:43 +00:00
2021-04-11 04:28:10 +00:00
# Prevents Xcode from overriding the -fno-strict-aliasing flag
set ( CMAKE_XCODE_ATTRIBUTE_GCC_STRICT_ALIASING NO )
2011-12-11 20:27:06 +00:00
# Specify target CPUs.
2021-04-17 22:40:35 +00:00
if ( _ARCH_64 AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64" )
check_and_add_flag ( HAVE_MSSSE3 -mssse3 )
check_and_add_flag ( HAVE_ARCH_CORE2 -march=core2 )
endif ( )
2011-12-11 20:27:06 +00:00
# Linker flags.
# Drop unreachable code and data.
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-dead_strip,-dead_strip_dylibs" )
2017-03-01 12:43:43 +00:00
2021-03-15 17:13:22 +00:00
# Set FMT_EXCEPTIONS = 0, for consistency with -fno-exceptions earlier.
2020-10-14 18:50:38 +00:00
# If we set only -fno-exceptions, fmt fails to compile when included from
# Objective-C++ because fmt tries try to use throw because __EXCEPTIONS is defined.
2021-03-15 17:13:22 +00:00
add_definitions ( -DFMT_EXCEPTIONS=0 )
2020-10-14 18:50:38 +00:00
2011-12-07 07:26:44 +00:00
find_library ( APPKIT_LIBRARY AppKit )
find_library ( APPSERV_LIBRARY ApplicationServices )
find_library ( CARBON_LIBRARY Carbon )
find_library ( COCOA_LIBRARY Cocoa )
2018-03-30 19:43:49 +00:00
find_library ( COREFOUNDATION_LIBRARY CoreFoundation )
2011-12-07 07:26:44 +00:00
find_library ( CORESERV_LIBRARY CoreServices )
2018-03-30 19:43:49 +00:00
find_library ( FORCEFEEDBACK_LIBRARY ForceFeedback )
2016-07-23 19:06:45 +00:00
find_library ( FOUNDATION_LIBRARY Foundation )
2011-12-07 07:26:44 +00:00
find_library ( IOB_LIBRARY IOBluetooth )
find_library ( IOK_LIBRARY IOKit )
2014-10-22 07:25:01 +00:00
find_library ( OPENGL_LIBRARY OpenGL )
2011-02-07 15:51:38 +00:00
endif ( )
2011-12-07 07:26:44 +00:00
2017-01-25 04:51:09 +00:00
if ( ENABLE_LTO )
2021-04-25 23:18:17 +00:00
if ( CMAKE_C_COMPILER_ID MATCHES "MSVC" )
add_compile_options ( /GL )
string ( APPEND CMAKE_EXE_LINKER_FLAGS " /LTCG" )
else ( )
check_and_add_flag ( LTO -flto )
if ( CMAKE_CXX_COMPILER_ID STREQUAL GNU )
set ( CMAKE_AR gcc-ar )
set ( CMAKE_RANLIB gcc-ranlib )
endif ( )
2017-01-25 04:51:09 +00:00
endif ( )
endif ( )
2022-02-18 18:50:27 +00:00
if ( UNIX )
if ( LINUX_LOCAL_DEV OR ( CMAKE_SYSTEM_NAME STREQUAL "Linux" AND STEAM ) )
add_definitions ( -DLINUX_LOCAL_DEV )
endif ( )
2017-01-25 05:25:52 +00:00
endif ( )
2015-11-07 18:50:47 +00:00
2017-01-17 04:41:53 +00:00
# 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
# changes, so just setting them in the project scope via
# include_directories and link_directories is not sufficient
2024-05-03 00:30:15 +00:00
if ( CMAKE_SYSTEM_NAME MATCHES "FreeBSD" )
2017-01-17 04:41:53 +00:00
set ( CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};/usr/local" )
set ( CMAKE_REQUIRED_INCLUDES "/usr/local/include" )
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/lib" )
2022-08-10 06:21:47 +00:00
if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14.0 )
# Workaround: the llvm libc++ and versions of clang eariler than 14 have a bug with consteval
# so we define FMT_CONSTEVAL to blank to just disable consteval in fmt
add_definitions ( -DFMT_CONSTEVAL= )
endif ( )
2017-01-17 04:41:53 +00:00
endif ( )
2015-06-29 01:57:30 +00:00
# Dolphin requires threads.
2017-01-24 08:09:32 +00:00
find_package ( Threads )
2015-06-29 01:57:30 +00:00
2010-11-05 04:19:22 +00:00
if ( NOT CMAKE_BUILD_TYPE )
2010-11-05 23:38:37 +00:00
set ( CMAKE_BUILD_TYPE "Release" CACHE STRING
2017-01-25 02:50:39 +00:00
" B u i l d type ( Release/Debug/RelWithDebInfo/MinSizeRel ) " F O R C E )
2017-01-25 05:25:52 +00:00
endif ( )
2010-11-05 04:19:22 +00:00
2017-01-25 22:32:13 +00:00
if ( ENABLE_GPROF )
check_and_add_flag ( HAVE_PG -pg )
if ( NOT FLAG_C_HAVE_PG )
message ( FATAL_ERROR "Compiler option -pg is not supported" )
2012-12-30 04:48:22 +00:00
endif ( )
2017-01-25 22:32:13 +00:00
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg" )
2017-01-25 05:02:01 +00:00
endif ( )
2010-11-05 02:23:24 +00:00
2010-12-13 05:29:13 +00:00
if ( FASTLOG )
add_definitions ( -DDEBUGFAST )
endif ( )
2018-04-21 16:37:17 +00:00
if ( ENABLE_VTUNE )
set ( VTUNE_DIR "/opt/intel/vtune_amplifier" )
2015-02-12 00:36:29 +00:00
add_definitions ( -DUSE_VTUNE )
include_directories ( "${VTUNE_DIR}/include" )
2015-02-22 19:49:30 +00:00
set ( VTUNE_LIBRARIES
" $ { V T U N E _ D I R } / l i b 6 4 / l i b j i t p r o f i l i n g . a "
" $ { V T U N E _ D I R } / l i b 6 4 / l i b i t t n o t i f y . a "
)
2017-01-25 05:25:52 +00:00
endif ( )
2015-02-12 00:36:29 +00:00
2013-07-13 23:42:04 +00:00
if ( ANDROID )
2017-01-17 20:47:24 +00:00
message ( STATUS "Building for Android" )
2016-02-05 16:54:59 +00:00
if ( NOT ENABLE_HEADLESS )
add_definitions ( -DANDROID )
2018-10-24 08:14:50 +00:00
if ( ENABLE_NOGUI )
message ( STATUS "Building Android app, disabling NoGUI frontend." )
set ( ENABLE_NOGUI 0 )
endif ( )
2016-02-05 16:54:59 +00:00
else ( )
# Lie to cmake a bit. We are cross compiling to Android
# but not as a shared library. We want an executable.
set ( ANDROID 0 )
endif ( )
2013-07-13 23:42:04 +00:00
set ( USE_UPNP 0 )
2018-07-06 22:40:15 +00:00
set ( ENABLE_QT 0 )
2018-06-08 20:56:11 +00:00
set ( USE_DISCORD_PRESENCE 0 )
2017-03-01 12:43:43 +00:00
2016-02-05 16:54:59 +00:00
# We are cross compiling, search only the toolchain for libraries and includes
SET ( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
SET ( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
2017-01-17 20:34:18 +00:00
SET ( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
2016-06-08 17:49:46 +00:00
SET ( CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY )
2013-07-13 23:42:04 +00:00
endif ( )
2016-01-26 13:35:17 +00:00
if ( ENABLE_HEADLESS )
2018-10-03 13:03:36 +00:00
message ( STATUS "Enabling Headless! Disabling GUI." )
2018-07-06 22:40:15 +00:00
set ( ENABLE_QT 0 )
2018-06-08 20:56:11 +00:00
set ( USE_DISCORD_PRESENCE 0 )
2016-01-26 13:35:17 +00:00
endif ( )
2023-02-17 15:49:02 +00:00
# Set file offset size to 64 bits. On modern Unixes, this is typically already the case. Exceptions:
2017-01-25 02:51:17 +00:00
#
2023-02-17 15:49:02 +00:00
# glibc may default to 32 bits. This can be configured by setting _FILE_OFFSET_BITS=64.
#
# bionic (Android) defaults to 32 bits for 32-bit ABIs. Here too we can use _FILE_OFFSET_BITS=64,
# but only on API 25 and up. Since we're currently supporting older API levels and 32-bit Android
# isn't a build configuration we officially support, let's leave this as it is for now.
# More details: https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md
if ( NOT ANDROID AND NOT CMAKE_SYSTEM_NAME MATCHES "Windows" )
2017-01-25 02:51:17 +00:00
add_definitions ( -D_FILE_OFFSET_BITS=64 )
add_definitions ( -D_LARGEFILE_SOURCE )
endif ( )
2010-12-13 05:29:13 +00:00
2010-11-01 15:47:02 +00:00
########################################
# Dependency checking
#
2011-02-11 02:38:23 +00:00
# TODO: We should have options for dependencies included in the externals to
# override autodetection of system libraries and force the usage of the
# externals.
2013-08-29 10:40:16 +00:00
include ( CheckLib )
include ( CheckCXXSourceRuns )
2013-11-24 22:28:20 +00:00
2019-11-03 11:48:25 +00:00
set ( OpenGL_GL_PREFERENCE GLVND CACHE STRING "Linux-only: if GLVND, use the vendor-neutral GL libraries (default). If LEGACY, use the legacy ones (might be necessary to have optirun/primusrun work)" )
set_property ( CACHE OpenGL_GL_PREFERENCE PROPERTY STRINGS GLVND LEGACY )
2017-01-17 20:32:55 +00:00
find_package ( OpenGL )
2016-02-05 16:54:59 +00:00
if ( OPENGL_GL )
2014-01-18 04:11:59 +00:00
include_directories ( ${ OPENGL_INCLUDE_DIR } )
2016-02-05 16:54:59 +00:00
endif ( )
2014-01-18 04:11:59 +00:00
2018-10-03 13:03:36 +00:00
if ( ENABLE_X11 )
2024-04-18 10:58:08 +00:00
pkg_check_modules ( X11 x11 IMPORTED_TARGET )
2018-10-14 13:17:31 +00:00
if ( X11_FOUND )
add_definitions ( -DHAVE_X11=1 )
2024-04-18 10:58:08 +00:00
pkg_check_modules ( XRANDR xrandr IMPORTED_TARGET )
2018-10-14 13:17:31 +00:00
if ( XRANDR_FOUND )
add_definitions ( -DHAVE_XRANDR=1 )
endif ( )
2024-04-18 10:58:08 +00:00
pkg_check_modules ( X11_INPUT REQUIRED xi>=1.5.0 IMPORTED_TARGET )
2018-10-14 13:17:31 +00:00
message ( STATUS "X11 support enabled" )
2016-02-05 16:54:59 +00:00
else ( )
2018-10-14 13:17:31 +00:00
message ( WARNING "X11 support enabled but not found. This build will not support X11." )
2017-01-25 05:25:52 +00:00
endif ( )
2018-10-14 13:17:31 +00:00
endif ( )
2013-07-21 04:43:48 +00:00
2018-10-14 13:17:31 +00:00
if ( ENABLE_EGL )
find_package ( EGL )
if ( EGL_FOUND )
add_definitions ( -DHAVE_EGL=1 )
message ( STATUS "EGL OpenGL interface enabled" )
else ( )
message ( WARNING "EGL support enabled but not found. This build will not support EGL." )
endif ( )
2016-02-05 16:54:59 +00:00
endif ( )
2017-05-22 19:13:19 +00:00
2016-02-05 16:54:59 +00:00
if ( ENCODE_FRAMEDUMPS )
2022-03-23 19:24:35 +00:00
if ( WIN32 )
if ( _M_X86_64 )
set ( FFMPEG_DIR Externals/FFmpeg-bin/x64 )
elseif ( _M_ARM_64 )
set ( FFMPEG_DIR Externals/FFmpeg-bin/ARM64 )
endif ( )
2017-05-22 19:13:19 +00:00
endif ( )
2021-10-02 04:49:25 +00:00
find_package ( FFmpeg COMPONENTS avcodec avformat avutil swresample swscale )
2017-05-22 19:13:19 +00:00
if ( FFmpeg_FOUND )
2022-04-28 17:20:16 +00:00
if ( APPLE )
2021-10-02 04:49:25 +00:00
find_library ( COREMEDIA_LIBRARY CoreMedia )
find_library ( VIDEOTOOLBOX_LIBRARY VideoToolbox )
find_library ( COREVIDEO_LIBRARY CoreVideo )
find_library ( AUDIOTOOLBOX_LIBRARY AudioToolbox )
endif ( )
2017-05-22 19:13:19 +00:00
message ( STATUS "libav/ffmpeg found, enabling AVI frame dumps" )
2017-05-26 07:32:35 +00:00
add_definitions ( -DHAVE_FFMPEG )
2022-04-27 06:11:50 +00:00
if ( WIN32 )
# Our prebuilt binaries depend on Bcrypt
set_property ( TARGET FFmpeg::avutil APPEND PROPERTY
I N T E R F A C E _ L I N K _ L I B R A R I E S " B c r y p t . l i b "
)
endif ( )
2017-05-22 19:13:19 +00:00
else ( )
message ( STATUS "libav/ffmpeg not found, disabling AVI frame dumps" )
2013-02-26 19:49:00 +00:00
endif ( )
2016-02-05 16:54:59 +00:00
endif ( )
2010-11-14 21:14:26 +00:00
2016-02-05 16:54:59 +00:00
if ( OPROFILING )
2017-01-17 20:32:55 +00:00
find_package ( OProfile )
2016-02-05 16:54:59 +00:00
if ( OPROFILE_FOUND )
2017-01-17 20:47:24 +00:00
message ( STATUS "OProfile found, enabling profiling support" )
2016-02-05 16:54:59 +00:00
add_definitions ( -DUSE_OPROFILE=1 )
2011-01-08 05:27:18 +00:00
else ( )
2016-02-05 16:54:59 +00:00
message ( FATAL_ERROR "OProfile not found. Can't build profiling support." )
2011-01-08 05:27:18 +00:00
endif ( )
endif ( )
2012-02-18 08:46:58 +00:00
2015-06-30 11:57:54 +00:00
if ( ENABLE_EVDEV )
2020-09-09 03:24:34 +00:00
find_package ( LIBUDEV REQUIRED )
find_package ( LIBEVDEV REQUIRED )
2015-06-29 00:17:35 +00:00
if ( LIBUDEV_FOUND AND LIBEVDEV_FOUND )
2017-01-17 20:47:24 +00:00
message ( STATUS "libevdev/libudev found, enabling evdev controller backend" )
2015-06-29 00:17:35 +00:00
add_definitions ( -DHAVE_LIBUDEV=1 )
add_definitions ( -DHAVE_LIBEVDEV=1 )
else ( )
2015-06-30 11:57:54 +00:00
message ( FATAL_ERROR "Couldn't find libevdev and/or libudev. Can't build evdev controller backend.\nDisable ENABLE_EVDEV if you wish to build without controller support" )
2015-06-29 00:17:35 +00:00
endif ( )
endif ( )
2015-10-25 03:20:03 +00:00
if ( UNIX )
2017-01-17 20:47:24 +00:00
message ( STATUS "Using named pipes as controller inputs" )
2015-10-25 03:20:03 +00:00
add_definitions ( -DUSE_PIPES=1 )
2019-05-03 19:46:37 +00:00
message ( STATUS "Watching game memory for changes" )
add_definitions ( -DUSE_MEMORYWATCHER=1 )
2015-10-25 03:20:03 +00:00
endif ( )
2021-08-06 19:22:18 +00:00
if ( ENABLE_SDL )
2023-08-03 14:30:26 +00:00
dolphin_find_optional_system_library ( SDL2 Externals/SDL 2.26.0 )
2021-08-06 19:22:18 +00:00
endif ( )
2016-06-17 00:28:34 +00:00
if ( ENABLE_ANALYTICS )
2017-01-17 20:47:24 +00:00
message ( STATUS "Enabling analytics collection (subject to end-user opt-in)" )
2016-06-17 00:28:34 +00:00
add_definitions ( -DUSE_ANALYTICS=1 )
endif ( )
2022-03-15 22:40:13 +00:00
if ( ENABLE_AUTOUPDATE )
message ( STATUS "Enabling automatic update support" )
add_definitions ( -DAUTOUPDATE=1 )
endif ( )
2010-11-01 15:47:02 +00:00
########################################
# Setup include directories (and make sure they are preferred over the Externals)
#
2014-02-18 11:09:38 +00:00
include_directories ( Source/Core )
2016-01-06 21:35:15 +00:00
if ( ANDROID )
include_directories ( Source/Android )
endif ( )
2014-02-18 11:09:38 +00:00
2010-11-01 15:47:02 +00:00
########################################
# Process externals and setup their include directories
#
# NOTES about adding Externals:
2018-04-08 19:34:33 +00:00
# - If an external provides a target, or one can be introduced with find_package, consider using it.
# - If a target doesn't exist, consider introducing a target for it with add_library and adding all necessary
# includes, definitions, etc, to that target. This way, only libraries that need those attributes simply
# need to link that target in, as opposed to them being provided to every library
# (which is the case with the directory-based include_directories, add_definitions, etc)
#
2010-11-05 04:19:22 +00:00
# - make sure to tell cmake to link them statically or dynamically (most
# should be linked statically)
# - place the CMakeLists.txt in the first-level subdirectory, e.g.
2013-12-11 21:15:55 +00:00
# Externals/zlib/CMakeLists.txt (that is: NOT in some Src/ subdirectory)
2010-11-01 15:47:02 +00:00
#
2022-08-08 00:18:36 +00:00
if ( _M_X86_64 )
2018-06-22 22:52:34 +00:00
add_subdirectory ( Externals/Bochs_disasm )
endif ( )
2018-04-08 19:34:33 +00:00
add_subdirectory ( Externals/cpp-optparse )
2018-09-03 16:09:23 +00:00
2023-09-24 09:48:57 +00:00
dolphin_find_optional_system_library ( fmt Externals/fmt 10.1 )
2023-04-16 07:46:42 +00:00
2018-11-26 10:40:34 +00:00
add_subdirectory ( Externals/imgui )
2022-12-22 19:32:42 +00:00
add_subdirectory ( Externals/implot )
2018-09-03 16:09:23 +00:00
add_subdirectory ( Externals/glslang )
2023-04-06 23:30:34 +00:00
# SPIRV-Cross is used on Windows for GLSL to HLSL conversion for the Direct3D 11 and Direct3D 12
# video backends, and on Apple devices for the Metal video backend.
if ( WIN32 OR APPLE )
add_subdirectory ( Externals/spirv_cross )
endif ( )
2024-02-04 23:10:07 +00:00
add_subdirectory ( Externals/tinygltf )
2018-09-03 16:09:23 +00:00
if ( ENABLE_VULKAN )
2020-10-23 21:47:39 +00:00
add_definitions ( -DHAS_VULKAN )
2021-07-31 23:14:22 +00:00
2022-05-31 01:01:24 +00:00
if ( APPLE AND USE_BUNDLED_MOLTENVK )
2021-07-31 23:14:22 +00:00
add_subdirectory ( Externals/MoltenVK )
endif ( )
2023-05-31 22:05:06 +00:00
if ( ANDROID AND _M_ARM_64 )
add_subdirectory ( Externals/libadrenotools )
endif ( )
2018-09-03 16:09:23 +00:00
endif ( )
2018-04-15 16:42:56 +00:00
2020-10-23 21:48:37 +00:00
if ( NOT WIN32 OR ( NOT ( CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" ) ) )
# OpenGL is available on all platforms except windows-arm64
add_definitions ( -DHAS_OPENGL )
endif ( )
2023-04-16 07:46:42 +00:00
dolphin_find_optional_system_library ( pugixml Externals/pugixml )
2017-06-12 10:24:54 +00:00
2023-12-01 14:13:07 +00:00
dolphin_find_optional_system_library_pkgconfig ( ENET libenet>=1.3.18 enet::enet Externals/enet )
2010-11-01 15:47:02 +00:00
2023-11-27 06:02:39 +00:00
dolphin_find_optional_system_library_pkgconfig ( xxhash libxxhash>=0.8.2 xxhash::xxhash Externals/xxhash )
2015-01-20 21:43:26 +00:00
2023-04-16 07:46:42 +00:00
dolphin_find_optional_system_library ( BZip2 Externals/bzip2 )
2019-12-30 13:01:05 +00:00
2023-04-16 07:46:42 +00:00
dolphin_find_optional_system_library ( LibLZMA Externals/liblzma )
# Imported target added in CMake 3.14
dolphin_make_imported_target_if_missing ( LibLZMA::LibLZMA LIBLZMA )
2019-12-30 14:07:54 +00:00
2023-04-16 07:46:42 +00:00
dolphin_find_optional_system_library_pkgconfig ( ZSTD libzstd>=1.4.0 zstd::zstd Externals/zstd )
2020-05-03 17:42:12 +00:00
2023-04-10 21:49:38 +00:00
dolphin_find_optional_system_library_pkgconfig ( ZLIB zlib-ng ZLIB::ZLIB Externals/zlib-ng )
2013-12-23 23:01:34 +00:00
2024-04-21 16:38:53 +00:00
# https://github.com/zlib-ng/minizip-ng/commit/6c5f265a55f1a12a7a016cd2962feff91cff5d2e
add_definitions ( -DMZ_COMPAT_VERSION=110 ) # This macro is for forwards compatibility with 4.0.4+
2023-04-16 07:46:42 +00:00
dolphin_find_optional_system_library_pkgconfig ( MINIZIP minizip>=3.0.0 minizip::minizip Externals/minizip )
2017-09-05 05:37:40 +00:00
2023-04-16 07:46:42 +00:00
dolphin_find_optional_system_library ( LZO Externals/LZO )
2010-11-01 15:47:02 +00:00
2023-10-02 04:52:48 +00:00
dolphin_find_optional_system_library_pkgconfig ( lz4 liblz4>=1.8 LZ4::LZ4 Externals/lz4 )
2023-04-16 07:46:42 +00:00
dolphin_find_optional_system_library_pkgconfig ( SPNG spng spng::spng Externals/libspng )
2013-04-13 20:09:05 +00:00
2017-08-09 19:55:43 +00:00
# Using static FreeSurround from Externals
# There is no system FreeSurround library.
message ( STATUS "Using static FreeSurround from Externals" )
add_subdirectory ( Externals/FreeSurround )
2019-05-08 21:57:47 +00:00
if ( APPLE OR WIN32 )
2019-01-19 22:26:03 +00:00
message ( STATUS "Using ed25519 from Externals" )
add_subdirectory ( Externals/ed25519 )
2020-04-29 10:55:24 +00:00
include_directories ( Externals/ed25519 )
2019-01-19 22:26:03 +00:00
endif ( )
2017-04-10 16:44:17 +00:00
# Using static soundtouch from Externals
# Unable to use system soundtouch library: We require shorts, not floats.
add_subdirectory ( Externals/soundtouch )
2020-04-29 09:30:26 +00:00
include_directories ( Externals/soundtouch )
2013-01-09 16:26:12 +00:00
2023-04-16 07:46:42 +00:00
dolphin_find_optional_system_library ( CUBEB Externals/cubeb )
2017-03-22 23:09:04 +00:00
2016-09-28 17:32:17 +00:00
if ( NOT ANDROID )
2023-04-16 07:46:42 +00:00
dolphin_find_optional_system_library ( LibUSB Externals/libusb )
2016-11-20 13:28:40 +00:00
add_definitions ( -D__LIBUSB__ )
2016-09-28 17:32:07 +00:00
endif ( )
2012-12-23 23:58:11 +00:00
2023-04-16 07:46:42 +00:00
dolphin_find_optional_system_library ( SFML Externals/SFML 2.1 COMPONENTS network system )
2010-11-04 02:01:07 +00:00
2013-07-09 00:13:02 +00:00
if ( USE_UPNP )
2023-04-16 07:46:42 +00:00
dolphin_find_optional_system_library ( MINIUPNPC Externals/miniupnpc 1.6 )
2013-07-09 00:13:02 +00:00
add_definitions ( -DUSE_UPNP )
2010-11-18 23:27:27 +00:00
endif ( )
2010-11-04 02:01:07 +00:00
2023-04-16 07:46:42 +00:00
dolphin_find_optional_system_library ( MBEDTLS Externals/mbedtls 2.28 )
2013-08-15 11:36:17 +00:00
2023-04-16 07:46:42 +00:00
dolphin_find_optional_system_library ( CURL Externals/curl )
2016-06-17 00:28:34 +00:00
2023-03-30 18:12:48 +00:00
if ( NOT ANDROID )
2023-04-16 07:46:42 +00:00
dolphin_find_optional_system_library ( Iconv Externals/libiconv-1.14 )
2016-02-05 16:54:59 +00:00
else ( )
2017-01-17 20:47:24 +00:00
message ( STATUS "Using static iconv from Externals" )
2023-04-16 05:57:34 +00:00
add_subdirectory ( Externals/libiconv-1.14 EXCLUDE_FROM_ALL )
2016-02-05 16:54:59 +00:00
endif ( )
2016-07-24 15:20:40 +00:00
if ( NOT ANDROID )
2023-04-16 07:46:42 +00:00
dolphin_find_optional_system_library ( HIDAPI Externals/hidapi )
2016-07-24 15:20:40 +00:00
endif ( )
2018-06-08 20:56:11 +00:00
if ( USE_DISCORD_PRESENCE )
message ( STATUS "Using static DiscordRPC from Externals" )
2020-12-03 03:23:28 +00:00
add_subdirectory ( Externals/discord-rpc EXCLUDE_FROM_ALL )
2020-04-29 09:45:59 +00:00
include_directories ( Externals/discord-rpc/include )
2018-07-06 17:23:26 +00:00
endif ( )
2018-06-08 20:56:11 +00:00
2021-07-04 10:41:46 +00:00
if ( NOT ENABLE_QT )
set ( USE_MGBA 0 )
endif ( )
if ( USE_MGBA )
2023-04-16 07:46:42 +00:00
dolphin_find_optional_system_library ( LIBMGBA Externals/mGBA )
2021-07-04 10:41:46 +00:00
endif ( )
2020-09-09 03:24:34 +00:00
find_package ( SYSTEMD )
2018-03-08 06:00:40 +00:00
if ( SYSTEMD_FOUND )
message ( STATUS "libsystemd found, enabling traversal server watchdog support" )
add_definitions ( -DHAVE_LIBSYSTEMD )
else ( )
message ( STATUS "libsystemd not found, disabling traversal server watchdog support" )
endif ( )
2022-05-19 04:25:02 +00:00
if ( STEAM )
add_definitions ( -DSTEAM )
endif ( )
2020-04-29 11:07:51 +00:00
if ( WIN32 )
2021-03-04 08:59:59 +00:00
include_directories ( Externals/WIL/include )
2020-04-29 11:07:51 +00:00
include_directories ( Externals/OpenAL/include )
endif ( )
2020-04-29 09:45:59 +00:00
include_directories ( Externals/picojson )
2020-12-16 23:40:20 +00:00
add_subdirectory ( Externals/expr )
2020-05-04 22:17:06 +00:00
add_subdirectory ( Externals/rangeset )
2022-04-17 01:06:55 +00:00
add_subdirectory ( Externals/FatFs )
2023-03-18 16:22:17 +00:00
if ( USE_RETRO_ACHIEVEMENTS )
add_subdirectory ( Externals/rcheevos )
endif ( )
2023-03-11 05:24:20 +00:00
2010-11-01 15:47:02 +00:00
########################################
2011-08-21 22:07:19 +00:00
# Pre-build events: Define configuration variables and write SCM info header
2010-11-01 15:47:02 +00:00
#
2011-08-21 21:30:19 +00:00
2022-09-14 05:51:02 +00:00
# Remove in-tree revision information generated by Visual Studio
# This is because the compiler will check in-tree first and use this, even if it is outdated
file ( REMOVE "${PROJECT_SOURCE_DIR}/Source/Core/Common/scmrev.h" )
2023-06-28 17:44:01 +00:00
file ( MAKE_DIRECTORY ${ CMAKE_CURRENT_BINARY_DIR } /Source/Core/Common )
if ( NOT EXISTS ${ CMAKE_CURRENT_BINARY_DIR } /Source/Core/Common/scmrev.h )
file ( TOUCH ${ CMAKE_CURRENT_BINARY_DIR } /Source/Core/Common/scmrev.h )
endif ( )
find_package ( Git )
if ( NOT GIT_FOUND )
set ( GIT_EXECUTABLE "" )
endif ( )
add_custom_target (
d o l p h i n _ s c m r e v
2024-02-19 16:41:01 +00:00
$ { C M A K E _ C O M M A N D } - D P R O J E C T _ S O U R C E _ D I R = $ { P R O J E C T _ S O U R C E _ D I R } - D P R O J E C T _ B I N A R Y _ D I R = $ { P R O J E C T _ B I N A R Y _ D I R } - D D I S T R I B U T O R = $ { D I S T R I B U T O R } - D D O L P H I N _ D E F A U L T _ U P D A T E _ T R A C K = $ { D O L P H I N _ D E F A U L T _ U P D A T E _ T R A C K } - D G I T _ F O U N D = $ { G I T _ F O U N D } - D G I T _ E X E C U T A B L E = $ { G I T _ E X E C U T A B L E } - D D O L P H I N _ W C _ R E V I S I O N = $ { D O L P H I N _ W C _ R E V I S I O N } - D D O L P H I N _ W C _ D E S C R I B E = $ { D O L P H I N _ W C _ D E S C R I B E } - D D O L P H I N _ W C _ B R A N C H = $ { D O L P H I N _ W C _ B R A N C H } - P $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / C M a k e / S c m R e v G e n . c m a k e
2023-06-28 17:44:01 +00:00
B Y P R O D U C T S $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / S o u r c e / C o r e / C o m m o n / s c m r e v . h
V E R B A T I M
2017-02-06 06:26:44 +00:00
)
2023-06-28 17:44:01 +00:00
# This is here so #include "Common/scmrev.h" finds the generated header.
2016-06-26 03:30:32 +00:00
include_directories ( "${PROJECT_BINARY_DIR}/Source/Core" )
2010-12-19 14:02:43 +00:00
2014-03-03 02:38:46 +00:00
########################################
# Unit testing.
#
2018-12-08 22:06:23 +00:00
if ( ENABLE_TESTS )
2024-04-18 10:58:08 +00:00
dolphin_find_optional_system_library_pkgconfig ( GTEST
g t e s t g t e s t : : g t e s t E x t e r n a l s / g t e s t
)
# dolphin_find_optional_system_library_pkgconfig() doesn't add an alias if it
# uses the bundled libraries, so we add one ourselves.
if ( NOT TARGET gtest::gtest )
add_library ( gtest::gtest ALIAS gtest )
2023-06-14 13:16:01 +00:00
endif ( )
2024-04-18 10:58:08 +00:00
# Force gtest to link the C runtime dynamically on Windows in order to avoid
# runtime mismatches.
2021-04-24 21:12:30 +00:00
set ( gtest_force_shared_crt ON CACHE BOOL "" FORCE )
2018-12-08 22:06:23 +00:00
else ( )
message ( STATUS "Unit tests are disabled" )
endif ( )
2014-03-03 02:38:46 +00:00
2017-05-20 23:21:59 +00:00
########################################
# Process Dolphin source now that all setup is complete
#
2010-11-01 15:47:02 +00:00
add_subdirectory ( Source )
########################################
2010-11-04 13:47:17 +00:00
# Install shared data files
2010-11-01 15:47:02 +00:00
#
2017-02-05 19:16:27 +00:00
if ( NOT CMAKE_SYSTEM_NAME MATCHES "Darwin|Windows" )
install ( DIRECTORY Data/Sys/ DESTINATION ${ datadir } /sys PATTERN )
endif ( )
if ( NOT CMAKE_SYSTEM_NAME MATCHES "Linux|FreeBSD|OpenBSD|Darwin" )
2010-12-12 15:25:03 +00:00
install ( FILES Data/license.txt DESTINATION ${ datadir } )
endif ( )
2017-02-05 19:16:27 +00:00
if ( CMAKE_SYSTEM_NAME MATCHES "Linux|FreeBSD|OpenBSD" )
2013-01-07 22:50:48 +00:00
# Install the application icon and menu item
2016-03-09 15:54:17 +00:00
install ( FILES Data/dolphin-emu.svg
2016-02-18 17:02:54 +00:00
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ P R E F I X } / s h a r e / i c o n s / h i c o l o r / s c a l a b l e / a p p s )
2016-03-09 15:54:17 +00:00
install ( FILES Data/dolphin-emu.png
2018-03-26 06:13:15 +00:00
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ P R E F I X } / s h a r e / i c o n s / h i c o l o r / 2 5 6 x 2 5 6 / a p p s )
2016-03-09 15:54:17 +00:00
install ( FILES Data/dolphin-emu.desktop
2013-01-07 22:50:48 +00:00
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ P R E F I X } / s h a r e / a p p l i c a t i o n s )
2016-03-04 04:21:39 +00:00
# Install manpages
install ( FILES Data/dolphin-emu.6
2022-10-11 18:44:04 +00:00
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ M A N D I R } / m a n 6 )
2016-03-04 04:21:39 +00:00
install ( FILES Data/dolphin-emu-nogui.6
2022-10-11 18:44:04 +00:00
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ M A N D I R } / m a n 6 )
2013-01-07 22:50:48 +00:00
endif ( )
2010-11-01 15:47:02 +00:00
# packaging information
set ( CPACK_PACKAGE_NAME "dolphin-emu" )
set ( CPACK_PACKAGE_VENDOR "Dolphin Team" )
2011-12-11 15:21:17 +00:00
set ( CPACK_PACKAGE_VERSION_MAJOR ${ DOLPHIN_VERSION_MAJOR } )
set ( CPACK_PACKAGE_VERSION_MINOR ${ DOLPHIN_VERSION_MINOR } )
set ( CPACK_PACKAGE_VERSION_PATCH ${ DOLPHIN_VERSION_PATCH } )
2012-12-22 11:51:01 +00:00
set ( CPACK_PACKAGE_DESCRIPTION_FILE ${ PROJECT_SOURCE_DIR } /Data/cpack_package_description.txt )
2016-08-10 17:23:21 +00:00
set ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "A GameCube and Wii emulator" )
2010-11-01 15:47:02 +00:00
2012-12-22 11:51:01 +00:00
set ( CPACK_RPM_PACKAGE_GROUP System/Emulators/Other )
set ( CPACK_RPM_PACKAGE_LICENSE GPL-2.0 )
2010-11-01 15:47:02 +00:00
# TODO: CPACK_RESOURCE_FILE_README
# TODO: CPACK_RESOURCE_FILE_WELCOME
# TODO: CPACK_PACKAGE_ICON
# TODO: CPACK_NSIS_*
# TODO: Use CPack components for DSPSpy, etc => cpack_add_component
2010-11-11 15:50:52 +00:00
2021-10-16 00:29:49 +00:00
# Debian Specific. Install dpkg-dev for automatic deps generation
set ( CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON )
set ( CPACK_DEBIAN_PACKAGE_SECTION "Games" )
2010-12-15 14:47:13 +00:00
set ( CPACK_SET_DESTDIR ON )
set ( CPACK_SOURCE_GENERATOR "TGZ;TBZ2;ZIP" )
2012-12-22 11:51:01 +00:00
set ( CPACK_SOURCE_IGNORE_FILES "\\\\.#;/#;.*~;\\\\.swp;/\\\\.git" )
2010-12-15 14:47:13 +00:00
list ( APPEND CPACK_SOURCE_IGNORE_FILES "${CMAKE_BINARY_DIR}" )
2010-11-11 15:50:52 +00:00
# CPack must be included after the CPACK_* variables are set in order for those
# variables to take effect.
2013-02-26 19:49:00 +00:00
Include ( CPack )