-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
168 lines (153 loc) · 5.19 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
168
cmake_minimum_required(VERSION 3.20)
project(antler LANGUAGES C CXX)
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 17)
message("Configuring antler ...")
#find_package(glslang REQUIRED)
# default to release build if unspecified
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
message("Build type: ${CMAKE_BUILD_TYPE}")
# define the antler build modes (glfw, headless, and hook)
option(ATLR_BUILD_HOST_HEADLESS "Build antler in headless host mode" ON)
option(ATLR_BUILD_HOST_GLFW "Build antler in GLFW host mode" ON)
option(ATLR_BUILD_HOST_GLFW_IMGUI "Build antler in GLFW host mode with imgui" ON)
option(ATLR_BUILD_HOOK "Build antler in hook mode" ON)
option(ATLR_BUILD_SAMPLES "Build antler samples" ON)
message("Build antler in headless host mode: ${ATLR_BUILD_HOST_HEADLESS}")
message("Build antler in GLFW host mode: ${ATLR_BUILD_HOST_GLFW}")
message("Build antler in GLFW host mode with imgui: ${ATLR_BUILD_HOST_GLFW_IMGUI}")
message("Build antler in hook mode: ${ATLR_BUILD_HOOK}")
message("Build antler samples: ${ATLR_BUILD_SAMPLES}")
# compile flags
set(CMAKE_C_FLAGS_DEBUG "-g -Wall -DATLR_DEBUG")
set(CMAKE_C_FLAGS_RELEASE "-O3")
set(CMAKE_CXX_FLAGS_DEBUG "-g -Wall -DATLR_DEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
# antler libraries ###################################################################################
####################################################################################################
if (ATLR_BUILD_HOST_HEADLESS)
add_library(antler-host-headless
"src/transforms.c"
"src/logger.c"
"src/util.c"
"src/instance.c"
"src/device.c"
"src/commands.c"
"src/buffer.c"
"src/image.c"
"src/descriptor.c"
"src/pipeline.c"
"src/render-pass.c"
"src/offscreen-canvas.c")
target_include_directories(antler-host-headless PUBLIC "${PROJECT_SOURCE_DIR}/src")
target_compile_definitions(antler-host-headless PUBLIC ATLR_BUILD_HOST_HEADLESS)
endif()
if (ATLR_BUILD_HOST_GLFW)
add_library(antler-host-glfw
"src/transforms.c"
"src/logger.c"
"src/util.c"
"src/instance.c"
"src/device.c"
"src/commands.c"
"src/buffer.c"
"src/image.c"
"src/descriptor.c"
"src/pipeline.c"
"src/render-pass.c"
"src/swapchain.c"
"src/offscreen-canvas.c"
"src/camera.c")
target_include_directories(antler-host-glfw PUBLIC "${PROJECT_SOURCE_DIR}/src")
target_compile_definitions(antler-host-glfw PUBLIC ATLR_BUILD_HOST_GLFW)
endif()
if (ATLR_BUILD_HOST_GLFW_IMGUI AND NOT ATLR_BUILD_HOST_GLFW)
add_library(antler-host-glfw OBJECT
"src/transforms.c"
"src/logger.c"
"src/util.c"
"src/instance.c"
"src/device.c"
"src/commands.c"
"src/buffer.c"
"src/image.c"
"src/descriptor.c"
"src/pipeline.c"
"src/render-pass.c"
"src/swapchain.c"
"src/offscreen-canvas.c"
"src/camera.c")
target_include_directories(antler-host-glfw PUBLIC "${PROJECT_SOURCE_DIR}/src")
target_compile_definitions(antler-host-glfw PUBLIC ATLR_BUILD_HOST_GLFW)
endif()
if (ATLR_BUILD_HOOK)
add_library(antler-hook
"src/transforms.c"
"src/logger.c"
"src/util.c"
"src/instance.c"
"src/device.c"
"src/commands.c"
"src/buffer.c"
"src/image.c"
"src/descriptor.c"
"src/pipeline.c"
"src/render-pass.c"
"src/offscreen-canvas.c")
target_include_directories(antler-hook PUBLIC "${PROJECT_SOURCE_DIR}/src")
target_compile_definitions(antler-hook PUBLIC ATLR_BUILD_HOOK)
endif()
# GLFW
if (ATLR_BUILD_HOST_GLFW OR ATLR_BUILD_HOST_GLFW_IMGUI)
add_subdirectory(lib/glfw)
target_include_directories(antler-host-glfw PUBLIC "${PROJECT_SOURCE_DIR}/lib/glfw/include")
target_link_libraries(antler-host-glfw PUBLIC glfw)
endif()
# stb
if (ATLR_BUILD_HOST_HEADLESS)
target_include_directories(antler-host-headless PUBLIC "${PROJECT_SOURCE_DIR}/lib/stb")
endif()
if (ATLR_BUILD_HOST_GLFW OR ATLR_BUILD_HOST_GLFW_IMGUI)
target_include_directories(antler-host-glfw PUBLIC "${PROJECT_SOURCE_DIR}/lib/stb")
endif()
if (ATLR_BUILD_HOOK)
target_include_directories(antler-hook PUBLIC "${PROJECT_SOURCE_DIR}/lib/stb")
endif()
# Vulkan
message("Requiring package \'Vulkan\'")
find_package(Vulkan REQUIRED)
if (ATLR_BUILD_HOST_HEADLESS)
target_include_directories(antler-host-headless PUBLIC "${Vulkan_INCLUDE_DIRS}")
target_link_libraries(antler-host-headless PUBLIC
"${Vulkan_LIBRARIES}" glslang SPIRV glslang-default-resource-limits)
endif()
if (ATLR_BUILD_HOST_GLFW OR ATLR_BUILD_HOST_GLFW_IMGUI)
target_include_directories(antler-host-glfw PUBLIC "${Vulkan_INCLUDE_DIRS}")
target_link_libraries(antler-host-glfw PUBLIC
"${Vulkan_LIBRARIES}" glslang SPIRV glslang-default-resource-limits)
endif()
if (ATLR_BUILD_HOOK)
target_include_directories(antler-hook PUBLIC "${Vulkan_INCLUDE_DIRS}")
target_link_libraries(antler-hook PUBLIC
"${Vulkan_LIBRARIES}" glslang SPIRV glslang-default-resource-limits)
endif()
# antler imgui lib
if (ATLR_BUILD_HOST_GLFW_IMGUI)
add_library(antler-imgui
"src/antler-imgui.cpp"
"lib/imgui/imgui.cpp"
"lib/imgui/imgui_draw.cpp"
"lib/imgui/imgui_tables.cpp"
"lib/imgui/imgui_widgets.cpp"
"lib/imgui/backends/imgui_impl_glfw.cpp")
target_include_directories(antler-imgui PUBLIC
"${PROJECT_SOURCE_DIR}/lib/imgui"
"${PROJECT_SOURCE_DIR}/lib/imgui/backends")
target_link_libraries(antler-imgui PUBLIC antler-host-glfw)
endif()
# samples
if (ATLR_BUILD_SAMPLES)
add_subdirectory(samples)
endif()