-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
167 lines (143 loc) · 2.8 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
cmake_minimum_required(VERSION 3.14)
project(
dr-app
VERSION 0.2.0
LANGUAGES C CXX
)
#
# Global config
#
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
list(
PREPEND CMAKE_MODULE_PATH
"${CMAKE_CURRENT_LIST_DIR}/cmake"
)
# Show FetchContent download progress
set(FETCHCONTENT_QUIET FALSE)
include(deps/dr)
include(deps/imgui)
include(deps/sokol)
#
# Util target
#
add_library(
dr-app-util STATIC
src/camera.cpp
src/file_utils.cpp
src/gfx_resource.cpp
src/gfx_utils.cpp
src/task_queue.cpp
src/thread_pool.cpp
)
add_library(dr::app-util ALIAS dr-app-util)
target_include_directories(
dr-app-util
PUBLIC
"${CMAKE_CURRENT_LIST_DIR}/include"
)
target_link_libraries(
dr-app-util
PUBLIC
dr::dr
sokol::sokol
)
target_compile_options(
dr-app-util
PRIVATE
-Wall -Wextra -Wpedantic -Werror
)
if(EMSCRIPTEN)
# Emscripten compiler options
target_link_options(
dr-app-util
PUBLIC
"-sSTACK_SIZE=512kb" # https://groups.google.com/g/emscripten-discuss/c/MgHWuq2oq7Q
)
# Enable use of std::thread
target_compile_options(dr-app-util PUBLIC -pthread)
target_link_options(dr-app-util PUBLIC -pthread)
endif()
#
# App target
#
if(APPLE AND NOT EMSCRIPTEN)
# NOTE: sokol_app.h implementation must compiled as Objective-C on macOS
add_library(
dr-app-sokol STATIC
"src/shim/sokol.mm"
)
else()
add_library(
dr-app-sokol STATIC
"src/shim/sokol.cpp"
)
endif()
target_link_libraries(
dr-app-sokol
PUBLIC
imgui::imgui
sokol::sokol
)
# NOTE: sokol_app.h requires linking to platform-specific libraries (details in header)
if(EMSCRIPTEN)
# ...
elseif(WIN32)
# ...
elseif(APPLE)
target_link_libraries(
dr-app-sokol
PRIVATE
"-framework Cocoa"
"-framework QuartzCore"
"-framework OpenGL"
)
elseif(UNIX)
target_link_libraries(
dr-app-sokol
PRIVATE
X11
Xi
Xcursor
GL
dl
pthread
)
endif()
add_library(
dr-app STATIC
src/app.cpp
src/app.c
src/event_handlers.cpp
src/shim/imgui.cpp
)
add_library(dr::app ALIAS dr-app)
target_include_directories(
dr-app
PUBLIC
"${CMAKE_CURRENT_LIST_DIR}/include"
)
include(deps/dr)
target_link_libraries(
dr-app
PUBLIC
dr-app-sokol
dr-app-util
)
target_compile_options(
dr-app
PRIVATE
-Wall -Wextra -Wpedantic -Werror
)
#
# Optional targets
#
option(DR_APP_EXAMPLE "Generate example targets" OFF)
if(DR_APP_EXAMPLE)
add_subdirectory(example)
endif()
option(DR_APP_TEST "Generate test target" OFF)
if(DR_APP_TEST)
enable_testing()
add_subdirectory(test)
endif()