forked from ppy/osu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
59 lines (49 loc) · 2.29 KB
/
Copy pathCMakeLists.txt
File metadata and controls
59 lines (49 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
cmake_minimum_required(VERSION 3.18)
project(osu_native LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Maximum release optimizations for lowest-latency audio callback path.
# -O3: aggressive inlining & vectorisation
# -flto: link-time optimisation across translation units
# -ffast-math: enable SIMD-friendly FP (safe — we only memset + store a double)
# -ffunction/data-sections + --gc-sections: dead-code elimination
# -fvisibility=hidden: only OSU_EXPORT symbols are visible
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -flto -ffast-math -ffunction-sections -fdata-sections -fvisibility=hidden -DNDEBUG")
set(CMAKE_C_FLAGS_RELEASE "-O3 -flto -ffast-math -ffunction-sections -fdata-sections -fvisibility=hidden -DNDEBUG")
# -Wl,-z,max-page-size=16384: align ELF LOAD segments to 16 KB for Android 15+
# devices with 16 KB page sizes. Without this, the .so will fail to load on
# such devices. NDK r28+ supports this flag.
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "-Wl,--gc-sections -Wl,-z,max-page-size=16384 -s")
# Disable Oboe's flowgraph module — we don't use any audio processing/conversion
# features (our bridge outputs silence for latency measurement only).
# This reduces the Oboe portion of the binary by ~50%.
set(OBOE_ENABLE_FLOWGRAPH OFF CACHE BOOL "Disable Oboe flowgraph to reduce binary size")
# Download and build Oboe main branch from source to ensure we have the latest
# features (like ADPF performance hints) regardless of the build environment.
include(FetchContent)
FetchContent_Declare(oboe
GIT_REPOSITORY https://github.com/google/oboe.git
GIT_TAG main
)
FetchContent_MakeAvailable(oboe)
# Patch Oboe's deprecated -Ofast flag to avoid build warnings/errors
# and ensure we use the same optimized flags as the rest of the project.
get_target_property(OBOE_OPTIONS oboe COMPILE_OPTIONS)
if(OBOE_OPTIONS)
string(REPLACE "-Ofast" "-O3;-ffast-math" OBOE_OPTIONS "${OBOE_OPTIONS}")
set_target_properties(oboe PROPERTIES COMPILE_OPTIONS "${OBOE_OPTIONS}")
endif()
set(OBOE_LIB oboe)
find_library(vulkan-lib vulkan)
find_library(log-lib log)
find_library(android-lib android)
add_library(osu_native SHARED
oboe_bridge.cpp
vulkan_bridge.cpp
)
target_link_libraries(osu_native
${OBOE_LIB}
${vulkan-lib}
${log-lib}
${android-lib}
)