1 # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 # file Copyright.txt or https://cmake.org/licensing for details.
4 #[=======================================================================[.rst:
10 Find Vulkan, which is a low-overhead, cross-platform 3D graphics
16 .. versionadded:: 3.24
18 This module respects several optional COMPONENTS.
19 There are corresponding imported targets for each of these.
25 The ``glslangValidator`` tool.
28 The SPIR-V generator library.
31 The static library for Vulkan shader compilation.
34 Tools to process SPIR-V modules.
37 On macOS, an additional component ``MoltenVK`` is available.
40 .. versionadded:: 3.25
42 The DirectX Shader Compiler.
44 The ``glslc`` and ``glslangValidator`` components are provided even
45 if not explicitly requested (for backward compatibility).
50 This module defines :prop_tgt:`IMPORTED` targets if Vulkan has been found:
53 The main Vulkan library.
56 .. versionadded:: 3.19
58 The GLSLC SPIR-V compiler, if it has been found.
61 .. versionadded:: 3.21
63 Provides just Vulkan headers include paths, if found. No library is
64 included in this target. This can be useful for applications that
65 load Vulkan library dynamically.
67 ``Vulkan::glslangValidator``
68 .. versionadded:: 3.21
70 The glslangValidator tool, if found. It is used to compile GLSL and
71 HLSL shaders into SPIR-V.
74 .. versionadded:: 3.24
76 Defined if SDK has the Khronos-reference front-end shader parser and SPIR-V
77 generator library (glslang).
79 ``Vulkan::shaderc_combined``
80 .. versionadded:: 3.24
82 Defined if SDK has the Google static library for Vulkan shader compilation
85 ``Vulkan::SPIRV-Tools``
86 .. versionadded:: 3.24
88 Defined if SDK has the Khronos library to process SPIR-V modules
92 .. versionadded:: 3.24
94 Defined if SDK has the Khronos library which implement a subset of Vulkan API
95 over Apple Metal graphics framework. (MoltenVK).
98 .. versionadded:: 3.25
100 Defined if SDK has the Vulkan meta-loader (volk).
103 .. versionadded:: 3.25
105 Defined if SDK has the DirectX shader compiler library.
108 .. versionadded:: 3.25
110 Defined if SDK has the DirectX shader compiler CLI tool.
115 This module defines the following variables:
118 set to true if Vulkan was found
119 ``Vulkan_INCLUDE_DIRS``
120 include directories for Vulkan
122 link against this library to use Vulkan
124 .. versionadded:: 3.23
126 value from ``vulkan/vulkan_core.h``
127 ``Vulkan_glslc_FOUND``
128 .. versionadded:: 3.24
130 True, if the SDK has the glslc executable.
131 ``Vulkan_glslangValidator_FOUND``
132 .. versionadded:: 3.24
134 True, if the SDK has the glslangValidator executable.
135 ``Vulkan_glslang_FOUND``
136 .. versionadded:: 3.24
138 True, if the SDK has the glslang library.
139 ``Vulkan_shaderc_combined_FOUND``
140 .. versionadded:: 3.24
142 True, if the SDK has the shaderc_combined library.
143 ``Vulkan_SPIRV-Tools_FOUND``
144 .. versionadded:: 3.24
146 True, if the SDK has the SPIRV-Tools library.
147 ``Vulkan_MoltenVK_FOUND``
148 .. versionadded:: 3.24
150 True, if the SDK has the MoltenVK library.
151 ``Vulkan_volk_FOUND``
152 .. versionadded:: 3.25
154 True, if the SDK has the volk library.
156 ``Vulkan_dxc_lib_FOUND``
157 .. versionadded:: 3.25
159 True, if the SDK has the DirectX shader compiler library.
161 ``Vulkan_dxc_exe_FOUND``
162 .. versionadded:: 3.25
164 True, if the SDK has the DirectX shader compiler CLI tool.
167 The module will also defines these cache variables:
169 ``Vulkan_INCLUDE_DIR``
170 the Vulkan include directory
172 the path to the Vulkan library
173 ``Vulkan_GLSLC_EXECUTABLE``
174 the path to the GLSL SPIR-V compiler
175 ``Vulkan_GLSLANG_VALIDATOR_EXECUTABLE``
176 the path to the glslangValidator tool
177 ``Vulkan_glslang_LIBRARY``
178 .. versionadded:: 3.24
180 Path to the glslang library.
181 ``Vulkan_shaderc_combined_LIBRARY``
182 .. versionadded:: 3.24
184 Path to the shaderc_combined library.
185 ``Vulkan_SPIRV-Tools_LIBRARY``
186 .. versionadded:: 3.24
188 Path to the SPIRV-Tools library.
189 ``Vulkan_MoltenVK_LIBRARY``
190 .. versionadded:: 3.24
192 Path to the MoltenVK library.
194 ``Vulkan_volk_LIBRARY``
195 .. versionadded:: 3.25
197 Path to the volk library.
199 ``Vulkan_dxc_LIBRARY``
200 .. versionadded:: 3.25
202 Path to the DirectX shader compiler library.
204 ``Vulkan_dxc_EXECUTABLE``
205 .. versionadded:: 3.25
207 Path to the DirectX shader compiler CLI tool.
212 .. versionadded:: 3.18
214 The ``VULKAN_SDK`` environment variable optionally specifies the
215 location of the Vulkan SDK root directory for the given
216 architecture. It is typically set by sourcing the toplevel
217 ``setup-env.sh`` script of the Vulkan SDK directory into the shell
220 #]=======================================================================]
223 cmake_policy(SET CMP0057 NEW)
224 cmake_policy(SET CMP0159 NEW) # file(STRINGS) with REGEX updates CMAKE_MATCH_<n>
226 # Provide compatibility with a common invalid component request that
227 # was silently ignored prior to CMake 3.24.
228 if("FATAL_ERROR" IN_LIST Vulkan_FIND_COMPONENTS)
229 message(AUTHOR_WARNING
230 "Ignoring unknown component 'FATAL_ERROR'.\n"
231 "The find_package() command documents no such argument."
233 list(REMOVE_ITEM Vulkan_FIND_COMPONENTS "FATAL_ERROR")
236 # For backward compatibility as `FindVulkan` in previous CMake versions allow to retrieve `glslc`
237 # and `glslangValidator` without requesting the corresponding component.
238 if(NOT glslc IN_LIST Vulkan_FIND_COMPONENTS)
239 list(APPEND Vulkan_FIND_COMPONENTS glslc)
241 if(NOT glslangValidator IN_LIST Vulkan_FIND_COMPONENTS)
242 list(APPEND Vulkan_FIND_COMPONENTS glslangValidator)
246 set(_Vulkan_library_name vulkan-1)
247 set(_Vulkan_hint_include_search_paths
248 "$ENV{VULKAN_SDK}/include"
250 if(CMAKE_SIZEOF_VOID_P EQUAL 8)
251 set(_Vulkan_hint_executable_search_paths
252 "$ENV{VULKAN_SDK}/bin"
254 set(_Vulkan_hint_library_search_paths
255 "$ENV{VULKAN_SDK}/lib"
256 "$ENV{VULKAN_SDK}/bin"
259 set(_Vulkan_hint_executable_search_paths
260 "$ENV{VULKAN_SDK}/bin32"
261 "$ENV{VULKAN_SDK}/bin"
263 set(_Vulkan_hint_library_search_paths
264 "$ENV{VULKAN_SDK}/lib32"
265 "$ENV{VULKAN_SDK}/bin32"
266 "$ENV{VULKAN_SDK}/lib"
267 "$ENV{VULKAN_SDK}/bin"
271 set(_Vulkan_library_name vulkan)
272 set(_Vulkan_hint_include_search_paths
273 "$ENV{VULKAN_SDK}/include"
275 set(_Vulkan_hint_executable_search_paths
276 "$ENV{VULKAN_SDK}/bin"
278 set(_Vulkan_hint_library_search_paths
279 "$ENV{VULKAN_SDK}/lib"
282 if(APPLE AND DEFINED ENV{VULKAN_SDK})
283 cmake_path(SET _MoltenVK_path NORMALIZE "$ENV{VULKAN_SDK}/../MoltenVK")
284 if(EXISTS "${_MoltenVK_path}")
285 list(APPEND _Vulkan_hint_include_search_paths
286 "${_MoltenVK_path}/include"
288 if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
289 list(APPEND _Vulkan_hint_library_search_paths
290 "${_MoltenVK_path}/dylib/iOS"
292 elseif(CMAKE_SYSTEM_NAME STREQUAL "tvOS")
293 list(APPEND _Vulkan_hint_library_search_paths
294 "${_MoltenVK_path}/dylib/tvOS"
297 list(APPEND _Vulkan_hint_library_search_paths
298 "${_MoltenVK_path}/dylib/macOS"
302 unset(_MoltenVK_path)
305 find_path(Vulkan_INCLUDE_DIR
306 NAMES vulkan/vulkan.h
308 ${_Vulkan_hint_include_search_paths}
310 mark_as_advanced(Vulkan_INCLUDE_DIR)
312 find_library(Vulkan_LIBRARY
313 NAMES ${_Vulkan_library_name}
315 ${_Vulkan_hint_library_search_paths}
317 mark_as_advanced(Vulkan_LIBRARY)
319 if(glslc IN_LIST Vulkan_FIND_COMPONENTS)
320 find_program(Vulkan_GLSLC_EXECUTABLE
323 ${_Vulkan_hint_executable_search_paths}
325 mark_as_advanced(Vulkan_GLSLC_EXECUTABLE)
327 if(glslangValidator IN_LIST Vulkan_FIND_COMPONENTS)
328 find_program(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE
329 NAMES glslangValidator
331 ${_Vulkan_hint_executable_search_paths}
333 mark_as_advanced(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE)
335 if(glslang IN_LIST Vulkan_FIND_COMPONENTS)
336 find_library(Vulkan_glslang-spirv_LIBRARY
339 ${_Vulkan_hint_library_search_paths}
341 mark_as_advanced(Vulkan_glslang-spirv_LIBRARY)
343 find_library(Vulkan_glslang-spirv_DEBUG_LIBRARY
346 ${_Vulkan_hint_library_search_paths}
348 mark_as_advanced(Vulkan_glslang-spirv_DEBUG_LIBRARY)
350 find_library(Vulkan_glslang-oglcompiler_LIBRARY
353 ${_Vulkan_hint_library_search_paths}
355 mark_as_advanced(Vulkan_glslang-oglcompiler_LIBRARY)
357 find_library(Vulkan_glslang-oglcompiler_DEBUG_LIBRARY
360 ${_Vulkan_hint_library_search_paths}
362 mark_as_advanced(Vulkan_glslang-oglcompiler_DEBUG_LIBRARY)
364 find_library(Vulkan_glslang-osdependent_LIBRARY
367 ${_Vulkan_hint_library_search_paths}
369 mark_as_advanced(Vulkan_glslang-osdependent_LIBRARY)
371 find_library(Vulkan_glslang-osdependent_DEBUG_LIBRARY
374 ${_Vulkan_hint_library_search_paths}
376 mark_as_advanced(Vulkan_glslang-osdependent_DEBUG_LIBRARY)
378 find_library(Vulkan_glslang-machineindependent_LIBRARY
379 NAMES MachineIndependent
381 ${_Vulkan_hint_library_search_paths}
383 mark_as_advanced(Vulkan_glslang-machineindependent_LIBRARY)
385 find_library(Vulkan_glslang-machineindependent_DEBUG_LIBRARY
386 NAMES MachineIndependentd
388 ${_Vulkan_hint_library_search_paths}
390 mark_as_advanced(Vulkan_glslang-machineindependent_DEBUG_LIBRARY)
392 find_library(Vulkan_glslang-genericcodegen_LIBRARY
395 ${_Vulkan_hint_library_search_paths}
397 mark_as_advanced(Vulkan_glslang-genericcodegen_LIBRARY)
399 find_library(Vulkan_glslang-genericcodegen_DEBUG_LIBRARY
400 NAMES GenericCodeGend
402 ${_Vulkan_hint_library_search_paths}
404 mark_as_advanced(Vulkan_glslang-genericcodegen_DEBUG_LIBRARY)
406 find_library(Vulkan_glslang_LIBRARY
409 ${_Vulkan_hint_library_search_paths}
411 mark_as_advanced(Vulkan_glslang_LIBRARY)
413 find_library(Vulkan_glslang_DEBUG_LIBRARY
416 ${_Vulkan_hint_library_search_paths}
418 mark_as_advanced(Vulkan_glslang_DEBUG_LIBRARY)
420 if(shaderc_combined IN_LIST Vulkan_FIND_COMPONENTS)
421 find_library(Vulkan_shaderc_combined_LIBRARY
422 NAMES shaderc_combined
424 ${_Vulkan_hint_library_search_paths})
425 mark_as_advanced(Vulkan_shaderc_combined_LIBRARY)
427 find_library(Vulkan_shaderc_combined_DEBUG_LIBRARY
428 NAMES shaderc_combinedd
430 ${_Vulkan_hint_library_search_paths})
431 mark_as_advanced(Vulkan_shaderc_combined_DEBUG_LIBRARY)
433 if(SPIRV-Tools IN_LIST Vulkan_FIND_COMPONENTS)
434 find_library(Vulkan_SPIRV-Tools_LIBRARY
437 ${_Vulkan_hint_library_search_paths})
438 mark_as_advanced(Vulkan_SPIRV-Tools_LIBRARY)
440 find_library(Vulkan_SPIRV-Tools_DEBUG_LIBRARY
443 ${_Vulkan_hint_library_search_paths})
444 mark_as_advanced(Vulkan_SPIRV-Tools_DEBUG_LIBRARY)
446 if(MoltenVK IN_LIST Vulkan_FIND_COMPONENTS)
447 find_library(Vulkan_MoltenVK_LIBRARY
450 ${_Vulkan_hint_library_search_paths})
451 mark_as_advanced(Vulkan_MoltenVK_LIBRARY)
453 find_path(Vulkan_MoltenVK_INCLUDE_DIR
454 NAMES MoltenVK/mvk_vulkan.h
456 ${_Vulkan_hint_include_search_paths}
458 mark_as_advanced(Vulkan_MoltenVK_INCLUDE_DIR)
460 if(volk IN_LIST Vulkan_FIND_COMPONENTS)
461 find_library(Vulkan_volk_LIBRARY
464 ${_Vulkan_hint_library_search_paths})
465 mark_as_advanced(Vulkan_Volk_LIBRARY)
468 if (dxc IN_LIST Vulkan_FIND_COMPONENTS)
469 find_library(Vulkan_dxc_LIBRARY
472 ${_Vulkan_hint_library_search_paths})
473 mark_as_advanced(Vulkan_dxc_LIBRARY)
475 find_program(Vulkan_dxc_EXECUTABLE
478 ${_Vulkan_hint_executable_search_paths})
479 mark_as_advanced(Vulkan_dxc_EXECUTABLE)
482 if(Vulkan_GLSLC_EXECUTABLE)
483 set(Vulkan_glslc_FOUND TRUE)
485 set(Vulkan_glslc_FOUND FALSE)
488 if(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE)
489 set(Vulkan_glslangValidator_FOUND TRUE)
491 set(Vulkan_glslangValidator_FOUND FALSE)
494 if (Vulkan_dxc_EXECUTABLE)
495 set(Vulkan_dxc_exe_FOUND TRUE)
497 set(Vulkan_dxc_exe_FOUND FALSE)
500 function(_Vulkan_set_library_component_found component)
501 cmake_parse_arguments(PARSE_ARGV 1 _ARG
504 "DEPENDENT_COMPONENTS")
506 set(all_dependent_component_found TRUE)
507 foreach(dependent_component IN LISTS _ARG_DEPENDENT_COMPONENTS)
508 if(NOT Vulkan_${dependent_component}_FOUND)
509 set(all_dependent_component_found FALSE)
514 if(all_dependent_component_found AND (Vulkan_${component}_LIBRARY OR Vulkan_${component}_DEBUG_LIBRARY))
515 set(Vulkan_${component}_FOUND TRUE PARENT_SCOPE)
517 # For Windows Vulkan SDK, third party tools binaries are provided with different MSVC ABI:
518 # - Release binaries uses a runtime library
519 # - Debug binaries uses a debug runtime library
520 # This lead to incompatibilities in linking for some configuration types due to CMake-default or project-configured selected MSVC ABI.
521 if(WIN32 AND NOT _ARG_NO_WARNING)
522 if(NOT Vulkan_${component}_LIBRARY)
524 "Library ${component} for Release configuration is missing, imported target Vulkan::${component} may not be able to link when targeting this build configuration due to incompatible MSVC ABI.")
526 if(NOT Vulkan_${component}_DEBUG_LIBRARY)
528 "Library ${component} for Debug configuration is missing, imported target Vulkan::${component} may not be able to link when targeting this build configuration due to incompatible MSVC ABI. Consider re-installing the Vulkan SDK and request debug libraries to fix this warning.")
532 set(Vulkan_${component}_FOUND FALSE PARENT_SCOPE)
536 _Vulkan_set_library_component_found(glslang-spirv NO_WARNING)
537 _Vulkan_set_library_component_found(glslang-oglcompiler NO_WARNING)
538 _Vulkan_set_library_component_found(glslang-osdependent NO_WARNING)
539 _Vulkan_set_library_component_found(glslang-machineindependent NO_WARNING)
540 _Vulkan_set_library_component_found(glslang-genericcodegen NO_WARNING)
541 _Vulkan_set_library_component_found(glslang DEPENDENT_COMPONENTS glslang-spirv)
542 _Vulkan_set_library_component_found(shaderc_combined)
543 _Vulkan_set_library_component_found(SPIRV-Tools)
544 _Vulkan_set_library_component_found(volk)
545 _Vulkan_set_library_component_found(dxc)
547 if(Vulkan_MoltenVK_INCLUDE_DIR AND Vulkan_MoltenVK_LIBRARY)
548 set(Vulkan_MoltenVK_FOUND TRUE)
550 set(Vulkan_MoltenVK_FOUND FALSE)
553 set(Vulkan_LIBRARIES ${Vulkan_LIBRARY})
554 set(Vulkan_INCLUDE_DIRS ${Vulkan_INCLUDE_DIR})
556 # detect version e.g 1.2.189
557 set(Vulkan_VERSION "")
558 if(Vulkan_INCLUDE_DIR)
559 set(VULKAN_CORE_H ${Vulkan_INCLUDE_DIR}/vulkan/vulkan_core.h)
560 if(EXISTS ${VULKAN_CORE_H})
561 file(STRINGS ${VULKAN_CORE_H} VulkanHeaderVersionLine REGEX "^#define VK_HEADER_VERSION ")
562 string(REGEX MATCHALL "[0-9]+" VulkanHeaderVersion "${VulkanHeaderVersionLine}")
563 file(STRINGS ${VULKAN_CORE_H} VulkanHeaderVersionLine2 REGEX "^#define VK_HEADER_VERSION_COMPLETE ")
564 string(REGEX MATCHALL "[0-9]+" VulkanHeaderVersion2 "${VulkanHeaderVersionLine2}")
565 list(LENGTH VulkanHeaderVersion2 _len)
566 # versions >= 1.2.175 have an additional numbers in front of e.g. '0, 1, 2' instead of '1, 2'
568 list(REMOVE_AT VulkanHeaderVersion2 0)
570 list(APPEND VulkanHeaderVersion2 ${VulkanHeaderVersion})
571 list(JOIN VulkanHeaderVersion2 "." Vulkan_VERSION)
575 if(Vulkan_MoltenVK_FOUND)
576 set(Vulkan_MoltenVK_VERSION "")
577 if(Vulkan_MoltenVK_INCLUDE_DIR)
578 set(VK_MVK_MOLTENVK_H ${Vulkan_MoltenVK_INCLUDE_DIR}/MoltenVK/vk_mvk_moltenvk.h)
579 if(EXISTS ${VK_MVK_MOLTENVK_H})
580 file(STRINGS ${VK_MVK_MOLTENVK_H} _Vulkan_MoltenVK_VERSION_MAJOR REGEX "^#define MVK_VERSION_MAJOR ")
581 string(REGEX MATCHALL "[0-9]+" _Vulkan_MoltenVK_VERSION_MAJOR "${_Vulkan_MoltenVK_VERSION_MAJOR}")
582 file(STRINGS ${VK_MVK_MOLTENVK_H} _Vulkan_MoltenVK_VERSION_MINOR REGEX "^#define MVK_VERSION_MINOR ")
583 string(REGEX MATCHALL "[0-9]+" _Vulkan_MoltenVK_VERSION_MINOR "${_Vulkan_MoltenVK_VERSION_MINOR}")
584 file(STRINGS ${VK_MVK_MOLTENVK_H} _Vulkan_MoltenVK_VERSION_PATCH REGEX "^#define MVK_VERSION_PATCH ")
585 string(REGEX MATCHALL "[0-9]+" _Vulkan_MoltenVK_VERSION_PATCH "${_Vulkan_MoltenVK_VERSION_PATCH}")
586 set(Vulkan_MoltenVK_VERSION "${_Vulkan_MoltenVK_VERSION_MAJOR}.${_Vulkan_MoltenVK_VERSION_MINOR}.${_Vulkan_MoltenVK_VERSION_PATCH}")
587 unset(_Vulkan_MoltenVK_VERSION_MAJOR)
588 unset(_Vulkan_MoltenVK_VERSION_MINOR)
589 unset(_Vulkan_MoltenVK_VERSION_PATCH)
594 include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
595 find_package_handle_standard_args(Vulkan
604 if(Vulkan_FOUND AND NOT TARGET Vulkan::Vulkan)
605 add_library(Vulkan::Vulkan UNKNOWN IMPORTED)
606 set_target_properties(Vulkan::Vulkan PROPERTIES
607 IMPORTED_LOCATION "${Vulkan_LIBRARIES}"
608 INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
611 if(Vulkan_FOUND AND NOT TARGET Vulkan::Headers)
612 add_library(Vulkan::Headers INTERFACE IMPORTED)
613 set_target_properties(Vulkan::Headers PROPERTIES
614 INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
617 if(Vulkan_FOUND AND Vulkan_GLSLC_EXECUTABLE AND NOT TARGET Vulkan::glslc)
618 add_executable(Vulkan::glslc IMPORTED)
619 set_property(TARGET Vulkan::glslc PROPERTY IMPORTED_LOCATION "${Vulkan_GLSLC_EXECUTABLE}")
622 if(Vulkan_FOUND AND Vulkan_GLSLANG_VALIDATOR_EXECUTABLE AND NOT TARGET Vulkan::glslangValidator)
623 add_executable(Vulkan::glslangValidator IMPORTED)
624 set_property(TARGET Vulkan::glslangValidator PROPERTY IMPORTED_LOCATION "${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE}")
628 if((Vulkan_glslang-spirv_LIBRARY OR Vulkan_glslang-spirv_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-spirv)
629 add_library(Vulkan::glslang-spirv STATIC IMPORTED)
630 set_property(TARGET Vulkan::glslang-spirv
632 INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
633 if(Vulkan_glslang-spirv_LIBRARY)
634 set_property(TARGET Vulkan::glslang-spirv APPEND
636 IMPORTED_CONFIGURATIONS Release)
637 set_property(TARGET Vulkan::glslang-spirv
639 IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-spirv_LIBRARY}")
641 if(Vulkan_glslang-spirv_DEBUG_LIBRARY)
642 set_property(TARGET Vulkan::glslang-spirv APPEND
644 IMPORTED_CONFIGURATIONS Debug)
645 set_property(TARGET Vulkan::glslang-spirv
647 IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-spirv_DEBUG_LIBRARY}")
651 if((Vulkan_glslang-oglcompiler_LIBRARY OR Vulkan_glslang-oglcompiler_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-oglcompiler)
652 add_library(Vulkan::glslang-oglcompiler STATIC IMPORTED)
653 set_property(TARGET Vulkan::glslang-oglcompiler
655 INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
656 if(Vulkan_glslang-oglcompiler_LIBRARY)
657 set_property(TARGET Vulkan::glslang-oglcompiler APPEND
659 IMPORTED_CONFIGURATIONS Release)
660 set_property(TARGET Vulkan::glslang-oglcompiler
662 IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-oglcompiler_LIBRARY}")
664 if(Vulkan_glslang-oglcompiler_DEBUG_LIBRARY)
665 set_property(TARGET Vulkan::glslang-oglcompiler APPEND
667 IMPORTED_CONFIGURATIONS Debug)
668 set_property(TARGET Vulkan::glslang-oglcompiler
670 IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-oglcompiler_DEBUG_LIBRARY}")
674 if((Vulkan_glslang-osdependent_LIBRARY OR Vulkan_glslang-osdependent_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-osdependent)
675 add_library(Vulkan::glslang-osdependent STATIC IMPORTED)
676 set_property(TARGET Vulkan::glslang-osdependent
678 INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
679 if(Vulkan_glslang-osdependent_LIBRARY)
680 set_property(TARGET Vulkan::glslang-osdependent APPEND
682 IMPORTED_CONFIGURATIONS Release)
683 set_property(TARGET Vulkan::glslang-osdependent
685 IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-osdependent_LIBRARY}")
687 if(Vulkan_glslang-osdependent_DEBUG_LIBRARY)
688 set_property(TARGET Vulkan::glslang-osdependent APPEND
690 IMPORTED_CONFIGURATIONS Debug)
691 set_property(TARGET Vulkan::glslang-osdependent
693 IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-osdependent_DEBUG_LIBRARY}")
697 if((Vulkan_glslang-machineindependent_LIBRARY OR Vulkan_glslang-machineindependent_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-machineindependent)
698 add_library(Vulkan::glslang-machineindependent STATIC IMPORTED)
699 set_property(TARGET Vulkan::glslang-machineindependent
701 INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
702 if(Vulkan_glslang-machineindependent_LIBRARY)
703 set_property(TARGET Vulkan::glslang-machineindependent APPEND
705 IMPORTED_CONFIGURATIONS Release)
706 set_property(TARGET Vulkan::glslang-machineindependent
708 IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-machineindependent_LIBRARY}")
710 if(Vulkan_glslang-machineindependent_DEBUG_LIBRARY)
711 set_property(TARGET Vulkan::glslang-machineindependent APPEND
713 IMPORTED_CONFIGURATIONS Debug)
714 set_property(TARGET Vulkan::glslang-machineindependent
716 IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-machineindependent_DEBUG_LIBRARY}")
720 if((Vulkan_glslang-genericcodegen_LIBRARY OR Vulkan_glslang-genericcodegen_DEBUG_LIBRARY) AND NOT TARGET Vulkan::glslang-genericcodegen)
721 add_library(Vulkan::glslang-genericcodegen STATIC IMPORTED)
722 set_property(TARGET Vulkan::glslang-genericcodegen
724 INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
725 if(Vulkan_glslang-genericcodegen_LIBRARY)
726 set_property(TARGET Vulkan::glslang-genericcodegen APPEND
728 IMPORTED_CONFIGURATIONS Release)
729 set_property(TARGET Vulkan::glslang-genericcodegen
731 IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-genericcodegen_LIBRARY}")
733 if(Vulkan_glslang-genericcodegen_DEBUG_LIBRARY)
734 set_property(TARGET Vulkan::glslang-genericcodegen APPEND
736 IMPORTED_CONFIGURATIONS Debug)
737 set_property(TARGET Vulkan::glslang-genericcodegen
739 IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-genericcodegen_DEBUG_LIBRARY}")
743 if((Vulkan_glslang_LIBRARY OR Vulkan_glslang_DEBUG_LIBRARY)
744 AND TARGET Vulkan::glslang-spirv
745 AND NOT TARGET Vulkan::glslang)
746 add_library(Vulkan::glslang STATIC IMPORTED)
747 set_property(TARGET Vulkan::glslang
749 INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
750 if(Vulkan_glslang_LIBRARY)
751 set_property(TARGET Vulkan::glslang APPEND
753 IMPORTED_CONFIGURATIONS Release)
754 set_property(TARGET Vulkan::glslang
756 IMPORTED_LOCATION_RELEASE "${Vulkan_glslang_LIBRARY}")
758 if(Vulkan_glslang_DEBUG_LIBRARY)
759 set_property(TARGET Vulkan::glslang APPEND
761 IMPORTED_CONFIGURATIONS Debug)
762 set_property(TARGET Vulkan::glslang
764 IMPORTED_LOCATION_DEBUG "${Vulkan_glslang_DEBUG_LIBRARY}")
766 target_link_libraries(Vulkan::glslang
768 Vulkan::glslang-spirv
769 # OGLCompiler library has been fully removed since version 14.0.0
770 # OSDependent, MachineIndependent, and GenericCodeGen may also be removed in the future.
771 # See https://github.com/KhronosGroup/glslang/issues/3462
772 $<TARGET_NAME_IF_EXISTS:Vulkan::glslang-oglcompiler>
773 $<TARGET_NAME_IF_EXISTS:Vulkan::glslang-osdependent>
774 $<TARGET_NAME_IF_EXISTS:Vulkan::glslang-machineindependent>
775 $<TARGET_NAME_IF_EXISTS:Vulkan::glslang-genericcodegen>
779 if((Vulkan_shaderc_combined_LIBRARY OR Vulkan_shaderc_combined_DEBUG_LIBRARY) AND NOT TARGET Vulkan::shaderc_combined)
780 add_library(Vulkan::shaderc_combined STATIC IMPORTED)
781 set_property(TARGET Vulkan::shaderc_combined
783 INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
784 if(Vulkan_shaderc_combined_LIBRARY)
785 set_property(TARGET Vulkan::shaderc_combined APPEND
787 IMPORTED_CONFIGURATIONS Release)
788 set_property(TARGET Vulkan::shaderc_combined
790 IMPORTED_LOCATION_RELEASE "${Vulkan_shaderc_combined_LIBRARY}")
792 if(Vulkan_shaderc_combined_DEBUG_LIBRARY)
793 set_property(TARGET Vulkan::shaderc_combined APPEND
795 IMPORTED_CONFIGURATIONS Debug)
796 set_property(TARGET Vulkan::shaderc_combined
798 IMPORTED_LOCATION_DEBUG "${Vulkan_shaderc_combined_DEBUG_LIBRARY}")
802 find_package(Threads REQUIRED)
803 target_link_libraries(Vulkan::shaderc_combined
809 if((Vulkan_SPIRV-Tools_LIBRARY OR Vulkan_SPIRV-Tools_DEBUG_LIBRARY) AND NOT TARGET Vulkan::SPIRV-Tools)
810 add_library(Vulkan::SPIRV-Tools STATIC IMPORTED)
811 set_property(TARGET Vulkan::SPIRV-Tools
813 INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
814 if(Vulkan_SPIRV-Tools_LIBRARY)
815 set_property(TARGET Vulkan::SPIRV-Tools APPEND
817 IMPORTED_CONFIGURATIONS Release)
818 set_property(TARGET Vulkan::SPIRV-Tools
820 IMPORTED_LOCATION_RELEASE "${Vulkan_SPIRV-Tools_LIBRARY}")
822 if(Vulkan_SPIRV-Tools_DEBUG_LIBRARY)
823 set_property(TARGET Vulkan::SPIRV-Tools APPEND
825 IMPORTED_CONFIGURATIONS Debug)
826 set_property(TARGET Vulkan::SPIRV-Tools
828 IMPORTED_LOCATION_DEBUG "${Vulkan_SPIRV-Tools_DEBUG_LIBRARY}")
832 if(Vulkan_volk_LIBRARY AND NOT TARGET Vulkan::volk)
833 add_library(Vulkan::volk STATIC IMPORTED)
834 set_property(TARGET Vulkan::volk
836 INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
837 set_property(TARGET Vulkan::volk APPEND
839 IMPORTED_CONFIGURATIONS Release)
840 set_property(TARGET Vulkan::volk APPEND
842 IMPORTED_LOCATION_RELEASE "${Vulkan_volk_LIBRARY}")
845 set_property(TARGET Vulkan::volk APPEND
847 IMPORTED_LINK_INTERFACE_LIBRARIES dl)
851 if (Vulkan_dxc_LIBRARY AND NOT TARGET Vulkan::dxc_lib)
852 add_library(Vulkan::dxc_lib STATIC IMPORTED)
853 set_property(TARGET Vulkan::dxc_lib
855 INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
856 set_property(TARGET Vulkan::dxc_lib APPEND
858 IMPORTED_CONFIGURATIONS Release)
859 set_property(TARGET Vulkan::dxc_lib APPEND
861 IMPORTED_LOCATION_RELEASE "${Vulkan_dxc_LIBRARY}")
864 if(Vulkan_dxc_EXECUTABLE AND NOT TARGET Vulkan::dxc_exe)
865 add_executable(Vulkan::dxc_exe IMPORTED)
866 set_property(TARGET Vulkan::dxc_exe PROPERTY IMPORTED_LOCATION "${Vulkan_dxc_EXECUTABLE}")
871 if(Vulkan_MoltenVK_FOUND)
872 if(Vulkan_MoltenVK_LIBRARY AND NOT TARGET Vulkan::MoltenVK)
873 add_library(Vulkan::MoltenVK SHARED IMPORTED)
874 set_target_properties(Vulkan::MoltenVK
876 INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_MoltenVK_INCLUDE_DIR}"
877 IMPORTED_LOCATION "${Vulkan_MoltenVK_LIBRARY}"
882 unset(_Vulkan_library_name)
883 unset(_Vulkan_hint_include_search_paths)
884 unset(_Vulkan_hint_executable_search_paths)
885 unset(_Vulkan_hint_library_search_paths)