forked from jummy0/sb2-decomp
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
152 lines (134 loc) · 5.68 KB
/
Copy pathCMakeLists.txt
File metadata and controls
152 lines (134 loc) · 5.68 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
cmake_minimum_required(VERSION 3.16)
project(SPEEDY_BLUPI_WINDOWS LANGUAGES CXX)
# -----------------------------------------------------------------------------
# Include-path hygiene rules for this build
# -----------------------------------------------------------------------------
# free-api ships compatibility headers that intentionally use legacy WinAPI/CRT
# names (windows.h, io.h, direct.h, ...). On MinGW, exposing such a directory
# globally (e.g. via include_directories()) silently shadows MinGW's own
# headers and breaks libstdc++ <cmath>/<cstdio> resolution while compiling
# bundled SDL.
#
# Therefore:
# * DO NOT use bare include_directories(...) at this scope or above SDL.
# * DO NOT prepend project root, src/, include/ or freeapi compat dirs to
# CMAKE_CXX_FLAGS / CMAKE_C_FLAGS or to a global INTERFACE target.
# * Use target_include_directories(<our-target> PRIVATE/PUBLIC ...) only.
# * Compatibility headers are owned by the dedicated INTERFACE target
# `freeapi_compat_headers` (defined in free-api/CMakeLists.txt) and are
# reachable ONLY through `free-api` -> game/free-direct. SDL and other
# third_party targets must never link against `freeapi_compat_headers`.
# -----------------------------------------------------------------------------
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(cmake/ThirdPartySDL.cmake)
# Backend selection:
# FREEDIRECT - native DirectX 3 replacement backend
set(SPEEDY_BLUPI_BACKEND "FREEDIRECT" CACHE STRING "Backend: FREEDIRECT")
set_property(CACHE SPEEDY_BLUPI_BACKEND PROPERTY STRINGS FREEDIRECT)
# Setting the output file
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
# Adding source code files
file(GLOB_RECURSE SOURCES "src/*.cpp")
# web_persistence.cpp is included via GLOB above when __EMSCRIPTEN__;
# on native builds the file compiles to an empty translation unit (guarded
# by #if defined(__EMSCRIPTEN__)) so no special exclusion is needed.
# On Android the "executable" is a shared library loaded by SDLActivity.
# SDL's Java glue expects the native library to be named "libmain.so".
if(ANDROID)
set(_free_eggbert_target main)
add_library(${_free_eggbert_target} SHARED ${SOURCES} include/meta/meta.hpp)
else()
set(_free_eggbert_target SPEEDY_BLUPI_WINDOWS)
add_executable(${_free_eggbert_target} ${SOURCES} include/meta/meta.hpp)
endif()
# On Emscripten the output is HTML+JS+WASM; set the suffix accordingly.
if(EMSCRIPTEN)
set_target_properties(${_free_eggbert_target} PROPERTIES SUFFIX ".html")
endif()
target_include_directories(${_free_eggbert_target}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
)
if(MSVC)
target_compile_options(${_free_eggbert_target}
PRIVATE
/permissive-
/W0
)
else()
target_compile_options(${_free_eggbert_target}
PRIVATE
-fpermissive
-fms-extensions
-fPIC
-w
-Wno-narrowing
-Wno-int-to-pointer-cast
-g
-O0
)
endif()
if (SPEEDY_BLUPI_BACKEND STREQUAL "FREEDIRECT")
message(STATUS "Using FREEDIRECT backend")
target_compile_definitions(${_free_eggbert_target} PRIVATE FREEDIRECT)
configure_vendored_sdl()
# Diagnostics: enable internal counters & heartbeat in Free Direct (1 s snapshots).
# Default ON in this build; set FREE_DIRECT_DIAGNOSTICS=OFF to disable. Counters
# are no-ops at runtime unless env var FREE_DIRECT_DIAGNOSTICS=1 is also set.
set(FREE_DIRECT_DIAGNOSTICS ON CACHE BOOL "Enable Free Direct diagnostics counters")
# Disable free-api tests by default when building for Emscripten or Android
# (they are not runnable in those environments).
if(EMSCRIPTEN OR ANDROID)
set(FREE_API_BUILD_TESTS OFF CACHE BOOL "Build free-api tests" FORCE)
endif()
add_subdirectory(../free-api FREE_API)
if(ANDROID)
target_link_libraries(free-api PUBLIC android log)
endif()
if(ANDROID)
add_subdirectory(../free-direct FREE_DIRECT EXCLUDE_FROM_ALL)
else()
add_subdirectory(../free-direct FREE_DIRECT)
endif()
if(ANDROID)
target_link_libraries(${_free_eggbert_target}
PRIVATE
free-api
free-direct
SDL3::SDL3
android
log
)
else()
target_link_libraries(${_free_eggbert_target}
PRIVATE
free-api
free-direct
)
endif()
# Emscripten-specific link options: produce HTML output and preload game data
# directly from the repository asset directories into the virtual filesystem.
if(EMSCRIPTEN)
target_link_options(${_free_eggbert_target} PRIVATE
-sUSE_SDL=0
-sALLOW_MEMORY_GROWTH=1
-sINITIAL_MEMORY=67108864
-sASYNCIFY
"SHELL:--preload-file ${CMAKE_SOURCE_DIR}/gamefiles/DATA@/data_readonly"
"SHELL:--preload-file ${CMAKE_SOURCE_DIR}/gamefiles/IMAGE08@/image08"
"SHELL:--preload-file ${CMAKE_SOURCE_DIR}/gamefiles/IMAGE16@/image16"
"SHELL:--preload-file ${CMAKE_SOURCE_DIR}/gamefiles/SOUND@/sound"
-sFORCE_FILESYSTEM=1
"-sEXPORTED_RUNTIME_METHODS=['FS','ccall','cwrap']"
"-sEXPORTED_FUNCTIONS=['_main','_FreeEggbert_ExportPersistentData','_FreeEggbert_ImportPersistentData']"
)
endif()
if(NOT ANDROID)
free_eggbert_copy_sdl_runtime(${_free_eggbert_target})
free_eggbert_copy_mingw_runtime(${_free_eggbert_target})
free_eggbert_copy_soundfont(${_free_eggbert_target})
endif()
else()
message(FATAL_ERROR "Unknown SPEEDY_BLUPI_BACKEND: ${SPEEDY_BLUPI_BACKEND}")
endif()