2010-11-01 15:47:02 +00:00
########################################
# General setup
#
2014-09-14 19:03:07 +00:00
cmake_minimum_required ( VERSION 2.8.8 )
2015-02-12 00:36:29 +00:00
project ( dolphin-emu )
2012-03-14 00:14:00 +00:00
2013-02-11 19:08:41 +00:00
option ( USE_EGL "Enables EGL OpenGL Interface" OFF )
2014-08-06 23:08:24 +00:00
option ( TRY_X11 "Enables X11 Support" ON )
2015-06-02 22:30:09 +00:00
option ( USE_SHARED_ENET "Use shared libenet if found rather than Dolphin's soon-to-compatibly-diverge version" OFF )
2016-03-04 03:55:44 +00:00
option ( USE_SHARED_GTEST "Use shared gtest library if found" OFF )
2013-07-09 00:13:02 +00:00
option ( USE_UPNP "Enables UPnP port mapping support" ON )
2014-09-14 19:03:07 +00:00
option ( DISABLE_WX "Disable wxWidgets (use Qt or CLI interface)" OFF )
2015-11-27 08:33:07 +00:00
option ( ENABLE_QT2 "Enable Qt2 (use the other experimental Qt interface)" OFF )
2013-10-20 20:51:25 +00:00
option ( ENABLE_PCH "Use PCH to speed up compilation" 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 )
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 )
2016-06-17 22:13:37 +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." )
2015-06-29 01:09:24 +00: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 11:57:54 +00:00
if ( ${ CMAKE_SYSTEM_NAME } STREQUAL "Linux" AND NOT ANDROID )
option ( ENABLE_EVDEV "Enables the evdev controller backend" ON )
endif ( )
2014-10-29 04:11:57 +00:00
if ( APPLE )
option ( OSX_USE_DEFAULT_SEARCH_PATH "Don't prioritize system library paths" OFF )
endif ( )
2013-01-25 19:55:05 +00:00
option ( ENCODE_FRAMEDUMPS "Encode framedumps in AVI format" ON )
2014-04-23 09:11:41 +00:00
option ( FASTLOG "Enable all logs" OFF )
option ( OPROFILING "Enable profiling" OFF )
option ( GDBSTUB "Enable gdb stub for remote debugging." OFF )
2015-02-12 00:36:29 +00:00
if ( ${ CMAKE_SYSTEM_NAME } STREQUAL "Linux" )
option ( VTUNE "Enable Intel VTune integration for JIT symbols." OFF )
endif ( )
2014-11-06 01:53:34 +00:00
2015-01-03 12:17:57 +00:00
if ( APPLE )
2014-11-06 01:53:34 +00:00
option ( SKIP_POSTPROCESS_BUNDLE "Skip postprocessing bundle for redistributability" OFF )
endif ( )
2013-01-25 19:55:05 +00:00
########################################
# Optional Targets
2014-02-23 15:21:01 +00:00
# TODO: Add DSPSpy
2013-01-25 19:55:05 +00:00
option ( DSPTOOL "Build dsptool" OFF )
2012-03-14 00:14:00 +00:00
# Update compiler before calling project()
if ( APPLE )
# Use clang compiler
2013-09-23 04:25:41 +00:00
if ( NOT DEFINED CMAKE_CXX_COMPILER )
set ( CMAKE_CXX_COMPILER "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++" )
if ( NOT EXISTS "${CMAKE_CXX_COMPILER}" )
set ( CMAKE_CXX_COMPILER "clang++" )
endif ( )
endif ( )
2014-01-05 12:18:05 +00:00
if ( NOT DEFINED CMAKE_C_COMPILER )
2013-09-23 04:25:41 +00:00
set ( CMAKE_C_COMPILER "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" )
if ( NOT EXISTS "${CMAKE_C_COMPILER}" )
set ( CMAKE_C_COMPILER "clang" )
endif ( )
2012-03-14 00:14:00 +00:00
endif ( )
endif ( )
2013-08-16 07:26:34 +00:00
set ( CMAKE_MODULE_PATH ${ CMAKE_MODULE_PATH } ${ CMAKE_SOURCE_DIR } /CMakeTests )
2014-11-20 00:55:52 +00:00
# Libraries to link
set ( LIBS )
2010-11-04 13:47:17 +00:00
# Set up paths
2015-01-03 12:17:57 +00:00
if ( APPLE )
2011-12-14 01:50:36 +00:00
# The gettext module will install the translations unconditionally.
# Redirect the installation to a build directory where it does no harm.
set ( CMAKE_INSTALL_PREFIX ${ CMAKE_BINARY_DIR } /install-dummy )
else ( )
set ( bindir ${ CMAKE_INSTALL_PREFIX } /bin CACHE PATH "bindir" )
set ( datadir ${ CMAKE_INSTALL_PREFIX } /share/dolphin-emu CACHE PATH "datadir" )
2016-04-02 20:16:29 +00:00
set ( mandir ${ CMAKE_INSTALL_PREFIX } /share/man CACHE PATH "mandir" )
2011-12-14 01:50:36 +00:00
add_definitions ( -DDATA_DIR= "${datadir}/" )
endif ( )
2010-11-04 13:47:17 +00:00
2016-07-17 10:30:00 +00: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 ( ${ CMAKE_SYSTEM_NAME } STREQUAL "Linux" )
add_definitions ( -D_FILE_OFFSET_BITS=64 )
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
2011-01-09 16:36:19 +00:00
# Precompiled header support for MSVC:
2011-02-11 02:38:23 +00:00
# Call this after setting the source list (and don't add the source file used
# to generate the pch file, this will be done here automatically)
2011-01-09 16:36:19 +00:00
function ( enable_precompiled_headers PRECOMPILED_HEADER SOURCE_FILE SOURCE_VARIABLE_NAME )
if ( MSVC )
set ( files ${ ${SOURCE_VARIABLE_NAME } } )
# Generate precompiled header translation unit
get_filename_component ( pch_basename ${ PRECOMPILED_HEADER } NAME_WE )
set ( pch_abs ${ CMAKE_CURRENT_SOURCE_DIR } / ${ PRECOMPILED_HEADER } )
set ( pch_unity ${ CMAKE_CURRENT_SOURCE_DIR } / ${ SOURCE_FILE } )
2011-02-11 02:38:23 +00:00
set_source_files_properties ( ${ pch_unity } PROPERTIES COMPILE_FLAGS
" / Y c \ " $ { p c h _ a b s } \ " " )
2011-01-09 16:36:19 +00:00
# Update properties of source files to use the precompiled header.
2011-02-11 02:38:23 +00:00
# Additionally, force the inclusion of the precompiled header at
# beginning of each source file.
2011-01-09 16:36:19 +00:00
foreach ( source_file ${ files } )
2011-02-11 02:38:23 +00:00
set_source_files_properties ( ${ source_file } PROPERTIES COMPILE_FLAGS
" / Y u \ " $ { p c h _ a b s } \ " / F I \ " $ { p c h _ a b s } \ " " )
2011-01-09 16:36:19 +00:00
endforeach ( source_file )
2011-02-11 02:38:23 +00:00
# Finally, update the source file collection to contain the
# precompiled header translation unit
2011-01-09 16:36:19 +00:00
set ( ${ SOURCE_VARIABLE_NAME } ${ pch_unity } ${ ${SOURCE_VARIABLE_NAME } } PARENT_SCOPE )
endif ( MSVC )
endfunction ( enable_precompiled_headers )
2011-08-14 20:17:57 +00:00
# for revision info
include ( FindGit OPTIONAL )
if ( GIT_FOUND AND NOT DOLPHIN_WC_REVISION )
2013-07-11 02:49:13 +00:00
# defines DOLPHIN_WC_REVISION
2013-05-22 11:34:02 +00:00
EXECUTE_PROCESS ( WORKING_DIRECTORY ${ PROJECT_SOURCE_DIR } COMMAND ${ GIT_EXECUTABLE } rev-parse HEAD
2013-07-11 02:49:13 +00:00
O U T P U T _ V A R I A B L E D O L P H I N _ W C _ R E V I S I O N
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
# defines DOLPHIN_WC_DESCRIBE
2013-05-22 11:34:02 +00:00
EXECUTE_PROCESS ( WORKING_DIRECTORY ${ PROJECT_SOURCE_DIR } COMMAND ${ GIT_EXECUTABLE } describe --always --long --dirty
2013-07-11 02:49:13 +00:00
O U T P U T _ V A R I A B L E D O L P H I N _ W C _ D E S C R I B E
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
2011-08-23 01:06:17 +00:00
2013-08-10 22:12:24 +00:00
# remove hash (and trailing "-0" if needed) from description
STRING ( REGEX REPLACE "(-0)?-[^-]+((-dirty)?)$" "\\2" DOLPHIN_WC_DESCRIBE "${DOLPHIN_WC_DESCRIBE}" )
2011-08-23 01:06:17 +00:00
2013-07-11 02:49:13 +00:00
# defines DOLPHIN_WC_BRANCH
2013-05-22 11:34:02 +00:00
EXECUTE_PROCESS ( WORKING_DIRECTORY ${ PROJECT_SOURCE_DIR } COMMAND ${ GIT_EXECUTABLE } rev-parse --abbrev-ref HEAD
2013-07-11 02:49:13 +00:00
O U T P U T _ V A R I A B L E D O L P H I N _ W C _ B R A N C H
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
2011-08-20 21:05:43 +00:00
endif ( )
2011-12-11 15:21:17 +00:00
# version number
2016-06-24 08:09:07 +00:00
set ( DOLPHIN_VERSION_MAJOR "5" )
2013-09-21 05:29:41 +00:00
set ( DOLPHIN_VERSION_MINOR "0" )
2015-06-09 19:06:28 +00:00
if ( DOLPHIN_WC_BRANCH STREQUAL "stable" )
2011-12-11 15:21:17 +00:00
set ( DOLPHIN_VERSION_PATCH "0" )
else ( )
set ( DOLPHIN_VERSION_PATCH ${ DOLPHIN_WC_REVISION } )
endif ( )
2014-03-02 11:21:50 +00:00
2016-05-29 16:26:53 +00: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 11:21:50 +00:00
# Architecture detection and arch specific settings
2013-02-26 19:49:00 +00:00
message ( ${ 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 ( NOT ENABLE_GENERIC )
if ( ${ CMAKE_SYSTEM_PROCESSOR } MATCHES "^x86" OR
$ { C M A K E _ S Y S T E M _ P R O C E S S O R } M A T C H E S " i . 8 6 " O R
2015-06-12 06:34:16 +00:00
$ { C M A K E _ S Y S T E M _ P R O C E S S O R } M A T C H E S " a m d 6 4 " O R
2015-01-03 12:17:57 +00:00
APPLE )
2014-05-26 01:52:52 +00:00
if ( _ARCH_64 )
set ( _M_X86 1 )
set ( _M_X86_64 1 )
add_definitions ( -D_M_X86=1 -D_M_X86_64=1 -msse2 )
2016-03-14 18:26:00 +00:00
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-pie" )
2014-05-26 01:52:52 +00:00
else ( )
message ( FATAL_ERROR "x86_32 is an unsupported platform. Enable generic build if you really want a JIT-less binary." )
endif ( )
elseif ( ${ CMAKE_SYSTEM_PROCESSOR } MATCHES "^arm" )
2015-06-08 03:44:13 +00:00
message ( FATAL_ERROR "ARMv7 is an unsupported platform. Enable generic build if you really want a JIT-less binary." )
2015-01-03 12:17:57 +00:00
elseif ( ${ CMAKE_SYSTEM_PROCESSOR } STREQUAL "aarch64" )
2014-05-26 01:52:52 +00:00
# This option only applies to 64bit ARM
set ( _M_ARM 1 )
set ( _M_ARM_64 1 )
add_definitions ( -D_M_ARM=1 -D_M_ARM_64=1 )
2014-12-20 02:45:55 +00:00
add_definitions ( -march=armv8-a+crc )
2014-03-02 11:21:50 +00:00
else ( )
2014-05-26 01:52:52 +00:00
set ( ENABLE_GENERIC 1 )
2013-11-30 18:25:01 +00:00
endif ( )
2014-05-26 01:52:52 +00:00
endif ( )
if ( ENABLE_GENERIC )
2014-03-17 16:36:27 +00:00
message ( "Warning! Building generic build!" )
2014-03-02 11:21:50 +00:00
set ( _M_GENERIC 1 )
add_definitions ( -D_M_GENERIC=1 )
2013-02-26 19:49:00 +00:00
endif ( )
2011-01-09 16:36:19 +00:00
2013-01-30 03:28:55 +00:00
include ( CheckCXXCompilerFlag )
macro ( check_and_add_flag var flag )
CHECK_CXX_COMPILER_FLAG ( ${ flag } FLAG_ ${ var } )
if ( FLAG_ ${ var } )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" )
endif ( )
endmacro ( )
2011-01-09 16:36:19 +00:00
# Enabling all warnings in MSVC spams too much
if ( NOT MSVC )
add_definitions ( -Wall )
2016-06-16 20:31:51 +00:00
add_definitions ( -D_DEFAULT_SOURCE )
2013-01-30 03:28:55 +00: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 12:01:59 +00:00
check_and_add_flag ( MISSING_DECLARATIONS -Wmissing-declarations )
2014-07-08 12:51:14 +00:00
check_and_add_flag ( MISSING_VARIABLE_DECLARATIONS -Wmissing-variable-declarations )
2011-01-09 16:36:19 +00:00
endif ( NOT MSVC )
2010-11-01 15:47:02 +00:00
# gcc uses some optimizations which might break stuff without this flag
2013-01-30 03:48:26 +00:00
add_definitions ( -fno-strict-aliasing -fno-exceptions )
2010-11-13 22:07:27 +00:00
2013-01-30 03:28:55 +00:00
check_and_add_flag ( VISIBILITY_INLINES_HIDDEN -fvisibility-inlines-hidden )
2010-11-01 15:47:02 +00:00
2010-12-04 15:19:04 +00:00
if ( UNIX AND NOT APPLE )
2013-01-30 03:28:55 +00:00
check_and_add_flag ( VISIBILITY_HIDDEN -fvisibility=hidden )
2010-11-17 01:03:39 +00:00
endif ( )
2010-11-14 15:13:04 +00:00
2014-04-23 09:15:25 +00:00
if ( ENABLE_LTO )
check_and_add_flag ( LTO -flto )
2014-05-03 09:54:31 +00:00
if ( CMAKE_CXX_COMPILER_ID STREQUAL GNU )
set ( CMAKE_AR gcc-ar )
set ( CMAKE_RANLIB gcc-ranlib )
endif ( )
2014-04-23 09:15:25 +00:00
endif ( )
2012-03-26 03:27:18 +00:00
if ( APPLE )
2014-10-29 04:11:57 +00: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
# are not part of OS X (ffmpeg, libusb, 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...
# See http://www.cmake.org/cmake/help/v3.0/command/find_program.html
set ( CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};/usr" )
endif ( )
2011-12-05 04:42:02 +00:00
2011-12-11 20:27:06 +00:00
# Identify the target system:
2013-03-19 13:50:56 +00:00
# Ask for 64-bit binary.
set ( TARGET_FLAGS "-arch x86_64" )
2011-12-11 20:27:06 +00: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.
2014-11-13 00:51:23 +00:00
set ( OSX_MIN_VERSION "10.9" )
2011-12-11 20:27:06 +00:00
set ( TARGET_FLAGS "${TARGET_FLAGS} -mmacosx-version-min=${OSX_MIN_VERSION}" )
2014-11-13 00:51:23 +00:00
set ( SYSROOT_LEGACY_PATH "/Developer/SDKs/MacOSX10.9.sdk" )
set ( SYSROOT_PATH "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk" )
2012-03-26 03:27:18 +00:00
if ( EXISTS "${SYSROOT_PATH}/" )
2013-07-11 02:49:13 +00:00
set ( TARGET_SYSROOT ${ SYSROOT_PATH } )
2012-03-26 03:27:18 +00:00
elseif ( EXISTS "${SYSROOT_LEGACY_PATH}/" )
2013-07-11 02:49:13 +00:00
set ( TARGET_SYSROOT ${ SYSROOT_LEGACY_PATH } )
2012-03-23 01:11:45 +00:00
endif ( )
2012-03-26 03:27:18 +00:00
if ( ${ TARGET_SYSROOT } )
2013-07-11 02:49:13 +00:00
set ( TARGET_FLAGS "${TARGET_FLAGS} -isysroot ${TARGET_SYSROOT}" )
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-syslibroot,${TARGET_SYSROOT}" )
2012-03-14 00:14:00 +00:00
endif ( )
2011-12-15 05:41:39 +00:00
# Do not warn about frameworks that are not available on all architectures.
# This avoids a warning when linking with QuickTime.
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-no_arch_warnings" )
2011-12-11 20:27:06 +00:00
# Specify target CPUs.
2013-03-29 14:31:15 +00:00
set ( TARGET_FLAGS "${TARGET_FLAGS} -mssse3" )
set ( TARGET_FLAGS "${TARGET_FLAGS} -march=core2" )
2011-12-11 20:27:06 +00:00
# Target flags apply to both C and C++ compilation.
2011-12-17 14:31:36 +00:00
# CMake passes these to the compiler on the link command line as well.
2011-12-11 20:27:06 +00:00
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TARGET_FLAGS}" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TARGET_FLAGS}" )
# 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 07:26:44 +00:00
find_library ( APPKIT_LIBRARY AppKit )
find_library ( APPSERV_LIBRARY ApplicationServices )
find_library ( ATB_LIBRARY AudioToolbox )
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 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 )
2011-12-11 20:24:40 +00:00
find_library ( QUICKTIME_LIBRARY QuickTime )
2011-12-07 07:26:44 +00:00
find_library ( WEBKIT_LIBRARY WebKit )
2014-01-28 23:11:51 +00:00
find_library ( FORCEFEEDBACK ForceFeedback )
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
2010-11-08 14:04:56 +00:00
if ( WIN32 )
add_definitions ( -D_SECURE_SCL=0 )
add_definitions ( -D_CRT_SECURE_NO_WARNINGS )
add_definitions ( -D_CRT_SECURE_NO_DEPRECATE )
endif ( WIN32 )
2015-11-07 18:50:47 +00: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 22:15:08 +00:00
option ( LINUX_LOCAL_DEV "Enable relocatable binary" OFF )
if ( LINUX_LOCAL_DEV )
add_definitions ( '-DLINUX_LOCAL_DEV' )
endif ( LINUX_LOCAL_DEV )
2015-11-07 18:50:47 +00:00
endif ( UNIX )
2015-06-29 01:57:30 +00:00
# Dolphin requires threads.
# The Apple build may not need an explicit flag because one of the
# frameworks may already provide it.
# But for non-OSX systems, we will use the CMake Threads package.
IF ( NOT APPLE )
FIND_PACKAGE ( Threads )
ENDIF ( NOT APPLE )
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
2010-11-05 04:19:22 +00:00
" B u i l d type ( Release/Debug/RelWithDebInfo/MinSizeRe ) " F O R C E )
2010-11-05 23:38:37 +00:00
endif ( NOT CMAKE_BUILD_TYPE )
2010-11-05 04:19:22 +00:00
2012-12-30 04:48:22 +00:00
2010-11-05 02:23:24 +00:00
if ( CMAKE_BUILD_TYPE STREQUAL Debug )
add_definitions ( -D_DEBUG -ggdb )
set ( wxWidgets_USE_DEBUG ON CACHE BOOL "Use wxWidgets Debugging" )
2012-12-30 04:48:22 +00:00
option ( ENABLE_GPROF "Enable gprof profiling (must be using Debug build)" OFF )
if ( ENABLE_GPROF )
add_definitions ( -pg )
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg" )
endif ( )
2010-11-05 02:23:24 +00:00
endif ( CMAKE_BUILD_TYPE STREQUAL Debug )
2013-03-29 16:58:30 +00:00
if ( CMAKE_BUILD_TYPE STREQUAL Release AND NOT APPLE )
2010-11-05 02:23:24 +00:00
add_definitions ( -fomit-frame-pointer )
2013-04-01 20:07:45 +00:00
endif ( )
2010-11-01 15:47:02 +00:00
2010-12-13 05:29:13 +00:00
if ( FASTLOG )
add_definitions ( -DDEBUGFAST )
endif ( )
2013-01-06 10:28:27 +00:00
if ( GDBSTUB )
add_definitions ( -DUSE_GDBSTUB )
endif ( GDBSTUB )
2015-02-12 00:36:29 +00: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 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 "
)
2015-02-12 00:36:29 +00:00
endif ( VTUNE )
2013-07-13 23:42:04 +00:00
if ( ANDROID )
message ( "Building for Android" )
2016-02-05 16:54:59 +00: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 23:42:04 +00:00
set ( USE_X11 0 )
set ( USE_UPNP 0 )
2014-08-06 23:08:24 +00:00
set ( USE_EGL 1 )
2016-02-05 16:54:59 +00: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 )
2016-07-17 09:54:31 +00:00
elseif ( NOT APPLE AND NOT CMAKE_SYSTEM_NAME MATCHES OpenBSD )
2016-02-05 16:54:59 +00:00
list ( APPEND LIBS rt )
2013-07-13 23:42:04 +00:00
endif ( )
2016-01-26 13:35:17 +00:00
if ( ENABLE_HEADLESS )
message ( "Enabling Headless! Disabling GUI, force enabling EGL!" )
set ( USE_X11 0 )
set ( USE_EGL 1 )
set ( DISABLE_WX 1 )
set ( ENABLE_QT2 0 )
add_definitions ( -DUSE_HEADLESS )
endif ( )
2012-05-16 22:11:55 +00:00
add_definitions ( -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE )
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
2016-02-05 16:54:59 +00:00
include ( FindOpenGL )
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
2016-02-05 16:54:59 +00:00
include ( FindALSA OPTIONAL )
if ( ALSA_FOUND )
add_definitions ( -DHAVE_ALSA=1 )
message ( "ALSA found, enabling ALSA sound backend" )
else ( )
add_definitions ( -DHAVE_ALSA=0 )
message ( "ALSA NOT found, disabling ALSA sound backend" )
endif ( ALSA_FOUND )
check_lib ( AO ao ao QUIET )
if ( AO_FOUND )
add_definitions ( -DHAVE_AO=1 )
message ( "ao found, enabling ao sound backend" )
else ( )
add_definitions ( -DHAVE_AO=0 )
message ( "ao NOT found, disabling ao sound backend" )
endif ( AO_FOUND )
check_lib ( BLUEZ bluez bluez QUIET )
if ( BLUEZ_FOUND )
add_definitions ( -DHAVE_BLUEZ=1 )
message ( "bluez found, enabling bluetooth support" )
else ( )
add_definitions ( -DHAVE_BLUEZ=0 )
message ( "bluez NOT found, disabling bluetooth support" )
endif ( BLUEZ_FOUND )
check_lib ( PULSEAUDIO libpulse pulse QUIET )
if ( PULSEAUDIO_FOUND )
add_definitions ( -DHAVE_PULSEAUDIO=1 )
message ( "PulseAudio found, enabling PulseAudio sound backend" )
else ( )
add_definitions ( -DHAVE_PULSEAUDIO=0 )
message ( "PulseAudio NOT found, disabling PulseAudio sound backend" )
endif ( PULSEAUDIO_FOUND )
2010-11-01 15:47:02 +00:00
2016-02-05 16:54:59 +00:00
include ( FindOpenAL OPTIONAL )
if ( OPENAL_FOUND )
add_definitions ( -DHAVE_OPENAL=1 )
include_directories ( ${ OPENAL_INCLUDE_DIR } )
message ( "OpenAL found, enabling OpenAL sound backend" )
else ( )
add_definitions ( -DHAVE_OPENAL=0 )
message ( "OpenAL NOT found, disabling OpenAL sound backend" )
endif ( OPENAL_FOUND )
2014-10-21 10:56:01 +00:00
2016-02-05 16:54:59 +00:00
include ( FindLLVM OPTIONAL )
if ( LLVM_FOUND )
add_definitions ( -DHAS_LLVM=1 )
set ( HAS_LLVM 1 )
2014-10-21 10:56:01 +00:00
2016-02-05 16:54:59 +00:00
include_directories ( ${ LLVM_INCLUDE_DIRS } )
list ( APPEND LIBS ${ LLVM_LIBRARIES } )
2014-10-21 10:56:01 +00:00
2016-02-05 16:54:59 +00:00
message ( STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}" )
endif ( )
2014-08-06 23:08:24 +00:00
2016-02-05 16:54:59 +00:00
set ( USE_X11 0 )
if ( UNIX AND NOT APPLE AND NOT ANDROID AND NOT ENABLE_HEADLESS )
include ( FindX11 )
if ( TRY_X11 AND X11_FOUND )
set ( USE_X11 1 )
add_definitions ( -DHAVE_X11=1 )
include_directories ( ${ X11_INCLUDE_DIR } )
message ( "X11 support enabled" )
else ( )
set ( USE_X11 0 )
SET ( X11_FOUND "" )
message ( "X11 support disabled" )
add_definitions ( -DHAVE_X11=0 )
endif ( TRY_X11 AND X11_FOUND )
if ( NOT USE_X11 )
message ( FATAL_ERROR "\n"
" N o s u i t a b l e d i s p l a y p l a t f o r m f o u n d \ n "
" R e q u i r e s x 1 1 t o r u n " )
2013-02-26 19:49:00 +00:00
endif ( )
2016-02-05 16:54:59 +00:00
endif ( )
2010-11-01 15:47:02 +00:00
2016-02-05 16:54:59 +00:00
if ( USE_X11 )
check_lib ( XRANDR xrandr Xrandr )
if ( XRANDR_FOUND )
add_definitions ( -DHAVE_XRANDR=1 )
else ( )
add_definitions ( -DHAVE_XRANDR=0 )
endif ( XRANDR_FOUND )
2013-07-21 04:43:48 +00:00
2016-02-05 16:54:59 +00:00
pkg_check_modules ( XINPUT2 xi>=1.5.0 )
if ( XINPUT2_FOUND )
add_definitions ( -DHAVE_X11_XINPUT2=1 )
else ( )
add_definitions ( -DHAVE_X11_XINPUT2=0 )
endif ( XINPUT2_FOUND )
endif ( )
if ( ENCODE_FRAMEDUMPS )
check_libav ( )
if ( LIBAV_FOUND )
LIST ( APPEND LIBS ${ LIBAV_LDFLAGS } )
2013-02-26 19:49:00 +00:00
endif ( )
2014-11-20 00:55:52 +00:00
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
set ( CMAKE_REQUIRED_LIBRARIES portaudio )
CHECK_CXX_SOURCE_RUNS (
" #include <portaudio.h>
i n t main ( int argc, char **argv )
{ if ( Pa_GetVersion( ) > = 1 8 9 0 ) r e t u r n 0 ; e l s e r e t u r n 1 ; } "
P O R T A U D I O )
unset ( CMAKE_REQUIRED_LIBRARIES )
if ( PORTAUDIO )
message ( "PortAudio found, enabling mic support" )
add_definitions ( -DHAVE_PORTAUDIO=1 )
set ( PORTAUDIO_FOUND TRUE )
else ( )
message ( "PortAudio not found, disabling mic support" )
add_definitions ( -DHAVE_PORTAUDIO=0 )
set ( PORTAUDIO_FOUND FALSE )
endif ( PORTAUDIO )
if ( OPROFILING )
include ( FindOProfile )
if ( OPROFILE_FOUND )
message ( "OProfile found, enabling profiling support" )
add_definitions ( -DUSE_OPROFILE=1 )
include_directories ( ${ OPROFILE_INCLUDE_DIRS } )
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
2014-08-06 23:08:24 +00:00
if ( USE_EGL )
message ( "EGL OpenGL interface enabled" )
add_definitions ( -DUSE_EGL=1 )
endif ( )
2015-06-30 11:57:54 +00:00
if ( ENABLE_EVDEV )
include ( FindLibudev REQUIRED )
include ( FindLibevdev REQUIRED )
2015-06-29 00:17:35 +00:00
if ( LIBUDEV_FOUND AND LIBEVDEV_FOUND )
message ( "libevdev/libudev found, enabling evdev controller backend" )
add_definitions ( -DHAVE_LIBUDEV=1 )
add_definitions ( -DHAVE_LIBEVDEV=1 )
include_directories ( ${ LIBUDEV_INCLUDE_DIR } ${ LIBEVDEV_INCLUDE_DIR } )
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 )
message ( "Using named pipes as controller inputs" )
add_definitions ( -DUSE_PIPES=1 )
2015-12-30 01:59:16 +00:00
message ( "Watching game memory for changes" )
add_definitions ( -DUSE_MEMORYWATCHER=1 )
2015-10-25 03:20:03 +00:00
endif ( )
2016-06-17 00:28:34 +00:00
if ( ENABLE_ANALYTICS )
message ( "Enabling analytics collection (subject to end-user opt-in)" )
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 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:
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 21:15:55 +00: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 12:34:44 +00:00
2016-06-26 05:06:20 +00:00
add_subdirectory ( Externals/glslang )
2016-02-05 16:54:59 +00:00
if ( USE_SHARED_ENET )
2015-06-02 22:00:50 +00:00
check_lib ( ENET libenet enet enet/enet.h QUIET )
2015-06-02 22:28:11 +00: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 01:45:04 +00:00
endif ( )
if ( ENET_FOUND )
2015-06-02 22:00:50 +00:00
message ( "Using shared enet" )
2015-03-01 01:45:04 +00:00
else ( )
2015-02-15 12:34:44 +00:00
message ( "Using static enet from Externals" )
2015-03-01 01:45:04 +00:00
include_directories ( Externals/enet/include )
2015-02-15 12:34:44 +00:00
add_subdirectory ( Externals/enet )
endif ( )
LIST ( APPEND LIBS enet )
2010-11-01 15:47:02 +00:00
2015-01-20 21:43:26 +00:00
if ( NOT XXHASH_FOUND )
message ( "Using static xxhash from Externals" )
add_subdirectory ( Externals/xxhash )
include_directories ( Externals/xxhash )
endif ( )
LIST ( APPEND LIBS xxhash )
2013-12-23 23:01:34 +00:00
# If zlib has already been found on a previous run of cmake don't check again
# as the check seems to take a long time.
if ( NOT ZLIB_FOUND )
include ( FindZLIB OPTIONAL )
endif ( )
if ( ZLIB_FOUND )
set ( ZLIB_FOUND 1 CACHE INTERNAL "" )
message ( "Using shared zlib" )
include_directories ( ${ ZLIB_INCLUDE_DIRS } )
else ( ZLIB_FOUND )
message ( "Shared zlib not found, falling back to the static library" )
add_subdirectory ( Externals/zlib )
include_directories ( Externals/zlib )
endif ( ZLIB_FOUND )
2016-02-05 16:54:59 +00:00
if ( NOT APPLE )
2015-06-02 22:00:50 +00:00
check_lib ( LZO "(no .pc for lzo2)" lzo2 lzo/lzo1x.h QUIET )
2011-12-18 23:54:45 +00:00
endif ( )
2010-11-18 23:27:27 +00:00
if ( LZO_FOUND )
2010-11-04 02:01:07 +00:00
message ( "Using shared lzo" )
else ( )
2011-12-18 23:54:45 +00:00
message ( "Using static lzo from Externals" )
2010-11-04 02:01:07 +00:00
add_subdirectory ( Externals/LZO )
include_directories ( Externals/LZO )
2011-12-05 04:33:35 +00:00
set ( LZO lzo2 )
2010-11-18 23:27:27 +00:00
endif ( )
2014-11-20 00:55:52 +00:00
list ( APPEND LIBS ${ LZO } )
2010-11-01 15:47:02 +00:00
2016-02-05 16:54:59 +00:00
if ( NOT APPLE )
2015-06-02 22:00:50 +00:00
check_lib ( PNG libpng png png.h QUIET )
2013-11-15 01:09:38 +00:00
endif ( )
if ( PNG_FOUND )
message ( "Using shared libpng" )
else ( )
2013-04-13 20:09:05 +00:00
message ( "Using static libpng from Externals" )
add_subdirectory ( Externals/libpng )
include_directories ( Externals/libpng )
2013-11-15 01:09:38 +00:00
set ( PNG png )
2013-04-13 20:09:05 +00:00
endif ( )
2013-01-09 16:26:12 +00:00
if ( OPENAL_FOUND )
2015-01-03 12:17:57 +00:00
if ( NOT APPLE )
2015-06-02 22:00:50 +00:00
check_lib ( SOUNDTOUCH soundtouch SoundTouch soundtouch/SoundTouch.h QUIET )
2013-01-09 16:26:12 +00:00
endif ( )
if ( SOUNDTOUCH_FOUND )
message ( "Using shared soundtouch" )
else ( )
message ( "Using static soundtouch from Externals" )
add_subdirectory ( Externals/soundtouch )
2013-01-09 16:42:05 +00:00
include_directories ( Externals )
2013-01-09 16:26:12 +00:00
endif ( )
endif ( )
2015-06-29 01:09:24 +00:00
if ( ENABLE_SDL )
include ( FindSDL2 OPTIONAL )
2013-02-26 19:49:00 +00:00
if ( SDL2_FOUND )
message ( "Using shared SDL2" )
2014-05-05 00:41:02 +00:00
add_definitions ( -DHAVE_SDL=1 )
2013-02-26 19:49:00 +00:00
include_directories ( ${ SDL2_INCLUDE_DIR } )
else ( SDL2_FOUND )
# SDL2 not found, try SDL
2015-06-29 01:09:24 +00:00
include ( FindSDL OPTIONAL )
2013-07-10 03:07:27 +00:00
if ( SDL_FOUND )
message ( "Using shared SDL" )
2014-05-05 00:41:02 +00:00
add_definitions ( -DHAVE_SDL=1 )
2013-07-10 03:07:27 +00:00
include_directories ( ${ SDL_INCLUDE_DIR } )
else ( SDL_FOUND )
2014-05-05 00:41:02 +00:00
message ( "SDL NOT found, disabling SDL input" )
2013-07-10 03:07:27 +00:00
endif ( SDL_FOUND )
2013-02-26 19:49:00 +00:00
endif ( SDL2_FOUND )
endif ( )
2010-11-01 15:47:02 +00:00
2012-12-30 03:57:37 +00:00
include ( FindLibUSB OPTIONAL )
2012-12-23 23:58:11 +00:00
if ( LIBUSB_FOUND )
message ( "Using shared LibUSB" )
2012-12-30 03:57:37 +00:00
add_definitions ( -D__LIBUSB__ )
2012-12-23 23:58:11 +00:00
include_directories ( ${ LIBUSB_INCLUDE_DIR } )
endif ( LIBUSB_FOUND )
2014-11-09 22:30:06 +00:00
set ( SFML_REQD_VERSION 2.1 )
2016-02-05 16:54:59 +00:00
if ( NOT APPLE )
2014-11-09 22:30:06 +00:00
find_package ( SFML ${ SFML_REQD_VERSION } COMPONENTS network system )
2011-12-18 23:54:45 +00:00
endif ( )
2014-11-09 22:30:06 +00:00
if ( SFML_FOUND )
2013-07-11 02:49:13 +00:00
message ( "Using shared SFML" )
2010-11-04 02:01:07 +00:00
else ( )
2014-11-09 22:30:06 +00:00
message ( "Using static SFML ${SFML_REQD_VERSION} from Externals" )
add_definitions ( -DSFML_STATIC )
2013-07-11 02:49:13 +00:00
add_subdirectory ( Externals/SFML )
2014-08-20 13:44:18 +00: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-09 00:13:02 +00:00
if ( USE_UPNP )
2016-02-05 16:54:59 +00:00
if ( NOT APPLE )
2013-07-10 03:07:27 +00:00
include ( FindMiniupnpc )
endif ( )
2015-10-12 00:26:35 +00:00
if ( MINIUPNPC_FOUND AND MINIUPNPC_API_VERSION GREATER 8 )
2013-07-10 03:07:27 +00:00
message ( "Using shared miniupnpc" )
else ( )
message ( "Using static miniupnpc from Externals" )
add_subdirectory ( Externals/miniupnpc )
2015-10-12 00:26:35 +00:00
set ( MINIUPNPC_INCLUDE_DIRS Externals/miniupnpc/src )
set ( MINIUPNPC_LIBRARIES miniupnpc )
2013-07-10 03:07:27 +00:00
endif ( )
2013-07-09 00:13:02 +00:00
add_definitions ( -DUSE_UPNP )
2015-10-12 00:26:35 +00: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 16:54:59 +00:00
if ( NOT APPLE )
2015-09-26 05:09:19 +00:00
include ( FindMbedTLS )
2013-09-03 01:07:47 +00:00
endif ( )
2015-09-26 05:09:19 +00:00
if ( MBEDTLS_FOUND )
message ( "Using shared mbed TLS" )
include_directories ( ${ MBEDTLS_INCLUDE_DIRS } )
2013-09-03 01:07:47 +00:00
else ( )
2015-09-26 05:09:19 +00:00
message ( "Using static mbed TLS from Externals" )
set ( MBEDTLS_LIBRARIES mbedtls mbedcrypto mbedx509 )
add_subdirectory ( Externals/mbedtls/ )
include_directories ( Externals/mbedtls/include )
2013-09-03 01:07:47 +00:00
endif ( )
2013-08-15 11:36:17 +00:00
2016-06-17 00:28:34 +00:00
include ( FindCURL OPTIONAL )
if ( CURL_FOUND )
message ( "Using shared libcurl" )
include_directories ( ${ CURL_INCLUDE_DIRS } )
else ( )
message ( "Using static libcurl from Externals" )
add_subdirectory ( Externals/curl )
set ( CURL_LIBRARIES curl )
include_directories ( BEFORE Externals/curl/include )
endif ( )
2016-02-05 16:54:59 +00:00
if ( NOT APPLE )
2015-06-02 22:00:50 +00:00
check_lib ( SOIL "(no .pc for SOIL)" SOIL SOIL/SOIL.h QUIET )
2011-12-18 23:54:45 +00:00
endif ( )
2010-11-18 23:27:27 +00:00
if ( SOIL_FOUND )
2010-11-04 02:01:07 +00:00
message ( "Using shared SOIL" )
else ( )
2011-12-18 23:54:45 +00:00
message ( "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 16:54:59 +00: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 ( )
2013-08-29 09:43:31 +00:00
message ( "Using static iconv from Externals" )
include_directories ( Externals/libiconv-1.14/include )
add_subdirectory ( Externals/libiconv-1.14 )
2016-02-05 16:54:59 +00:00
set ( ICONV_LIBRARIES iconv )
endif ( )
list ( APPEND LIBS ${ ICONV_LIBRARIES } )
find_library ( OPENSLES_LIBRARIES NAMES OpenSLES )
find_path ( OPENSLES_INCLUDE_DIR NAMES SLES/OpenSLES.h )
if ( OPENSLES_LIBRARIES AND OPENSLES_INCLUDE_DIR )
set ( OPENSLES_FOUND 1 )
add_definitions ( -DHAVE_OPENSLES=1 )
include_directories ( ${ OPENSLES_INCLUDE_DIR } )
message ( "OpenSLES found, enabling OpenSLES sound backend" )
2013-08-29 09:43:31 +00:00
endif ( )
2016-01-06 01:56:22 +00:00
if ( ENABLE_QT2 )
2014-09-14 19:03:07 +00:00
find_package ( Qt5Widgets REQUIRED )
message ( "Found Qt version ${Qt5Core_VERSION}, enabling the Qt backend" )
endif ( )
2016-02-05 16:54:59 +00:00
if ( NOT DISABLE_WX )
2012-03-20 06:16:01 +00:00
include ( FindwxWidgets OPTIONAL )
FIND_PACKAGE ( wxWidgets COMPONENTS core aui adv )
2010-11-08 14:04:56 +00:00
2013-02-26 19:49:00 +00:00
if ( wxWidgets_FOUND )
2013-08-25 00:49:58 +00:00
EXECUTE_PROCESS ( WORKING_DIRECTORY ${ PROJECT_SOURCE_DIR }
2013-02-26 19:49:00 +00:00
C O M M A N D s h " $ { w x W i d g e t s _ C O N F I G _ E X E C U T A B L E } "
2013-07-11 02:49:13 +00:00
$ { w x W i d g e t s _ C O N F I G _ O P T I O N S } - - v e r s i o n
2011-12-04 02:37:02 +00:00
O U T P U T _ V A R I A B L E w x W i d g e t s _ V E R S I O N
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E
E R R O R _ Q U I E T
)
message ( "Found wxWidgets version ${wxWidgets_VERSION}" )
2016-06-26 05:25:29 +00:00
set ( wxMIN_VERSION "3.1.0" )
2012-05-02 19:40:40 +00:00
if ( ${ wxWidgets_VERSION } VERSION_LESS ${ wxMIN_VERSION } )
message ( "At least ${wxMIN_VERSION} is required; ignoring found version" )
2011-12-04 02:37:02 +00:00
unset ( wxWidgets_FOUND )
endif ( )
endif ( wxWidgets_FOUND )
2010-11-08 14:04:56 +00:00
2013-07-11 02:49:13 +00: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
O U T P U T _ V A R I A B L E D I S T _ N A M E
E R R O R _ Q U I E T O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
if ( ${ CMAKE_MAJOR_VERSION } . ${ CMAKE_MINOR_VERSION } . ${ CMAKE_PATCH_VERSION }
V E R S I O N _ E Q U A L 2 . 8 . 2 O R " $ { D I S T _ N A M E } " S T R E Q U A L " n a t t y " )
2015-06-02 22:00:50 +00:00
check_lib ( GTK2 gtk+-2.0 gtk+-2.0 gtk.h REQUIRED )
2013-07-11 02:49:13 +00:00
else ( )
include ( FindGTK2 )
if ( GTK2_FOUND )
include_directories ( ${ GTK2_INCLUDE_DIRS } )
2014-11-20 00:55:52 +00:00
list ( APPEND LIBS ${ GTK2_LIBRARIES } )
2014-11-10 23:57:26 +00: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-11 02:49:13 +00:00
endif ( )
2010-11-08 14:04:56 +00:00
2012-03-19 11:54:32 +00:00
if ( wxWidgets_FOUND )
include ( ${ wxWidgets_USE_FILE } )
2010-11-08 14:04:56 +00:00
message ( "wxWidgets found, enabling GUI build" )
else ( wxWidgets_FOUND )
2011-12-18 23:54:45 +00:00
message ( "Using static wxWidgets from Externals" )
2012-03-19 11:54:32 +00: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 12:17:57 +00:00
if ( APPLE )
2011-12-04 02:59:42 +00:00
add_definitions ( -D__WXOSX_COCOA__ )
2016-06-26 05:25:29 +00:00
elseif ( ${ CMAKE_SYSTEM_NAME } MATCHES "Linux|FreeBSD" )
2012-03-19 11:54:32 +00:00
add_definitions ( -D__WXGTK__ )
2012-03-23 00:06:45 +00:00
# Check for required libs
2015-06-02 22:00:50 +00: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 12:17:57 +00:00
elseif ( WIN32 )
2012-03-19 11:54:32 +00:00
add_definitions ( -D__WXMSW__ )
2011-12-04 02:59:42 +00:00
else ( )
2012-03-19 11:54:32 +00:00
message ( FATAL_ERROR "wxWidgets in Externals is not compatible with your platform" )
2011-12-04 02:59:42 +00:00
endif ( )
2013-07-11 02:49:13 +00:00
2015-06-21 17:29:04 +00:00
include_directories ( SYSTEM
2012-03-19 11:54:32 +00:00
E x t e r n a l s / w x W i d g e t s 3
E x t e r n a l s / w x W i d g e t s 3 / i n c l u d e )
add_subdirectory ( Externals/wxWidgets3 )
2011-12-05 00:10:45 +00:00
set ( wxWidgets_FOUND TRUE )
2012-03-19 11:54:32 +00:00
set ( wxWidgets_LIBRARIES "wx" )
2010-11-08 14:04:56 +00:00
endif ( wxWidgets_FOUND )
2010-11-17 01:03:39 +00:00
add_definitions ( -DHAVE_WX=1 )
2016-02-05 16:54:59 +00:00
endif ( NOT DISABLE_WX )
2010-11-01 15:47:02 +00:00
2015-01-03 12:17:57 +00:00
if ( ${ CMAKE_SYSTEM_NAME } MATCHES "FreeBSD|NetBSD" )
2014-11-20 00:55:52 +00:00
set ( LIBS ${ LIBS } usbhid )
endif ( )
2015-01-03 12:17:57 +00:00
if ( APPLE )
2014-11-20 00:55:52 +00:00
# Link against OS X system frameworks.
list ( APPEND LIBS
$ { A P P K I T _ L I B R A R Y }
$ { A U _ L I B R A R Y }
$ { C O R E A U D I O _ L I B R A R Y }
$ { C O R E F U N D _ L I B R A R Y }
$ { C O R E S E R V _ L I B R A R Y }
$ { I O K _ L I B R A R Y }
$ { F O R C E F E E D B A C K }
)
endif ( )
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
#
2013-10-20 00:14:00 +00:00
if ( DOLPHIN_WC_BRANCH STREQUAL "master" OR DOLPHIN_WC_BRANCH STREQUAL "stable" )
set ( DOLPHIN_WC_IS_STABLE "1" )
2011-08-21 21:30:19 +00:00
else ( )
2013-10-20 00:14:00 +00:00
set ( DOLPHIN_WC_IS_STABLE "0" )
2011-08-21 21:30:19 +00:00
endif ( )
2013-12-07 20:14:29 +00:00
file ( WRITE ${ PROJECT_BINARY_DIR } /Source/Core/Common/scmrev.h
2011-08-21 21:30:19 +00:00
" #define SCM_REV_STR \"" ${DOLPHIN_WC_REVISION} "\"\n"
" #define SCM_DESC_STR \"" ${DOLPHIN_WC_DESCRIBE} "\"\n"
" #define SCM_BRANCH_STR \"" ${DOLPHIN_WC_BRANCH} "\"\n"
2013-10-20 00:14:00 +00:00
" #define SCM_IS_MASTER " ${DOLPHIN_WC_IS_STABLE} "\n"
2016-06-17 22:13:37 +00:00
" #define SCM_DISTRIBUTOR_STR \"" ${DISTRIBUTOR} "\"\n"
2011-08-21 21:30:19 +00:00
)
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.
#
2016-03-04 03:55:44 +00:00
include ( FindGTest )
if ( GTEST_FOUND AND USE_SHARED_GTEST )
message ( "Using shared gtest" )
include_directories ( ${ GTEST_INCLUDE_DIRS } )
else ( )
message ( "Using static gtest from Externals" )
include_directories ( Externals/gtest/include )
add_subdirectory ( Externals/gtest )
2016-03-13 04:02:27 +00:00
endif ( )
2014-03-03 02:38:46 +00:00
enable_testing ( )
add_custom_target ( unittests )
add_custom_command ( TARGET unittests POST_BUILD COMMAND ${ CMAKE_CTEST_COMMAND } )
2011-07-18 01:47:55 +00:00
2010-11-01 15:47:02 +00:00
########################################
# Start compiling our code
#
2015-09-06 08:10:40 +00:00
add_definitions ( -std=c++1y )
2014-11-04 01:29:33 +00:00
# These aren't actually needed for C11/C++11
# but some dependencies require them (LLVM, libav).
add_definitions ( -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS )
2015-06-02 22:27:50 +00:00
# Do this at the last minute because try_compile ignores linker flags. Yay...
if ( APPLE )
# Some of our code contains Objective C constructs.
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -x objective-c -stdlib=libc++" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -x objective-c++ -stdlib=libc++" )
# Avoid mistaking an object file for a source file on the link command line.
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -x none" )
endif ( )
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
#
2015-01-03 12:17:57 +00:00
if ( NOT APPLE )
2011-12-14 01:50:36 +00:00
install ( DIRECTORY Data/Sys/ DESTINATION ${ datadir } /sys PATTERN )
endif ( )
2016-07-18 02:25:13 +00:00
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 ( )
2016-07-18 02:25:13 +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
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 / 4 8 x 4 8 / 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
2016-04-02 20:16:29 +00:00
D E S T I N A T I O N $ { 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
2016-04-02 20:16:29 +00:00
D E S T I N A T I O N $ { 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
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 )