CMake: Tidy up build system
And fix Windows CMake... who knows how long for.
This commit is contained in:
parent
a88ee93b4d
commit
bdae36c41f
178
CMakeLists.txt
178
CMakeLists.txt
|
@ -5,6 +5,17 @@ project(duckstation C CXX)
|
|||
cmake_policy(SET CMP0069 NEW)
|
||||
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
|
||||
|
||||
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
|
||||
message(FATAL_ERROR "DuckStation does not support in-tree builds. Please make a build directory that is not the source"
|
||||
"directory and generate your CMake project there using either `cmake -B build_directory` or by "
|
||||
"running cmake from the build directory.")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE MATCHES "Debug|Devel|MinSizeRel|RelWithDebInfo|Release")
|
||||
message(STATUS "CMAKE_BUILD_TYPE not set, defaulting to Release.")
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
endif()
|
||||
|
||||
message(STATUS "CMake Version: ${CMAKE_VERSION}")
|
||||
message(STATUS "CMake System Name: ${CMAKE_SYSTEM_NAME}")
|
||||
message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
|
||||
|
@ -13,58 +24,19 @@ message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
|
|||
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules/")
|
||||
include(DuckStationUtils)
|
||||
|
||||
# Platform detection.
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
set(LINUX TRUE)
|
||||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
|
||||
set(FREEBSD TRUE)
|
||||
endif()
|
||||
|
||||
# Renderer options.
|
||||
option(ENABLE_OPENGL "Build with OpenGL renderer" ON)
|
||||
option(ENABLE_VULKAN "Build with Vulkan renderer" ON)
|
||||
|
||||
# Global options.
|
||||
if(NOT ANDROID)
|
||||
option(BUILD_NOGUI_FRONTEND "Build the NoGUI frontend" OFF)
|
||||
option(BUILD_QT_FRONTEND "Build the Qt frontend" ON)
|
||||
option(BUILD_REGTEST "Build regression test runner" OFF)
|
||||
option(BUILD_TESTS "Build unit tests" OFF)
|
||||
|
||||
set(ENABLE_CUBEB ON)
|
||||
set(ENABLE_DISCORD_PRESENCE ON)
|
||||
set(ENABLE_SDL2 ON)
|
||||
|
||||
if(LINUX OR FREEBSD)
|
||||
option(ENABLE_X11 "Support X11 window system" ON)
|
||||
option(ENABLE_WAYLAND "Support Wayland window system" ON)
|
||||
endif()
|
||||
if(APPLE)
|
||||
option(SKIP_POSTPROCESS_BUNDLE "Disable bundle post-processing, including Qt additions" OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Everything except Windows/Mac use EGL.
|
||||
if(ENABLE_OPENGL AND (LINUX OR FREEBSD OR ANDROID))
|
||||
set(ENABLE_EGL TRUE)
|
||||
endif()
|
||||
|
||||
if(ENABLE_X11)
|
||||
find_package(X11 REQUIRED)
|
||||
if (NOT X11_Xrandr_FOUND)
|
||||
message(FATAL_ERROR "XRandR extension is required")
|
||||
endif()
|
||||
endif()
|
||||
if(ENABLE_WAYLAND)
|
||||
message(STATUS "Wayland support enabled")
|
||||
endif()
|
||||
# Detect system attributes.
|
||||
detect_operating_system()
|
||||
detect_compiler()
|
||||
detect_architecture()
|
||||
detect_page_size()
|
||||
|
||||
# Build options. Depends on system attributes.
|
||||
include(DuckStationBuildOptions)
|
||||
|
||||
# Set _DEBUG macro for Debug builds.
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
|
||||
|
||||
|
||||
# Release build optimizations for MSVC.
|
||||
if(MSVC)
|
||||
add_definitions("/D_CRT_SECURE_NO_WARNINGS")
|
||||
|
@ -88,100 +60,15 @@ if(MSVC)
|
|||
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /OPT:REF /OPT:ICF")
|
||||
endif()
|
||||
|
||||
|
||||
# Default symbol visibility to hidden, that way we don't go through the PLT for intra-library calls.
|
||||
if(ANDROID)
|
||||
cmake_policy(SET CMP0063 NEW)
|
||||
set(CMAKE_POLICY_DEFAULT_CMP0063 NEW)
|
||||
set(CMAKE_C_VISIBILITY_PRESET hidden)
|
||||
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-semantic-interposition")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-semantic-interposition")
|
||||
endif()
|
||||
|
||||
|
||||
# Warning disables.
|
||||
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
if(COMPILER_CLANG OR COMPILER_CLANG_CL OR COMPILER_GCC)
|
||||
include(CheckCXXFlag)
|
||||
check_cxx_flag(-Wall COMPILER_SUPPORTS_WALL)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-switch")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch")
|
||||
if(NOT ANDROID)
|
||||
check_cxx_flag(-Wno-class-memaccess COMPILER_SUPPORTS_MEMACCESS)
|
||||
check_cxx_flag(-Wno-invalid-offsetof COMPILER_SUPPORTS_OFFSETOF)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-switch")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
# Detect processor type.
|
||||
if(APPLE AND NOT "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "")
|
||||
# Universal binaries.
|
||||
if("x86_64" IN_LIST CMAKE_OSX_ARCHITECTURES)
|
||||
set(CPU_ARCH_X64 TRUE)
|
||||
message(STATUS "Building x86_64 MacOS binaries.")
|
||||
endif()
|
||||
if("arm64" IN_LIST CMAKE_OSX_ARCHITECTURES)
|
||||
set(CPU_ARCH_ARM64 TRUE)
|
||||
message(STATUS "Building ARM64 MacOS binaries.")
|
||||
endif()
|
||||
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "amd64" OR
|
||||
"${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "AMD64" OR "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "x86_64")
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(CPU_ARCH_X64 TRUE)
|
||||
message(STATUS "Building x86_64 binaries.")
|
||||
else()
|
||||
# Cross-compiling 32-bit build. 32-bit hosts are not supported.
|
||||
set(CPU_ARCH_X86 TRUE)
|
||||
message(FATAL_ERROR "Building x86_32 binaries is not supported.")
|
||||
endif()
|
||||
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i386" OR
|
||||
"${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i686")
|
||||
set(CPU_ARCH_X86 TRUE)
|
||||
message(FATAL_ERROR "Building x86_32 binaries is not supported.")
|
||||
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64")
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8) # Might have an A64 kernel, e.g. Raspbian.
|
||||
set(CPU_ARCH_ARM64 TRUE)
|
||||
message(STATUS "Building ARM64 binaries.")
|
||||
else()
|
||||
set(CPU_ARCH_ARM32 TRUE)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -marm -march=armv7-a")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -marm -march=armv7-a")
|
||||
message(STATUS "Building ARM32 binaries on ARM64.")
|
||||
endif()
|
||||
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv7-a" OR
|
||||
"${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv7l")
|
||||
set(CPU_ARCH_ARM32 TRUE)
|
||||
message(STATUS "Building ARM32 binaries.")
|
||||
if(ANDROID)
|
||||
# Force ARM mode, since apparently ANDROID_ARM_MODE isn't working..
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -marm")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -marm")
|
||||
else()
|
||||
# Enable NEON.
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -marm -march=armv7-a")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -marm -march=armv7-a")
|
||||
endif()
|
||||
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "riscv64")
|
||||
set(CPU_ARCH_RISCV64 TRUE)
|
||||
message(STATUS "Building RISC-V 64 binaries.")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -finline-atomics")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -finline-atomics")
|
||||
|
||||
# Still need this, apparently.
|
||||
link_libraries("-latomic")
|
||||
|
||||
if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
||||
# Frame pointers generate an annoying amount of code on leaf functions.
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fomit-frame-pointer")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fomit-frame-pointer")
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown system processor: ${CMAKE_SYSTEM_PROCESSOR}")
|
||||
endif()
|
||||
|
||||
# Detect page size if needed.
|
||||
detect_page_size()
|
||||
|
||||
|
||||
# We don't need exceptions, disable them to save a bit of code size.
|
||||
if(MSVC)
|
||||
|
@ -193,29 +80,15 @@ else()
|
|||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti")
|
||||
endif()
|
||||
|
||||
|
||||
# Write binaries to a seperate directory.
|
||||
if(WIN32)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin/${CPU_ARCH}")
|
||||
else()
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
|
||||
endif()
|
||||
|
||||
# Needed for Linux - put shared libraries in the binary directory.
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
|
||||
|
||||
|
||||
# Enable threads everywhere.
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
|
||||
# Enable large file support on Linux 32-bit platforms.
|
||||
# Android is deliberately ommitted here as it didn't support 64-bit ops on files until Android 7/N.
|
||||
if((LINUX OR FREEBSD) AND (CPU_ARCH_X86 OR CPU_ARCH_ARM32))
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
add_definitions("-D_FILE_OFFSET_BITS=64")
|
||||
endif()
|
||||
|
||||
# Optional unit tests.
|
||||
if(BUILD_TESTS)
|
||||
enable_testing()
|
||||
endif()
|
||||
|
@ -232,6 +105,5 @@ include(DuckStationDependencies)
|
|||
add_subdirectory(dep)
|
||||
add_subdirectory(src)
|
||||
|
||||
if(ANDROID)
|
||||
add_subdirectory(android/app/src/cpp)
|
||||
endif()
|
||||
# Output build summary.
|
||||
include(DuckStationBuildSummary)
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
# Renderer options.
|
||||
option(ENABLE_OPENGL "Build with OpenGL renderer" ON)
|
||||
option(ENABLE_VULKAN "Build with Vulkan renderer" ON)
|
||||
option(BUILD_NOGUI_FRONTEND "Build the NoGUI frontend" OFF)
|
||||
option(BUILD_QT_FRONTEND "Build the Qt frontend" ON)
|
||||
option(BUILD_REGTEST "Build regression test runner" OFF)
|
||||
option(BUILD_TESTS "Build unit tests" OFF)
|
||||
|
||||
if(LINUX OR BSD)
|
||||
option(ENABLE_X11 "Support X11 window system" ON)
|
||||
option(ENABLE_WAYLAND "Support Wayland window system" ON)
|
||||
endif()
|
||||
if(APPLE)
|
||||
option(SKIP_POSTPROCESS_BUNDLE "Disable bundle post-processing, including Qt additions" OFF)
|
||||
endif()
|
|
@ -0,0 +1,45 @@
|
|||
if(ENABLE_OPENGL)
|
||||
message(STATUS "Building with OpenGL support.")
|
||||
endif()
|
||||
if(ENABLE_VULKAN)
|
||||
message(STATUS "Building with Vulkan support.")
|
||||
endif()
|
||||
if(ENABLE_X11)
|
||||
message(STATUS "Building with X11 support.")
|
||||
endif()
|
||||
if(ENABLE_WAYLAND)
|
||||
message(STATUS "Building with Wayland support.")
|
||||
endif()
|
||||
|
||||
if(BUILD_QT_FRONTEND)
|
||||
message(STATUS "Qt frontend will be built.")
|
||||
endif()
|
||||
if(BUILD_NOGUI_FRONTEND)
|
||||
message(STATUS "NoGUI frontend will be built.")
|
||||
endif()
|
||||
if(BUILD_REGTEST)
|
||||
message(STATUS "RegTest frontend will be built.")
|
||||
endif()
|
||||
if(BUILD_TESTS)
|
||||
message(STATUS "Unit tests will be built enabled.")
|
||||
endif()
|
||||
|
||||
if(NOT IS_SUPPORTED_COMPILER)
|
||||
message(WARNING "
|
||||
*************** UNSUPPORTED CONFIGURATION ***************
|
||||
You are not compiling DuckStation with a supported compiler.
|
||||
It may not even build successfully.
|
||||
DuckStation only supports the Clang and MSVC compilers.
|
||||
No support will be provided, continue at your own risk.
|
||||
*********************************************************")
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
message(WARNING "
|
||||
*************** UNSUPPORTED CONFIGURATION ***************
|
||||
You are compiling DuckStation with CMake on Windows.
|
||||
It may not even build successfully.
|
||||
DuckStation only supports MSBuild on Windows.
|
||||
No support will be provided, continue at your own risk.
|
||||
*********************************************************")
|
||||
endif()
|
|
@ -1,7 +1,3 @@
|
|||
if(ENABLE_SDL2)
|
||||
find_package(SDL2 2.30.2 REQUIRED)
|
||||
endif()
|
||||
if(NOT WIN32 AND NOT ANDROID)
|
||||
# From PCSX2: On macOS, Mono.framework contains an ancient version of libpng. We don't want that.
|
||||
# Avoid it by telling cmake to avoid finding frameworks while we search for libpng.
|
||||
if(APPLE)
|
||||
|
@ -9,14 +5,29 @@ if(NOT WIN32 AND NOT ANDROID)
|
|||
set(CMAKE_FIND_FRAMEWORK NEVER)
|
||||
endif()
|
||||
|
||||
# Enable threads everywhere.
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
find_package(SDL2 2.30.2 REQUIRED)
|
||||
find_package(Zstd 1.5.5 REQUIRED)
|
||||
find_package(WebP REQUIRED) # v1.3.2, spews an error on Linux because no pkg-config.
|
||||
find_package(ZLIB REQUIRED) # 1.3, but Mac currently doesn't use it.
|
||||
find_package(PNG 1.6.40 REQUIRED)
|
||||
find_package(JPEG REQUIRED) # No version because flatpak uses libjpeg-turbo.
|
||||
find_package(CURL REQUIRED)
|
||||
find_package(Freetype 2.13.1 REQUIRED)
|
||||
|
||||
if(NOT WIN32)
|
||||
find_package(CURL REQUIRED)
|
||||
endif()
|
||||
|
||||
if(ENABLE_X11)
|
||||
find_package(X11 REQUIRED)
|
||||
if (NOT X11_Xrandr_FOUND)
|
||||
message(FATAL_ERROR "XRandR extension is required")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ENABLE_VULKAN OR APPLE)
|
||||
find_package(Shaderc REQUIRED)
|
||||
endif()
|
||||
|
@ -24,16 +35,19 @@ if(NOT WIN32 AND NOT ANDROID)
|
|||
if(APPLE)
|
||||
# SPIRV-Cross is currently only used on MacOS.
|
||||
find_package(spirv_cross_c_shared REQUIRED)
|
||||
endif()
|
||||
|
||||
set(CMAKE_FIND_FRAMEWORK ${FIND_FRAMEWORK_BACKUP})
|
||||
endif()
|
||||
endif()
|
||||
if(LINUX AND NOT ANDROID)
|
||||
if(LINUX)
|
||||
find_package(UDEV REQUIRED)
|
||||
endif()
|
||||
if(UNIX AND NOT APPLE)
|
||||
|
||||
if(NOT WIN32 AND NOT APPLE)
|
||||
find_package(Libbacktrace)
|
||||
if(NOT LIBBACKTRACE_FOUND)
|
||||
message(WARNING "libbacktrace not found, crashes will not produce backtraces.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
set(CMAKE_FIND_FRAMEWORK ${FIND_FRAMEWORK_BACKUP})
|
||||
endif()
|
||||
|
|
|
@ -6,13 +6,105 @@ function(disable_compiler_warnings_for_target target)
|
|||
endif()
|
||||
endfunction()
|
||||
|
||||
function(detect_operating_system)
|
||||
message(STATUS "CMake Version: ${CMAKE_VERSION}")
|
||||
message(STATUS "CMake System Name: ${CMAKE_SYSTEM_NAME}")
|
||||
|
||||
# LINUX wasn't added until CMake 3.25.
|
||||
if (CMAKE_VERSION VERSION_LESS 3.25.0 AND CMAKE_SYSTEM_NAME MATCHES "Linux")
|
||||
# Have to make it visible in this scope as well for below.
|
||||
set(LINUX TRUE PARENT_SCOPE)
|
||||
set(LINUX TRUE)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
message(STATUS "Building for Windows.")
|
||||
elseif(APPLE AND NOT IOS)
|
||||
message(STATUS "Building for MacOS.")
|
||||
elseif(LINUX)
|
||||
message(STATUS "Building for Linux.")
|
||||
elseif(BSD)
|
||||
message(STATUS "Building for *BSD.")
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported platform.")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(detect_compiler)
|
||||
if(MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
set(COMPILER_CLANG_CL TRUE PARENT_SCOPE)
|
||||
set(IS_SUPPORTED_COMPILER TRUE PARENT_SCOPE)
|
||||
message(STATUS "Building with Clang-CL.")
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
||||
set(COMPILER_CLANG TRUE PARENT_SCOPE)
|
||||
set(IS_SUPPORTED_COMPILER TRUE PARENT_SCOPE)
|
||||
message(STATUS "Building with Clang/LLVM.")
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
set(COMPILER_GCC TRUE PARENT_SCOPE)
|
||||
set(IS_SUPPORTED_COMPILER FALSE PARENT_SCOPE)
|
||||
message(STATUS "Building with GNU GCC.")
|
||||
elseif(MSVC)
|
||||
set(IS_SUPPORTED_COMPILER TRUE PARENT_SCOPE)
|
||||
message(STATUS "Building with MSVC.")
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown compiler: ${CMAKE_CXX_COMPILER_ID}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(detect_architecture)
|
||||
if(APPLE AND NOT "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "")
|
||||
# Universal binaries.
|
||||
if("x86_64" IN_LIST CMAKE_OSX_ARCHITECTURES)
|
||||
message(STATUS "Building x86_64 MacOS binaries.")
|
||||
set(CPU_ARCH_X64 TRUE PARENT_SCOPE)
|
||||
endif()
|
||||
if("arm64" IN_LIST CMAKE_OSX_ARCHITECTURES)
|
||||
message(STATUS "Building ARM64 MacOS binaries.")
|
||||
set(CPU_ARCH_ARM64 TRUE PARENT_SCOPE)
|
||||
endif()
|
||||
elseif(("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "amd64" OR
|
||||
"${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "AMD64" OR "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "x86_64") AND
|
||||
CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
message(STATUS "Building x86_64 binaries.")
|
||||
set(CPU_ARCH_X64 TRUE PARENT_SCOPE)
|
||||
elseif(("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64") AND
|
||||
CMAKE_SIZEOF_VOID_P EQUAL 8) # Might have an A64 kernel, e.g. Raspbian.
|
||||
message(STATUS "Building ARM64 binaries.")
|
||||
set(CPU_ARCH_ARM64 TRUE PARENT_SCOPE)
|
||||
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv7-a" OR
|
||||
"${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv7l" OR
|
||||
(("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64")
|
||||
AND CMAKE_SIZEOF_VOID_P EQUAL 4))
|
||||
message(STATUS "Building ARM32 binaries.")
|
||||
set(CPU_ARCH_ARM32 TRUE PARENT_SCOPE)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -marm -march=armv7-a" PARENT_SCOPE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -marm -march=armv7-a" PARENT_SCOPE)
|
||||
elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "riscv64")
|
||||
message(STATUS "Building RISC-V 64 binaries.")
|
||||
set(CPU_ARCH_RISCV64 TRUE PARENT_SCOPE)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -finline-atomics" PARENT_SCOPE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -finline-atomics" PARENT_SCOPE)
|
||||
|
||||
# Still need this, apparently.
|
||||
link_libraries("-latomic")
|
||||
|
||||
if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
||||
# Frame pointers generate an annoying amount of code on leaf functions.
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fomit-frame-pointer" PARENT_SCOPE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fomit-frame-pointer" PARENT_SCOPE)
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown system processor: ${CMAKE_SYSTEM_PROCESSOR}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(detect_page_size)
|
||||
# This is only needed for ARM64, or if the user hasn't overridden it explicitly.
|
||||
if(NOT CPU_ARCH_ARM64 OR HOST_PAGE_SIZE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(NOT LINUX OR ANDROID)
|
||||
if(NOT LINUX)
|
||||
# For universal Apple builds, we use preprocessor macros to determine page size.
|
||||
# Similar for Windows, except it's always 4KB.
|
||||
return()
|
||||
|
|
|
@ -27,23 +27,17 @@ add_subdirectory(rcheevos EXCLUDE_FROM_ALL)
|
|||
disable_compiler_warnings_for_target(rcheevos)
|
||||
add_subdirectory(rapidyaml EXCLUDE_FROM_ALL)
|
||||
disable_compiler_warnings_for_target(rapidyaml)
|
||||
|
||||
if(ENABLE_CUBEB)
|
||||
add_subdirectory(cubeb EXCLUDE_FROM_ALL)
|
||||
disable_compiler_warnings_for_target(cubeb)
|
||||
disable_compiler_warnings_for_target(speex)
|
||||
endif()
|
||||
add_subdirectory(discord-rpc EXCLUDE_FROM_ALL)
|
||||
disable_compiler_warnings_for_target(discord-rpc)
|
||||
|
||||
if(ENABLE_OPENGL)
|
||||
add_subdirectory(glad EXCLUDE_FROM_ALL)
|
||||
disable_compiler_warnings_for_target(glad)
|
||||
endif()
|
||||
|
||||
if(ENABLE_DISCORD_PRESENCE)
|
||||
add_subdirectory(discord-rpc EXCLUDE_FROM_ALL)
|
||||
disable_compiler_warnings_for_target(discord-rpc)
|
||||
endif()
|
||||
|
||||
if(CPU_ARCH_X64)
|
||||
add_subdirectory(xbyak EXCLUDE_FROM_ALL)
|
||||
add_subdirectory(zydis EXCLUDE_FROM_ALL)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CMAKE_MINIMUM_REQUIRED(VERSION 3.1 FATAL_ERROR)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.5 FATAL_ERROR)
|
||||
|
||||
# ---[ Project and semantic versioning.
|
||||
PROJECT(clog C CXX)
|
||||
|
|
|
@ -20,11 +20,9 @@ if(WIN32)
|
|||
src/wgl.c
|
||||
)
|
||||
else()
|
||||
if(ENABLE_EGL)
|
||||
target_sources(glad PRIVATE
|
||||
include/EGL/eglplatform.h
|
||||
include/glad/egl.h
|
||||
src/egl.c
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
@ -27,6 +27,4 @@ target_include_directories(reshadefx INTERFACE
|
|||
)
|
||||
|
||||
# reshadefx is not C++20-compatible.
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
set_property(TARGET reshadefx PROPERTY CXX_STANDARD 17)
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
add_library(WinPixEventRuntime::WinPixEventRuntime UNKNOWN IMPORTED GLOBAL)
|
||||
add_library(WinPixEventRuntime::WinPixEventRuntime SHARED IMPORTED GLOBAL)
|
||||
|
||||
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64")
|
||||
set_target_properties(WinPixEventRuntime::WinPixEventRuntime PROPERTIES
|
||||
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/libarm64/WinPixEventRuntime.lib"
|
||||
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/binarm64/WinPixEventRuntime.dll"
|
||||
IMPORTED_IMPLIB "${CMAKE_CURRENT_SOURCE_DIR}/libarm64/WinPixEventRuntime.lib"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||
)
|
||||
else()
|
||||
set_target_properties(WinPixEventRuntime::WinPixEventRuntime PROPERTIES
|
||||
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/lib64/WinPixEventRuntime.lib"
|
||||
IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/bin64/WinPixEventRuntime.dll"
|
||||
IMPORTED_IMPLIB "${CMAKE_CURRENT_SOURCE_DIR}/lib64/WinPixEventRuntime.lib"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/include"
|
||||
)
|
||||
endif()
|
||||
|
|
|
@ -146,7 +146,7 @@ if(CPU_ARCH_X64)
|
|||
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
||||
target_link_libraries(core PRIVATE zydis)
|
||||
endif()
|
||||
message("Building x64 recompiler")
|
||||
message(STATUS "Building x64 recompiler.")
|
||||
endif()
|
||||
if(CPU_ARCH_ARM32)
|
||||
target_compile_definitions(core PUBLIC "ENABLE_RECOMPILER=1" "ENABLE_NEWREC=1")
|
||||
|
@ -156,7 +156,7 @@ if(CPU_ARCH_ARM32)
|
|||
cpu_newrec_compiler_aarch32.h
|
||||
)
|
||||
target_link_libraries(core PUBLIC vixl)
|
||||
message("Building AArch32 recompiler")
|
||||
message(STATUS "Building AArch32 recompiler.")
|
||||
endif()
|
||||
if(CPU_ARCH_ARM64)
|
||||
target_compile_definitions(core PUBLIC "ENABLE_RECOMPILER=1" "ENABLE_NEWREC=1" "ENABLE_MMAP_FASTMEM=1")
|
||||
|
@ -166,7 +166,7 @@ if(CPU_ARCH_ARM64)
|
|||
cpu_newrec_compiler_aarch64.h
|
||||
)
|
||||
target_link_libraries(core PUBLIC vixl)
|
||||
message("Building AArch64 recompiler")
|
||||
message(STATUS "Building AArch64 recompiler.")
|
||||
endif()
|
||||
if(CPU_ARCH_RISCV64)
|
||||
target_compile_definitions(core PUBLIC "ENABLE_NEWREC=1" "ENABLE_MMAP_FASTMEM=1")
|
||||
|
@ -175,10 +175,10 @@ if(CPU_ARCH_RISCV64)
|
|||
cpu_newrec_compiler_riscv64.h
|
||||
)
|
||||
target_link_libraries(core PUBLIC biscuit::biscuit riscv-disas)
|
||||
message("Building RISC-V 64-bit recompiler")
|
||||
message(STATUS "Building RISC-V 64-bit recompiler.")
|
||||
endif()
|
||||
|
||||
if(ENABLE_DISCORD_PRESENCE)
|
||||
if(NOT ANDROID)
|
||||
target_compile_definitions(core PUBLIC -DENABLE_DISCORD_PRESENCE=1)
|
||||
target_link_libraries(core PRIVATE discord-rpc)
|
||||
endif()
|
||||
|
|
|
@ -195,14 +195,31 @@ if(WIN32)
|
|||
"${WINDEPLOYQT_EXE}" --libdir="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
|
||||
--plugindir="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/QtPlugins"
|
||||
$<IF:$<CONFIG:Debug>,--debug,--release>
|
||||
--no-translations
|
||||
--no-compiler-runtime
|
||||
--no-system-d3d-compiler
|
||||
--no-system-dxc-compiler
|
||||
--no-translations
|
||||
"$<TARGET_FILE:duckstation-qt>"
|
||||
)
|
||||
add_custom_command(TARGET duckstation-qt POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/qt.conf.win" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/qt.conf"
|
||||
)
|
||||
#set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/translations")
|
||||
|
||||
set(DEPS_TO_COPY freetype.dll harfbuzz.dll libjpeg.dll libpng16.dll libsharpyuv.dll libwebp.dll SDL2.dll shaderc_shared.dll zlib1.dll zstd.dll)
|
||||
foreach(DEP ${DEPS_TO_COPY})
|
||||
list(APPEND DEP_BINS "${CMAKE_PREFIX_PATH}/bin/${DEP}")
|
||||
endforeach()
|
||||
add_custom_command(TARGET duckstation-qt POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DEP_BINS} "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
|
||||
)
|
||||
if(CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||
get_property(WINPIXEVENTRUNTIME_DLL TARGET WinPixEventRuntime::WinPixEventRuntime PROPERTY IMPORTED_LOCATION)
|
||||
message(STATUS WP "${WINPIXEVENTRUNTIME_DLL}")
|
||||
add_custom_command(TARGET duckstation-qt POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${WINPIXEVENTRUNTIME_DLL}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
|
||||
)
|
||||
endif()
|
||||
elseif(APPLE)
|
||||
# Don't generate a bundle for XCode, it makes code signing fail...
|
||||
if(NOT CMAKE_GENERATOR MATCHES "Xcode")
|
||||
|
@ -226,21 +243,21 @@ elseif(APPLE)
|
|||
# Copy icon into the bundle
|
||||
target_sources(duckstation-qt PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/DuckStation.icns")
|
||||
set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/DuckStation.icns" PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
|
||||
endif()
|
||||
|
||||
# Translation setup
|
||||
qt_add_lrelease(duckstation-qt TS_FILES ${TS_FILES} QM_FILES_OUTPUT_VARIABLE QM_FILES)
|
||||
foreach (QM_FILE IN LISTS QM_FILES)
|
||||
target_sources(duckstation-qt PRIVATE ${QM_FILE})
|
||||
set_source_files_properties(${QM_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION Resources/translations)
|
||||
endforeach()
|
||||
copy_base_translations(duckstation-qt)
|
||||
else()
|
||||
# Translation setup.
|
||||
qt_add_lrelease(duckstation-qt TS_FILES ${TS_FILES} QM_FILES_OUTPUT_VARIABLE QM_FILES)
|
||||
if(NOT APPLE)
|
||||
set(QM_OUTPUT_DIR "$<TARGET_FILE_DIR:duckstation-qt>/translations")
|
||||
add_custom_command(TARGET duckstation-qt POST_BUILD COMMAND "${CMAKE_COMMAND}" -E make_directory "${QM_OUTPUT_DIR}")
|
||||
foreach (QM_FILE IN LISTS QM_FILES)
|
||||
get_filename_component(QM_FILE_NAME ${QM_FILE} NAME)
|
||||
add_custom_command(TARGET duckstation-qt POST_BUILD COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${QM_FILE}" "${QM_OUTPUT_DIR}/${QM_FILE_NAME}")
|
||||
endforeach()
|
||||
copy_base_translations(duckstation-qt)
|
||||
else()
|
||||
foreach (QM_FILE IN LISTS QM_FILES)
|
||||
target_sources(duckstation-qt PRIVATE ${QM_FILE})
|
||||
set_source_files_properties(${QM_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION Resources/translations)
|
||||
endforeach()
|
||||
endif()
|
||||
copy_base_translations(duckstation-qt)
|
||||
|
|
|
@ -78,14 +78,6 @@ target_include_directories(util PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
|||
target_link_libraries(util PUBLIC common simpleini imgui)
|
||||
target_link_libraries(util PRIVATE libchdr JPEG::JPEG PNG::PNG WebP::libwebp ZLIB::ZLIB soundtouch xxhash Zstd::Zstd reshadefx)
|
||||
|
||||
if(ENABLE_CUBEB)
|
||||
target_sources(util PRIVATE
|
||||
cubeb_audio_stream.cpp
|
||||
)
|
||||
target_compile_definitions(util PUBLIC "ENABLE_CUBEB=1")
|
||||
target_link_libraries(util PRIVATE cubeb)
|
||||
endif()
|
||||
|
||||
if(ENABLE_X11)
|
||||
target_compile_definitions(util PRIVATE "-DENABLE_X11=1")
|
||||
target_link_libraries(util PRIVATE X11::X11 X11::Xrandr)
|
||||
|
@ -180,26 +172,21 @@ if(ENABLE_VULKAN OR APPLE)
|
|||
target_link_libraries(util PUBLIC Shaderc::shaderc_shared)
|
||||
endif()
|
||||
|
||||
if(ENABLE_SDL2)
|
||||
if(NOT ANDROID)
|
||||
target_sources(util PRIVATE
|
||||
cubeb_audio_stream.cpp
|
||||
sdl_audio_stream.cpp
|
||||
sdl_input_source.cpp
|
||||
sdl_input_source.h
|
||||
)
|
||||
target_compile_definitions(util PUBLIC "ENABLE_SDL2=1")
|
||||
target_link_libraries(util PUBLIC SDL2::SDL2)
|
||||
|
||||
# Copy bundled SDL2 to output on Windows.
|
||||
if(WIN32)
|
||||
# Copy SDL2 DLL to binary directory.
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
get_property(SDL2_DLL_PATH TARGET SDL2::SDL2 PROPERTY IMPORTED_LOCATION_DEBUG)
|
||||
else()
|
||||
get_property(SDL2_DLL_PATH TARGET SDL2::SDL2 PROPERTY IMPORTED_LOCATION_RELEASE)
|
||||
endif()
|
||||
add_custom_command(TARGET util POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SDL2_DLL_PATH}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/SDL2.dll")
|
||||
endif()
|
||||
target_compile_definitions(util PUBLIC
|
||||
"ENABLE_CUBEB=1"
|
||||
"ENABLE_SDL2=1"
|
||||
)
|
||||
target_link_libraries(util PUBLIC
|
||||
cubeb
|
||||
SDL2::SDL2
|
||||
)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
|
|
Loading…
Reference in New Issue