forked from vsg-dev/VulkanSceneGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vsg_glslangConfig.cmake
259 lines (218 loc) · 8.24 KB
/
vsg_glslangConfig.cmake
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
#.rst:
# Findglslang
# ----------
#
# Try to find glslang in the VulkanSDK
#
# IMPORTED Targets
# ^^^^^^^^^^^^^^^^
#
# This module defines :prop_tgt:`IMPORTED` target ``glslang::glslang``, if
# glslang has been found.
#
# Result Variables
# ^^^^^^^^^^^^^^^^
#
# This module defines the following variables::
#
# glslang_FOUND - True if glslang was found
# glslang_INCLUDE_DIRS - include directories for glslang
# glslang_LIBRARIES - link against this library to use glslang
#
# The module will also define two cache variables::
#
# glslang_INCLUDE_DIR - the glslang include directory
# glslang_LIBRARY - the path to the glslang library
#
if (DEFINED ENV{VULKAN_SDK})
if(WIN32)
set(ADDITIONAL_PATHS_INCLUDE "$ENV{VULKAN_SDK}/Include")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(ADDITIONAL_PATHS_LIBS
"$ENV{VULKAN_SDK}/Lib"
"$ENV{VULKAN_SDK}/Bin"
)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(ADDITIONAL_PATHS_LIBS
"$ENV{VULKAN_SDK}/Lib32"
"$ENV{VULKAN_SDK}/Bin32"
)
endif()
else()
set(ADDITIONAL_PATHS_INCLUDE "$ENV{VULKAN_SDK}/include")
set(ADDITIONAL_PATHS_LIBS "$ENV{VULKAN_SDK}/lib")
endif()
endif()
find_path(glslang_INCLUDE_DIR
NAMES glslang/Public/ShaderLang.h
PATHS ${ADDITIONAL_PATHS_INCLUDE}
)
find_path(spirv_INCLUDE_DIR
NAMES glslang/SPIRV/GlslangToSpv.h
PATHS ${ADDITIONAL_PATHS_INCLUDE}
)
find_library(glslang_LIBRARY
NAMES glslang
PATHS ${ADDITIONAL_PATHS_LIBS}
)
find_library(OSDependent_LIBRARY
NAMES OSDependent
PATHS ${ADDITIONAL_PATHS_LIBS}
)
find_library(SPIRV_LIBRARY
NAMES SPIRV
PATHS ${ADDITIONAL_PATHS_LIBS}
)
find_library(OGLCompiler_LIBRARY
NAMES OGLCompiler
PATHS ${ADDITIONAL_PATHS_LIBS}
)
find_library(HLSL_LIBRARY
NAMES HLSL
PATHS ${ADDITIONAL_PATHS_LIBS}
)
find_library(MachineIndependent_LIBRARY
NAMES MachineIndependent
PATHS ${ADDITIONAL_PATHS_LIBS}
)
find_library(GenericCodeGen_LIBRARY
NAMES GenericCodeGen
PATHS ${ADDITIONAL_PATHS_LIBS}
)
find_library(SPIRV-Tools_LIBRARY
NAMES SPIRV-Tools
PATHS ${ADDITIONAL_PATHS_LIBS}
)
find_library(SPIRV-Tools-opt_LIBRARY
NAMES SPIRV-Tools-opt
PATHS ${ADDITIONAL_PATHS_LIBS}
)
if(WIN32)
find_library(glslang_LIBRARY_debug
NAMES glslangd
PATHS ${ADDITIONAL_PATHS_LIBS}
)
find_library(OSDependent_LIBRARY_debug
NAMES OSDependentd
PATHS ${ADDITIONAL_PATHS_LIBS}
)
find_library(SPIRV_LIBRARY_debug
NAMES SPIRVd
PATHS ${ADDITIONAL_PATHS_LIBS}
)
find_library(OGLCompiler_LIBRARY_debug
NAMES OGLCompilerd
PATHS ${ADDITIONAL_PATHS_LIBS}
)
find_library(HLSL_LIBRARY_debug
NAMES HLSLd
PATHS ${ADDITIONAL_PATHS_LIBS}
)
find_library(MachineIndependent_LIBRARY_debug
NAMES MachineIndependentd
PATHS ${ADDITIONAL_PATHS_LIBS}
)
find_library(GenericCodeGen_LIBRARY_debug
NAMES GenericCodeGend
PATHS ${ADDITIONAL_PATHS_LIBS}
)
find_library(SPIRV-Tools_LIBRARY_debug
NAMES SPIRV-Toolsd
PATHS ${ADDITIONAL_PATHS_LIBS}
)
find_library(SPIRV-Tools-opt_LIBRARY_debug
NAMES SPIRV-Tools-optd
PATHS ${ADDITIONAL_PATHS_LIBS}
)
endif()
mark_as_advanced(glslang_INCLUDE_DIR glslang_LIBRARY)
if(glslang_LIBRARY AND glslang_INCLUDE_DIR AND SPIRV-Tools_LIBRARY AND SPIRV-Tools-opt_LIBRARY)
set(glslang_FOUND "YES")
message(STATUS "Found glslang: ${glslang_LIBRARY}")
else()
set(glslang_FOUND "NO")
message(STATUS "Failed to find glslang")
endif()
if(glslang_FOUND AND NOT TARGET glslang::glslang)
set(glslang_INCLUDE_DIRS ${glslang_INCLUDE_DIR})
add_library(glslang::glslang UNKNOWN IMPORTED)
set_target_properties(glslang::glslang PROPERTIES IMPORTED_LOCATION "${glslang_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${glslang_INCLUDE_DIRS}")
add_library(glslang::OSDependent UNKNOWN IMPORTED)
set_target_properties(glslang::OSDependent PROPERTIES IMPORTED_LOCATION "${OSDependent_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${OSDependent_INCLUDE_DIRS}")
add_library(glslang::SPIRV UNKNOWN IMPORTED)
set_target_properties(glslang::SPIRV PROPERTIES IMPORTED_LOCATION "${SPIRV_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${spirv_INCLUDE_DIR}")
add_library(glslang::OGLCompiler UNKNOWN IMPORTED)
set_target_properties(glslang::OGLCompiler PROPERTIES IMPORTED_LOCATION "${OGLCompiler_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${glslang_INCLUDE_DIRS}")
add_library(glslang::HLSL UNKNOWN IMPORTED)
set_target_properties(glslang::HLSL PROPERTIES IMPORTED_LOCATION "${HLSL_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${glslang_INCLUDE_DIRS}")
if (SPIRV-Tools_LIBRARY)
add_library(glslang::SPIRV-Tools UNKNOWN IMPORTED)
set_target_properties(glslang::SPIRV-Tools PROPERTIES IMPORTED_LOCATION "${SPIRV-Tools_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${SPIRV-Tools__INCLUDE_DIR}")
endif()
if (SPIRV-Tools-opt_LIBRARY)
add_library(glslang::SPIRV-Tools-opt UNKNOWN IMPORTED)
set_target_properties(glslang::SPIRV-Tools-opt PROPERTIES IMPORTED_LOCATION "${SPIRV-Tools-opt_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${SPIRV-Tools-opt_INCLUDE_DIR}")
endif()
if (MachineIndependent_LIBRARY)
add_library(glslang::MachineIndependent UNKNOWN IMPORTED)
set_target_properties(glslang::MachineIndependent PROPERTIES IMPORTED_LOCATION "${MachineIndependent_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${MachineIndependent_INCLUDE_DIRS}")
endif()
if (GenericCodeGen_LIBRARY)
add_library(glslang::GenericCodeGen UNKNOWN IMPORTED)
set_target_properties(glslang::GenericCodeGen PROPERTIES IMPORTED_LOCATION "${GenericCodeGen_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${GenericCodeGen_INCLUDE_DIRS}")
endif()
if(WIN32)
if (glslang_LIBRARY_debug)
set_target_properties(glslang::glslang PROPERTIES IMPORTED_LOCATION_DEBUG "${glslang_LIBRARY_debug}")
endif()
if (OSDependent_LIBRARY_debug)
set_target_properties(glslang::OSDependent PROPERTIES IMPORTED_LOCATION_DEBUG "${OSDependent_LIBRARY_debug}")
endif()
if (SPIRV_LIBRARY_debug)
set_target_properties(glslang::SPIRV PROPERTIES IMPORTED_LOCATION_DEBUG "${SPIRV_LIBRARY_debug}")
endif()
if (OGLCompiler_LIBRARY_debug)
set_target_properties(glslang::OGLCompiler PROPERTIES IMPORTED_LOCATION_DEBUG "${OGLCompiler_LIBRARY_debug}")
endif()
if (HLSL_LIBRARY_debug)
set_target_properties(glslang::HLSL PROPERTIES IMPORTED_LOCATION_DEBUG "${HLSL_LIBRARY_debug}")
endif()
if (MachineIndependent_LIBRARY_debug)
set_target_properties(glslang::MachineIndependent PROPERTIES IMPORTED_LOCATION_DEBUG "${MachineIndependent_LIBRARY_debug}")
endif()
if (GenericCodeGen_LIBRARY_debug)
set_target_properties(glslang::GenericCodeGen PROPERTIES IMPORTED_LOCATION_DEBUG "${GenericCodeGen_LIBRARY_debug}")
endif()
if (SPIRV-Tools_LIBRARY_debug)
set_target_properties(glslang::SPIRV-Tools PROPERTIES IMPORTED_LOCATION_DEBUG "${SPIRV-Tools_LIBRARY_debug}")
endif()
if (SPIRV-Tools-opt_LIBRARY_debug)
set_target_properties(glslang::SPIRV-Tools-opt PROPERTIES IMPORTED_LOCATION_DEBUG "${SPIRV-Tools-opt_LIBRARY_debug}")
endif()
endif()
if (MachineIndependent_LIBRARY AND GenericCodeGen_LIBRARY)
# VULKAN_SDK and associated glslang 1.2.147.1 onwards
set(glslang_LIBRARIES
glslang::MachineIndependent
glslang::OSDependent
glslang::OGLCompiler
glslang::SPIRV
glslang::GenericCodeGen
)
else()
# VULKAN_SDK and associated glslang before 1.2.147.1
set(glslang_LIBRARIES
glslang::glslang
glslang::OSDependent
glslang::OGLCompiler
glslang::SPIRV
glslang::HLSL
)
endif()
if (SPIRV-Tools-opt_LIBRARY)
list(APPEND glslang_LIBRARIES glslang::SPIRV-Tools-opt)
endif()
if (SPIRV-Tools_LIBRARY)
list(APPEND glslang_LIBRARIES glslang::SPIRV-Tools)
endif()
endif()