Implement hot reloading

This commit is contained in:
2025-01-05 19:41:44 +00:00
parent 1531817dc4
commit 2077ecde63
6 changed files with 100 additions and 13 deletions

View File

@@ -5,6 +5,7 @@ project(epec-mcu-emulator LANGUAGES C)
option(WERROR "Treat warnings as errors" OFF)
option(UBSAN "Enable undefined behaviour sanitizer" OFF)
option(PERFMON "Monitor performance of game code" ON)
option(HOTRELOAD "Enable hot reloading of game code" OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
@@ -19,6 +20,9 @@ macro(set_default_target_options target)
target_compile_options(${target} PRIVATE -fsanitize=undefined)
target_link_options(${target} PRIVATE -fsanitize=undefined)
endif()
if(${HOTRELOAD})
target_compile_definitions(engine PRIVATE HOTRELOAD)
endif()
endmacro()
add_custom_target(format
@@ -40,3 +44,9 @@ find_package(SDL2_image REQUIRED)
add_subdirectory(engine)
add_subdirectory(game)
# Really this should be in engine/CMakeLists.txt, but it has to go
# after the declaration of the game target.
if(${HOTRELOAD})
target_compile_definitions(engine PRIVATE GAMELIB=\"$<TARGET_FILE:game>\")
endif()