first commit
This commit is contained in:
commit
5c7d1905a9
25 changed files with 4034 additions and 0 deletions
120
CMakeLists.txt
Normal file
120
CMakeLists.txt
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
cmake_minimum_required(VERSION 3.20)
|
||||
project(sdl3_flecs_template VERSION 1.0.0 LANGUAGES CXX)
|
||||
|
||||
# C++ Standard
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
# Build type defaults to Debug
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Debug)
|
||||
endif()
|
||||
|
||||
# Compiler warnings
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
||||
add_compile_options(-Wall -Wextra -Wpedantic)
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
add_compile_options(-g -O0)
|
||||
else()
|
||||
add_compile_options(-O2)
|
||||
endif()
|
||||
elseif(MSVC)
|
||||
add_compile_options(/W4)
|
||||
endif()
|
||||
|
||||
# =============================================================================
|
||||
# Dependencies
|
||||
# =============================================================================
|
||||
|
||||
# SDL3 - Using FetchContent for automatic download
|
||||
include(FetchContent)
|
||||
|
||||
# SDL3
|
||||
FetchContent_Declare(
|
||||
SDL3
|
||||
GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
|
||||
GIT_TAG main
|
||||
GIT_SHALLOW TRUE
|
||||
GIT_PROGRESS TRUE
|
||||
)
|
||||
|
||||
set(SDL_SHARED OFF CACHE BOOL "" FORCE)
|
||||
set(SDL_STATIC ON CACHE BOOL "" FORCE)
|
||||
set(SDL_TEST OFF CACHE BOOL "" FORCE)
|
||||
|
||||
# Platform-specific SDL backends
|
||||
if(EMSCRIPTEN)
|
||||
set(SDL_X11 OFF CACHE BOOL "" FORCE)
|
||||
set(SDL_WAYLAND OFF CACHE BOOL "" FORCE)
|
||||
else()
|
||||
# Disable X11, use Wayland only on Linux
|
||||
set(SDL_X11 OFF CACHE BOOL "" FORCE)
|
||||
set(SDL_WAYLAND ON CACHE BOOL "" FORCE)
|
||||
endif()
|
||||
|
||||
FetchContent_MakeAvailable(SDL3)
|
||||
|
||||
# FLECS
|
||||
FetchContent_Declare(
|
||||
flecs
|
||||
GIT_REPOSITORY https://github.com/SanderMertens/flecs.git
|
||||
GIT_TAG master
|
||||
GIT_SHALLOW TRUE
|
||||
GIT_PROGRESS TRUE
|
||||
)
|
||||
|
||||
FetchContent_MakeAvailable(flecs)
|
||||
|
||||
# =============================================================================
|
||||
# Main Executable
|
||||
# =============================================================================
|
||||
|
||||
add_executable(${PROJECT_NAME}
|
||||
src/main.cpp
|
||||
src/game.cpp
|
||||
src/systems.cpp
|
||||
src/pipeline.cpp
|
||||
)
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
SDL3::SDL3-static
|
||||
flecs::flecs_static
|
||||
)
|
||||
|
||||
# Platform-specific settings
|
||||
if(EMSCRIPTEN)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES SUFFIX ".html")
|
||||
target_link_options(${PROJECT_NAME} PRIVATE
|
||||
-sUSE_SDL=0
|
||||
-sALLOW_MEMORY_GROWTH=1
|
||||
-sTOTAL_MEMORY=67108864
|
||||
-sMAX_WEBGL_VERSION=2
|
||||
--shell-file ${CMAKE_CURRENT_SOURCE_DIR}/web/shell.html
|
||||
)
|
||||
elseif(WIN32)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE winmm imm32 version setupapi)
|
||||
elseif(UNIX AND NOT APPLE)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
# Linux dependencies are handled by SDL3
|
||||
endif()
|
||||
|
||||
# =============================================================================
|
||||
# Install
|
||||
# =============================================================================
|
||||
|
||||
install(TARGETS ${PROJECT_NAME}
|
||||
RUNTIME DESTINATION bin
|
||||
)
|
||||
|
||||
# =============================================================================
|
||||
# CPack (optional packaging)
|
||||
# =============================================================================
|
||||
|
||||
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
|
||||
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
|
||||
include(CPack)
|
||||
Loading…
Add table
Add a link
Reference in a new issue