Skip to content

Commit 732977d

Browse files
committed
Minimal changes to get an Emscripten build
Disable stack traces in loguru (excinfo.h is not available in Emscripten) and set Emscripten linker flags.
1 parent 55a3544 commit 732977d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

CMakeLists.txt

+16
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ else() # Windows build relies on vcpkg
4040
add_compile_definitions(SDL_MAIN_HANDLED)
4141
endif()
4242

43+
if (EMSCRIPTEN)
44+
message(STATUS "Targeting Emscripten")
45+
# loguru tries to include excinfo.h, which is not available under Emscripten.
46+
add_compile_definitions(LOGURU_STACKTRACES=0)
47+
endif()
48+
4349
option(DPPC_BUILD_PPC_TESTS "Build PowerPC tests" OFF)
4450
option(DPPC_BUILD_BENCHMARKS "Build benchmarking programs" OFF)
4551

@@ -118,6 +124,16 @@ add_executable(dingusppc ${SOURCES} $<TARGET_OBJECTS:core>
118124

119125
if (WIN32)
120126
target_link_libraries(dingusppc PRIVATE SDL2::SDL2 SDL2::SDL2main cubeb)
127+
elseif (EMSCRIPTEN)
128+
target_link_libraries(dingusppc PRIVATE SDL2::SDL2 SDL2::SDL2main cubeb
129+
${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS_INIT}
130+
"-gsource-map"
131+
# 256 MB max for emulated Mac RAM, plus 32 MB of emulator overhead
132+
"-s INITIAL_MEMORY=301989888"
133+
"-s MODULARIZE"
134+
"-s EXPORT_ES6"
135+
"-s EXPORT_NAME=emulator"
136+
"-s 'EXTRA_EXPORTED_RUNTIME_METHODS=[\"FS\"]'")
121137
else()
122138
target_link_libraries(dingusppc PRIVATE SDL2::SDL2 SDL2::SDL2main cubeb
123139
${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS_INIT})

0 commit comments

Comments
 (0)