Last active
April 9, 2025 11:47
-
-
Save nezvers/f144c03b7cf5eae9c8c1bcba902f9630 to your computer and use it in GitHub Desktop.
SDL3 Cmake template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cmake_minimum_required(VERSION 3.12) | |
| include(FetchContent) | |
| set(PROJECT_NAME Sdl3Template) | |
| project(${PROJECT_NAME}) | |
| # ? | |
| set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) | |
| set(CMAKE_CXX_STANDARD 17) | |
| # Detect and add SDL3 | |
| find_package(sdl3 3.2.8 QUIET) | |
| if (NOT sdl3_FOUND) | |
| FetchContent_Declare( | |
| sdl3 | |
| DOWNLOAD_EXTRACT_TIMESTAMP OFF | |
| URL https://github.com/libsdl-org/SDL/archive/refs/tags/release-3.2.8.zip | |
| ) | |
| # Build static SDL3 | |
| set(BUILD_SHARED_LIBS OFF) | |
| FetchContent_GetProperties(sdl3) | |
| if (NOT sdl3_POPULATED) | |
| set(FETCHCONTENT_QUIET NO) | |
| FetchContent_MakeAvailable(sdl3) | |
| endif() | |
| endif() | |
| include_directories(${CMAKE_SOURCE_DIR}/include) | |
| file(GLOB SRC_FILES "src/*.cpp" "src/*.hpp" "src/*.c" "src/*.h") | |
| add_executable(${PROJECT_NAME} ${SRC_FILES}) | |
| target_include_directories(${PROJECT_NAME} PRIVATE "include") | |
| target_link_libraries(${PROJECT_NAME} PRIVATE SDL3-static) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment