126 lines
3.3 KiB
CMake
126 lines
3.3 KiB
CMake
cmake_minimum_required(VERSION 4.1)
|
|
project(game)
|
|
|
|
set(CMAKE_CXX_STANDARD 23)
|
|
|
|
include(FetchContent)
|
|
|
|
FetchContent_Declare(
|
|
raylib
|
|
GIT_REPOSITORY https://github.com/raysan5/raylib.git
|
|
GIT_TAG 242dfee5ef022cbd5ba3e7dcdbed4b51d83ebf7e
|
|
)
|
|
|
|
FetchContent_MakeAvailable(raylib)
|
|
|
|
target_compile_definitions(raylib PRIVATE SUPPORT_CUSTOM_FRAME_CONTROL)
|
|
|
|
FetchContent_Declare(
|
|
freetype
|
|
GIT_REPOSITORY https://github.com/freetype/freetype.git
|
|
GIT_TAG 526ec5c47b9ebccc4754c85ac0c0cdf7c85a5e9b
|
|
)
|
|
|
|
set(FT_DISABLE_ZLIB TRUE CACHE BOOL "" FORCE)
|
|
set(FT_DISABLE_BZIP2 TRUE CACHE BOOL "" FORCE)
|
|
set(FT_DISABLE_PNG TRUE CACHE BOOL "" FORCE)
|
|
set(FT_DISABLE_HARFBUZZ TRUE CACHE BOOL "" FORCE)
|
|
set(FT_DISABLE_BROTLI TRUE CACHE BOOL "" FORCE)
|
|
|
|
FetchContent_MakeAvailable(freetype)
|
|
|
|
FetchContent_Declare(
|
|
harfbuzz
|
|
GIT_REPOSITORY https://github.com/harfbuzz/harfbuzz.git
|
|
GIT_TAG b42511e071162fe76102f613a6ccc009726c99af
|
|
)
|
|
|
|
set(HB_HAVE_FREETYPE ON CACHE BOOL "" FORCE)
|
|
set(HB_HAVE_GLIB OFF CACHE BOOL "" FORCE)
|
|
set(HB_HAVE_ICU OFF CACHE BOOL "" FORCE)
|
|
|
|
FetchContent_MakeAvailable(harfbuzz)
|
|
|
|
FetchContent_Declare(
|
|
stb
|
|
GIT_REPOSITORY https://github.com/nothings/stb.git
|
|
GIT_TAG master
|
|
)
|
|
|
|
FetchContent_MakeAvailable(stb)
|
|
|
|
if(NOT TARGET stb)
|
|
# 3. Create a header-only "Interface" target
|
|
add_library(stb INTERFACE)
|
|
|
|
# 4. Point the target to the downloaded folder
|
|
target_include_directories(stb INTERFACE ${stb_SOURCE_DIR})
|
|
endif()
|
|
|
|
FetchContent_Declare(
|
|
tracy
|
|
GIT_REPOSITORY https://github.com/wolfpld/tracy.git
|
|
GIT_TAG master
|
|
SYSTEM
|
|
)
|
|
|
|
FetchContent_MakeAvailable(tracy)
|
|
|
|
FetchContent_Declare(
|
|
kb
|
|
GIT_REPOSITORY https://github.com/JimmyLefevre/kb.git
|
|
GIT_TAG main
|
|
)
|
|
|
|
FetchContent_MakeAvailable(kb)
|
|
|
|
if(NOT TARGET kb)
|
|
add_library(kb INTERFACE)
|
|
target_include_directories(kb INTERFACE "${kb_SOURCE_DIR}")
|
|
endif()
|
|
|
|
FetchContent_Declare(
|
|
enet
|
|
GIT_REPOSITORY https://github.com/lsalzman/enet.git
|
|
GIT_TAG master
|
|
)
|
|
|
|
FetchContent_MakeAvailable(enet)
|
|
target_include_directories(enet INTERFACE "${enet_SOURCE_DIR}/include")
|
|
|
|
add_executable(game src/main.cpp
|
|
src/font.cpp
|
|
src/misc.cpp
|
|
src/misc.h
|
|
src/entity.cpp
|
|
src/entity.h
|
|
src/font.h)
|
|
|
|
target_link_libraries(game PRIVATE raylib freetype harfbuzz stb Tracy::TracyClient kb enet)
|
|
|
|
target_compile_definitions(game PUBLIC TRACY_ENABLE)
|
|
|
|
file(GLOB_RECURSE ASSET_FILES "assets/*")
|
|
set(ASSET_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/assets")
|
|
set(ALL_COPIED_ASSETS "")
|
|
|
|
# 2. Create a specific copy command for every file
|
|
foreach(ASSET_PATH ${ASSET_FILES})
|
|
# Get the relative path so we can recreate the folder structure
|
|
file(RELATIVE_PATH REL_PATH "${CMAKE_CURRENT_SOURCE_DIR}/assets" ${ASSET_PATH})
|
|
set(DEST_PATH "${ASSET_OUTPUT_DIR}/${REL_PATH}")
|
|
|
|
add_custom_command(
|
|
OUTPUT ${DEST_PATH}
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${ASSET_PATH} ${DEST_PATH}
|
|
DEPENDS ${ASSET_PATH}
|
|
COMMENT "Syncing ${REL_PATH}"
|
|
)
|
|
|
|
list(APPEND ALL_COPIED_ASSETS ${DEST_PATH})
|
|
endforeach()
|
|
|
|
# 3. Create a "dummy" target that the game depends on
|
|
add_custom_target(copy_assets_target DEPENDS ${ALL_COPIED_ASSETS})
|
|
add_dependencies(game copy_assets_target)
|