2010-11-01 15:47:02 +00:00
########################################
# General setup
#
2017-01-16 21:40:57 -05:00
cmake_minimum_required(VERSION 3.5.0)
2017-01-23 23:44:15 -08:00
set(CMAKE_OSX_ARCHITECTURES "x86_64")
2017-01-23 23:45:54 -08:00
# Minimum OS X version.
# This is inserted into the Info.plist as well.
# Note that the SDK determines the maximum version of which optional
# features can be used, not the minimum required version to run.
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE string "")
2012-03-13 17:14:00 -07:00
2017-01-23 23:44:15 -08:00
project(dolphin-emu)
2013-02-11 13:08:41 -06:00
option(USE_EGL "Enables EGL OpenGL Interface" OFF)
2014-08-06 19:08:24 -04:00
option(TRY_X11 "Enables X11 Support" ON)
2015-06-02 18:30:09 -04:00
option(USE_SHARED_ENET "Use shared libenet if found rather than Dolphin's soon-to-compatibly-diverge version" OFF)
2016-03-03 22:55:44 -05:00
option(USE_SHARED_GTEST "Use shared gtest library if found" OFF)
2013-07-08 20:13:02 -04:00
option(USE_UPNP "Enables UPnP port mapping support" ON)
2014-09-14 15:03:07 -04:00
option(DISABLE_WX "Disable wxWidgets (use Qt or CLI interface)" OFF)
2015-11-27 00:33:07 -08:00
option(ENABLE_QT2 "Enable Qt2 (use the other experimental Qt interface)" OFF)
2014-04-23 04:15:25 -05:00
option(ENABLE_LTO "Enables Link Time Optimization" OFF)
2014-05-25 20:52:52 -05:00
option(ENABLE_GENERIC "Enables generic build that should run on any little-endian host" OFF)
2016-01-26 07:35:17 -06: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_AO "Enables libao sound backend" ON)
option(ENABLE_PULSEAUDIO "Enables PulseAudio sound backend" ON)
option(ENABLE_OPENAL "Enables OpenAL sound backend" ON)
2016-12-03 18:37:02 +00:00
option(ENABLE_LLVM "Enables LLVM support, for disassembly" ON)
2016-12-03 18:37:23 +00:00
option(ENABLE_BLUEZ "Enables bluetooth support" ON)
2015-06-29 13:09:24 +12:00
2016-06-17 02:28:34 +02: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)
2016-06-18 00:13:37 +02: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.")
2015-06-29 13:09:24 +12:00
# Enable SDL for default on operating systems that aren't OSX, Android, Linux or Windows.
if(NOT APPLE AND NOT ANDROID AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND NOT MSVC)
option(ENABLE_SDL "Enables SDL as a generic controller backend" ON)
else()
option(ENABLE_SDL "Enables SDL as a generic controller backend" OFF)
endif()
2015-06-30 23:57:54 +12:00
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND NOT ANDROID)
option(ENABLE_EVDEV "Enables the evdev controller backend" ON)
endif()
2014-10-29 00:11:57 -04:00
if(APPLE)
option(OSX_USE_DEFAULT_SEARCH_PATH "Don't prioritize system library paths" OFF)
endif()
2013-01-25 13:55:05 -06:00
option(ENCODE_FRAMEDUMPS "Encode framedumps in AVI format" ON)
2014-04-23 04:11:41 -05:00
option(FASTLOG "Enable all logs" OFF)
option(OPROFILING "Enable profiling" OFF)
option(GDBSTUB "Enable gdb stub for remote debugging." OFF)
2015-02-12 01:36:29 +01:00
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
option(VTUNE "Enable Intel VTune integration for JIT symbols." OFF)
endif()
2014-11-05 20:53:34 -05:00
2015-01-03 13:17:57 +01:00
if(APPLE)
2014-11-05 20:53:34 -05:00
option(SKIP_POSTPROCESS_BUNDLE "Skip postprocessing bundle for redistributability" OFF)
endif()
2013-01-25 13:55:05 -06:00
########################################
# Optional Targets
2014-02-23 16:21:01 +01:00
# TODO: Add DSPSpy
2013-01-25 13:55:05 -06:00
option(DSPTOOL "Build dsptool" OFF)
2017-01-25 01:48:16 +01:00
list(APPEND CMAKE_MODULE_PATH
${CMAKE_SOURCE_DIR}/CMakeTests
)
# Support functions
include(CheckAndAddFlag)
2017-01-25 05:23:06 +01:00
include(CheckCCompilerFlag)
2017-01-25 16:20:03 +01:00
include(DolphinCompileDefinitions)
2017-01-25 01:48:16 +01:00
2017-02-03 04:19:23 +01:00
# Enable folders for IDE
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
2014-11-19 19:55:52 -05:00
# Libraries to link
set(LIBS)
2010-11-04 13:47:17 +00:00
# Set up paths
2017-02-05 20:16:27 +01:00
set(bindir ${CMAKE_INSTALL_PREFIX}/bin CACHE PATH "bindir")
set(datadir ${CMAKE_INSTALL_PREFIX}/share/dolphin-emu CACHE PATH "datadir")
set(mandir ${CMAKE_INSTALL_PREFIX}/share/man CACHE PATH "mandir")
add_definitions(-DDATA_DIR="${datadir}/")
2010-11-04 13:47:17 +00:00
2017-01-17 21:34:18 +01: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
2017-01-17 22:38:02 +01:00
# setup CCache
include(CCache)
2011-08-14 13:17:57 -07:00
# for revision info
2017-01-17 21:32:55 +01:00
find_package(Git)
2011-08-14 13:17:57 -07:00
if(GIT_FOUND AND NOT DOLPHIN_WC_REVISION)
2013-07-10 21:49:13 -05:00
# defines DOLPHIN_WC_REVISION
2013-05-22 23:34:02 +12:00
EXECUTE_PROCESS(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
2013-07-10 21:49:13 -05:00
OUTPUT_VARIABLE DOLPHIN_WC_REVISION
OUTPUT_STRIP_TRAILING_WHITESPACE)
# defines DOLPHIN_WC_DESCRIBE
2013-05-22 23:34:02 +12:00
EXECUTE_PROCESS(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} describe --always --long --dirty
2013-07-10 21:49:13 -05:00
OUTPUT_VARIABLE DOLPHIN_WC_DESCRIBE
OUTPUT_STRIP_TRAILING_WHITESPACE)
2011-08-22 20:06:17 -05:00
2013-08-10 17:12:24 -05:00
# remove hash (and trailing "-0" if needed) from description
STRING(REGEX REPLACE "(-0)?-[^-]+((-dirty)?)$" "\\2" DOLPHIN_WC_DESCRIBE "${DOLPHIN_WC_DESCRIBE}")
2011-08-22 20:06:17 -05:00
2013-07-10 21:49:13 -05:00
# defines DOLPHIN_WC_BRANCH
2013-05-22 23:34:02 +12:00
EXECUTE_PROCESS(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
2013-07-10 21:49:13 -05:00
OUTPUT_VARIABLE DOLPHIN_WC_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE)
2011-08-20 14:05:43 -07:00
endif()
2011-12-11 16:21:17 +01:00
# version number
2016-06-24 10:09:07 +02:00
set(DOLPHIN_VERSION_MAJOR "5")
2013-09-21 07:29:41 +02:00
set(DOLPHIN_VERSION_MINOR "0")
2015-06-09 21:06:28 +02:00
if(DOLPHIN_WC_BRANCH STREQUAL "stable")
2011-12-11 16:21:17 +01:00
set(DOLPHIN_VERSION_PATCH "0")
else()
set(DOLPHIN_VERSION_PATCH ${DOLPHIN_WC_REVISION})
endif()
2014-03-02 05:21:50 -06:00
2016-05-29 18:26:53 +02:00
# If Dolphin is not built from a Git repository, default the version info to
# reasonable values.
if(NOT DOLPHIN_WC_REVISION)
set(DOLPHIN_WC_DESCRIBE "${DOLPHIN_VERSION_MAJOR}.${DOLPHIN_VERSION_MINOR}")
set(DOLPHIN_WC_REVISION "${DOLPHIN_WC_DESCRIBE} (no further info)")
set(DOLPHIN_WC_BRANCH "master")
endif()
2014-03-02 05:21:50 -06:00
# Architecture detection and arch specific settings
2017-01-17 21:47:24 +01:00
message(STATUS "Detected architecture: ${CMAKE_SYSTEM_PROCESSOR}")
2014-03-02 05:21:50 -06: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-25 20:52:52 -05:00
if(ENABLE_GENERIC)
2017-01-17 21:47:24 +01:00
message(STATUS "Warning! Building generic build!")
2014-03-02 05:21:50 -06:00
set(_M_GENERIC 1)
add_definitions(-D_M_GENERIC=1)
2017-01-27 00:56:38 -08:00
elseif(_ARCH_64 AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64")
2016-06-08 19:49:46 +02:00
set(_M_X86 1)
set(_M_X86_64 1)
2017-01-25 06:02:01 +01:00
add_definitions(-D_M_X86=1)
add_definitions(-D_M_X86_64=1)
check_and_add_flag(HAVE_SSE2 -msse2)
2017-01-25 06:03:44 +01:00
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
2016-06-08 19:49:46 +02:00
set(_M_ARM 1)
set(_M_ARM_64 1)
2017-01-25 06:02:01 +01:00
add_definitions(-D_M_ARM=1)
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 19:49:46 +02:00
else()
2017-01-27 00:56:38 -08:00
message(FATAL_ERROR "You're building on an unsupported platform: "
"'${CMAKE_SYSTEM_PROCESSOR}' with ${CMAKE_SIZEOF_VOID_P}-byte pointers."
" Enable generic build if you really want a JIT-less binary.")
2013-02-26 13:49:00 -06:00
endif()
2011-01-09 16:36:19 +00:00
2013-01-29 21:28:55 -06:00
2017-01-17 20:00:56 +01:00
# Enforce minimum GCC version
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
message(FATAL_ERROR "Dolphin requires at least GCC 5.0 (found ${CMAKE_CXX_COMPILER_VERSION})")
endif()
2017-01-25 06:06:25 +01:00
if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
check_and_add_flag(EXCEPTIONS /EHsc)
2017-01-25 16:20:03 +01:00
dolphin_compile_definitions(-D_DEBUG DEBUG_ONLY)
2017-01-25 06:08:19 +01:00
2017-02-03 04:42:52 +01:00
string(APPEND CMAKE_EXE_LINKER_FLAGS " /NXCOMPAT")
string(APPEND CMAKE_EXE_LINKER_FLAGS " /BASE:0x00400000")
string(APPEND CMAKE_EXE_LINKER_FLAGS " /DYNAMICBASE:NO")
string(APPEND CMAKE_EXE_LINKER_FLAGS " /FIXED")
2017-01-25 06:08:19 +01:00
# Only MSBuild needs this, other generators will compile one file at a time
if(CMAKE_GENERATOR MATCHES "Visual Studio")
add_compile_options("/MP")
endif()
2017-01-25 06:06:25 +01:00
else()
2016-06-16 17:31:51 -03:00
add_definitions(-D_DEFAULT_SOURCE)
2017-01-25 06:02:01 +01:00
check_and_add_flag(HAVE_WALL -Wall)
2013-01-29 21:28:55 -06:00
# TODO: would like these but they produce overwhelming amounts of warnings
#check_and_add_flag(EXTRA -Wextra)
#check_and_add_flag(MISSING_FIELD_INITIALIZERS -Wmissing-field-initializers)
#check_and_add_flag(SWITCH_DEFAULT -Wswitch-default)
#check_and_add_flag(FLOAT_EQUAL -Wfloat-equal)
#check_and_add_flag(CONVERSION -Wconversion)
#check_and_add_flag(ZERO_AS_NULL_POINTER_CONSTANT -Wzero-as-null-pointer-constant)
check_and_add_flag(TYPE_LIMITS -Wtype-limits)
check_and_add_flag(SIGN_COMPARE -Wsign-compare)
check_and_add_flag(IGNORED_QUALIFIERS -Wignored-qualifiers)
check_and_add_flag(UNINITIALIZED -Wuninitialized)
check_and_add_flag(LOGICAL_OP -Wlogical-op)
check_and_add_flag(SHADOW -Wshadow)
check_and_add_flag(INIT_SELF -Winit-self)
2014-07-08 14:01:59 +02:00
check_and_add_flag(MISSING_DECLARATIONS -Wmissing-declarations)
2014-07-08 14:51:14 +02:00
check_and_add_flag(MISSING_VARIABLE_DECLARATIONS -Wmissing-variable-declarations)
2017-01-25 05:33:36 +01:00
2017-01-25 05:33:36 +01: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)
check_and_add_flag(VISIBILITY_INLINES_HIDDEN -fvisibility-inlines-hidden)
check_and_add_flag(VISIBILITY_HIDDEN -fvisibility=hidden)
2017-01-25 16:19:35 +01:00
check_and_add_flag(FOMIT_FRAME_POINTER -fomit-frame-pointer RELEASE_ONLY)
2017-01-25 16:20:03 +01:00
dolphin_compile_definitions(_DEBUG DEBUG_ONLY)
2017-01-25 16:19:35 +01:00
check_and_add_flag(GGDB -ggdb DEBUG_ONLY)
2017-01-25 06:07:01 +01:00
if(NOT ANDROID AND _M_X86_64)
# PIE is required on Android, but not supported with the x86_64 jit currently
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-pie")
check_c_compiler_flag("-no-pie" NO_PIE_UPSTREAM)
if(NO_PIE_UPSTREAM)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -no-pie")
endif()
endif()
2017-01-25 06:06:25 +01:00
endif()
2010-11-01 15:47:02 +00:00
2017-01-27 00:58:21 -08:00
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
2014-10-29 00:11:57 -04:00
if(NOT OSX_USE_DEFAULT_SEARCH_PATH)
# 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 13:32:07 -04: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 00:11:57 -04:00
# See http://www.cmake.org/cmake/help/v3.0/command/find_program.html
2017-01-25 06:03:44 +01:00
list(APPEND CMAKE_PREFIX_PATH "/usr")
2014-10-29 00:11:57 -04:00
endif()
2011-12-05 05:42:02 +01:00
2011-12-11 21:27:06 +01:00
# Specify target CPUs.
2017-01-25 05:49:47 +01:00
check_and_add_flag(HAVE_MSSSE3 -mssse3)
check_and_add_flag(HAVE_ARCH_CORE2 -march=core2)
2011-12-11 21:27:06 +01:00
# Linker flags.
# Drop unreachable code and data.
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-dead_strip,-dead_strip_dylibs")
# Reserve the minimum size for the zero page.
# Our JIT requires virtual memory space below 2GB, while the default zero
# page on x86_64 is 4GB in size.
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-pagezero_size,0x1000")
2011-12-07 08:26:44 +01:00
find_library(APPKIT_LIBRARY AppKit)
find_library(APPSERV_LIBRARY ApplicationServices)
find_library(AU_LIBRARY AudioUnit)
find_library(CARBON_LIBRARY Carbon)
find_library(COCOA_LIBRARY Cocoa)
find_library(COREAUDIO_LIBRARY CoreAudio)
find_library(COREFUND_LIBRARY CoreFoundation)
find_library(CORESERV_LIBRARY CoreServices)
2016-07-23 15:06:45 -04:00
find_library(FOUNDATION_LIBRARY Foundation)
2011-12-07 08:26:44 +01:00
find_library(IOB_LIBRARY IOBluetooth)
find_library(IOK_LIBRARY IOKit)
2014-01-29 08:11:51 +09:00
find_library(FORCEFEEDBACK ForceFeedback)
2014-10-22 00:25:01 -07:00
find_library(OPENGL_LIBRARY OpenGL)
2017-01-23 23:58:33 -08:00
# Link against OS X system frameworks.
list(APPEND LIBS
${APPKIT_LIBRARY}
${AU_LIBRARY}
${COREAUDIO_LIBRARY}
${COREFUND_LIBRARY}
${CORESERV_LIBRARY}
${IOK_LIBRARY}
${FORCEFEEDBACK}
)
2011-02-07 15:51:38 +00:00
endif()
2011-12-07 08:26:44 +01:00
2017-01-25 05:51:09 +01:00
if(ENABLE_LTO)
check_and_add_flag(LTO -flto)
if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
set(CMAKE_AR gcc-ar)
set(CMAKE_RANLIB gcc-ranlib)
endif()
endif()
2015-11-07 10:50:47 -08:00
# Add an option to build relocatable binaries on Linux
# The Sys folder will need to be copied to the Binaries folder.
if(UNIX)
2015-11-10 14:15:08 -08:00
option(LINUX_LOCAL_DEV "Enable relocatable binary" OFF)
if(LINUX_LOCAL_DEV)
2017-01-25 06:02:01 +01:00
add_definitions(-DLINUX_LOCAL_DEV)
2017-01-25 06:25:52 +01:00
endif()
endif()
2015-11-07 10:50:47 -08:00
2017-01-16 20:41:53 -08: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
2017-01-25 06:03:44 +01:00
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD|NetBSD")
2017-01-16 20:41:53 -08: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")
endif()
2015-06-29 13:57:30 +12:00
# Dolphin requires threads.
2017-01-24 00:09:32 -08:00
find_package(Threads)
2015-06-29 13:57:30 +12: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 03:50:39 +01:00
"Build type (Release/Debug/RelWithDebInfo/MinSizeRel)" FORCE)
2017-01-25 06:25:52 +01:00
endif()
2010-11-05 04:19:22 +00:00
2017-01-25 23:32:13 +01:00
option(ENABLE_GPROF "Enable gprof profiling (must be using Debug build)" OFF)
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 17:48:22 +13:00
endif()
2017-01-25 23:32:13 +01:00
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg")
2017-01-25 06:02:01 +01:00
endif()
2010-11-05 02:23:24 +00:00
2010-12-13 05:29:13 +00:00
if(FASTLOG)
add_definitions(-DDEBUGFAST)
endif()
2013-01-06 23:28:27 +13:00
if(GDBSTUB)
add_definitions(-DUSE_GDBSTUB)
2017-01-25 06:25:52 +01:00
endif()
2013-01-06 23:28:27 +13:00
2015-02-12 01:36:29 +01:00
if(VTUNE)
if(EXISTS "$ENV{VTUNE_AMPLIFIER_XE_2015_DIR}")
set(VTUNE_DIR "$ENV{VTUNE_AMPLIFIER_XE_2015_DIR}")
elseif(EXISTS "$ENV{VTUNE_AMPLIFIER_XE_2013_DIR}")
set(VTUNE_DIR "$ENV{VTUNE_AMPLIFIER_XE_2013_DIR}")
else()
message(ERROR "Could find neither VTUNE_AMPLIFIER_XE_2015_DIR nor VTUNE_AMPLIFIER_XE_2013_DIR.")
endif()
add_definitions(-DUSE_VTUNE)
include_directories("${VTUNE_DIR}/include")
2015-02-22 20:49:30 +01:00
set(VTUNE_LIBRARIES
"${VTUNE_DIR}/lib64/libjitprofiling.a"
"${VTUNE_DIR}/lib64/libittnotify.a"
)
2017-01-25 06:25:52 +01:00
endif()
2015-02-12 01:36:29 +01:00
2013-07-13 18:42:04 -05:00
if(ANDROID)
2017-01-17 21:47:24 +01:00
message(STATUS "Building for Android")
2016-02-05 10:54:59 -06:00
if(NOT ENABLE_HEADLESS)
add_definitions(-DANDROID)
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 18:42:04 -05:00
set(USE_X11 0)
set(USE_UPNP 0)
2014-08-06 19:08:24 -04:00
set(USE_EGL 1)
2016-02-05 10:54:59 -06:00
set(DISABLE_WX 1)
set(ENABLE_QT2 0)
# 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 21:34:18 +01:00
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
2016-06-08 19:49:46 +02:00
SET(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
2017-01-20 22:55:20 +01:00
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
2016-02-05 10:54:59 -06:00
list(APPEND LIBS rt)
2013-07-13 18:42:04 -05:00
endif()
2016-01-26 07:35:17 -06:00
if(ENABLE_HEADLESS)
2017-01-17 21:47:24 +01:00
message(STATUS "Enabling Headless! Disabling GUI, force enabling EGL!")
2016-01-26 07:35:17 -06:00
set(USE_X11 0)
set(USE_EGL 1)
set(DISABLE_WX 1)
set(ENABLE_QT2 0)
add_definitions(-DUSE_HEADLESS)
endif()
2017-01-25 03:51:17 +01:00
# Set file offset size to 64 bits.
#
# On modern Unixes, this is typically already the case. The lone exception is
# glibc, which may default to 32 bits. glibc allows this to be configured
# by setting _FILE_OFFSET_BITS.
if(NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
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 05:40:16 -05:00
include(CheckLib)
include(CheckCXXSourceRuns)
2013-11-24 16:28:20 -06:00
2017-01-17 21:32:55 +01:00
find_package(OpenGL)
2016-02-05 10:54:59 -06:00
if (OPENGL_GL)
2014-01-18 04:11:59 +00:00
include_directories(${OPENGL_INCLUDE_DIR})
2016-02-05 10:54:59 -06:00
endif()
2014-01-18 04:11:59 +00:00
2016-12-03 18:37:23 +00:00
if(ENABLE_BLUEZ)
check_lib(BLUEZ bluez bluez QUIET)
if(BLUEZ_FOUND)
add_definitions(-DHAVE_BLUEZ=1)
2017-01-17 21:47:24 +01:00
message(STATUS "bluez found, enabling bluetooth support")
2016-12-03 18:37:23 +00:00
else()
add_definitions(-DHAVE_BLUEZ=0)
2017-01-17 21:47:24 +01:00
message(STATUS "bluez NOT found, disabling bluetooth support")
2016-12-03 18:37:23 +00:00
endif()
2016-02-05 10:54:59 -06:00
else()
2017-01-17 21:47:24 +01:00
message(STATUS "bluez explicitly disabled, disabling bluetooth support")
2016-12-03 18:37:23 +00:00
endif()
2016-02-05 10:54:59 -06:00
2016-12-03 18:36:34 +00:00
if(ENABLE_PULSEAUDIO)
check_lib(PULSEAUDIO libpulse pulse QUIET)
if(PULSEAUDIO_FOUND)
add_definitions(-DHAVE_PULSEAUDIO=1)
2017-01-17 21:47:24 +01:00
message(STATUS "PulseAudio found, enabling PulseAudio sound backend")
2016-12-03 18:36:34 +00:00
else()
add_definitions(-DHAVE_PULSEAUDIO=0)
2017-01-17 21:47:24 +01:00
message(STATUS "PulseAudio NOT found, disabling PulseAudio sound backend")
2016-12-03 18:36:34 +00:00
endif()
2016-02-05 10:54:59 -06:00
else()
2017-01-17 21:47:24 +01:00
message(STATUS "PulseAudio explicitly disabled, disabling PulseAudio sound backend")
2016-12-03 18:36:34 +00:00
endif()
if(ENABLE_OPENAL)
2017-02-03 04:50:12 +01:00
if(WIN32)
set(ENV{OPENALDIR} ${CMAKE_CURRENT_LIST_DIR}/Externals/OpenAL)
endif()
2017-01-17 21:32:55 +01:00
find_package(OpenAL)
2016-12-03 18:36:34 +00:00
if(OPENAL_FOUND)
add_definitions(-DHAVE_OPENAL=1)
include_directories(${OPENAL_INCLUDE_DIR})
2017-01-17 21:47:24 +01:00
message(STATUS "OpenAL found, enabling OpenAL sound backend")
2016-12-03 18:36:34 +00:00
else()
add_definitions(-DHAVE_OPENAL=0)
2017-01-17 21:47:24 +01:00
message(STATUS "OpenAL NOT found, disabling OpenAL sound backend")
2016-12-03 18:36:34 +00:00
endif()
2016-02-05 10:54:59 -06:00
else()
2017-01-17 21:47:24 +01:00
message(STATUS "OpenAL explicitly disabled, disabling OpenAL sound backend")
2016-12-03 18:36:34 +00:00
endif()
2014-10-21 05:56:01 -05:00
2016-12-03 18:37:02 +00:00
if(ENABLE_LLVM)
2017-01-17 21:32:55 +01:00
find_package(LLVM)
2016-12-03 18:37:02 +00:00
if (LLVM_FOUND)
add_definitions(-DHAS_LLVM=1)
set(HAS_LLVM 1)
2014-10-21 05:56:01 -05:00
2016-12-03 18:37:02 +00:00
include_directories(${LLVM_INCLUDE_DIRS})
list(APPEND LIBS ${LLVM_LIBRARIES})
2014-10-21 05:56:01 -05:00
2016-12-03 18:37:02 +00:00
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
endif()
2016-02-05 10:54:59 -06:00
endif()
2014-08-06 19:08:24 -04:00
2016-02-05 10:54:59 -06:00
set(USE_X11 0)
if(UNIX AND NOT APPLE AND NOT ANDROID AND NOT ENABLE_HEADLESS)
2017-01-17 21:32:55 +01:00
find_package(X11)
2016-02-05 10:54:59 -06:00
if(TRY_X11 AND X11_FOUND)
set(USE_X11 1)
add_definitions(-DHAVE_X11=1)
include_directories(${X11_INCLUDE_DIR})
2017-01-17 21:47:24 +01:00
message(STATUS "X11 support enabled")
2016-02-05 10:54:59 -06:00
else()
set(USE_X11 0)
SET(X11_FOUND "")
2017-01-17 21:47:24 +01:00
message(STATUS "X11 support disabled")
2016-02-05 10:54:59 -06:00
add_definitions(-DHAVE_X11=0)
2017-01-25 06:25:52 +01:00
endif()
2016-02-05 10:54:59 -06:00
if (NOT USE_X11)
message(FATAL_ERROR "\n"
"No suitable display platform found\n"
"Requires x11 to run")
2013-02-26 13:49:00 -06:00
endif()
2016-02-05 10:54:59 -06:00
endif()
2010-11-01 15:47:02 +00:00
2016-02-05 10:54:59 -06:00
if(USE_X11)
check_lib(XRANDR xrandr Xrandr)
if(XRANDR_FOUND)
add_definitions(-DHAVE_XRANDR=1)
else()
add_definitions(-DHAVE_XRANDR=0)
2017-01-25 06:25:52 +01:00
endif()
2013-07-21 00:43:48 -04:00
2017-01-21 02:35:46 +01:00
pkg_check_modules(X11_INPUT REQUIRED xi>=1.5.0)
2016-02-05 10:54:59 -06:00
endif()
if(ENCODE_FRAMEDUMPS)
check_libav()
if(LIBAV_FOUND)
LIST(APPEND LIBS ${LIBAV_LDFLAGS})
2013-02-26 13:49:00 -06:00
endif()
2014-11-19 19:55:52 -05:00
2016-02-05 10:54:59 -06:00
endif()
2010-11-14 21:14:26 +00:00
2016-09-28 13:43:01 -04:00
if(NOT ANDROID)
2016-02-05 10:54:59 -06:00
set(PORTAUDIO_FOUND TRUE)
2016-09-28 13:43:01 -04:00
add_definitions(-DHAVE_PORTAUDIO=1)
if(NOT APPLE)
set(CMAKE_REQUIRED_LIBRARIES portaudio)
CHECK_CXX_SOURCE_RUNS(
"#include <portaudio.h>
int main(int argc, char **argv)
{ if(Pa_GetVersion() >= 1890) return 0; else return 1; }"
SYSTEM_PORTAUDIO)
unset(CMAKE_REQUIRED_LIBRARIES)
endif()
if(SYSTEM_PORTAUDIO AND NOT APPLE)
2017-01-17 21:47:24 +01:00
message(STATUS "Using shared PortAudio for mic support")
2016-10-25 15:19:54 -07:00
set(PORTAUDIO_LIBRARIES portaudio)
2016-09-28 13:43:01 -04:00
else()
2017-01-17 21:47:24 +01:00
message(STATUS "Using static PortAudio from Externals for mic support")
2017-01-27 01:32:23 -08:00
option(PA_USE_ASIO "Enable PortAudio support for ASIO" OFF)
option(PA_USE_DS "Enable PortAudio support for DirectSound" OFF)
option(PA_USE_WDMKS "Enable PortAudio support for WDMKS" OFF)
2017-02-03 04:24:13 +01:00
add_subdirectory(Externals/portaudio EXCLUDE_FROM_ALL)
2016-10-25 15:19:54 -07:00
set(PORTAUDIO_LIBRARIES portaudio_static)
2016-09-28 13:43:01 -04:00
endif()
endif()
2016-02-05 10:54:59 -06:00
if(OPROFILING)
2017-01-17 21:32:55 +01:00
find_package(OProfile)
2016-02-05 10:54:59 -06:00
if(OPROFILE_FOUND)
2017-01-17 21:47:24 +01:00
message(STATUS "OProfile found, enabling profiling support")
2016-02-05 10:54:59 -06:00
add_definitions(-DUSE_OPROFILE=1)
include_directories(${OPROFILE_INCLUDE_DIRS})
2011-01-08 05:27:18 +00:00
else()
2016-02-05 10:54:59 -06: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 09:46:58 +01:00
2014-08-06 19:08:24 -04:00
if(USE_EGL)
2017-01-17 21:47:24 +01:00
message(STATUS "EGL OpenGL interface enabled")
2014-08-06 19:08:24 -04:00
add_definitions(-DUSE_EGL=1)
endif()
2015-06-30 23:57:54 +12:00
if(ENABLE_EVDEV)
2017-01-17 21:32:55 +01:00
find_package(Libudev REQUIRED)
find_package(Libevdev REQUIRED)
2015-06-29 12:17:35 +12:00
if(LIBUDEV_FOUND AND LIBEVDEV_FOUND)
2017-01-17 21:47:24 +01:00
message(STATUS "libevdev/libudev found, enabling evdev controller backend")
2015-06-29 12:17:35 +12:00
add_definitions(-DHAVE_LIBUDEV=1)
add_definitions(-DHAVE_LIBEVDEV=1)
include_directories(${LIBUDEV_INCLUDE_DIR} ${LIBEVDEV_INCLUDE_DIR})
else()
2015-06-30 23:57:54 +12: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 12:17:35 +12:00
endif()
endif()
2015-10-24 20:20:03 -07:00
if(UNIX)
2017-01-17 21:47:24 +01:00
message(STATUS "Using named pipes as controller inputs")
2015-10-24 20:20:03 -07:00
add_definitions(-DUSE_PIPES=1)
2017-01-17 21:47:24 +01:00
message(STATUS "Watching game memory for changes")
2015-12-29 17:59:16 -08:00
add_definitions(-DUSE_MEMORYWATCHER=1)
2015-10-24 20:20:03 -07:00
endif()
2016-06-17 02:28:34 +02:00
if(ENABLE_ANALYTICS)
2017-01-17 21:47:24 +01:00
message(STATUS "Enabling analytics collection (subject to end-user opt-in)")
2016-06-17 02:28:34 +02:00
add_definitions(-DUSE_ANALYTICS=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 12:09:38 +01:00
include_directories(Source/Core)
2016-01-06 15:35:15 -06:00
if(ANDROID)
include_directories(Source/Android)
endif()
2014-02-18 12:09:38 +01:00
2010-11-01 15:47:02 +00:00
########################################
# Process externals and setup their include directories
#
# NOTES about adding Externals:
2010-11-05 04:19:22 +00:00
# - add the include directory here
# - 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 15:15:55 -06:00
# Externals/zlib/CMakeLists.txt (that is: NOT in some Src/ subdirectory)
2010-11-01 15:47:02 +00:00
#
add_subdirectory(Externals/Bochs_disasm)
include_directories(Externals/Bochs_disasm)
2015-02-15 04:34:44 -08:00
2016-06-26 15:06:20 +10:00
add_subdirectory(Externals/glslang)
2016-02-05 10:54:59 -06:00
if(USE_SHARED_ENET)
2015-06-02 18:00:50 -04:00
check_lib(ENET libenet enet enet/enet.h QUIET)
2015-06-02 18:28:11 -04:00
include(CheckSymbolExists)
if (ENET_FOUND)
set(CMAKE_REQUIRED_INCLUDES ${ENET_INCLUDE_DIRS})
# hack: LDFLAGS already contains -lenet but all flags but the first are
# dropped; ugh, cmake
set(CMAKE_REQUIRED_FLAGS ${ENET_LDFLAGS})
set(CMAKE_REQUIRED_LIBRARIES ${ENET_LIBRARIES})
CHECK_SYMBOL_EXISTS(enet_socket_get_address enet/enet.h ENET_HAVE_SGA)
set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_FLAGS)
set(CMAKE_REQUIRED_LIBRARIES)
if (NOT ENET_HAVE_SGA)
# enet is too old
set(ENET_FOUND FALSE)
endif()
endif()
2015-03-01 02:45:04 +01:00
endif()
if (ENET_FOUND)
2017-01-17 21:47:24 +01:00
message(STATUS "Using shared enet")
2015-03-01 02:45:04 +01:00
else()
2017-01-17 21:47:24 +01:00
message(STATUS "Using static enet from Externals")
2015-03-01 02:45:04 +01:00
include_directories(Externals/enet/include)
2015-02-15 04:34:44 -08:00
add_subdirectory(Externals/enet)
endif()
LIST(APPEND LIBS enet)
2010-11-01 15:47:02 +00:00
2015-01-20 22:43:26 +01:00
if(NOT XXHASH_FOUND)
2017-01-17 21:47:24 +01:00
message(STATUS "Using static xxhash from Externals")
2015-01-20 22:43:26 +01:00
add_subdirectory(Externals/xxhash)
include_directories(Externals/xxhash)
endif()
LIST(APPEND LIBS xxhash)
2017-01-17 21:32:55 +01:00
find_package(ZLIB)
2013-12-23 16:01:34 -07:00
if(ZLIB_FOUND)
2017-01-17 21:47:24 +01:00
message(STATUS "Using shared zlib")
2013-12-23 16:01:34 -07:00
include_directories(${ZLIB_INCLUDE_DIRS})
2017-01-25 06:27:05 +01:00
else()
2017-01-17 21:47:24 +01:00
message(STATUS "Shared zlib not found, falling back to the static library")
2013-12-23 16:01:34 -07:00
add_subdirectory(Externals/zlib)
include_directories(Externals/zlib)
2017-01-25 06:25:52 +01:00
endif()
2013-12-23 16:01:34 -07:00
2016-02-05 10:54:59 -06:00
if(NOT APPLE)
2015-06-02 18:00:50 -04:00
check_lib(LZO "(no .pc for lzo2)" lzo2 lzo/lzo1x.h QUIET)
2011-12-19 00:54:45 +01:00
endif()
2010-11-18 23:27:27 +00:00
if(LZO_FOUND)
2017-01-17 21:47:24 +01:00
message(STATUS "Using shared lzo")
2010-11-04 02:01:07 +00:00
else()
2017-01-17 21:47:24 +01:00
message(STATUS "Using static lzo from Externals")
2010-11-04 02:01:07 +00:00
add_subdirectory(Externals/LZO)
include_directories(Externals/LZO)
2011-12-05 05:33:35 +01:00
set(LZO lzo2)
2010-11-18 23:27:27 +00:00
endif()
2014-11-19 19:55:52 -05:00
list(APPEND LIBS ${LZO})
2010-11-01 15:47:02 +00:00
2016-02-05 10:54:59 -06:00
if(NOT APPLE)
2015-06-02 18:00:50 -04:00
check_lib(PNG libpng png png.h QUIET)
2013-11-15 01:09:38 +00:00
endif()
if (PNG_FOUND)
2017-01-17 21:47:24 +01:00
message(STATUS "Using shared libpng")
2013-11-15 01:09:38 +00:00
else()
2017-01-17 21:47:24 +01:00
message(STATUS "Using static libpng from Externals")
2013-04-13 15:09:05 -05:00
add_subdirectory(Externals/libpng)
include_directories(Externals/libpng)
2013-11-15 01:09:38 +00:00
set(PNG png)
2013-04-13 15:09:05 -05:00
endif()
2013-01-09 10:26:12 -06:00
if(OPENAL_FOUND)
2015-01-03 13:17:57 +01:00
if(NOT APPLE)
2015-06-02 18:00:50 -04:00
check_lib(SOUNDTOUCH soundtouch SoundTouch soundtouch/SoundTouch.h QUIET)
2013-01-09 10:26:12 -06:00
endif()
if (SOUNDTOUCH_FOUND)
2017-01-17 21:47:24 +01:00
message(STATUS "Using shared soundtouch")
2013-01-09 10:26:12 -06:00
else()
2017-01-17 21:47:24 +01:00
message(STATUS "Using static soundtouch from Externals")
2013-01-09 10:26:12 -06:00
add_subdirectory(Externals/soundtouch)
2013-01-09 10:42:05 -06:00
include_directories(Externals)
2013-01-09 10:26:12 -06:00
endif()
endif()
2016-09-28 13:32:17 -04:00
if(NOT ANDROID)
2016-11-20 14:28:40 +01:00
add_definitions(-D__LIBUSB__)
if(NOT APPLE)
find_package(LibUSB)
endif()
if(LIBUSB_FOUND AND NOT APPLE)
2017-01-17 21:47:24 +01:00
message(STATUS "Using shared LibUSB")
2016-11-20 14:28:40 +01:00
include_directories(${LIBUSB_INCLUDE_DIR})
else()
2017-01-17 21:47:24 +01:00
message(STATUS "Using static LibUSB from Externals")
2016-11-20 14:28:40 +01:00
add_subdirectory(Externals/libusb)
set(LIBUSB_LIBRARIES usb)
endif()
set(LIBUSB_FOUND true)
2016-09-28 13:32:07 -04:00
endif()
2012-12-24 12:58:11 +13:00
2014-11-09 22:30:06 +00:00
set(SFML_REQD_VERSION 2.1)
2016-02-05 10:54:59 -06:00
if(NOT APPLE)
2014-11-09 22:30:06 +00:00
find_package(SFML ${SFML_REQD_VERSION} COMPONENTS network system)
2011-12-19 00:54:45 +01:00
endif()
2014-11-09 22:30:06 +00:00
if(SFML_FOUND)
2017-01-17 21:47:24 +01:00
message(STATUS "Using shared SFML")
2010-11-04 02:01:07 +00:00
else()
2017-01-17 21:47:24 +01:00
message(STATUS "Using static SFML ${SFML_REQD_VERSION} from Externals")
2014-11-09 22:30:06 +00:00
add_definitions(-DSFML_STATIC)
2013-07-10 21:49:13 -05:00
add_subdirectory(Externals/SFML)
2014-08-20 17:44:18 +04:00
include_directories(BEFORE Externals/SFML/include)
2010-11-18 23:27:27 +00:00
endif()
2010-11-04 02:01:07 +00:00
2013-07-08 20:13:02 -04:00
if(USE_UPNP)
2016-02-05 10:54:59 -06:00
if(NOT APPLE)
2017-01-17 21:32:55 +01:00
find_package(Miniupnpc)
2013-07-09 22:07:27 -05:00
endif()
2015-10-12 02:26:35 +02:00
if(MINIUPNPC_FOUND AND MINIUPNPC_API_VERSION GREATER 8)
2017-01-17 21:47:24 +01:00
message(STATUS "Using shared miniupnpc")
2013-07-09 22:07:27 -05:00
else()
2017-01-17 21:47:24 +01:00
message(STATUS "Using static miniupnpc from Externals")
2013-07-09 22:07:27 -05:00
add_subdirectory(Externals/miniupnpc)
2015-10-12 02:26:35 +02:00
set(MINIUPNPC_INCLUDE_DIRS Externals/miniupnpc/src)
set(MINIUPNPC_LIBRARIES miniupnpc)
2013-07-09 22:07:27 -05:00
endif()
2013-07-08 20:13:02 -04:00
add_definitions(-DUSE_UPNP)
2015-10-12 02:26:35 +02:00
include_directories(${MINIUPNPC_INCLUDE_DIRS})
list(APPEND LIBS ${MINIUPNPC_LIBRARIES})
2010-11-18 23:27:27 +00:00
endif()
2010-11-04 02:01:07 +00:00
2016-02-05 10:54:59 -06:00
if(NOT APPLE)
2017-01-17 21:32:55 +01:00
find_package(MbedTLS)
2013-09-02 20:07:47 -05:00
endif()
2015-09-26 07:09:19 +02:00
if(MBEDTLS_FOUND)
2017-01-17 21:47:24 +01:00
message(STATUS "Using shared mbed TLS")
2015-09-26 07:09:19 +02:00
include_directories(${MBEDTLS_INCLUDE_DIRS})
2013-09-02 20:07:47 -05:00
else()
2017-01-17 21:47:24 +01:00
message(STATUS "Using static mbed TLS from Externals")
2015-09-26 07:09:19 +02:00
set(MBEDTLS_LIBRARIES mbedtls mbedcrypto mbedx509)
add_subdirectory(Externals/mbedtls/)
include_directories(Externals/mbedtls/include)
2013-09-02 20:07:47 -05:00
endif()
2013-08-15 23:36:17 +12:00
2017-01-17 21:32:55 +01:00
find_package(CURL)
2016-06-17 02:28:34 +02:00
if(CURL_FOUND)
2017-01-17 21:47:24 +01:00
message(STATUS "Using shared libcurl")
2016-06-17 02:28:34 +02:00
include_directories(${CURL_INCLUDE_DIRS})
else()
2017-01-17 21:47:24 +01:00
message(STATUS "Using static libcurl from Externals")
2016-06-17 02:28:34 +02:00
add_subdirectory(Externals/curl)
set(CURL_LIBRARIES curl)
include_directories(BEFORE Externals/curl/include)
endif()
2016-02-05 10:54:59 -06:00
if(NOT APPLE)
2015-06-02 18:00:50 -04:00
check_lib(SOIL "(no .pc for SOIL)" SOIL SOIL/SOIL.h QUIET)
2011-12-19 00:54:45 +01:00
endif()
2010-11-18 23:27:27 +00:00
if(SOIL_FOUND)
2017-01-17 21:47:24 +01:00
message(STATUS "Using shared SOIL")
2010-11-04 02:01:07 +00:00
else()
2017-01-17 21:47:24 +01:00
message(STATUS "Using static SOIL from Externals")
2010-11-04 02:01:07 +00:00
add_subdirectory(Externals/SOIL)
include_directories(Externals/SOIL)
2010-11-18 23:27:27 +00:00
endif()
2010-11-01 15:47:02 +00:00
2016-02-05 10:54:59 -06:00
find_library(ICONV_LIBRARIES NAMES iconv libiconv libiconv-2 c)
find_path(ICONV_INCLUDE_DIR NAMES iconv.h)
if (ICONV_LIBRARIES AND ICONV_INCLUDE_DIR)
mark_as_advanced(ICONV_INCLUDE_DIR ICONV_LIBRARIES)
else()
2017-01-17 21:47:24 +01:00
message(STATUS "Using static iconv from Externals")
2013-08-29 04:43:31 -05:00
include_directories(Externals/libiconv-1.14/include)
add_subdirectory(Externals/libiconv-1.14)
2016-02-05 10:54:59 -06:00
set(ICONV_LIBRARIES iconv)
endif()
list(APPEND LIBS ${ICONV_LIBRARIES})
2016-07-24 17:20:40 +02:00
if(NOT ANDROID)
find_package(HIDAPI)
if(HIDAPI_FOUND)
2017-01-17 21:47:24 +01:00
message(STATUS "Using shared ${HIDAPI_LIBRARIES} ${HIDAPI_VERSION}")
2016-07-24 17:20:40 +02:00
include_directories(${HIDAPI_INCLUDE_DIRS})
list(APPEND LIBS ${HIDAPI_LIBRARIES})
else()
include_directories(Externals/hidapi/hidapi)
if(APPLE)
2017-01-17 21:47:24 +01:00
message(STATUS "Using static hidapi from Externals")
2016-07-24 17:20:40 +02:00
add_subdirectory(Externals/hidapi/mac)
list(APPEND LIBS hidapi)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
2017-01-17 21:47:24 +01:00
message(STATUS "Using static hidapi-hidraw from Externals")
2016-07-24 17:20:40 +02:00
add_subdirectory(Externals/hidapi/linux)
list(APPEND LIBS hidapi-hidraw udev)
2017-01-20 22:55:43 +01:00
elseif(MSVC)
message(STATUS "Using static hidapi-hid from Externals")
add_subdirectory(Externals/hidapi/windows)
list(APPEND LIBS hidapi-hid)
2016-07-24 17:20:40 +02:00
else()
2017-01-17 21:47:24 +01:00
message(STATUS "Using static hidapi-libusb from Externals")
2016-07-24 17:20:40 +02:00
add_subdirectory(Externals/hidapi/libusb)
list(APPEND LIBS hidapi-libusb)
endif()
endif()
set(HIDAPI_FOUND 1)
add_definitions(-DHAVE_HIDAPI=1)
endif()
2016-02-05 10:54:59 -06:00
if(NOT DISABLE_WX)
2017-01-17 21:32:55 +01:00
find_package(wxWidgets COMPONENTS core aui adv)
2010-11-08 14:04:56 +00:00
2016-08-30 17:31:22 -05:00
if(_ARCH_32)
add_definitions(-DwxSIZE_T_IS_UINT)
endif()
2013-02-26 13:49:00 -06:00
if(wxWidgets_FOUND)
2013-08-25 02:49:58 +02:00
EXECUTE_PROCESS(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
2013-02-26 13:49:00 -06:00
COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}"
2013-07-10 21:49:13 -05:00
${wxWidgets_CONFIG_OPTIONS} --version
2011-12-04 03:37:02 +01:00
OUTPUT_VARIABLE wxWidgets_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
2017-01-17 21:47:24 +01:00
message(STATUS "Found wxWidgets version ${wxWidgets_VERSION}")
2016-06-26 05:25:29 +00:00
set(wxMIN_VERSION "3.1.0")
2012-05-02 14:40:40 -05:00
if(${wxWidgets_VERSION} VERSION_LESS ${wxMIN_VERSION})
2017-01-17 21:47:24 +01:00
message(STATUS "At least ${wxMIN_VERSION} is required; ignoring found version")
2011-12-04 03:37:02 +01:00
unset(wxWidgets_FOUND)
endif()
2017-01-25 06:25:52 +01:00
endif()
2010-11-08 14:04:56 +00:00
2013-07-10 21:49:13 -05:00
if(UNIX AND NOT APPLE)
# There is a bug in the FindGTK module in cmake version 2.8.2 that
# does not find gdk-pixbuf-2.0. On the other hand some 2.8.3
# users have complained that pkg-config does not find
# gdk-pixbuf-2.0. On yet another hand, cmake version 2.8.3 in
# Ubuntu Natty does not find the glib libraries correctly.
# Ugly!!!
execute_process(COMMAND lsb_release -c -s
OUTPUT_VARIABLE DIST_NAME
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}
VERSION_EQUAL 2.8.2 OR "${DIST_NAME}" STREQUAL "natty")
2015-06-02 18:00:50 -04:00
check_lib(GTK2 gtk+-2.0 gtk+-2.0 gtk.h REQUIRED)
2013-07-10 21:49:13 -05:00
else()
2017-01-17 21:32:55 +01:00
find_package(GTK2)
2013-07-10 21:49:13 -05:00
if(GTK2_FOUND)
include_directories(${GTK2_INCLUDE_DIRS})
2014-11-19 19:55:52 -05:00
list(APPEND LIBS ${GTK2_LIBRARIES})
2014-11-10 17:57:26 -06:00
else()
message(FATAL_ERROR "GTK is required to build the WX UI. Please install the GTK development libraries.")
2011-01-08 19:14:45 +00:00
endif()
2010-11-17 01:03:39 +00:00
endif()
2013-07-10 21:49:13 -05:00
endif()
2010-11-08 14:04:56 +00:00
2012-03-19 04:54:32 -07:00
if(wxWidgets_FOUND)
include(${wxWidgets_USE_FILE})
2017-01-17 21:47:24 +01:00
message(STATUS "wxWidgets found, enabling GUI build")
2017-01-25 06:27:05 +01:00
else()
2017-01-17 21:47:24 +01:00
message(STATUS "Using static wxWidgets from Externals")
2012-03-19 04:54:32 -07:00
# These definitions and includes are used when building dolphin against wx,
# not when building wx itself (see wxw3 CMakeLists.txt for that)
2015-01-03 13:17:57 +01:00
if(APPLE)
2016-06-26 05:25:29 +00:00
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux|FreeBSD")
2012-03-23 01:06:45 +01:00
# Check for required libs
2015-06-02 18:00:50 -04:00
check_lib(GTHREAD2 gthread-2.0 gthread-2.0 glib/gthread.h REQUIRED)
check_lib(PANGOCAIRO pangocairo pangocairo pango/pangocairo.h REQUIRED)
2016-07-19 03:15:28 +00:00
# On Linux "backtrace" is part of glibc. FreeBSD has a separate library.
# Required for wxUSE_STACKWALKER in Externals/wxWidgets3/wx/wxgtk.h
find_package(Backtrace REQUIRED)
2015-01-03 13:17:57 +01:00
elseif(WIN32)
2011-12-04 03:59:42 +01:00
else()
2012-03-19 04:54:32 -07:00
message(FATAL_ERROR "wxWidgets in Externals is not compatible with your platform")
2011-12-04 03:59:42 +01:00
endif()
2013-07-10 21:49:13 -05:00
2015-06-21 13:29:04 -04:00
include_directories(SYSTEM
2012-03-19 04:54:32 -07:00
Externals/wxWidgets3
Externals/wxWidgets3/include)
add_subdirectory(Externals/wxWidgets3)
2011-12-05 01:10:45 +01:00
set(wxWidgets_FOUND TRUE)
2012-03-19 04:54:32 -07:00
set(wxWidgets_LIBRARIES "wx")
2017-01-25 06:25:52 +01:00
endif()
endif()
2010-11-01 15:47:02 +00:00
2015-01-03 13:17:57 +01:00
if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD|NetBSD")
2014-11-19 19:55:52 -05:00
set(LIBS ${LIBS} usbhid)
endif()
2010-11-01 15:47:02 +00:00
########################################
2011-08-21 17:07:19 -05:00
# Pre-build events: Define configuration variables and write SCM info header
2010-11-01 15:47:02 +00:00
#
2013-10-20 02:14:00 +02:00
if(DOLPHIN_WC_BRANCH STREQUAL "master" OR DOLPHIN_WC_BRANCH STREQUAL "stable")
set(DOLPHIN_WC_IS_STABLE "1")
2011-08-21 16:30:19 -05:00
else()
2013-10-20 02:14:00 +02:00
set(DOLPHIN_WC_IS_STABLE "0")
2011-08-21 16:30:19 -05:00
endif()
2017-02-05 22:26:44 -08:00
configure_file(
"${PROJECT_SOURCE_DIR}/Source/Core/Common/scmrev.h.in"
"${PROJECT_BINARY_DIR}/Source/Core/Common/scmrev.h"
)
2016-06-25 23:30:32 -04:00
include_directories("${PROJECT_BINARY_DIR}/Source/Core")
2010-12-19 14:02:43 +00:00
2014-03-03 03:38:46 +01:00
########################################
# Unit testing.
#
2017-01-17 21:32:55 +01:00
find_package(GTest)
2016-03-03 22:55:44 -05:00
if(GTEST_FOUND AND USE_SHARED_GTEST)
2017-01-17 21:47:24 +01:00
message(STATUS "Using shared gtest")
2016-03-03 22:55:44 -05:00
include_directories(${GTEST_INCLUDE_DIRS})
else()
2017-01-17 21:47:24 +01:00
message(STATUS "Using static gtest from Externals")
2016-03-03 22:55:44 -05:00
include_directories(Externals/gtest/include)
2017-02-05 20:19:30 +01:00
add_subdirectory(Externals/gtest EXCLUDE_FROM_ALL)
2016-03-13 04:02:27 +00:00
endif()
2014-03-03 03:38:46 +01:00
enable_testing()
add_custom_target(unittests)
add_custom_command(TARGET unittests POST_BUILD COMMAND ${CMAKE_CTEST_COMMAND})
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 20:16:27 +01: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 20:16:27 +01:00
if(CMAKE_SYSTEM_NAME MATCHES "Linux|FreeBSD|OpenBSD")
2013-01-07 16:50:48 -06:00
# Install the application icon and menu item
2016-03-09 10:54:17 -05:00
install(FILES Data/dolphin-emu.svg
2016-02-18 17:02:54 +00:00
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/scalable/apps)
2016-03-09 10:54:17 -05:00
install(FILES Data/dolphin-emu.png
2016-02-18 17:02:54 +00:00
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/icons/hicolor/48x48/apps)
2016-03-09 10:54:17 -05:00
install(FILES Data/dolphin-emu.desktop
2013-01-07 16:50:48 -06:00
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications)
2016-03-03 23:21:39 -05:00
# Install manpages
install(FILES Data/dolphin-emu.6
2016-04-02 13:16:29 -07:00
DESTINATION ${mandir}/man6)
2016-03-03 23:21:39 -05:00
install(FILES Data/dolphin-emu-nogui.6
2016-04-02 13:16:29 -07:00
DESTINATION ${mandir}/man6)
2013-01-07 16:50:48 -06: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 16:21:17 +01: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 12:51:01 +01:00
set(CPACK_PACKAGE_DESCRIPTION_FILE ${PROJECT_SOURCE_DIR}/Data/cpack_package_description.txt)
2016-08-10 19:23:21 +02:00
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A GameCube and Wii emulator")
2010-11-01 15:47:02 +00:00
2012-12-22 12:51:01 +01: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
2010-12-15 14:47:13 +00:00
set(CPACK_SET_DESTDIR ON)
set(CPACK_SOURCE_GENERATOR "TGZ;TBZ2;ZIP")
2012-12-22 12:51:01 +01: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 13:49:00 -06:00
Include(CPack)