Files
IMX6U-Game/src/Apps/Game/CMakeLists.txt
T
2026-07-08 15:55:13 +08:00

110 lines
3.8 KiB
CMake

set(TOM_GAME_TARGET IMX6U-Game)
set(TOM_ATLAS_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/generated/tom_atlas.h")
set_source_files_properties(${TOM_ATLAS_HEADER} PROPERTIES GENERATED TRUE)
add_executable(${TOM_GAME_TARGET}
Main.cpp
src/app/TomGameApp.cpp
src/audio/VoiceEffect.cpp
src/audio/VoicePlayer.cpp
src/audio/VoiceRecorder.cpp
src/gameplay/KeywordCommandRouter.cpp
src/gameplay/SpriteButton.cpp
src/gameplay/TomAnimator.cpp
src/gameplay/TomHud.cpp
src/gameplay/VoiceInteractionController.cpp
src/recognition/KeywordRecognizer.cpp
src/recognition/TinyKwsRecognizer.cpp
src/recognition/TinyKwsModelData.cpp
src/ui/TomSettingsPanel.cpp
${TOM_ATLAS_HEADER}
)
target_include_directories(${TOM_GAME_TARGET} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/src/app
${CMAKE_CURRENT_SOURCE_DIR}/src/audio
${CMAKE_CURRENT_SOURCE_DIR}/src/gameplay
${CMAKE_CURRENT_SOURCE_DIR}/src/recognition
${CMAKE_CURRENT_SOURCE_DIR}/src/ui
${CMAKE_CURRENT_SOURCE_DIR}/generated
)
imx6u_configure_app_target(${TOM_GAME_TARGET})
if(CMAKE_CROSSCOMPILING AND NOT EXISTS "${TOM_ATLAS_HEADER}")
message(FATAL_ERROR
"Tom atlas header is missing. Run GenerateTomAtlasHeader in a host build before cross compiling."
)
endif()
if(NOT TARGET_IMX)
set(TOM_ATLAS_TOOL_SOURCES
tools/asset_pipeline/SpriteAssetTool.cpp
)
if(WIN32)
add_executable(TomAtlasTool EXCLUDE_FROM_ALL ${TOM_ATLAS_TOOL_SOURCES})
target_include_directories(TomAtlasTool PRIVATE
${PROJECT_SOURCE_DIR}/libs/Win/SDL2/include
${PROJECT_SOURCE_DIR}/libs/Win/SDL_image/include
)
target_link_directories(TomAtlasTool PRIVATE
${SDL2_LIB_DIR}
${SDL2_IMAGE_LIB_DIR}
)
target_link_libraries(TomAtlasTool PRIVATE SDL2main SDL2 SDL2_image)
add_custom_command(TARGET TomAtlasTool POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${SDL2_DLL}"
"$<TARGET_FILE_DIR:TomAtlasTool>"
)
add_custom_command(TARGET TomAtlasTool POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${SDL2_IMAGE_DLL}"
"$<TARGET_FILE_DIR:TomAtlasTool>"
)
elseif(SDL2_image_FOUND)
add_executable(TomAtlasTool EXCLUDE_FROM_ALL ${TOM_ATLAS_TOOL_SOURCES})
target_include_directories(TomAtlasTool PRIVATE
${SDL2_image_INCLUDE_DIRS}
${SDL2_IMAGE_INCLUDE_DIRS}
)
target_link_libraries(TomAtlasTool PRIVATE SDL2::SDL2)
if(TARGET SDL2_image::SDL2_image)
target_link_libraries(TomAtlasTool PRIVATE SDL2_image::SDL2_image)
else()
target_link_libraries(TomAtlasTool PRIVATE
${SDL2_image_LIBRARIES}
${SDL2_IMAGE_LIBRARIES}
)
endif()
else()
message(STATUS "TomAtlasTool disabled: SDL2_image was not found")
endif()
if(TARGET TomAtlasTool)
if(NOT CMAKE_CROSSCOMPILING)
add_custom_target(GenerateTomAtlasHeader
COMMAND ${CMAKE_COMMAND} -E make_directory
"src/Apps/Game/generated"
COMMAND $<TARGET_FILE:TomAtlasTool>
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
DEPENDS TomAtlasTool
COMMENT "Generating Tom atlas header from PNG assets"
VERBATIM
)
add_dependencies(${TOM_GAME_TARGET} GenerateTomAtlasHeader)
else()
add_custom_target(GenerateTomAtlasHeader
COMMAND ${CMAKE_COMMAND} -E echo
"GenerateTomAtlasHeader is host-only. Run it in build-win or build-linux before cross compiling."
VERBATIM
)
endif()
endif()
endif()