refactoring app name to spacetris and new icon

This commit is contained in:
2025-12-21 10:29:01 +01:00
parent 18c29fed1e
commit a6c2c78cb5
26 changed files with 402 additions and 951 deletions

View File

@ -15,7 +15,7 @@ if(DEFINED CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_TOOLCHAIN_FILE}" CACHE STRING "" FORCE)
endif()
project(tetris_sdl3 LANGUAGES CXX)
project(spacetris_sdl3 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@ -72,27 +72,39 @@ set(TETRIS_SOURCES
if(APPLE)
set(APP_ICON "${CMAKE_SOURCE_DIR}/assets/favicon/AppIcon.icns")
if(EXISTS "${APP_ICON}")
add_executable(tetris MACOSX_BUNDLE ${TETRIS_SOURCES} "${APP_ICON}")
add_executable(spacetris MACOSX_BUNDLE ${TETRIS_SOURCES} "${APP_ICON}")
set_source_files_properties("${APP_ICON}" PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
set_target_properties(tetris PROPERTIES
set_target_properties(spacetris PROPERTIES
MACOSX_BUNDLE_ICON_FILE "AppIcon"
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_SOURCE_DIR}/cmake/MacBundleInfo.plist.in"
)
else()
message(WARNING "App icon not found at ${APP_ICON}; bundle will use default icon")
add_executable(tetris MACOSX_BUNDLE ${TETRIS_SOURCES})
set_target_properties(tetris PROPERTIES
add_executable(spacetris MACOSX_BUNDLE ${TETRIS_SOURCES})
set_target_properties(spacetris PROPERTIES
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_SOURCE_DIR}/cmake/MacBundleInfo.plist.in"
)
endif()
else()
add_executable(tetris ${TETRIS_SOURCES})
add_executable(spacetris ${TETRIS_SOURCES})
endif()
# Ensure the built executable is named `spacetris`.
set_target_properties(spacetris PROPERTIES OUTPUT_NAME "spacetris")
if (WIN32)
# No compatibility copy; built executable is `spacetris`.
endif()
if (WIN32)
# Embed the application icon into the executable
set_source_files_properties(src/app_icon.rc PROPERTIES LANGUAGE RC)
target_sources(tetris PRIVATE src/app_icon.rc)
target_sources(spacetris PRIVATE src/app_icon.rc)
endif()
if(MSVC)
# Prevent PDB write contention on MSVC by enabling /FS for this target
target_compile_options(spacetris PRIVATE /FS)
endif()
if (WIN32)
@ -107,14 +119,14 @@ if (WIN32)
COMMENT "Copy favicon.ico to build dir for resource compilation"
)
add_custom_target(copy_favicon ALL DEPENDS ${FAVICON_DEST})
add_dependencies(tetris copy_favicon)
add_dependencies(spacetris copy_favicon)
else()
message(WARNING "Favicon not found at ${FAVICON_SRC}; app icon may not compile")
endif()
# Also copy favicon into the runtime output folder (same dir as exe)
add_custom_command(TARGET tetris POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${FAVICON_SRC} $<TARGET_FILE_DIR:tetris>/favicon.ico
add_custom_command(TARGET spacetris POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${FAVICON_SRC} $<TARGET_FILE_DIR:spacetris>/favicon.ico
COMMENT "Copy favicon.ico next to executable"
)
endif()
@ -123,35 +135,35 @@ if(APPLE)
set(_mac_copy_commands)
if(EXISTS "${CMAKE_SOURCE_DIR}/assets")
list(APPEND _mac_copy_commands
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/assets" "$<TARGET_FILE_DIR:tetris>/assets"
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/assets" "$<TARGET_FILE_DIR:spacetris>/assets"
)
endif()
if(EXISTS "${CMAKE_SOURCE_DIR}/fonts")
list(APPEND _mac_copy_commands
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/fonts" "$<TARGET_FILE_DIR:tetris>/fonts"
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/fonts" "$<TARGET_FILE_DIR:spacetris>/fonts"
)
endif()
if(EXISTS "${CMAKE_SOURCE_DIR}/FreeSans.ttf")
list(APPEND _mac_copy_commands
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/FreeSans.ttf" "$<TARGET_FILE_DIR:tetris>/FreeSans.ttf"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/FreeSans.ttf" "$<TARGET_FILE_DIR:spacetris>/FreeSans.ttf"
)
endif()
if(_mac_copy_commands)
add_custom_command(TARGET tetris POST_BUILD
add_custom_command(TARGET spacetris POST_BUILD
${_mac_copy_commands}
COMMENT "Copying game assets into macOS bundle"
)
endif()
endif()
target_link_libraries(tetris PRIVATE SDL3::SDL3 SDL3_ttf::SDL3_ttf SDL3_image::SDL3_image cpr::cpr nlohmann_json::nlohmann_json)
target_link_libraries(spacetris PRIVATE SDL3::SDL3 SDL3_ttf::SDL3_ttf SDL3_image::SDL3_image cpr::cpr nlohmann_json::nlohmann_json)
if (WIN32)
target_link_libraries(tetris PRIVATE mfplat mfreadwrite mfuuid)
target_link_libraries(spacetris PRIVATE mfplat mfreadwrite mfuuid)
endif()
if(APPLE)
# Needed for MP3 decoding via AudioToolbox on macOS
target_link_libraries(tetris PRIVATE "-framework AudioToolbox" "-framework CoreFoundation")
target_link_libraries(spacetris PRIVATE "-framework AudioToolbox" "-framework CoreFoundation")
endif()
# Include production build configuration
@ -162,20 +174,20 @@ enable_testing()
# Unit tests (simple runner)
find_package(Catch2 CONFIG REQUIRED)
add_executable(tetris_tests
add_executable(spacetris_tests
tests/GravityTests.cpp
src/core/GravityManager.cpp
)
target_include_directories(tetris_tests PRIVATE ${CMAKE_SOURCE_DIR}/src)
target_link_libraries(tetris_tests PRIVATE Catch2::Catch2WithMain)
add_test(NAME GravityTests COMMAND tetris_tests)
target_include_directories(spacetris_tests PRIVATE ${CMAKE_SOURCE_DIR}/src)
target_link_libraries(spacetris_tests PRIVATE Catch2::Catch2WithMain)
add_test(NAME GravityTests COMMAND spacetris_tests)
if(EXISTS "${CMAKE_SOURCE_DIR}/vcpkg_installed/x64-windows/include")
target_include_directories(tetris_tests PRIVATE "${CMAKE_SOURCE_DIR}/vcpkg_installed/x64-windows/include")
target_include_directories(spacetris_tests PRIVATE "${CMAKE_SOURCE_DIR}/vcpkg_installed/x64-windows/include")
endif()
# Add new src subfolders to include path so old #includes continue to work
target_include_directories(tetris PRIVATE
target_include_directories(spacetris PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/src/audio
${CMAKE_SOURCE_DIR}/src/gameplay