This repository has been archived by the owner on Sep 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
CMakeLists.txt
227 lines (176 loc) · 6.83 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
#
# Copyright 2016 Google Inc. All Rights Reserved.
# 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.1)
set(CMAKE_CXX_STANDARD 11)
set(VULKAN_SDK_DIR "" CACHE PATH "Path to the Vulkan SDK")
#
# SPIRV-Headers
#
set(SPIRV-Headers_SOURCE_DIR ${CMAKE_BINARY_DIR}/spirv-headers-src)
# Download and unpack SPIRV-Headers at configure time
configure_file(CMakeLists.txt.spirv-headers.in
spirv-headers-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/spirv-headers-download)
execute_process(COMMAND ${CMAKE_COMMAND} --build .
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/spirv-headers-download)
# Add SPIRV-Headers directly to our build.
add_subdirectory(${CMAKE_BINARY_DIR}/spirv-headers-src
${CMAKE_BINARY_DIR}/spirv-headers-build)
#
# SPIRV-Tools
#
set(SPIRV_TOOLS_SRC ${CMAKE_BINARY_DIR}/spirv-tools-src)
SET(SPIRV_SKIP_EXECUTABLES OFF CACHE BOOL "" FORCE)
SET(SPIRV_SKIP_TESTS OFF CACHE BOOL "" FORCE)
# Download and unpack SPIRV-Tools at configure time
configure_file(CMakeLists.txt.spirv-tools.in
spirv-tools-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/spirv-tools-download)
execute_process(COMMAND ${CMAKE_COMMAND} --build .
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/spirv-tools-download)
# Add SPIRV-Tools directly to our build.
add_subdirectory(${CMAKE_BINARY_DIR}/spirv-tools-src
${CMAKE_BINARY_DIR}/spirv-tools-build)
#
# glm
#
add_definitions(-DGLM_ENABLE_EXPERIMENTAL)
set(GLM_SRC_DIR ${CMAKE_BINARY_DIR}/glm-src)
# Download and unpack glm at configure time
configure_file(CMakeLists.txt.glm.in
glm-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/glm-download)
execute_process(COMMAND ${CMAKE_COMMAND} --build .
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/glm-download)
#
# gli
#
set(GLI_SRC_DIR ${CMAKE_BINARY_DIR}/gli-src)
# Download and unpack gli at configure time
configure_file(CMakeLists.txt.gli.in
gli-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/gli-download)
execute_process(COMMAND ${CMAKE_COMMAND} --build .
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/gli-download)
if(NOT DEFINED ANDROID_NDK)
#
# Googletest
#
# Download and unpack googletest at configure time
configure_file(CMakeLists.txt.googletest.in
googletest-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download)
execute_process(COMMAND ${CMAKE_COMMAND} --build .
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download)
# Prevent GoogleTest from overriding our compiler/linker options
# when building with Visual Studio
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
# Add googletest directly to our build. This adds
# the following targets: gtest, gtest_main, gmock
# and gmock_main
add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src
${CMAKE_BINARY_DIR}/googletest-build)
#
# Glslang
#
# Download and unpack glslang at configure time
configure_file(CMakeLists.txt.glslang.in
glslang-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/glslang-download)
execute_process(COMMAND ${CMAKE_COMMAND} --build .
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/glslang-download)
# Add glslang directly to our build.
add_subdirectory(${CMAKE_BINARY_DIR}/glslang-src
${CMAKE_BINARY_DIR}/glslang-build)
#
# OpenVR
#
set(OPENVR_SOURCE_DIR ${CMAKE_BINARY_DIR}/openvr)
# Download and unpack OpenVR at configure time
configure_file(CMakeLists.txt.openvr.in
openvr-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/openvr-download)
execute_process(COMMAND ${CMAKE_COMMAND} --build .
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/openvr-download)
#
# zlib
#
set(SKIP_INSTALL_ALL true)
set(ZLIB_SRC_DIR ${CMAKE_BINARY_DIR}/zlib-src)
# Download and unpack zlib at configure time
configure_file(CMakeLists.txt.zlib.in
zlib-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/zlib-download)
execute_process(COMMAND ${CMAKE_COMMAND} --build .
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/zlib-download)
# Add zlib directly to our build.
add_subdirectory(${ZLIB_SRC_DIR}
${CMAKE_BINARY_DIR}/zlib-build)
set(ZLIB_LIBRARY zlib)
set(ZLIB_INCLUDE_DIR ${ZLIB_SRC_DIR} ${CMAKE_BINARY_DIR}/zlib-build)
#
# png
#
set(PNG_SRC_DIR ${CMAKE_BINARY_DIR}/png-src)
set(PNG_BUILD_DIR ${CMAKE_BINARY_DIR}/png-build)
set(PNG_INCLUDE_DIR ${PNG_SRC_DIR} ${PNG_BUILD_DIR})
# Download and unpack png at configure time
configure_file(CMakeLists.txt.png.in
png-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/png-download)
execute_process(COMMAND ${CMAKE_COMMAND} --build .
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/png-download)
# Add png directly to our build.
add_subdirectory(${PNG_SRC_DIR} ${PNG_BUILD_DIR})
endif()
enable_testing()
project (vulkan-cpp)
if(DEFINED ANDROID_NDK)
add_definitions(-DVK_USE_PLATFORM_ANDROID_KHR)
elseif(UNIX)
add_definitions(-DVK_USE_PLATFORM_XCB_KHR)
endif()
set(VULKAN_LIBRARY "vulkan")
if(WIN32)
if(NOT EXISTS ${VULKAN_SDK_DIR}/Include/vulkan/vulkan.h)
message(SEND_ERROR "On Windows VULKAN_SDK_DIR must be set.")
endif()
set(VULKAN_LIBRARY "vulkan-1")
endif()
add_subdirectory(spirv-reflection)
add_subdirectory(types)
add_subdirectory(vcc)
add_subdirectory(vcc-image)
add_subdirectory(sample/cube)
add_subdirectory(sample/heightmap)
add_subdirectory(sample/lighting)
add_subdirectory(sample/normal-mapping-and-cube-texture)
add_subdirectory(sample/teapot)
set(SAMPLES cube heightmap lighting normal-mapping-and-cube-texture teapot)
if(NOT DEFINED ANDROID_NDK)
add_subdirectory(spirv-reflection-test)
add_subdirectory(types-test)
add_subdirectory(vcc-test)
add_subdirectory(sample/openvr)
list(APPEND SAMPLES openvr)
set_property(TARGET ${SAMPLES} PROPERTY FOLDER "samples")
endif()