2025-01-19 01:35:41 +00:00
|
|
|
cmake_minimum_required(VERSION 3.27)
|
|
|
|
|
|
|
|
# Project setup
|
|
|
|
project(clay_examples_sdl3_simple_demo C)
|
|
|
|
set(CMAKE_C_STANDARD 99)
|
|
|
|
|
2025-02-04 04:00:19 +00:00
|
|
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
|
|
|
|
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
|
2025-01-19 01:35:41 +00:00
|
|
|
|
|
|
|
include(FetchContent)
|
|
|
|
set(FETCHCONTENT_QUIET FALSE)
|
|
|
|
|
|
|
|
# Download SDL3
|
|
|
|
FetchContent_Declare(
|
|
|
|
SDL
|
|
|
|
GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
|
2025-02-12 21:02:06 +00:00
|
|
|
GIT_TAG release-3.2.4
|
2025-01-19 01:35:41 +00:00
|
|
|
GIT_SHALLOW TRUE
|
|
|
|
GIT_PROGRESS TRUE
|
|
|
|
)
|
|
|
|
message(STATUS "Using SDL via FetchContent")
|
|
|
|
FetchContent_MakeAvailable(SDL)
|
|
|
|
set_property(DIRECTORY "${sdl_SOURCE_DIR}" PROPERTY EXCLUDE_FROM_ALL TRUE)
|
|
|
|
|
|
|
|
# Download SDL_ttf
|
|
|
|
FetchContent_Declare(
|
|
|
|
SDL_ttf
|
|
|
|
GIT_REPOSITORY https://github.com/libsdl-org/SDL_ttf.git
|
|
|
|
GIT_TAG main # Slightly risky to use main branch, but it's the only one available
|
|
|
|
GIT_SHALLOW TRUE
|
|
|
|
GIT_PROGRESS TRUE
|
|
|
|
)
|
|
|
|
message(STATUS "Using SDL_ttf via FetchContent")
|
|
|
|
FetchContent_MakeAvailable(SDL_ttf)
|
|
|
|
set_property(DIRECTORY "${sdl_ttf_SOURCE_DIR}" PROPERTY EXCLUDE_FROM_ALL TRUE)
|
|
|
|
|
2025-02-12 21:02:06 +00:00
|
|
|
# Download SDL_image
|
|
|
|
FetchContent_Declare(
|
|
|
|
SDL_image
|
|
|
|
GIT_REPOSITORY "https://github.com/libsdl-org/SDL_image.git"
|
|
|
|
GIT_TAG release-3.2.0 # Slightly risky to use main branch, but it's the only one available
|
|
|
|
GIT_SHALLOW TRUE
|
|
|
|
GIT_PROGRESS TRUE
|
|
|
|
)
|
|
|
|
message(STATUS "Using SDL_image via FetchContent")
|
|
|
|
FetchContent_MakeAvailable(SDL_image)
|
|
|
|
set_property(DIRECTORY "${SDL_image_SOURCE_DIR}" PROPERTY EXCLUDE_FROM_ALL TRUE)
|
|
|
|
|
2025-01-19 01:35:41 +00:00
|
|
|
# Example executable
|
|
|
|
add_executable(${PROJECT_NAME} main.c)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE
|
|
|
|
SDL3::SDL3
|
|
|
|
SDL3_ttf::SDL3_ttf
|
2025-02-12 21:02:06 +00:00
|
|
|
SDL3_image::SDL3_image
|
2025-01-19 01:35:41 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_command(
|
|
|
|
TARGET ${PROJECT_NAME} POST_BUILD
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/resources
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/resources
|
|
|
|
)
|