Files
cross-compilation-cmake-tem…/game/CMakeLists.txt
2026-04-03 19:54:39 +02:00

25 lines
826 B
CMake

add_executable(game
"src/main.cpp"
)
target_compile_features(game PRIVATE cxx_std_23)
target_link_libraries(game PRIVATE engine)
# On Windows with dynamic linking, copy SDL3.dll next to the game executable.
# $<TARGET_FILE_DIR:game> always resolves correctly regardless of build layout.
if(WIN32 AND SDL_LINK_TYPE STREQUAL "dynamic")
add_custom_command(TARGET game POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:SDL3::SDL3>
$<TARGET_FILE_DIR:game>
COMMENT "Copying SDL3.dll to game output directory"
)
endif()
# On Windows, use the WINDOWS subsystem (no console) for release only
if(WIN32)
if(CMAKE_BUILD_TYPE STREQUAL "Release")
set_target_properties(game PROPERTIES WIN32_EXECUTABLE TRUE)
endif()
endif()