forked from KhronosGroup/Vulkan-Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
373 lines (315 loc) · 12.2 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
# Copyright (c) 2019-2021, Arm Limited and Contributors
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 the "License";
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
cmake_minimum_required(VERSION 3.10)
project(third_party LANGUAGES C CXX)
# glm
add_library(glm INTERFACE)
set(GLM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/glm)
target_sources(glm INTERFACE ${GLM_DIR}/glm/glm.hpp)
target_include_directories(glm INTERFACE ${GLM_DIR})
target_compile_definitions(glm INTERFACE
GLM_FORCE_SWIZZLE
GLM_FORCE_RADIANS
GLM_FORCE_CTOR_INIT
GLM_ENABLE_EXPERIMENTAL
)
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
target_compile_definitions(glm INTERFACE GLM_FORCE_CXX14)
endif()
# tinygltf
add_library(tinygltf INTERFACE)
set(TINYGLTF_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tinygltf)
target_sources(tinygltf INTERFACE ${TINYGLTF_DIR}/tiny_gltf.h ${TINYGLTF_DIR}/json.hpp)
target_include_directories(tinygltf INTERFACE ${TINYGLTF_DIR})
# vulkan
add_library(vulkan INTERFACE)
set(VULKAN_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vulkan/include)
target_sources(vulkan INTERFACE ${VULKAN_INCLUDE_DIR}/vulkan/vulkan.h)
target_include_directories(vulkan INTERFACE ${VULKAN_INCLUDE_DIR})
target_compile_definitions(vulkan INTERFACE VK_NO_PROTOTYPES)
if(ANDROID)
target_compile_definitions(vulkan INTERFACE VK_USE_PLATFORM_ANDROID_KHR)
elseif(WIN32)
target_compile_definitions(vulkan INTERFACE VK_USE_PLATFORM_WIN32_KHR)
elseif(APPLE)
target_compile_definitions(vulkan INTERFACE VK_USE_PLATFORM_METAL_EXT)
elseif(UNIX)
# Choose WSI based on VKB_WSI_SELECTION
if (VKB_WSI_SELECTION STREQUAL XCB OR VKB_WSI_SELECTION STREQUAL XLIB OR VKB_WSI_SELECTION STREQUAL WAYLAND)
find_package(PkgConfig REQUIRED)
endif()
if (VKB_WSI_SELECTION STREQUAL XCB)
pkg_check_modules(XCB xcb REQUIRED)
if (XCB_FOUND)
target_compile_definitions(vulkan INTERFACE VK_USE_PLATFORM_XCB_KHR)
endif()
elseif (VKB_WSI_SELECTION STREQUAL XLIB)
pkg_check_modules(X11 x11 REQUIRED)
if (X11_FOUND)
target_compile_definitions(vulkan INTERFACE VK_USE_PLATFORM_XLIB_KHR)
endif()
elseif (VKB_WSI_SELECTION STREQUAL WAYLAND)
pkg_check_modules(WAYLAND wayland-client REQUIRED)
if (WAYLAND_FOUND)
target_compile_definitions(vulkan INTERFACE VK_USE_PLATFORM_WAYLAND_KHR)
endif()
elseif (VKB_WSI_SELECTION STREQUAL D2D)
set(DIRECT_TO_DISPLAY TRUE)
set(DIRECT_TO_DISPLAY TRUE PARENT_SCOPE)
target_compile_definitions(vulkan INTERFACE VK_USE_PLATFORM_DISPLAY_KHR)
else()
message(FATAL_ERROR "Unknown WSI")
endif()
endif()
# vma
add_library(vma INTERFACE)
set(VMA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vma/src)
target_sources(vma INTERFACE ${VMA_DIR}/vk_mem_alloc.h)
target_include_directories(vma INTERFACE ${VMA_DIR})
target_link_libraries(vma INTERFACE vulkan)
# libktx
set(KTX_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ktx)
set(KTX_SOURCES
${KTX_DIR}/lib/checkheader.c
${KTX_DIR}/lib/dfdutils/createdfd.c
${KTX_DIR}/lib/dfdutils/colourspaces.c
${KTX_DIR}/lib/dfdutils/dfd.h
${KTX_DIR}/lib/dfdutils/dfd2vk.inl
${KTX_DIR}/lib/dfdutils/interpretdfd.c
${KTX_DIR}/lib/dfdutils/printdfd.c
${KTX_DIR}/lib/dfdutils/queries.c
${KTX_DIR}/lib/dfdutils/vk2dfd.c
${KTX_DIR}/lib/etcdec.cxx
${KTX_DIR}/lib/etcunpack.cxx
${KTX_DIR}/lib/filestream.c
${KTX_DIR}/lib/filestream.h
${KTX_DIR}/lib/formatsize.h
${KTX_DIR}/lib/hashlist.c
${KTX_DIR}/lib/info.c
${KTX_DIR}/lib/ktxint.h
${KTX_DIR}/lib/memstream.c
${KTX_DIR}/lib/memstream.h
${KTX_DIR}/lib/stream.h
${KTX_DIR}/lib/strings.c
${KTX_DIR}/lib/swap.c
${KTX_DIR}/lib/uthash.h
${KTX_DIR}/lib/texture.c
${KTX_DIR}/lib/texture.h
# Basis Universal
${KTX_DIR}/lib/basis_sgd.h
${KTX_DIR}/lib/basis_transcode.cpp
${KTX_DIR}/lib/basisu/transcoder/basisu_containers.h
${KTX_DIR}/lib/basisu/transcoder/basisu_containers_impl.h
${KTX_DIR}/lib/basisu/transcoder/basisu_file_headers.h
${KTX_DIR}/lib/basisu/transcoder/basisu_global_selector_cb.h
${KTX_DIR}/lib/basisu/transcoder/basisu_global_selector_palette.h
${KTX_DIR}/lib/basisu/transcoder/basisu_transcoder_internal.h
${KTX_DIR}/lib/basisu/transcoder/basisu_transcoder_uastc.h
${KTX_DIR}/lib/basisu/transcoder/basisu_transcoder.cpp
${KTX_DIR}/lib/basisu/transcoder/basisu_transcoder.h
${KTX_DIR}/lib/basisu/transcoder/basisu.h
${KTX_DIR}/lib/basisu/zstd/zstd.c
# KT1
${KTX_DIR}/lib/texture1.c
${KTX_DIR}/lib/texture1.h
# KTX2
${KTX_DIR}/lib/texture2.c
${KTX_DIR}/lib/texture2.h
# Vulkan support
${KTX_DIR}/lib/vk_format.h
${KTX_DIR}/lib/vkformat_check.c
${KTX_DIR}/lib/vkformat_enum.h
${KTX_DIR}/lib/vkformat_str.c
${KTX_DIR}/lib/vk_funcs.c
${KTX_DIR}/lib/vk_funcs.h
${KTX_DIR}/lib/vkloader.c
)
set(KTX_INCLUDE_DIRS
${KTX_DIR}/include
${KTX_DIR}/lib
${KTX_DIR}/lib/basisu/zstd
${KTX_DIR}/lib/basisu/transcoder
${KTX_DIR}/other_include
)
add_library(ktx ${KTX_SOURCES})
target_compile_definitions(ktx PUBLIC LIBKTX)
if (WIN32)
target_compile_definitions(ktx PUBLIC "KTX_API=__declspec(dllexport)")
endif()
target_compile_definitions(ktx PUBLIC KTX_FEATURE_WRITE=0)
target_compile_definitions(ktx PUBLIC BASISD_SUPPORT_KTX2_ZSTD=0)
target_compile_definitions(ktx PUBLIC BASISU_NO_ITERATOR_DEBUG_LEVEL)
target_include_directories(ktx PUBLIC ${KTX_INCLUDE_DIRS})
target_link_libraries(ktx PUBLIC vulkan)
set_property(TARGET ktx PROPERTY FOLDER "ThirdParty")
# volk
set(VOLK_DIR "${CMAKE_CURRENT_SOURCE_DIR}/volk")
set(VOLK_FILES
"${VOLK_DIR}/volk.c"
"${VOLK_DIR}/volk.h")
add_library(volk STATIC ${VOLK_FILES})
target_link_libraries(volk PUBLIC vulkan)
target_include_directories(volk PUBLIC ${VOLK_DIR})
if (VKB_WSI_SELECTION STREQUAL XCB)
target_include_directories(volk PUBLIC ${XCB_INCLUDE_DIRS})
elseif (VKB_WSI_SELECTION STREQUAL XLIB)
target_include_directories(volk PUBLIC ${X11_INCLUDE_DIRS})
elseif (VKB_WSI_SELECTION STREQUAL WAYLAND)
target_include_directories(volk PUBLIC ${WAYLAND_INCLUDE_DIRS})
endif()
set_property(TARGET volk PROPERTY FOLDER "ThirdParty")
# imgui
set(IMGUI_DIR "${CMAKE_CURRENT_SOURCE_DIR}/imgui")
set(IMGUI_FILES
"${IMGUI_DIR}/imgui.cpp"
"${IMGUI_DIR}/imgui_demo.cpp"
"${IMGUI_DIR}/imgui_draw.cpp"
"${IMGUI_DIR}/imgui_widgets.cpp"
"${IMGUI_DIR}/imconfig.h"
"${IMGUI_DIR}/imgui.h"
"${IMGUI_DIR}/imgui_internal.h"
"${IMGUI_DIR}/imstb_rectpack.h"
"${IMGUI_DIR}/imstb_textedit.h"
"${IMGUI_DIR}/imstb_truetype.h")
add_library(imgui STATIC ${IMGUI_FILES})
target_include_directories(imgui PUBLIC ${IMGUI_DIR})
set_property(TARGET imgui PROPERTY FOLDER "ThirdParty")
# glslang
option(ENABLE_SPVREMAPPER OFF)
option(ENABLE_GLSLANG_BINARIES OFF)
set(ENABLE_HLSL ON)
option(ENABLE_OPT OFF)
option(BUILD_TESTING OFF)
option(BUILD_EXTERNAL OFF)
add_subdirectory(glslang)
if (NOT TARGET glslang-default-resource-limits)
add_library(glslang-default-resource-limits
glslang/StandAlone/ResourceLimits.cpp)
set_property(TARGET glslang-default-resource-limits PROPERTY FOLDER "ThirdParty")
target_include_directories(glslang-default-resource-limits
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/glslang/StandAlone)
endif()
if(NOT MSVC)
target_compile_options(glslang PRIVATE
"-Wno-logical-op-parentheses"
"-Wno-unused-parameter")
target_compile_options(SPIRV PRIVATE
"-Wno-logical-op-parentheses"
"-Wno-unused-parameter")
endif()
set_property(TARGET glslang PROPERTY FOLDER "ThirdParty")
set_property(TARGET OGLCompiler PROPERTY FOLDER "ThirdParty")
set_property(TARGET OSDependent PROPERTY FOLDER "ThirdParty")
set_property(TARGET SPIRV PROPERTY FOLDER "ThirdParty")
# spirv-cross
add_subdirectory(spirv-cross)
set_property(TARGET spirv-cross PROPERTY FOLDER "ThirdParty")
set_property(TARGET spirv-cross-core PROPERTY FOLDER "ThirdParty")
set_property(TARGET spirv-cross-glsl PROPERTY FOLDER "ThirdParty")
set_property(TARGET spirv-cross-cpp PROPERTY FOLDER "ThirdParty")
set_property(TARGET spirv-cross-hlsl PROPERTY FOLDER "ThirdParty")
set_property(TARGET spirv-cross-msl PROPERTY FOLDER "ThirdParty")
set_property(TARGET spirv-cross-reflect PROPERTY FOLDER "ThirdParty")
set_property(TARGET spirv-cross-util PROPERTY FOLDER "ThirdParty")
# hwcpipe
add_subdirectory(hwcpipe)
set_property(TARGET hwcpipe PROPERTY FOLDER "ThirdParty")
# stb
add_library(stb INTERFACE)
target_include_directories(stb INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/stb")
# astc
set(ASTC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/astc)
set(ASTC_INCLUDE_DIR ${ASTC_DIR}/Source)
set(ASTC_SOURCE_DIR ${ASTC_DIR}/Source)
set(ASTC_SOURCES
${ASTC_SOURCE_DIR}/astc_image_load_store.cpp
${ASTC_SOURCE_DIR}/astc_pick_best_endpoint_format.cpp
${ASTC_SOURCE_DIR}/astc_color_quantize.cpp
${ASTC_SOURCE_DIR}/astc_weight_align.cpp
${ASTC_SOURCE_DIR}/astc_integer_sequence.cpp
${ASTC_SOURCE_DIR}/astc_ideal_endpoints_and_weights.cpp
${ASTC_SOURCE_DIR}/astc_find_best_partitioning.cpp
${ASTC_SOURCE_DIR}/astc_compress_symbolic.cpp
${ASTC_SOURCE_DIR}/astc_decompress_symbolic.cpp
${ASTC_SOURCE_DIR}/astc_symbolic_physical.cpp
${ASTC_SOURCE_DIR}/astc_toplevel.cpp
${ASTC_SOURCE_DIR}/astc_stb_tga.cpp
${ASTC_SOURCE_DIR}/softfloat.cpp
${ASTC_SOURCE_DIR}/mathlib.cpp
${ASTC_SOURCE_DIR}/astc_quantization.cpp
${ASTC_SOURCE_DIR}/astc_block_sizes2.cpp
${ASTC_SOURCE_DIR}/astc_percentile_tables.cpp
${ASTC_SOURCE_DIR}/astc_averages_and_directions.cpp
${ASTC_SOURCE_DIR}/astc_partition_tables.cpp
${ASTC_SOURCE_DIR}/astc_color_unquantize.cpp
${ASTC_SOURCE_DIR}/astc_encoding_choice_error.cpp
${ASTC_SOURCE_DIR}/astc_kmeans_partitioning.cpp
${ASTC_SOURCE_DIR}/astc_weight_quant_xfer_tables.cpp
${ASTC_SOURCE_DIR}/astc_compute_variance.cpp
${ASTC_SOURCE_DIR}/astc_ktx_dds.cpp
)
add_library(astc ${ASTC_SOURCES})
target_include_directories(astc PUBLIC ${ASTC_INCLUDE_DIR})
target_compile_definitions(astc PRIVATE -DNO_STB_IMAGE_IMPLEMENTATION)
set_property(TARGET astc PROPERTY FOLDER "ThirdParty")
if(ANDROID)
# native_app_glue
set(NATIVE_APP_GLUE_DIR "${CMAKE_ANDROID_NDK}/sources/android/native_app_glue")
file(GLOB NATIVE_APP_GLUE_FILES "${NATIVE_APP_GLUE_DIR}/*.c" "${NATIVE_APP_GLUE_DIR}/*.h")
add_library(native_app_glue STATIC ${NATIVE_APP_GLUE_FILES})
target_include_directories(native_app_glue PUBLIC ${NATIVE_APP_GLUE_DIR})
set_property(TARGET native_app_glue PROPERTY FOLDER "ThirdParty")
else()
if (NOT DIRECT_TO_DISPLAY)
# GLFW
option(GLFW_BUILD_DOCS OFF)
option(GLFW_BUILD_TESTS OFF)
option(GLFW_BUILD_EXAMPLES OFF)
option(GLFW_BUILD_TESTS OFF)
option(GLFW_INSTALL OFF)
if (VKB_WSI_SELECTION STREQUAL WAYLAND)
set(GLFW_USE_WAYLAND ON)
endif()
add_subdirectory(glfw)
set_property(TARGET glfw PROPERTY FOLDER "ThirdParty")
endif()
endif()
# spdlog
add_subdirectory(spdlog)
set_property(TARGET spdlog_headers_for_ide PROPERTY FOLDER "ThirdParty")
# ctpl
add_library(ctpl INTERFACE)
set(CTPL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/CTPL)
target_sources(ctpl INTERFACE ${CTPL_DIR}/ctpl_stl.h)
target_include_directories(ctpl INTERFACE ${CTPL_DIR})
# cli11
set(CLI11_SANITIZERS OFF)
set(CLI11_BUILD_DOCS OFF)
set(CLI11_BUILD_TESTS OFF)
set(CLI11_BUILD_EXAMPLES OFF)
set(CLI11_BUILD_EXAMPLES_JSON OFF)
set(CLI11_SINGLE_FILE_TESTS OFF)
set(CLI11_INSTALL OFF)
set(CLI11_FORCE_LIBCXX OFF)
set(CLI11_CUDA_TESTS OFF)
set(CLI11_CLANG_TIDY OFF)
add_subdirectory(cli11)
# OpenCL
add_library(opencl INTERFACE)
set(OPENCL_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/opencl)
target_sources(opencl INTERFACE ${OPENCL_INCLUDE_DIR}/CL/opencl.h)
target_include_directories(opencl INTERFACE ${OPENCL_INCLUDE_DIR})