From 44c0b0dc9251f3738fc72408fbf5b0c1645905b0 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Mon, 30 Jan 2023 23:21:52 +1000 Subject: [PATCH] CMake: Build tweaks --- CMakeLists.txt | 21 +++++++++++++++------ dep/soundtouch/CMakeLists.txt | 2 +- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f76b5f71..b4b4b7cd8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) project(duckstation C CXX) +# Policy settings. +cmake_policy(SET CMP0069 NEW) +set(CMAKE_POLICY_DEFAULT_CMP0069 NEW) + message("CMake Version: ${CMAKE_VERSION}") message("CMake System Name: ${CMAKE_SYSTEM_NAME}") message("Build Type: ${CMAKE_BUILD_TYPE}") @@ -181,14 +185,12 @@ 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) - - # -fno-semantic-interposition appears to be broken on Macs... of course. - if((CMAKE_COMPILER_IS_GNUCC OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") AND NOT APPLE AND NOT ANDROID) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-semantic-interposition") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-semantic-interposition") - endif() + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-semantic-interposition") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-semantic-interposition") endif() @@ -241,6 +243,13 @@ else() endif() +# We don't need exceptions, disable them to save a bit of code size. +# Except xbyak still uses them :( +if(NOT ("${CPU_ARCH}" STREQUAL "x86" OR "${CPU_ARCH}" STREQUAL "x64")) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions") +endif() + + # Write binaries to a seperate directory. if(WIN32) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin/${CPU_ARCH}") diff --git a/dep/soundtouch/CMakeLists.txt b/dep/soundtouch/CMakeLists.txt index e38d58450..9045a61f8 100644 --- a/dep/soundtouch/CMakeLists.txt +++ b/dep/soundtouch/CMakeLists.txt @@ -31,7 +31,7 @@ target_sources(soundtouch PRIVATE target_include_directories(soundtouch PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include") target_compile_definitions(soundtouch PRIVATE ${COMPILE_DEFINITIONS}) target_compile_options(soundtouch PRIVATE ${COMPILE_OPTIONS}) -target_compile_definitions(soundtouch PRIVATE SOUNDTOUCH_FLOAT_SAMPLES ST_NO_EXCEPTION_HANDLING=1) +target_compile_definitions(soundtouch PUBLIC SOUNDTOUCH_FLOAT_SAMPLES ST_NO_EXCEPTION_HANDLING=1) if("${CPU_ARCH}" STREQUAL "aarch32" OR "${CPU_ARCH}" STREQUAL "aarch64") target_compile_definitions(soundtouch PRIVATE SOUNDTOUCH_USE_NEON)