mirror of
https://github.com/nicbarker/clay.git
synced 2025-04-21 05:38:04 +00:00
This example is rather basic but it does provide an example how one could setup a rendering loop between clay and SDL3. Although SDL3 is in its infancy and doesn't have an official stable release the API has been locked so there shouldn't be any code adaptations required for this example if one was to update to a more recent SDL3 release in the future.
48 lines
1.2 KiB
CMake
48 lines
1.2 KiB
CMake
cmake_minimum_required(VERSION 3.27)
|
|
|
|
# Project setup
|
|
project(clay_sdl3_renderer C)
|
|
set(CMAKE_C_FLAGS_DEBUG "-g -Wall -Werror")
|
|
set(CMAKE_C_FLAGS_RELEASE "-O3")
|
|
|
|
include(FetchContent)
|
|
set(FETCHCONTENT_QUIET FALSE)
|
|
|
|
# Download SDL3
|
|
FetchContent_Declare(
|
|
SDL
|
|
GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
|
|
GIT_TAG preview-3.1.6
|
|
GIT_SHALLOW TRUE
|
|
GIT_PROGRESS TRUE
|
|
)
|
|
message(STATUS "Using SDL via FetchContent")
|
|
FetchContent_MakeAvailable(SDL)
|
|
set_property(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/_deps/sdl-src" PROPERTY EXCLUDE_FROM_ALL TRUE)
|
|
|
|
# Download SDL_ttf
|
|
FetchContent_Declare(
|
|
SDL_ttf
|
|
GIT_REPOSITORY https://github.com/libsdl-org/SDL_ttf.git
|
|
GIT_TAG 40219a6
|
|
GIT_SHALLOW TRUE
|
|
GIT_PROGRESS TRUE
|
|
)
|
|
message(STATUS "Using SDL_ttf via FetchContent")
|
|
FetchContent_MakeAvailable(SDL_ttf)
|
|
set_property(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/_deps/sdl_ttf-src" PROPERTY EXCLUDE_FROM_ALL TRUE)
|
|
|
|
# Example executable
|
|
add_executable(${PROJECT_NAME} main.c)
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE
|
|
SDL3::SDL3
|
|
SDL3_ttf::SDL3_ttf
|
|
)
|
|
|
|
add_custom_command(
|
|
TARGET ${PROJECT_NAME} POST_BUILD
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
|
${CMAKE_CURRENT_SOURCE_DIR}/resources
|
|
${CMAKE_CURRENT_BINARY_DIR}/resources
|
|
)
|