2021-04-13 13:02:18 +00:00
cmake_minimum_required ( VERSION 3.16.9 )
2014-04-25 16:57:00 +00:00
2018-09-18 10:07:33 +00:00
project ( rpcs3 )
2021-04-17 13:40:24 +00:00
if ( ${ CMAKE_CXX_COMPILER_ID } MATCHES "GNU" )
2021-05-26 19:21:01 +00:00
if ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11 )
message ( FATAL_ERROR "RPCS3 requires at least gcc-11." )
2021-04-20 19:11:17 +00:00
endif ( )
2019-06-23 05:54:42 +00:00
elseif ( ${ CMAKE_CXX_COMPILER_ID } MATCHES "Clang" )
2021-04-13 13:02:18 +00:00
if ( CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.0 )
message ( FATAL_ERROR "RPCS3 requires at least clang-12.0." )
2021-04-20 19:11:17 +00:00
endif ( )
2019-06-23 05:54:42 +00:00
endif ( )
2021-06-05 01:07:09 +00:00
option ( USE_NATIVE_INSTRUCTIONS "USE_NATIVE_INSTRUCTIONS makes rpcs3 compile with -march=native, which is useful for local builds, but not good for packages." ON )
option ( WITH_LLVM "Enable usage of LLVM library" ON )
option ( BUILD_LLVM_SUBMODULE "Build LLVM from git submodule" ON )
option ( USE_ALSA "ALSA audio backend" ON )
option ( USE_PULSE "PulseAudio audio backend" ON )
option ( USE_FAUDIO "FAudio audio backend" ON )
option ( USE_LIBEVDEV "libevdev-based joystick support" ON )
option ( USE_DISCORD_RPC "Discord rich presence integration" ON )
option ( USE_SYSTEM_ZLIB "Prefer system ZLIB instead of the builtin one" ON )
option ( USE_VULKAN "Vulkan render backend" ON )
option ( USE_PRECOMPILED_HEADERS "Use precompiled headers" OFF )
2018-09-18 10:07:33 +00:00
2021-05-15 18:20:12 +00:00
set ( CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/buildfiles/cmake" )
2018-09-18 10:07:33 +00:00
2020-02-09 11:17:36 +00:00
set ( CMAKE_CXX_STANDARD 20 )
2018-09-18 10:07:33 +00:00
include ( CheckCXXCompilerFlag )
2021-04-18 14:36:00 +00:00
if ( NOT CMAKE_BUILD_TYPE )
2021-04-20 19:11:17 +00:00
message ( STATUS "No build type selected, default to Release" )
set ( CMAKE_BUILD_TYPE "Release" )
2014-07-10 16:46:10 +00:00
endif ( )
2021-04-20 19:11:50 +00:00
if ( NOT CMAKE_BUILD_TYPE MATCHES "Debug" )
2021-04-20 19:11:17 +00:00
add_definitions ( -DNDEBUG )
2021-01-18 10:49:16 +00:00
elseif ( NOT MSVC )
2021-04-20 19:11:17 +00:00
add_definitions ( -D_DEBUG )
2018-09-21 21:54:16 +00:00
endif ( )
2014-07-10 16:46:10 +00:00
if ( NOT CMAKE_SIZEOF_VOID_P EQUAL 8 )
2021-04-20 19:11:17 +00:00
message ( FATAL_ERROR "RPCS3 can only be compiled on 64-bit platforms." )
2014-07-10 16:46:10 +00:00
endif ( )
2017-03-02 21:49:42 +00:00
find_program ( CCACHE_FOUND ccache )
2021-04-18 14:36:00 +00:00
if ( CCACHE_FOUND )
2021-04-20 19:11:17 +00:00
set_property ( GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache )
set_property ( GLOBAL PROPERTY RULE_LAUNCH_LINK ccache )
2017-03-02 21:49:42 +00:00
endif ( )
2018-09-18 10:07:33 +00:00
if ( WIN32 )
2021-04-20 19:11:17 +00:00
add_definitions ( -DUNICODE )
add_definitions ( -D_WIN32_WINNT=0x0602 )
2018-06-14 19:39:48 +00:00
endif ( )
2018-11-10 14:43:38 +00:00
if ( APPLE )
2021-04-20 19:11:17 +00:00
include_directories ( /opt/local/include )
link_directories ( /opt/local/lib )
2018-11-10 14:43:38 +00:00
endif ( )
2019-06-23 05:54:42 +00:00
# Warnings are silenced for 3rdparty code
set ( CMAKE_CXX_FLAGS -w )
set ( CMAKE_C_FLAGS -w )
2019-06-28 04:15:49 +00:00
set ( LLVM_ENABLE_WARNINGS OFF CACHE BOOL "" )
if ( MSVC )
2021-04-20 19:11:17 +00:00
add_compile_options ( /wd4530 /utf-8 ) # C++ exception handler used, but unwind semantics are not enabled
2019-06-28 04:15:49 +00:00
endif ( )
2018-09-18 10:07:33 +00:00
add_subdirectory ( 3rdparty )
2019-06-28 04:15:49 +00:00
2019-06-23 05:54:42 +00:00
unset ( CMAKE_CXX_FLAGS )
unset ( CMAKE_C_FLAGS )
2018-06-07 16:38:19 +00:00
2021-04-18 14:36:00 +00:00
if ( NOT WIN32 )
2021-04-20 19:11:17 +00:00
add_compile_options ( -pthread )
2019-07-07 13:15:06 +00:00
endif ( )
2015-08-07 21:53:39 +00:00
# TODO: do real installation, including copying directory structure
set ( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${PROJECT_BINARY_DIR}/bin" )
set ( CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${PROJECT_BINARY_DIR}/bin" )
2017-06-22 20:05:32 +00:00
set ( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${PROJECT_BINARY_DIR}/bin" )
2017-06-12 18:45:29 +00:00
2019-10-12 19:12:03 +00:00
set ( CMAKE_EXPORT_COMPILE_COMMANDS ON )
2018-05-01 23:10:19 +00:00
add_subdirectory ( rpcs3 )