forked from LunarG/VulkanSamples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists-SDK.txt
244 lines (207 loc) · 10.9 KB
/
CMakeLists-SDK.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
cmake_minimum_required(VERSION 2.8.11)
project (VULKAN_SAMPLES)
# set (CMAKE_VERBOSE_MAKEFILE 1)
set(API_NAME "Vulkan" CACHE STRING "API name to use when building")
string(TOLOWER ${API_NAME} API_LOWERCASE)
if(EXISTS "${CMAKE_SOURCE_DIR}/../x86_64/include")
set(SDK_INCLUDE_PATH "${CMAKE_SOURCE_DIR}/../x86_64/include")
message("SDK_INCLUDE_PATH = ${SDK_INCLUDE_PATH}")
endif()
if(EXISTS "${CMAKE_SOURCE_DIR}/../x86_64/lib")
set(SDK_LIBRARY_PATH "${CMAKE_SOURCE_DIR}/../x86_64/lib")
message("SDK_LIBRARY_PATH = ${SDK_LIBRARY_PATH}")
endif()
# The MAJOR number of the version we're building, used in naming
# vulkan-<major>.dll (and other files).
set(MAJOR "1")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
set (CMAKE_INSTALL_PREFIX "")
set (UTILS_NAME vsamputils)
if(NOT WIN32)
include(FindPkgConfig)
option(BUILD_WSI_XCB_SUPPORT "Build XCB WSI support" ON)
option(BUILD_WSI_WAYLAND_SUPPORT "Build Wayland WSI support" OFF)
set(DEMOS_WSI_SELECTION "XCB" CACHE STRING "Select WSI target for demos (XCB, XLIB, WAYLAND, MIR, DISPLAY)")
set(SAMPLES_WSI_SELECTION "XCB" CACHE STRING "Select WSI target for api-samples (XCB, WAYLAND, DISPLAY)")
if (BUILD_WSI_XCB_SUPPORT)
find_package(XCB REQUIRED)
endif()
if (BUILD_WSI_WAYLAND_SUPPORT)
find_package(Wayland REQUIRED)
endif()
set (BUILDTGT_DIR build)
set (BINDATA_DIR x86_64/bin)
set (LIBSOURCE_DIR Lib)
else()
# For Windows, since 32-bit and 64-bit items can co-exist, we build each in its own build directory.
# 32-bit target data goes in build32, and 64-bit target data goes into build. So, include/link the
# appropriate data at build time.
if (CMAKE_CL_64)
set (BUILDTGT_DIR build)
set (BINDATA_DIR Bin)
set (LIBSOURCE_DIR Lib)
else()
set (BUILDTGT_DIR build32)
set (BINDATA_DIR Bin32)
set (LIBSOURCE_DIR Lib32)
endif()
endif()
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
set(COMMON_COMPILE_FLAGS "-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers")
set(COMMON_COMPILE_FLAGS "${COMMON_COMPILE_FLAGS} -fno-strict-aliasing -fno-builtin-memcmp")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 ${COMMON_COMPILE_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_COMPILE_FLAGS} -std=c++11")
if (UNIX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
endif()
endif()
find_program(GLSLANG_VALIDATOR NAMES glslangValidator
HINTS "${CMAKE_SOURCE_DIR}/../glslang/${BUILDTGT_DIR}/install/bin"
"${PROJECT_SOURCE_DIR}/../${BINDATA_DIR}" )
find_path(GLSLANG_SPIRV_INCLUDE_DIR SPIRV/spirv.hpp HINTS "${CMAKE_SOURCE_DIR}/../source/glslang/"
"${CMAKE_SOURCE_DIR}/../glslang"
DOC "Path to SPIRV/spirv.hpp")
find_path(SPIRV_TOOLS_INCLUDE_DIR spirv-tools/libspirv.h HINTS "${CMAKE_SOURCE_DIR}/../spirv-tools/include"
"${CMAKE_SOURCE_DIR}/../source/spirv-tools/include"
"${CMAKE_SOURCE_DIR}/../spirv-tools/external/include"
"${CMAKE_SOURCE_DIR}/../source/spirv-tools/external/include"
DOC "Path to spirv-tools/libspirv.h")
if (WIN32)
set (GLSLANG_SEARCH_PATH "${CMAKE_SOURCE_DIR}/../glslang/${BUILDTGT_DIR}/glslang/Release"
"${CMAKE_SOURCE_DIR}/../glslang/${BUILDTGT_DIR}/glslang/OSDependent/Windows/Release"
"${CMAKE_SOURCE_DIR}/../glslang/${BUILDTGT_DIR}/hlsl/Release"
"${CMAKE_SOURCE_DIR}/../glslang/${BUILDTGT_DIR}/OGLCompilersDLL/Release"
"${CMAKE_SOURCE_DIR}/../glslang/${BUILDTGT_DIR}/SPIRV/Release" )
set (SPIRV_TOOLS_SEARCH_PATH "${CMAKE_SOURCE_DIR}/../spirv-tools/${BUILDTGT_DIR}/source/Release")
set (SPIRV_TOOLS_OPT_SEARCH_PATH "${CMAKE_SOURCE_DIR}/../spirv-tools/${BUILDTGT_DIR}/source/opt/Release")
else()
set (GLSLANG_SEARCH_PATH "${CMAKE_SOURCE_DIR}/../glslang/build/install/lib" "${CMAKE_SOURCE_DIR}/../x86_64/lib/glslang" )
set (SPIRV_TOOLS_SEARCH_PATH "${CMAKE_SOURCE_DIR}/../spirv-tools/build" "${CMAKE_SOURCE_DIR}/../x86_64/lib/spirv-tools" )
set (SPIRV_TOOLS_OPT_SEARCH_PATH "${SPIRV_TOOLS_SEARCH_PATH}")
endif()
find_library(GLSLANG_LIB NAMES glslang
HINTS ${GLSLANG_SEARCH_PATH} )
find_library(OGLCompiler_LIB NAMES OGLCompiler
HINTS ${GLSLANG_SEARCH_PATH} )
find_library(OSDependent_LIB NAMES OSDependent
HINTS ${GLSLANG_SEARCH_PATH} )
find_library(HLSL_LIB NAMES HLSL
HINTS ${GLSLANG_SEARCH_PATH} )
find_library(SPIRV_LIB NAMES SPIRV
HINTS ${GLSLANG_SEARCH_PATH} )
find_library(SPIRV_TOOLS_LIB NAMES SPIRV-Tools
HINTS ${SPIRV_TOOLS_SEARCH_PATH} )
find_library(SPIRV_TOOLS_OPT_LIB NAMES SPIRV-Tools-opt
HINTS ${SPIRV_TOOLS_OPT_SEARCH_PATH} )
find_library(SPIRV_REMAPPER_LIB NAMES SPVRemapper
HINTS ${GLSLANG_SEARCH_PATH} )
# On Windows, we must pair Debug and Release appropriately
if (WIN32)
set (GLSLANG_DEBUG_SEARCH_PATH "${CMAKE_SOURCE_DIR}/../glslang/${BUILDTGT_DIR}/glslang/Debug"
"${CMAKE_SOURCE_DIR}/../glslang/${BUILDTGT_DIR}/glslang/OSDependent/Windows/Debug"
"${CMAKE_SOURCE_DIR}/../glslang/${BUILDTGT_DIR}/hlsl/Debug"
"${CMAKE_SOURCE_DIR}/../glslang/${BUILDTGT_DIR}/OGLCompilersDLL/Debug"
"${CMAKE_SOURCE_DIR}/../glslang/${BUILDTGT_DIR}/SPIRV/Debug")
set (SPIRV_TOOLS_DEBUG_SEARCH_PATH "${CMAKE_SOURCE_DIR}/../spirv-tools/${BUILDTGT_DIR}/source/Debug")
set (SPIRV_TOOLS_OPT_DEBUG_SEARCH_PATH "${CMAKE_SOURCE_DIR}/../spirv-tools/${BUILDTGT_DIR}/source/opt/Debug")
add_library(glslang STATIC IMPORTED)
add_library(OGLCompiler STATIC IMPORTED)
add_library(OSDependent STATIC IMPORTED)
add_library(HLSL STATIC IMPORTED)
add_library(SPIRV STATIC IMPORTED)
add_library(Loader STATIC IMPORTED)
add_library(SPIRV-Tools STATIC IMPORTED)
add_library(SPIRV-Tools-opt STATIC IMPORTED)
add_library(SPVRemapper STATIC IMPORTED)
find_library(GLSLANG_DLIB NAMES glslangd
HINTS ${GLSLANG_DEBUG_SEARCH_PATH} )
find_library(OGLCompiler_DLIB NAMES OGLCompilerd
HINTS ${GLSLANG_DEBUG_SEARCH_PATH} )
find_library(OSDependent_DLIB NAMES OSDependentd
HINTS ${GLSLANG_DEBUG_SEARCH_PATH} )
find_library(HLSL_DLIB NAMES HLSLd
HINTS ${GLSLANG_DEBUG_SEARCH_PATH} )
find_library(SPIRV_DLIB NAMES SPIRVd
HINTS ${GLSLANG_DEBUG_SEARCH_PATH} )
find_library(SPIRV_TOOLS_DLIB NAMES SPIRV-Tools
HINTS ${SPIRV_TOOLS_DEBUG_SEARCH_PATH} )
find_library(SPIRV_TOOLS_OPT_DLIB NAMES SPIRV-Tools-opt
HINTS ${SPIRV_TOOLS_OPT_DEBUG_SEARCH_PATH} )
find_library(SPIRV_REMAPPER_DLIB NAMES SPVRemapperd
HINTS ${GLSLANG_DEBUG_SEARCH_PATH} )
set_target_properties(glslang PROPERTIES
IMPORTED_LOCATION "${GLSLANG_LIB}"
IMPORTED_LOCATION_DEBUG "${GLSLANG_DLIB}")
set_target_properties(OGLCompiler PROPERTIES
IMPORTED_LOCATION "${OGLCompiler_LIB}"
IMPORTED_LOCATION_DEBUG "${OGLCompiler_DLIB}")
set_target_properties(OSDependent PROPERTIES
IMPORTED_LOCATION "${OSDependent_LIB}"
IMPORTED_LOCATION_DEBUG "${OSDependent_DLIB}")
set_target_properties(HLSL PROPERTIES
IMPORTED_LOCATION "${HLSL_LIB}"
IMPORTED_LOCATION_DEBUG "${HLSL_DLIB}")
set_target_properties(SPIRV PROPERTIES
IMPORTED_LOCATION "${SPIRV_LIB}"
IMPORTED_LOCATION_DEBUG "${SPIRV_DLIB}")
set_target_properties(SPIRV-Tools PROPERTIES
IMPORTED_LOCATION "${SPIRV_TOOLS_LIB}"
IMPORTED_LOCATION_DEBUG "${SPIRV_TOOLS_DLIB}")
set_target_properties(SPIRV-Tools-opt PROPERTIES
IMPORTED_LOCATION "${SPIRV_TOOLS_OPT_LIB}"
IMPORTED_LOCATION_DEBUG "${SPIRV_TOOLS_OPT_DLIB}")
set_target_properties(SPVRemapper PROPERTIES
IMPORTED_LOCATION "${SPIRV_REMAPPER_LIB}"
IMPORTED_LOCATION_DEBUG "${SPIRV_REMAPPER_DLIB}")
set (SPIRV_TOOLS_LIBRARIES SPIRV-Tools-opt SPIRV-Tools)
set (GLSLANG_LIBRARIES glslang OGLCompiler OSDependent HLSL SPIRV SPVRemapper ${SPIRV_TOOLS_LIBRARIES})
else ()
set (SPIRV_TOOLS_LIBRARIES ${SPIRV_TOOLS_OPT_LIB} ${SPIRV_TOOLS_LIB})
set (GLSLANG_LIBRARIES ${GLSLANG_LIB} ${OGLCompiler_LIB} ${OSDependent_LIB} ${HLSL_LIB} ${SPIRV_LIB} ${SPIRV_REMAPPER_LIB} ${SPIRV_TOOLS_LIBRARIES})
endif()
set (GLMINCLUDES "${CMAKE_SOURCE_DIR}/API-Samples/utils")
# to run with source glslang libs/headers
if(UNIX)
add_definitions(-DVK_USE_PLATFORM_XCB_KHR)
if (EXISTS "${CMAKE_SOURCE_DIR}/../glslang")
set (GLSLANGDIR "${CMAKE_SOURCE_DIR}/../glslang")
else()
set (GLSLANGDIR "${CMAKE_SOURCE_DIR}/../source/glslang")
endif()
else()
set (GLSLANGDIR "${CMAKE_SOURCE_DIR}/../glslang")
endif()
get_filename_component(GLMINC_PREFIX "${GLMINCLUDES}" ABSOLUTE)
if(NOT EXISTS ${GLMINC_PREFIX})
message(FATAL_ERROR "Necessary glm headers do not exist: " ${GLMINC_PREFIX})
endif()
get_filename_component(GLSLANG_PREFIX "${GLSLANGDIR}" ABSOLUTE)
if(NOT EXISTS ${GLSLANG_PREFIX})
message(FATAL_ERROR "Necessary glslang components do not exist: " ${GLSLANG_PREFIX})
endif()
add_definitions(-DVULKAN_SAMPLES_BASE_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/API-Samples/utils)
if(WIN32)
include_directories(${CMAKE_SOURCE_DIR}\\..\\Include)
else()
include_directories("/usr/include/vulkan" "${CMAKE_SOURCE_DIR}/../x86_64/include/vulkan" "${CMAKE_SOURCE_DIR}/include")
endif()
if(WIN32)
set (MOVE_CMD "move")
set (VULKAN_LOADER_NAME "${API_LOWERCASE}-${MAJOR}")
else()
set (MOVE_CMD "mv")
set (PTHREAD "pthread")
set (VULKAN_LOADER_NAME "${API_LOWERCASE}")
endif()
if(EXISTS "${CMAKE_SOURCE_DIR}/layers")
set (VULKAN_LOADER ${VULKAN_LOADER_NAME})
else()
find_library(VULKAN_LOADER NAMES ${VULKAN_LOADER_NAME}
HINTS "${CMAKE_SOURCE_DIR}/../${BINDATA_DIR}" "${CMAKE_SOURCE_DIR}/../x86_64/lib" )
endif()
add_definitions(-DAPI_NAME="${API_NAME}")
add_subdirectory(API-Samples)
add_subdirectory(Sample-Programs/Hologram)
add_subdirectory(Layer-Samples/Overlay)