mirror of https://github.com/PCSX2/pcsx2.git
CMake: Tidy up platform/architecture detection
This commit is contained in:
parent
182375314e
commit
0e15de7103
|
@ -28,7 +28,7 @@ add_library(pcsx2-zstd
|
||||||
zstd/lib/decompress/zstd_decompress.c
|
zstd/lib/decompress/zstd_decompress.c
|
||||||
)
|
)
|
||||||
|
|
||||||
if(NOT MSVC AND ${PCSX2_TARGET_ARCHITECTURES} MATCHES "x86_64")
|
if(_M_X86 AND (NOT MSVC OR USE_CLANG_CL))
|
||||||
target_sources(pcsx2-zstd PRIVATE zstd/lib/decompress/huf_decompress_amd64.S)
|
target_sources(pcsx2-zstd PRIVATE zstd/lib/decompress/huf_decompress_amd64.S)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
# Setting it to a range tells it that it supports the features on the newer
|
# Setting it to a range tells it that it supports the features on the newer
|
||||||
# versions as well, avoiding setting policies.
|
# versions as well, avoiding setting policies.
|
||||||
cmake_minimum_required(VERSION 3.16...3.24)
|
cmake_minimum_required(VERSION 3.16...3.25)
|
||||||
|
|
||||||
#Enabling this cmake policy gets rid of warnings regarding LTO.
|
# Enabling this cmake policy gets rid of warnings regarding LTO.
|
||||||
cmake_policy(SET CMP0069 NEW)
|
cmake_policy(SET CMP0069 NEW)
|
||||||
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
|
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Project Name
|
# Project Name
|
||||||
project(Pcsx2)
|
project(Pcsx2 C CXX)
|
||||||
|
|
||||||
# Variable to check that people use the good file
|
# Variable to check that people use the good file
|
||||||
set(TOP_CMAKE_WAS_SOURCED TRUE)
|
set(TOP_CMAKE_WAS_SOURCED TRUE)
|
||||||
|
@ -30,14 +30,11 @@ endif()
|
||||||
include(Pcsx2Utils)
|
include(Pcsx2Utils)
|
||||||
|
|
||||||
check_no_parenthesis_in_path()
|
check_no_parenthesis_in_path()
|
||||||
detectOperatingSystem()
|
detect_operating_system()
|
||||||
check_compiler_version("7.0" "7.0")
|
detect_compiler()
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# Include specific module
|
# Include specific module
|
||||||
# GNUInstallDirs must be done before BuildParameters
|
|
||||||
include(GNUInstallDirs)
|
|
||||||
# BuildParameters Must be done before SearchForStuff
|
|
||||||
include(BuildParameters)
|
include(BuildParameters)
|
||||||
include(SearchForStuff)
|
include(SearchForStuff)
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,6 @@
|
||||||
"patch": 0
|
"patch": 0
|
||||||
},
|
},
|
||||||
"configurePresets": [
|
"configurePresets": [
|
||||||
{
|
|
||||||
"name": "gcc-base",
|
|
||||||
"displayName": "GCC Base",
|
|
||||||
"description": "Base preset for GCC. Only for inheriting from.",
|
|
||||||
"hidden": true,
|
|
||||||
"binaryDir": "${sourceDir}/build"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "clang-base",
|
"name": "clang-base",
|
||||||
"displayName": "Base",
|
"displayName": "Base",
|
||||||
|
@ -32,69 +25,9 @@
|
||||||
"name": "ninja-multi",
|
"name": "ninja-multi",
|
||||||
"displayName": "Ninja Multi Config",
|
"displayName": "Ninja Multi Config",
|
||||||
"description": "Generate multiple ninja build files.",
|
"description": "Generate multiple ninja build files.",
|
||||||
"inherits": "gcc-base",
|
"inherits": "clang-base",
|
||||||
"generator": "Ninja Multi-Config"
|
"generator": "Ninja Multi-Config"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "gcc-debug",
|
|
||||||
"displayName": "GCC Debug",
|
|
||||||
"description": "GCC Debug build with make.",
|
|
||||||
"inherits": "gcc-base",
|
|
||||||
"generator": "Unix Makefiles",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "gcc-devel",
|
|
||||||
"displayName": "GCC Devel",
|
|
||||||
"description": "GCC Developer build using make.",
|
|
||||||
"inherits": "gcc-base",
|
|
||||||
"generator": "Unix Makefiles",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Devel"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "gcc-release",
|
|
||||||
"displayName": "GCC Release",
|
|
||||||
"description": "GCC Release build using make.",
|
|
||||||
"inherits": "gcc-base",
|
|
||||||
"generator": "Unix Makefiles",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Release"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "gcc-debug-ninja",
|
|
||||||
"displayName": "GCC Debug Ninja",
|
|
||||||
"description": "Debug build using ninja.",
|
|
||||||
"inherits": "gcc-base",
|
|
||||||
"generator": "Ninja",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Debug"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "gcc-devel-ninja",
|
|
||||||
"displayName": "GCC Devel Ninja",
|
|
||||||
"description": "GCC Developer build using ninja.",
|
|
||||||
"inherits": "gcc-base",
|
|
||||||
"generator": "Ninja",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Devel"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "gcc-release-ninja",
|
|
||||||
"displayName": "GCC Release Ninja",
|
|
||||||
"description": "GCC Release build using ninja.",
|
|
||||||
"inherits": "gcc-base",
|
|
||||||
"generator": "Ninja",
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_BUILD_TYPE": "Release"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "clang-debug",
|
"name": "clang-debug",
|
||||||
"displayName": "Clang Debug",
|
"displayName": "Clang Debug",
|
||||||
|
|
|
@ -38,21 +38,6 @@ endif()
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
option(USE_ASAN "Enable address sanitizer")
|
option(USE_ASAN "Enable address sanitizer")
|
||||||
|
|
||||||
if(MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
|
||||||
set(USE_CLANG_CL TRUE)
|
|
||||||
message(STATUS "Building with Clang-CL.")
|
|
||||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
|
||||||
set(USE_CLANG TRUE)
|
|
||||||
message(STATUS "Building with Clang/LLVM.")
|
|
||||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
||||||
set(USE_GCC TRUE)
|
|
||||||
message(STATUS "Building with GNU GCC")
|
|
||||||
elseif(MSVC)
|
|
||||||
message(STATUS "Building with MSVC")
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "Unknown compiler: ${CMAKE_CXX_COMPILER_ID}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# if no build type is set, use Devel as default
|
# if no build type is set, use Devel as default
|
||||||
# Note without the CMAKE_BUILD_TYPE options the value is still defined to ""
|
# Note without the CMAKE_BUILD_TYPE options the value is still defined to ""
|
||||||
|
@ -81,52 +66,38 @@ mark_as_advanced(CMAKE_C_FLAGS_DEVEL CMAKE_CXX_FLAGS_DEVEL CMAKE_LINKER_FLAGS_DE
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# Select the architecture
|
# Select the architecture
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
option(DISABLE_ADVANCE_SIMD "Disable advance use of SIMD (SSE2+ & AVX)" OFF)
|
if("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "x86_64" OR "${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "amd64" OR
|
||||||
|
"${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "AMD64" OR "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "x86_64")
|
||||||
|
# Multi-ISA only exists on x86.
|
||||||
|
option(DISABLE_ADVANCE_SIMD "Disable advance use of SIMD (SSE2+ & AVX)" OFF)
|
||||||
|
|
||||||
# Print if we are cross compiling.
|
|
||||||
if(CMAKE_CROSSCOMPILING)
|
|
||||||
message(STATUS "Cross compilation is enabled.")
|
|
||||||
else()
|
|
||||||
message(STATUS "Cross compilation is disabled.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Architecture bitness detection
|
|
||||||
include(TargetArch)
|
|
||||||
target_architecture(PCSX2_TARGET_ARCHITECTURES)
|
|
||||||
if(${PCSX2_TARGET_ARCHITECTURES} MATCHES "x86_64")
|
|
||||||
message(STATUS "Compiling a ${PCSX2_TARGET_ARCHITECTURES} build on a ${CMAKE_HOST_SYSTEM_PROCESSOR} host.")
|
|
||||||
|
|
||||||
# x86_64 requires -fPIC
|
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
||||||
|
|
||||||
if(NOT DEFINED ARCH_FLAG AND NOT MSVC)
|
|
||||||
if (DISABLE_ADVANCE_SIMD)
|
|
||||||
set(ARCH_FLAG "-msse -msse2 -msse4.1 -mfxsr")
|
|
||||||
else()
|
|
||||||
#set(ARCH_FLAG "-march=native -fabi-version=6")
|
|
||||||
set(ARCH_FLAG "-march=native")
|
|
||||||
endif()
|
|
||||||
elseif(NOT DEFINED ARCH_FLAG AND USE_CLANG_CL)
|
|
||||||
set(ARCH_FLAG "-msse4.1")
|
|
||||||
endif()
|
|
||||||
list(APPEND PCSX2_DEFS _M_X86=1)
|
list(APPEND PCSX2_DEFS _M_X86=1)
|
||||||
set(_M_X86 1)
|
set(_M_X86 TRUE)
|
||||||
|
if(DISABLE_ADVANCE_SIMD)
|
||||||
|
message(STATUS "Building for x86-64 (Multi-ISA).")
|
||||||
|
else()
|
||||||
|
message(STATUS "Building for x86-64.")
|
||||||
|
endif()
|
||||||
|
|
||||||
# SSE4.1 is not set by MSVC, it uses _M_SSE instead.
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
|
# SSE4.1 is not set by MSVC, it uses _M_SSE instead.
|
||||||
list(APPEND PCSX2_DEFS __SSE4_1__=1)
|
list(APPEND PCSX2_DEFS __SSE4_1__=1)
|
||||||
|
|
||||||
|
if(USE_CLANG_CL)
|
||||||
|
# clang-cl => need to explicitly enable SSE4.1.
|
||||||
|
add_compile_options("-msse4.1")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
# Multi-ISA => SSE4, otherwise native.
|
||||||
|
if (DISABLE_ADVANCE_SIMD)
|
||||||
|
add_compile_options("-msse" "-msse2" "-msse4.1" "-mfxsr")
|
||||||
|
else()
|
||||||
|
add_compile_options("-march=native")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "Unsupported architecture: ${PCSX2_TARGET_ARCHITECTURES}")
|
message(FATAL_ERROR "Unsupported architecture: ${CMAKE_HOST_SYSTEM_PROCESSOR}")
|
||||||
endif()
|
endif()
|
||||||
string(REPLACE " " ";" ARCH_FLAG_LIST "${ARCH_FLAG}")
|
|
||||||
add_compile_options("${ARCH_FLAG_LIST}")
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
|
||||||
# Set some default compiler flags
|
|
||||||
#-------------------------------------------------------------------------------
|
|
||||||
option(USE_PGO_GENERATE "Enable PGO optimization (generate profile)")
|
|
||||||
option(USE_PGO_OPTIMIZE "Enable PGO optimization (use profile)")
|
|
||||||
|
|
||||||
# Require C++20.
|
# Require C++20.
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
|
@ -183,7 +154,7 @@ endif()
|
||||||
|
|
||||||
# Enable debug information in release builds for Linux.
|
# Enable debug information in release builds for Linux.
|
||||||
# Makes the backtrace actually meaningful.
|
# Makes the backtrace actually meaningful.
|
||||||
if(UNIX AND NOT APPLE)
|
if(LINUX)
|
||||||
add_compile_options($<$<CONFIG:Release>:-g1>)
|
add_compile_options($<$<CONFIG:Release>:-g1>)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
# Once done, this will define
|
|
||||||
#
|
|
||||||
# LIBC_FOUND - system has libc
|
|
||||||
# LIBC_LIBRARIES - link these to use libc
|
|
||||||
|
|
||||||
if(LIBC_LIBRARIES)
|
|
||||||
set(LIBC_FIND_QUIETLY TRUE)
|
|
||||||
endif(LIBC_LIBRARIES)
|
|
||||||
|
|
||||||
find_library(libm NAMES m)
|
|
||||||
|
|
||||||
# OSX doesn't have rt. On Linux timer and aio dependency.
|
|
||||||
if(APPLE)
|
|
||||||
find_library(libdl NAMES dl)
|
|
||||||
set(LIBC_LIBRARIES ${librt} ${libdl} ${libm})
|
|
||||||
elseif(Linux)
|
|
||||||
find_library(libdl NAMES dl)
|
|
||||||
find_library(librt NAMES rt)
|
|
||||||
set(LIBC_LIBRARIES ${librt} ${libdl} ${libm})
|
|
||||||
else()
|
|
||||||
# FreeBSD doesn't have libdl
|
|
||||||
find_library(librt NAMES rt)
|
|
||||||
set(LIBC_LIBRARIES ${librt} ${libm})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# handle the QUIETLY and REQUIRED arguments and set LIBC_FOUND to TRUE if
|
|
||||||
# all listed variables are TRUE
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
find_package_handle_standard_args(Libc DEFAULT_MSG LIBC_LIBRARIES)
|
|
||||||
|
|
||||||
mark_as_advanced(LIBC_LIBRARIES)
|
|
||||||
|
|
|
@ -1,38 +1,36 @@
|
||||||
#-------------------------------------------------------------------------------
|
function(detect_operating_system)
|
||||||
# detectOperatingSystem
|
# LINUX wasn't added until CMake 3.25.
|
||||||
#-------------------------------------------------------------------------------
|
if (CMAKE_VERSION VERSION_LESS 3.25.0 AND CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||||
# This function detects on which OS cmake is run and set a flag to control the
|
set(LINUX TRUE PARENT_SCOPE)
|
||||||
# build process. Supported OS: Linux, MacOSX, Windows
|
endif()
|
||||||
#
|
|
||||||
# On linux, it also set a flag for specific distribution (ie Fedora)
|
|
||||||
#-------------------------------------------------------------------------------
|
|
||||||
function(detectOperatingSystem)
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(Windows TRUE PARENT_SCOPE)
|
message(STATUS "Building for Windows.")
|
||||||
elseif(UNIX AND APPLE)
|
elseif(APPLE AND NOT IOS)
|
||||||
if(IOS)
|
message(STATUS "Building for MacOS.")
|
||||||
message(WARNING "iOS isn't supported, the build will most likely fail")
|
elseif(LINUX)
|
||||||
endif()
|
message(STATUS "Building for Linux.")
|
||||||
set(MacOSX TRUE PARENT_SCOPE)
|
elseif(BSD)
|
||||||
elseif(UNIX)
|
message(STATUS "Building for *BSD.")
|
||||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
else()
|
||||||
set(Linux TRUE PARENT_SCOPE)
|
message(FATAL_ERROR "Unsupported platform.")
|
||||||
if (EXISTS /etc/os-release)
|
endif()
|
||||||
# Read the file without CR character
|
endfunction()
|
||||||
file(STRINGS /etc/os-release OS_RELEASE)
|
|
||||||
if("${OS_RELEASE}" MATCHES "^.*ID=fedora.*$")
|
function(detect_compiler)
|
||||||
set(Fedora TRUE PARENT_SCOPE)
|
if(MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
message(STATUS "Build Fedora specific")
|
set(USE_CLANG_CL TRUE PARENT_SCOPE)
|
||||||
elseif("${OS_RELEASE}" MATCHES "^.*ID=.*suse.*$")
|
message(STATUS "Building with Clang-CL.")
|
||||||
set(openSUSE TRUE PARENT_SCOPE)
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
||||||
message(STATUS "Build openSUSE specific")
|
set(USE_CLANG TRUE PARENT_SCOPE)
|
||||||
endif()
|
message(STATUS "Building with Clang/LLVM.")
|
||||||
endif()
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
elseif(CMAKE_SYSTEM_NAME MATCHES "kFreeBSD")
|
set(USE_GCC TRUE PARENT_SCOPE)
|
||||||
set(kFreeBSD TRUE PARENT_SCOPE)
|
message(STATUS "Building with GNU GCC. THIS IS NOT A SUPPORTED CONFIGURATION.")
|
||||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "GNU")
|
elseif(MSVC)
|
||||||
set(GNU TRUE PARENT_SCOPE)
|
message(STATUS "Building with MSVC.")
|
||||||
endif()
|
else()
|
||||||
|
message(FATAL_ERROR "Unknown compiler: ${CMAKE_CXX_COMPILER_ID}")
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
@ -119,24 +117,6 @@ function(write_svnrev_h)
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(check_compiler_version version_warn version_err)
|
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
|
||||||
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
|
|
||||||
string(STRIP "${GCC_VERSION}" GCC_VERSION)
|
|
||||||
if(GCC_VERSION VERSION_LESS ${version_err})
|
|
||||||
message(FATAL_ERROR "PCSX2 doesn't support your old GCC ${GCC_VERSION}! Please upgrade it!
|
|
||||||
|
|
||||||
The minimum supported version is ${version_err} but ${version_warn} is warmly recommended")
|
|
||||||
else()
|
|
||||||
if(GCC_VERSION VERSION_LESS ${version_warn})
|
|
||||||
message(WARNING "PCSX2 will stop supporting GCC ${GCC_VERSION} in the near future. Please upgrade to at least GCC ${version_warn}.")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(GCC_VERSION "${GCC_VERSION}" PARENT_SCOPE)
|
|
||||||
endif()
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
function(check_no_parenthesis_in_path)
|
function(check_no_parenthesis_in_path)
|
||||||
if ("${CMAKE_BINARY_DIR}" MATCHES "[()]" OR "${CMAKE_SOURCE_DIR}" MATCHES "[()]")
|
if ("${CMAKE_BINARY_DIR}" MATCHES "[()]" OR "${CMAKE_SOURCE_DIR}" MATCHES "[()]")
|
||||||
message(FATAL_ERROR "Your path contains some parenthesis. Unfortunately Cmake doesn't support them correctly.\nPlease rename your directory to avoid '(' and ')' characters\n")
|
message(FATAL_ERROR "Your path contains some parenthesis. Unfortunately Cmake doesn't support them correctly.\nPlease rename your directory to avoid '(' and ')' characters\n")
|
||||||
|
@ -163,25 +143,6 @@ function(alias_library new old)
|
||||||
add_library(${new} ALIAS _alias_${library_no_namespace})
|
add_library(${new} ALIAS _alias_${library_no_namespace})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# Helper macro to generate resources on linux (based on glib)
|
|
||||||
macro(add_custom_glib_res out xml prefix)
|
|
||||||
set(RESOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/res")
|
|
||||||
set(RESOURCE_FILES "${ARGN}")
|
|
||||||
# Note: trying to combine --generate-source and --generate-header doesn't work.
|
|
||||||
# It outputs whichever one comes last into the file named by the first
|
|
||||||
add_custom_command(
|
|
||||||
OUTPUT ${out}.h
|
|
||||||
COMMAND glib-compile-resources --sourcedir "${RESOURCE_DIR}" --generate-header
|
|
||||||
--c-name ${prefix} "${RESOURCE_DIR}/${xml}" --target=${out}.h
|
|
||||||
DEPENDS res/${xml} ${RESOURCE_FILES})
|
|
||||||
|
|
||||||
add_custom_command(
|
|
||||||
OUTPUT ${out}.cpp
|
|
||||||
COMMAND glib-compile-resources --sourcedir "${RESOURCE_DIR}" --generate-source
|
|
||||||
--c-name ${prefix} "${RESOURCE_DIR}/${xml}" --target=${out}.cpp
|
|
||||||
DEPENDS res/${xml} ${RESOURCE_FILES})
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
function(source_groups_from_vcxproj_filters file)
|
function(source_groups_from_vcxproj_filters file)
|
||||||
file(READ "${file}" filecontent)
|
file(READ "${file}" filecontent)
|
||||||
get_filename_component(parent "${file}" DIRECTORY)
|
get_filename_component(parent "${file}" DIRECTORY)
|
||||||
|
|
|
@ -48,9 +48,6 @@ else()
|
||||||
|
|
||||||
find_package(ZLIB REQUIRED)
|
find_package(ZLIB REQUIRED)
|
||||||
|
|
||||||
## Use pcsx2 package to find module
|
|
||||||
include(FindLibc)
|
|
||||||
|
|
||||||
## Use CheckLib package to find module
|
## Use CheckLib package to find module
|
||||||
include(CheckLib)
|
include(CheckLib)
|
||||||
|
|
||||||
|
@ -59,7 +56,7 @@ else()
|
||||||
check_lib(EGL EGL EGL/egl.h)
|
check_lib(EGL EGL EGL/egl.h)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(Linux)
|
if(LINUX)
|
||||||
check_lib(AIO aio libaio.h)
|
check_lib(AIO aio libaio.h)
|
||||||
# There are two udev pkg config files - udev.pc (wrong), libudev.pc (correct)
|
# There are two udev pkg config files - udev.pc (wrong), libudev.pc (correct)
|
||||||
# When cross compiling, pkg-config will be skipped so we have to look for
|
# When cross compiling, pkg-config will be skipped so we have to look for
|
||||||
|
@ -95,7 +92,7 @@ endif(WIN32)
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
|
|
||||||
# Also need SDL2.
|
# Also need SDL2.
|
||||||
find_package(SDL2 2.28.4 REQUIRED)
|
find_package(SDL2 2.28.5 REQUIRED)
|
||||||
|
|
||||||
set(ACTUALLY_ENABLE_TESTS ${ENABLE_TESTS})
|
set(ACTUALLY_ENABLE_TESTS ${ENABLE_TESTS})
|
||||||
if(ENABLE_TESTS)
|
if(ENABLE_TESTS)
|
||||||
|
@ -105,19 +102,6 @@ if(ENABLE_TESTS)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(GCC_VERSION VERSION_GREATER_EQUAL "9.0" AND GCC_VERSION VERSION_LESS "9.2")
|
|
||||||
message(WARNING "
|
|
||||||
It looks like you are compiling with 9.0.x or 9.1.x. Using these versions is not recommended,
|
|
||||||
as there is a bug known to cause the compiler to segfault while compiling. See patch
|
|
||||||
https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=275ab714637a64672c6630cfd744af2c70957d5a
|
|
||||||
Even with that patch, compiling with LTO may still segfault. Use at your own risk!
|
|
||||||
This text being in a compile log in an open issue may cause it to be closed.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Prevent fmt from being built with exceptions, or being thrown at call sites.
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DFMT_EXCEPTIONS=0")
|
|
||||||
|
|
||||||
add_subdirectory(3rdparty/fmt/fmt EXCLUDE_FROM_ALL)
|
|
||||||
add_subdirectory(3rdparty/rapidyaml/rapidyaml EXCLUDE_FROM_ALL)
|
add_subdirectory(3rdparty/rapidyaml/rapidyaml EXCLUDE_FROM_ALL)
|
||||||
add_subdirectory(3rdparty/lzma EXCLUDE_FROM_ALL)
|
add_subdirectory(3rdparty/lzma EXCLUDE_FROM_ALL)
|
||||||
add_subdirectory(3rdparty/libchdr EXCLUDE_FROM_ALL)
|
add_subdirectory(3rdparty/libchdr EXCLUDE_FROM_ALL)
|
||||||
|
@ -169,6 +153,10 @@ endif()
|
||||||
# Demangler for the debugger
|
# Demangler for the debugger
|
||||||
add_subdirectory(3rdparty/demangler EXCLUDE_FROM_ALL)
|
add_subdirectory(3rdparty/demangler EXCLUDE_FROM_ALL)
|
||||||
|
|
||||||
|
# Prevent fmt from being built with exceptions, or being thrown at call sites.
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DFMT_EXCEPTIONS=0")
|
||||||
|
add_subdirectory(3rdparty/fmt/fmt EXCLUDE_FROM_ALL)
|
||||||
|
|
||||||
# Deliberately at the end. We don't want to set the flag on third-party projects.
|
# Deliberately at the end. We don't want to set the flag on third-party projects.
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
# Don't warn about "deprecated" POSIX functions.
|
# Don't warn about "deprecated" POSIX functions.
|
||||||
|
|
|
@ -1,169 +0,0 @@
|
||||||
# Copyright (c) 2014 PCSX2 Dev Team
|
|
||||||
# Copyright (c) 2012 Petroules Corporation. All rights reserved.
|
|
||||||
#
|
|
||||||
# Redistribution and use in source and binary forms, with or without
|
|
||||||
# modification, are permitted provided that the following conditions are met:
|
|
||||||
#
|
|
||||||
# 1. Redistributions of source code must retain the above copyright notice, this
|
|
||||||
# list of conditions and the following disclaimer.
|
|
||||||
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
# this list of conditions and the following disclaimer in the documentation
|
|
||||||
# and/or other materials provided with the distribution.
|
|
||||||
#
|
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
#
|
|
||||||
# https://github.com/petroules/solar-cmake/blob/master/TargetArch.cmake
|
|
||||||
#
|
|
||||||
# Based on the Qt 5 processor detection code, so should be very accurate
|
|
||||||
# https://qt.gitorious.org/qt/qtbase/blobs/master/src/corelib/global/qprocessordetection.h
|
|
||||||
# Currently handles arm (v5, v6, v7), x86 (32/64), ia64, and ppc (32/64)
|
|
||||||
|
|
||||||
# Regarding POWER/PowerPC, just as is noted in the Qt source,
|
|
||||||
# "There are many more known variants/revisions that we do not handle/detect."
|
|
||||||
|
|
||||||
set(archdetect_c_code "
|
|
||||||
#if defined(__arm__) || defined(__TARGET_ARCH_ARM)
|
|
||||||
#if defined(__ARM_ARCH_7__) \\
|
|
||||||
|| defined(__ARM_ARCH_7A__) \\
|
|
||||||
|| defined(__ARM_ARCH_7R__) \\
|
|
||||||
|| defined(__ARM_ARCH_7M__) \\
|
|
||||||
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 7)
|
|
||||||
#error cmake_ARCH armv7
|
|
||||||
#elif defined(__ARM_ARCH_6__) \\
|
|
||||||
|| defined(__ARM_ARCH_6J__) \\
|
|
||||||
|| defined(__ARM_ARCH_6T2__) \\
|
|
||||||
|| defined(__ARM_ARCH_6Z__) \\
|
|
||||||
|| defined(__ARM_ARCH_6K__) \\
|
|
||||||
|| defined(__ARM_ARCH_6ZK__) \\
|
|
||||||
|| defined(__ARM_ARCH_6M__) \\
|
|
||||||
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 6)
|
|
||||||
#error cmake_ARCH armv6
|
|
||||||
#elif defined(__ARM_ARCH_5TEJ__) \\
|
|
||||||
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 5)
|
|
||||||
#error cmake_ARCH armv5
|
|
||||||
#else
|
|
||||||
#error cmake_ARCH arm
|
|
||||||
#endif
|
|
||||||
#elif defined(__i386) || defined(__i386__) || defined(_M_IX86)
|
|
||||||
#error cmake_ARCH i386
|
|
||||||
#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64)
|
|
||||||
#error cmake_ARCH x86_64
|
|
||||||
#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
|
|
||||||
#error cmake_ARCH ia64
|
|
||||||
#elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) \\
|
|
||||||
|| defined(_ARCH_COM) || defined(_ARCH_PWR) || defined(_ARCH_PPC) \\
|
|
||||||
|| defined(_M_MPPC) || defined(_M_PPC)
|
|
||||||
#if defined(__ppc64__) || defined(__powerpc64__) || defined(__64BIT__)
|
|
||||||
#error cmake_ARCH ppc64
|
|
||||||
#else
|
|
||||||
#error cmake_ARCH ppc
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#error cmake_ARCH unknown
|
|
||||||
")
|
|
||||||
|
|
||||||
# Set ppc_support to TRUE before including this file or ppc and ppc64
|
|
||||||
# will be treated as invalid architectures since they are no longer supported by Apple
|
|
||||||
|
|
||||||
function(target_architecture output_var)
|
|
||||||
if(APPLE AND CMAKE_OSX_ARCHITECTURES)
|
|
||||||
# On OS X we use CMAKE_OSX_ARCHITECTURES *if* it was set
|
|
||||||
# First let's normalize the order of the values
|
|
||||||
|
|
||||||
# Note that it's not possible to compile PowerPC applications if you are using
|
|
||||||
# the OS X SDK version 10.6 or later - you'll need 10.4/10.5 for that, so we
|
|
||||||
# disable it by default
|
|
||||||
# See this page for more information:
|
|
||||||
# http://stackoverflow.com/questions/5333490/how-can-we-restore-ppc-ppc64-as-well-as-full-10-4-10-5-sdk-support-to-xcode-4
|
|
||||||
|
|
||||||
# Architecture defaults to i386 or ppc on OS X 10.5 and earlier, depending on the CPU type detected at runtime.
|
|
||||||
# On OS X 10.6+ the default is x86_64 if the CPU supports it, i386 otherwise.
|
|
||||||
|
|
||||||
LIST(LENGTH CMAKE_OSX_ARCHITECTURES osx_arch_num)
|
|
||||||
if(NOT (osx_arch_num EQUAL 1))
|
|
||||||
message(FATAL_ERROR "Currently ${CMAKE_PROJECT_NAME} does not support multiple architectures in CMAKE_OSX_ARCHITECTURES")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
foreach(osx_arch ${CMAKE_OSX_ARCHITECTURES})
|
|
||||||
if("${osx_arch}" STREQUAL "ppc" AND ppc_support)
|
|
||||||
set(osx_arch_ppc TRUE)
|
|
||||||
elseif("${osx_arch}" STREQUAL "i386")
|
|
||||||
set(osx_arch_i386 TRUE)
|
|
||||||
elseif("${osx_arch}" STREQUAL "x86_64")
|
|
||||||
set(osx_arch_x86_64 TRUE)
|
|
||||||
elseif("${osx_arch}" STREQUAL "ppc64" AND ppc_support)
|
|
||||||
set(osx_arch_ppc64 TRUE)
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "Invalid OS X arch name: ${osx_arch}")
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
# Now add all the architectures in our normalized order
|
|
||||||
if(osx_arch_ppc)
|
|
||||||
list(APPEND ARCH ppc)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(osx_arch_i386)
|
|
||||||
list(APPEND ARCH i386)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(osx_arch_x86_64)
|
|
||||||
list(APPEND ARCH x86_64)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(osx_arch_ppc64)
|
|
||||||
list(APPEND ARCH ppc64)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
LIST(LENGTH ARCH osx_arch_num)
|
|
||||||
if(osx_arch_num LESS 1)
|
|
||||||
message(FATAL_ERROR "Invalid CMAKE_OSX_ARCHITECTURES: ${CMAKE_OSX_ARCHITECTURES}")
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
file(WRITE "${CMAKE_BINARY_DIR}/arch.c" "${archdetect_c_code}")
|
|
||||||
|
|
||||||
enable_language(C)
|
|
||||||
|
|
||||||
# Detect the architecture in a rather creative way...
|
|
||||||
# This compiles a small C program which is a series of ifdefs that selects a
|
|
||||||
# particular #error preprocessor directive whose message string contains the
|
|
||||||
# target architecture. The program will always fail to compile (both because
|
|
||||||
# file is not a valid C program, and obviously because of the presence of the
|
|
||||||
# #error preprocessor directives... but by exploiting the preprocessor in this
|
|
||||||
# way, we can detect the correct target architecture even when cross-compiling,
|
|
||||||
# since the program itself never needs to be run (only the compiler/preprocessor)
|
|
||||||
try_run(
|
|
||||||
run_result_unused
|
|
||||||
compile_result_unused
|
|
||||||
"${CMAKE_BINARY_DIR}"
|
|
||||||
"${CMAKE_BINARY_DIR}/arch.c"
|
|
||||||
COMPILE_OUTPUT_VARIABLE ARCH
|
|
||||||
CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
|
|
||||||
)
|
|
||||||
|
|
||||||
# Parse the architecture name from the compiler output
|
|
||||||
string(REGEX MATCH "cmake_ARCH ([a-zA-Z0-9_]+)" ARCH "${ARCH}")
|
|
||||||
|
|
||||||
# Get rid of the value marker leaving just the architecture name
|
|
||||||
string(REPLACE "cmake_ARCH " "" ARCH "${ARCH}")
|
|
||||||
|
|
||||||
# If we are compiling with an unknown architecture this variable should
|
|
||||||
# already be set to "unknown" but in the case that it's empty (i.e. due
|
|
||||||
# to a typo in the code), then set it to unknown
|
|
||||||
if (NOT ARCH)
|
|
||||||
set(ARCH unknown)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(${output_var} "${ARCH}" PARENT_SCOPE)
|
|
||||||
endfunction()
|
|
|
@ -36,17 +36,6 @@ else()
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(GCC_VERSION VERSION_EQUAL "8.0" OR GCC_VERSION VERSION_GREATER "8.0")
|
|
||||||
# gs is pretty bad at this
|
|
||||||
target_compile_options(PCSX2_FLAGS INTERFACE -Wno-packed-not-aligned -Wno-class-memaccess)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if ("${PGO}" STREQUAL "generate")
|
|
||||||
target_compile_options(PCSX2_FLAGS INTERFACE -fprofile-generate)
|
|
||||||
elseif("${PGO}" STREQUAL "use")
|
|
||||||
target_compile_options(PCSX2_FLAGS INTERFACE -fprofile-use)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(USE_LINKED_FFMPEG)
|
if(USE_LINKED_FFMPEG)
|
||||||
target_compile_definitions(PCSX2_FLAGS INTERFACE USE_LINKED_FFMPEG)
|
target_compile_definitions(PCSX2_FLAGS INTERFACE USE_LINKED_FFMPEG)
|
||||||
target_link_libraries(PCSX2_FLAGS INTERFACE FFMPEG::avcodec FFMPEG::avformat FFMPEG::avutil FFMPEG::swscale FFMPEG::swresample)
|
target_link_libraries(PCSX2_FLAGS INTERFACE FFMPEG::avcodec FFMPEG::avformat FFMPEG::avutil FFMPEG::swscale FFMPEG::swresample)
|
||||||
|
@ -697,7 +686,7 @@ if(WIN32)
|
||||||
GS/Renderers/DX12/GSDevice12.h
|
GS/Renderers/DX12/GSDevice12.h
|
||||||
GS/Renderers/DX12/GSTexture12.h
|
GS/Renderers/DX12/GSTexture12.h
|
||||||
)
|
)
|
||||||
elseif(Linux)
|
elseif(LINUX)
|
||||||
list(APPEND pcsx2USBSources
|
list(APPEND pcsx2USBSources
|
||||||
USB/usb-eyetoy/cam-linux.cpp
|
USB/usb-eyetoy/cam-linux.cpp
|
||||||
)
|
)
|
||||||
|
@ -1077,8 +1066,7 @@ target_sources(PCSX2 PRIVATE
|
||||||
)
|
)
|
||||||
|
|
||||||
# platform sources
|
# platform sources
|
||||||
# Linux
|
if(LINUX)
|
||||||
if(Linux)
|
|
||||||
target_sources(PCSX2 PRIVATE
|
target_sources(PCSX2 PRIVATE
|
||||||
${pcsx2LinuxSources}
|
${pcsx2LinuxSources}
|
||||||
${pcsx2LinuxHeaders}
|
${pcsx2LinuxHeaders}
|
||||||
|
@ -1090,8 +1078,7 @@ if(Linux)
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Windows
|
if(WIN32)
|
||||||
if(Windows)
|
|
||||||
target_sources(PCSX2 PRIVATE
|
target_sources(PCSX2 PRIVATE
|
||||||
${pcsx2WindowsSources}
|
${pcsx2WindowsSources}
|
||||||
)
|
)
|
||||||
|
@ -1100,8 +1087,7 @@ endif()
|
||||||
target_sources(PCSX2 PRIVATE ${pcsx2USBSources} ${pcsx2USBHeaders})
|
target_sources(PCSX2 PRIVATE ${pcsx2USBSources} ${pcsx2USBHeaders})
|
||||||
target_link_libraries(PCSX2_FLAGS INTERFACE jpgd)
|
target_link_libraries(PCSX2_FLAGS INTERFACE jpgd)
|
||||||
|
|
||||||
# MacOSX/BSD
|
if(APPLE OR BSD)
|
||||||
if(UNIX AND NOT Linux)
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
target_sources(PCSX2 PRIVATE
|
target_sources(PCSX2 PRIVATE
|
||||||
${pcsx2OSXSources})
|
${pcsx2OSXSources})
|
||||||
|
|
Loading…
Reference in New Issue