generated from nathan-jw/dohyo-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
76 lines (65 loc) · 2.02 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
cmake_minimum_required(VERSION 3.14)
# CMake settings
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_C_STANDARD 11)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# Project declaration
project(dohyo C CXX)
# CMake includes
include(FetchContent)
# Box2D
FetchContent_Declare(box2d
GIT_REPOSITORY https://github.com/erincatto/box2d.git
GIT_TAG f0763aca7d4dfa8f1c19c2c4a9e66fa6e93ea32e
)
FetchContent_MakeAvailable(box2d)
# SDL3
FetchContent_Declare(
SDL3
GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
GIT_TAG 080b3002c69f888d83f5de25be876ec4a672ed43
)
FetchContent_MakeAvailable(SDL3)
# Dear ImGui
FetchContent_Declare(
imgui
GIT_REPOSITORY https://github.com/ocornut/imgui.git
GIT_TAG 13c4084362b35ce58a25be70b9f1710dfe3377e9
)
FetchContent_MakeAvailable(imgui)
# Add main executable
add_executable(dohyo src/main.c
src/graphics/graphics.c
src/graphics/graphics.h
src/physics/physics.c
src/physics/physics.h
src/graphics/circles.c
src/graphics/circles.h)
# Add ImGui backend files
target_sources(dohyo PRIVATE
${imgui_SOURCE_DIR}/backends/imgui_impl_sdl3.cpp
${imgui_SOURCE_DIR}/backends/imgui_impl_opengl3.cpp
${imgui_SOURCE_DIR}/imgui.cpp
${imgui_SOURCE_DIR}/imgui_draw.cpp
${imgui_SOURCE_DIR}/imgui_tables.cpp
${imgui_SOURCE_DIR}/imgui_widgets.cpp
)
# Include directories
target_include_directories(dohyo PRIVATE
${imgui_SOURCE_DIR}
${SDL3_SOURCE_DIR}/include
)
# Link libraries
target_link_libraries(dohyo PRIVATE
box2d
SDL3::SDL3
)
# If on Windows, copy SDL3.dll from external/SDL3 into the build directory.
set(SDL3_SRC ${CMAKE_SOURCE_DIR}/external/SDL3/SDL3.dll)
if(WIN32 AND EXISTS ${SDL3_SRC})
file(COPY ${SDL3_SRC} DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
else()
message(WARNING "SDL3.dll not found at ${SDL3_SRC}. You cannot run Dohyo without this file.")
endif()