重构平台条件编译,剥离 LightGame 调试内容到 Debug 配置
- 把 USE_FRAMEBUFFER 替换为 TARGET_IMX / TARGET_PC 双正向互斥宏,由 CMake 选项 TARGET_IMX 推导,代码层只用 #ifdef 正向判断 - 新增 IMX6U_DEBUG 宏,通过 $<$<CONFIG:Debug>:...> 只在 Debug 构建中注入 - LightGame 关卡编辑器(LevelEditor + ImGui)改为仅 PC + Debug 编入,Release 不参与编译 - LightGame draw_debug、debug_mode_、--debug 命令行、[INFO] 启动日志全部用 IMX6U_DEBUG 门控,Release 二进制中完全消失 - [WARN] 硬件初始化失败提示保留在 Release,作为现场诊断信息 - README、APP_AND_CORE_ARCHITECTURE、Game README 同步新宏命名,并新增「构建类型与调试开关」小节
This commit is contained in:
+17
-8
@@ -9,7 +9,12 @@ if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
|
||||
endif()
|
||||
|
||||
option(USE_FRAMEBUFFER "Use Linux framebuffer instead of SDL2" OFF)
|
||||
option(TARGET_IMX "Build for IMX6U target board (framebuffer + Alsa + Evdev). OFF builds for PC (SDL2)." OFF)
|
||||
if(TARGET_IMX)
|
||||
set(TARGET_PC OFF)
|
||||
else()
|
||||
set(TARGET_PC ON)
|
||||
endif()
|
||||
|
||||
set(CORE_SOURCES
|
||||
src/Core/Asset/ObjLoader.cpp
|
||||
@@ -29,7 +34,7 @@ set(CORE_SOURCES
|
||||
src/Core/Shading/BlinnPhongShader.cpp
|
||||
)
|
||||
|
||||
if(USE_FRAMEBUFFER)
|
||||
if(TARGET_IMX)
|
||||
list(APPEND CORE_SOURCES
|
||||
src/Core/Platform/FBDisplay.cpp
|
||||
src/Core/Platform/Ap3216cPhotoSensor.cpp
|
||||
@@ -60,7 +65,7 @@ set(CORE_INCLUDE_DIRS
|
||||
assets/sprite
|
||||
)
|
||||
|
||||
if(NOT USE_FRAMEBUFFER)
|
||||
if(NOT TARGET_IMX)
|
||||
list(APPEND CORE_SOURCES
|
||||
third_party/imgui/imgui.cpp
|
||||
third_party/imgui/imgui_demo.cpp
|
||||
@@ -76,11 +81,15 @@ endif()
|
||||
add_library(imx6u_core STATIC ${CORE_SOURCES})
|
||||
target_include_directories(imx6u_core PUBLIC ${CORE_INCLUDE_DIRS})
|
||||
|
||||
if(USE_FRAMEBUFFER)
|
||||
target_compile_definitions(imx6u_core PUBLIC USE_FRAMEBUFFER)
|
||||
if(TARGET_IMX)
|
||||
target_compile_definitions(imx6u_core PUBLIC TARGET_IMX)
|
||||
else()
|
||||
target_compile_definitions(imx6u_core PUBLIC TARGET_PC)
|
||||
endif()
|
||||
|
||||
if(USE_FRAMEBUFFER)
|
||||
target_compile_definitions(imx6u_core PUBLIC $<$<CONFIG:Debug>:IMX6U_DEBUG>)
|
||||
|
||||
if(TARGET_IMX)
|
||||
else()
|
||||
if(WIN32)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
@@ -136,7 +145,7 @@ function(imx6u_configure_app_target target_name)
|
||||
)
|
||||
endif()
|
||||
|
||||
if(WIN32 AND NOT USE_FRAMEBUFFER)
|
||||
if(WIN32 AND NOT TARGET_IMX)
|
||||
add_custom_command(TARGET ${target_name} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${SDL2_DLL}"
|
||||
@@ -154,7 +163,7 @@ add_subdirectory(src/Apps/Game)
|
||||
add_subdirectory(src/Apps/Demo)
|
||||
add_subdirectory(src/Apps/LightGame)
|
||||
|
||||
if(BUILD_TESTING AND NOT USE_FRAMEBUFFER)
|
||||
if(BUILD_TESTING AND NOT TARGET_IMX)
|
||||
add_executable(render_pipeline_tests
|
||||
tests/render_pipeline_tests.cpp
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user