-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
61 lines (44 loc) · 2.07 KB
/
CMakeLists.txt
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
60
61
cmake_minimum_required(VERSION 3.21)
include(qpm_defines.cmake)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED 20)
project(${COMPILE_ID})
set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
# Enable link time optimization
# In my experience, this can be highly unstable but it nets a huge size optimization and likely performance
# However, the instability was seen using Android.mk/ndk-build builds. With Ninja + CMake, this problem seems to have been solved.
# As always, test thoroughly
# - Fern
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_compile_options(-frtti -fexceptions)
add_compile_options(-O3)
add_compile_definitions(VERSION=\"${MOD_VERSION}\")
add_compile_definitions(ID=\"${MOD_ID}\")
RECURSE_FILES(CPP_FILES ${SOURCE_DIR}/*.cpp)
RECURSE_FILES(C_FILES ${SOURCE_DIR}/*.c)
add_library(${COMPILE_ID} SHARED ${CPP_FILES} ${C_FILES})
target_include_directories(${COMPILE_ID} PRIVATE .)
target_include_directories(${COMPILE_ID} PRIVATE ${SOURCE_DIR})
target_include_directories(${COMPILE_ID} PRIVATE ${INCLUDE_DIR})
target_include_directories(${COMPILE_ID} PRIVATE ${EXTERN_DIR}/includes/${CODEGEN_ID}/include)
target_include_directories(${COMPILE_ID} PUBLIC ${SHARED_DIR})
target_link_libraries(${COMPILE_ID} PRIVATE -llog)
include(extern.cmake)
add_custom_command(TARGET ${COMPILE_ID} POST_BUILD
COMMAND ${CMAKE_STRIP} -d --strip-all "lib${COMPILE_ID}.so" -o "stripped_lib${COMPILE_ID}.so"
COMMENT "Strip debug symbols on binary."
)
add_custom_command(TARGET ${COMPILE_ID} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory debug
COMMENT "Create directory for debug symbols."
)
add_custom_command(TARGET ${COMPILE_ID} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E rename lib${COMPILE_ID}.so debug/lib${COMPILE_ID}.so
COMMENT "Rename the binary to debug_ since it has debug symbols."
)
add_custom_command(TARGET ${COMPILE_ID} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E rename stripped_lib${COMPILE_ID}.so lib${COMPILE_ID}.so
COMMENT "Rename the stripped binary."
)