Skip to content

Commit

Permalink
CMake: Build tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Feb 5, 2023
1 parent 178a659 commit d84a02a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
21 changes: 15 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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}")
Expand Down Expand Up @@ -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()


Expand Down Expand Up @@ -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}")
Expand Down
2 changes: 1 addition & 1 deletion dep/soundtouch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d84a02a

Please sign in to comment.