chore: sync from fn-registry agent
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
# engine_smoke — gamedev stack smoke test. Issue 0072a.
|
||||
# Standalone — does NOT use add_imgui_app() / fn_framework.
|
||||
#
|
||||
# Two build modes:
|
||||
# 1. As subdir of cpp/ (cmake -S cpp -B build): cpp/CMakeLists.txt already
|
||||
# adds vendor/sdl3 and exposes SDL3::SDL3-static. We just link.
|
||||
# 2. As top-level (cmake -S cpp/apps/engine_smoke -B build) — used by the
|
||||
# WASM pipeline and any standalone build. We do project() + manually
|
||||
# add_subdirectory the vendored SDL3.
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
# Detect mode: top-level vs subdir.
|
||||
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
project(engine_smoke CXX)
|
||||
set(_TOP_LEVEL TRUE)
|
||||
else()
|
||||
set(_TOP_LEVEL FALSE)
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
# Resolve the repo's cpp/vendor regardless of build mode.
|
||||
get_filename_component(_REPO_CPP_ROOT ${CMAKE_CURRENT_LIST_DIR}/../.. ABSOLUTE)
|
||||
set(_VENDOR ${_REPO_CPP_ROOT}/vendor)
|
||||
|
||||
if(_TOP_LEVEL)
|
||||
# Bring in SDL3 ourselves.
|
||||
if(NOT EXISTS ${_VENDOR}/sdl3/CMakeLists.txt)
|
||||
message(FATAL_ERROR "SDL3 vendoring missing: ${_VENDOR}/sdl3 — see cpp/vendor/sdl3.VENDORING.md")
|
||||
endif()
|
||||
set(SDL_SHARED OFF CACHE BOOL "" FORCE)
|
||||
set(SDL_STATIC ON CACHE BOOL "" FORCE)
|
||||
set(SDL_TEST_LIBRARY OFF CACHE BOOL "" FORCE)
|
||||
set(SDL_TESTS OFF CACHE BOOL "" FORCE)
|
||||
set(SDL_EXAMPLES OFF CACHE BOOL "" FORCE)
|
||||
set(SDL_INSTALL OFF CACHE BOOL "" FORCE)
|
||||
set(SDL_X11_XSCRNSAVER OFF CACHE BOOL "" FORCE)
|
||||
add_subdirectory(${_VENDOR}/sdl3 ${CMAKE_BINARY_DIR}/_sdl3 EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
# --- ImGui (sources we need) ---
|
||||
set(_IMGUI_SRCS
|
||||
${_VENDOR}/imgui/imgui.cpp
|
||||
${_VENDOR}/imgui/imgui_demo.cpp
|
||||
${_VENDOR}/imgui/imgui_draw.cpp
|
||||
${_VENDOR}/imgui/imgui_tables.cpp
|
||||
${_VENDOR}/imgui/imgui_widgets.cpp
|
||||
${_VENDOR}/imgui/backends/imgui_impl_sdl3.cpp
|
||||
${_VENDOR}/imgui/backends/imgui_impl_opengl3.cpp
|
||||
)
|
||||
|
||||
add_executable(engine_smoke
|
||||
main.cpp
|
||||
${_IMGUI_SRCS}
|
||||
)
|
||||
|
||||
target_include_directories(engine_smoke PRIVATE
|
||||
${_VENDOR}/imgui
|
||||
${_VENDOR}/sokol
|
||||
)
|
||||
|
||||
target_link_libraries(engine_smoke PRIVATE SDL3::SDL3-static)
|
||||
|
||||
if(NOT EMSCRIPTEN)
|
||||
find_package(OpenGL REQUIRED)
|
||||
target_link_libraries(engine_smoke PRIVATE OpenGL::GL)
|
||||
endif()
|
||||
|
||||
if(EMSCRIPTEN)
|
||||
set_target_properties(engine_smoke PROPERTIES SUFFIX ".html")
|
||||
target_compile_options(engine_smoke PRIVATE
|
||||
-Os
|
||||
-fno-exceptions
|
||||
-fno-rtti
|
||||
-ffunction-sections
|
||||
-fdata-sections
|
||||
)
|
||||
target_link_options(engine_smoke PRIVATE
|
||||
-Os
|
||||
-sUSE_WEBGL2=1
|
||||
-sFULL_ES3=1
|
||||
-sALLOW_MEMORY_GROWTH=1
|
||||
-sINITIAL_MEMORY=33554432
|
||||
-sASSERTIONS=0
|
||||
-sENVIRONMENT=web
|
||||
-Wl,--gc-sections
|
||||
# NOTE: -sFILESYSTEM=0 + --closure=1 broke under SDL3 (closure
|
||||
# references undeclared FS). Saves ~30KB JS + ~30KB wasm if
|
||||
# we ever stub SDL3 filesystem refs out. Re-enable per app.
|
||||
)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
set_target_properties(engine_smoke PROPERTIES WIN32_EXECUTABLE TRUE)
|
||||
endif()
|
||||
Reference in New Issue
Block a user