inital, almost working cross-compilation setup with Visual Studio and cmake

This commit is contained in:
Colin Sames
2026-04-03 15:51:02 +02:00
commit 39d875a316
356 changed files with 326295 additions and 0 deletions

36
cmake/SDLSetup.cmake Normal file
View File

@@ -0,0 +1,36 @@
# Resolves pre-built SDL3 libraries based on PLATFORM and SDL_LINK_TYPE.
# SDL must be pre-built once per platform via scripts/build_sdl_windows.ps1
# or scripts/build_sdl_linux.sh before configuring this project.
set(SDL_PREBUILT_DIR "${CMAKE_SOURCE_DIR}/prebuilt/${PLATFORM}")
if(SDL_LINK_TYPE STREQUAL "static")
set(SDL_SEARCH_DIR "${SDL_PREBUILT_DIR}/SDL3-static")
else()
set(SDL_SEARCH_DIR "${SDL_PREBUILT_DIR}/SDL3-dynamic")
endif()
message(STATUS "Looking for SDL3 in: ${SDL_SEARCH_DIR}")
find_package(SDL3 REQUIRED CONFIG
PATHS "${SDL_SEARCH_DIR}"
NO_DEFAULT_PATH
)
if(SDL_LINK_TYPE STREQUAL "static")
set(SDL_TARGET SDL3::SDL3-static)
else()
set(SDL_TARGET SDL3::SDL3)
endif()
message(STATUS "SDL_TARGET resolved to: ${SDL_TARGET}")
# On Windows with dynamic linking, copy the DLL next to the executable
if(SDL_LINK_TYPE STREQUAL "dynamic" AND WIN32)
add_custom_target(copy_sdl_dll ALL
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:SDL3::SDL3>
"${CMAKE_BINARY_DIR}/game"
COMMENT "Copying SDL3.dll to output directory"
)
endif()