Merge topic 'cpack-innosetup-linux'
[kiteware-cmake.git] / Modules / FindVulkan.cmake
blob226211919ed16370ac7b29ce10b3e40d3d1e4833
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:
5 FindVulkan
6 ----------
8 .. versionadded:: 3.7
10 Find Vulkan, which is a low-overhead, cross-platform 3D graphics
11 and computing API.
13 Optional COMPONENTS
14 ^^^^^^^^^^^^^^^^^^^
16 .. versionadded:: 3.24
18 This module respects several optional COMPONENTS.
19 There are corresponding imported targets for each of these.
21 ``glslc``
22   The SPIR-V compiler.
24 ``glslangValidator``
25   The ``glslangValidator`` tool.
27 ``glslang``
28   The SPIR-V generator library.
30 ``shaderc_combined``
31   The static library for Vulkan shader compilation.
33 ``SPIRV-Tools``
34   Tools to process SPIR-V modules.
36 ``MoltenVK``
37   On macOS, an additional component ``MoltenVK`` is available.
39 ``dxc``
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).
47 IMPORTED Targets
48 ^^^^^^^^^^^^^^^^
50 This module defines :prop_tgt:`IMPORTED` targets if Vulkan has been found:
52 ``Vulkan::Vulkan``
53   The main Vulkan library.
55 ``Vulkan::glslc``
56   .. versionadded:: 3.19
58   The GLSLC SPIR-V compiler, if it has been found.
60 ``Vulkan::Headers``
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.
73 ``Vulkan::glslang``
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
83   (shaderc_combined).
85 ``Vulkan::SPIRV-Tools``
86   .. versionadded:: 3.24
88   Defined if SDK has the Khronos library to process SPIR-V modules
89   (SPIRV-Tools).
91 ``Vulkan::MoltenVK``
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).
97 ``Vulkan::volk``
98   .. versionadded:: 3.25
100   Defined if SDK has the Vulkan meta-loader (volk).
102 ``Vulkan::dxc_lib``
103   .. versionadded:: 3.25
105   Defined if SDK has the DirectX shader compiler library.
107 ``Vulkan::dxc_exe``
108   .. versionadded:: 3.25
110   Defined if SDK has the DirectX shader compiler CLI tool.
112 Result Variables
113 ^^^^^^^^^^^^^^^^
115 This module defines the following variables:
117 ``Vulkan_FOUND``
118   set to true if Vulkan was found
119 ``Vulkan_INCLUDE_DIRS``
120   include directories for Vulkan
121 ``Vulkan_LIBRARIES``
122   link against this library to use Vulkan
123 ``Vulkan_VERSION``
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
171 ``Vulkan_LIBRARY``
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.
209 Hints
210 ^^^^^
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
218 environment.
220 #]=======================================================================]
222 cmake_policy(PUSH)
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."
232     )
233   list(REMOVE_ITEM Vulkan_FIND_COMPONENTS "FATAL_ERROR")
234 endif()
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)
240 endif()
241 if(NOT glslangValidator IN_LIST Vulkan_FIND_COMPONENTS)
242   list(APPEND Vulkan_FIND_COMPONENTS glslangValidator)
243 endif()
245 if(WIN32)
246   set(_Vulkan_library_name vulkan-1)
247   set(_Vulkan_hint_include_search_paths
248     "$ENV{VULKAN_SDK}/include"
249   )
250   if(CMAKE_SIZEOF_VOID_P EQUAL 8)
251     set(_Vulkan_hint_executable_search_paths
252       "$ENV{VULKAN_SDK}/bin"
253     )
254     set(_Vulkan_hint_library_search_paths
255       "$ENV{VULKAN_SDK}/lib"
256       "$ENV{VULKAN_SDK}/bin"
257     )
258   else()
259     set(_Vulkan_hint_executable_search_paths
260       "$ENV{VULKAN_SDK}/bin32"
261       "$ENV{VULKAN_SDK}/bin"
262     )
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"
268     )
269   endif()
270 else()
271   set(_Vulkan_library_name vulkan)
272   set(_Vulkan_hint_include_search_paths
273     "$ENV{VULKAN_SDK}/include"
274   )
275   set(_Vulkan_hint_executable_search_paths
276     "$ENV{VULKAN_SDK}/bin"
277   )
278   set(_Vulkan_hint_library_search_paths
279     "$ENV{VULKAN_SDK}/lib"
280   )
281 endif()
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"
287     )
288     if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
289       list(APPEND _Vulkan_hint_library_search_paths
290         "${_MoltenVK_path}/dylib/iOS"
291       )
292     elseif(CMAKE_SYSTEM_NAME STREQUAL "tvOS")
293       list(APPEND _Vulkan_hint_library_search_paths
294         "${_MoltenVK_path}/dylib/tvOS"
295       )
296     else()
297       list(APPEND _Vulkan_hint_library_search_paths
298         "${_MoltenVK_path}/dylib/macOS"
299       )
300     endif()
301   endif()
302   unset(_MoltenVK_path)
303 endif()
305 find_path(Vulkan_INCLUDE_DIR
306   NAMES vulkan/vulkan.h
307   HINTS
308     ${_Vulkan_hint_include_search_paths}
309   )
310 mark_as_advanced(Vulkan_INCLUDE_DIR)
312 find_library(Vulkan_LIBRARY
313   NAMES ${_Vulkan_library_name}
314   HINTS
315     ${_Vulkan_hint_library_search_paths}
316   )
317 mark_as_advanced(Vulkan_LIBRARY)
319 if(glslc IN_LIST Vulkan_FIND_COMPONENTS)
320   find_program(Vulkan_GLSLC_EXECUTABLE
321     NAMES glslc
322     HINTS
323       ${_Vulkan_hint_executable_search_paths}
324     )
325   mark_as_advanced(Vulkan_GLSLC_EXECUTABLE)
326 endif()
327 if(glslangValidator IN_LIST Vulkan_FIND_COMPONENTS)
328   find_program(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE
329     NAMES glslangValidator
330     HINTS
331       ${_Vulkan_hint_executable_search_paths}
332     )
333   mark_as_advanced(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE)
334 endif()
335 if(glslang IN_LIST Vulkan_FIND_COMPONENTS)
336   find_library(Vulkan_glslang-spirv_LIBRARY
337     NAMES SPIRV
338     HINTS
339       ${_Vulkan_hint_library_search_paths}
340     )
341   mark_as_advanced(Vulkan_glslang-spirv_LIBRARY)
343   find_library(Vulkan_glslang-spirv_DEBUG_LIBRARY
344     NAMES SPIRVd
345     HINTS
346       ${_Vulkan_hint_library_search_paths}
347     )
348   mark_as_advanced(Vulkan_glslang-spirv_DEBUG_LIBRARY)
350   find_library(Vulkan_glslang-oglcompiler_LIBRARY
351     NAMES OGLCompiler
352     HINTS
353       ${_Vulkan_hint_library_search_paths}
354     )
355   mark_as_advanced(Vulkan_glslang-oglcompiler_LIBRARY)
357   find_library(Vulkan_glslang-oglcompiler_DEBUG_LIBRARY
358     NAMES OGLCompilerd
359     HINTS
360       ${_Vulkan_hint_library_search_paths}
361     )
362   mark_as_advanced(Vulkan_glslang-oglcompiler_DEBUG_LIBRARY)
364   find_library(Vulkan_glslang-osdependent_LIBRARY
365     NAMES OSDependent
366     HINTS
367       ${_Vulkan_hint_library_search_paths}
368     )
369   mark_as_advanced(Vulkan_glslang-osdependent_LIBRARY)
371   find_library(Vulkan_glslang-osdependent_DEBUG_LIBRARY
372     NAMES OSDependentd
373     HINTS
374       ${_Vulkan_hint_library_search_paths}
375     )
376   mark_as_advanced(Vulkan_glslang-osdependent_DEBUG_LIBRARY)
378   find_library(Vulkan_glslang-machineindependent_LIBRARY
379     NAMES MachineIndependent
380     HINTS
381       ${_Vulkan_hint_library_search_paths}
382     )
383   mark_as_advanced(Vulkan_glslang-machineindependent_LIBRARY)
385   find_library(Vulkan_glslang-machineindependent_DEBUG_LIBRARY
386     NAMES MachineIndependentd
387     HINTS
388       ${_Vulkan_hint_library_search_paths}
389     )
390   mark_as_advanced(Vulkan_glslang-machineindependent_DEBUG_LIBRARY)
392   find_library(Vulkan_glslang-genericcodegen_LIBRARY
393     NAMES GenericCodeGen
394     HINTS
395       ${_Vulkan_hint_library_search_paths}
396     )
397   mark_as_advanced(Vulkan_glslang-genericcodegen_LIBRARY)
399   find_library(Vulkan_glslang-genericcodegen_DEBUG_LIBRARY
400     NAMES GenericCodeGend
401     HINTS
402       ${_Vulkan_hint_library_search_paths}
403     )
404   mark_as_advanced(Vulkan_glslang-genericcodegen_DEBUG_LIBRARY)
406   find_library(Vulkan_glslang_LIBRARY
407     NAMES glslang
408     HINTS
409       ${_Vulkan_hint_library_search_paths}
410     )
411   mark_as_advanced(Vulkan_glslang_LIBRARY)
413   find_library(Vulkan_glslang_DEBUG_LIBRARY
414     NAMES glslangd
415     HINTS
416       ${_Vulkan_hint_library_search_paths}
417     )
418   mark_as_advanced(Vulkan_glslang_DEBUG_LIBRARY)
419 endif()
420 if(shaderc_combined IN_LIST Vulkan_FIND_COMPONENTS)
421   find_library(Vulkan_shaderc_combined_LIBRARY
422     NAMES shaderc_combined
423     HINTS
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
429     HINTS
430     ${_Vulkan_hint_library_search_paths})
431   mark_as_advanced(Vulkan_shaderc_combined_DEBUG_LIBRARY)
432 endif()
433 if(SPIRV-Tools IN_LIST Vulkan_FIND_COMPONENTS)
434   find_library(Vulkan_SPIRV-Tools_LIBRARY
435     NAMES SPIRV-Tools
436     HINTS
437       ${_Vulkan_hint_library_search_paths})
438   mark_as_advanced(Vulkan_SPIRV-Tools_LIBRARY)
440   find_library(Vulkan_SPIRV-Tools_DEBUG_LIBRARY
441     NAMES SPIRV-Toolsd
442     HINTS
443       ${_Vulkan_hint_library_search_paths})
444   mark_as_advanced(Vulkan_SPIRV-Tools_DEBUG_LIBRARY)
445 endif()
446 if(MoltenVK IN_LIST Vulkan_FIND_COMPONENTS)
447   find_library(Vulkan_MoltenVK_LIBRARY
448     NAMES MoltenVK
449     HINTS
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
455     HINTS
456       ${_Vulkan_hint_include_search_paths}
457     )
458   mark_as_advanced(Vulkan_MoltenVK_INCLUDE_DIR)
459 endif()
460 if(volk IN_LIST Vulkan_FIND_COMPONENTS)
461   find_library(Vulkan_volk_LIBRARY
462           NAMES volk
463           HINTS
464             ${_Vulkan_hint_library_search_paths})
465   mark_as_advanced(Vulkan_Volk_LIBRARY)
466 endif()
468 if (dxc IN_LIST Vulkan_FIND_COMPONENTS)
469   find_library(Vulkan_dxc_LIBRARY
470           NAMES dxcompiler
471           HINTS
472             ${_Vulkan_hint_library_search_paths})
473   mark_as_advanced(Vulkan_dxc_LIBRARY)
475   find_program(Vulkan_dxc_EXECUTABLE
476           NAMES dxc
477           HINTS
478             ${_Vulkan_hint_executable_search_paths})
479   mark_as_advanced(Vulkan_dxc_EXECUTABLE)
480 endif()
482 if(Vulkan_GLSLC_EXECUTABLE)
483   set(Vulkan_glslc_FOUND TRUE)
484 else()
485   set(Vulkan_glslc_FOUND FALSE)
486 endif()
488 if(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE)
489   set(Vulkan_glslangValidator_FOUND TRUE)
490 else()
491   set(Vulkan_glslangValidator_FOUND FALSE)
492 endif()
494 if (Vulkan_dxc_EXECUTABLE)
495   set(Vulkan_dxc_exe_FOUND TRUE)
496 else()
497   set(Vulkan_dxc_exe_FOUND FALSE)
498 endif()
500 function(_Vulkan_set_library_component_found component)
501   cmake_parse_arguments(PARSE_ARGV 1 _ARG
502     "NO_WARNING"
503     ""
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)
510       break()
511     endif()
512   endforeach()
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)
523         message(WARNING
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.")
525       endif()
526       if(NOT Vulkan_${component}_DEBUG_LIBRARY)
527         message(WARNING
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.")
529       endif()
530     endif()
531   else()
532     set(Vulkan_${component}_FOUND FALSE PARENT_SCOPE)
533   endif()
534 endfunction()
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)
549 else()
550   set(Vulkan_MoltenVK_FOUND FALSE)
551 endif()
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'
567     if(_len EQUAL 3)
568         list(REMOVE_AT VulkanHeaderVersion2 0)
569     endif()
570     list(APPEND VulkanHeaderVersion2 ${VulkanHeaderVersion})
571     list(JOIN VulkanHeaderVersion2 "." Vulkan_VERSION)
572   endif()
573 endif()
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)
590     endif()
591   endif()
592 endif()
594 include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
595 find_package_handle_standard_args(Vulkan
596   REQUIRED_VARS
597     Vulkan_LIBRARY
598     Vulkan_INCLUDE_DIR
599   VERSION_VAR
600     Vulkan_VERSION
601   HANDLE_COMPONENTS
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}")
609 endif()
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}")
615 endif()
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}")
620 endif()
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}")
625 endif()
627 if(Vulkan_FOUND)
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
631       PROPERTY
632         INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
633     if(Vulkan_glslang-spirv_LIBRARY)
634       set_property(TARGET Vulkan::glslang-spirv APPEND
635         PROPERTY
636           IMPORTED_CONFIGURATIONS Release)
637       set_property(TARGET Vulkan::glslang-spirv
638         PROPERTY
639           IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-spirv_LIBRARY}")
640     endif()
641     if(Vulkan_glslang-spirv_DEBUG_LIBRARY)
642       set_property(TARGET Vulkan::glslang-spirv APPEND
643         PROPERTY
644           IMPORTED_CONFIGURATIONS Debug)
645       set_property(TARGET Vulkan::glslang-spirv
646         PROPERTY
647           IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-spirv_DEBUG_LIBRARY}")
648     endif()
649   endif()
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
654       PROPERTY
655         INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
656     if(Vulkan_glslang-oglcompiler_LIBRARY)
657       set_property(TARGET Vulkan::glslang-oglcompiler APPEND
658         PROPERTY
659           IMPORTED_CONFIGURATIONS Release)
660       set_property(TARGET Vulkan::glslang-oglcompiler
661         PROPERTY
662           IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-oglcompiler_LIBRARY}")
663     endif()
664     if(Vulkan_glslang-oglcompiler_DEBUG_LIBRARY)
665       set_property(TARGET Vulkan::glslang-oglcompiler APPEND
666         PROPERTY
667           IMPORTED_CONFIGURATIONS Debug)
668       set_property(TARGET Vulkan::glslang-oglcompiler
669         PROPERTY
670           IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-oglcompiler_DEBUG_LIBRARY}")
671     endif()
672   endif()
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
677       PROPERTY
678         INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
679     if(Vulkan_glslang-osdependent_LIBRARY)
680       set_property(TARGET Vulkan::glslang-osdependent APPEND
681         PROPERTY
682           IMPORTED_CONFIGURATIONS Release)
683       set_property(TARGET Vulkan::glslang-osdependent
684         PROPERTY
685           IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-osdependent_LIBRARY}")
686     endif()
687     if(Vulkan_glslang-osdependent_DEBUG_LIBRARY)
688       set_property(TARGET Vulkan::glslang-osdependent APPEND
689         PROPERTY
690           IMPORTED_CONFIGURATIONS Debug)
691       set_property(TARGET Vulkan::glslang-osdependent
692         PROPERTY
693           IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-osdependent_DEBUG_LIBRARY}")
694     endif()
695   endif()
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
700       PROPERTY
701         INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
702     if(Vulkan_glslang-machineindependent_LIBRARY)
703       set_property(TARGET Vulkan::glslang-machineindependent APPEND
704         PROPERTY
705           IMPORTED_CONFIGURATIONS Release)
706       set_property(TARGET Vulkan::glslang-machineindependent
707         PROPERTY
708           IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-machineindependent_LIBRARY}")
709     endif()
710     if(Vulkan_glslang-machineindependent_DEBUG_LIBRARY)
711       set_property(TARGET Vulkan::glslang-machineindependent APPEND
712         PROPERTY
713           IMPORTED_CONFIGURATIONS Debug)
714       set_property(TARGET Vulkan::glslang-machineindependent
715         PROPERTY
716           IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-machineindependent_DEBUG_LIBRARY}")
717     endif()
718   endif()
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
723       PROPERTY
724         INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
725     if(Vulkan_glslang-genericcodegen_LIBRARY)
726       set_property(TARGET Vulkan::glslang-genericcodegen APPEND
727         PROPERTY
728           IMPORTED_CONFIGURATIONS Release)
729       set_property(TARGET Vulkan::glslang-genericcodegen
730         PROPERTY
731           IMPORTED_LOCATION_RELEASE "${Vulkan_glslang-genericcodegen_LIBRARY}")
732     endif()
733     if(Vulkan_glslang-genericcodegen_DEBUG_LIBRARY)
734       set_property(TARGET Vulkan::glslang-genericcodegen APPEND
735         PROPERTY
736           IMPORTED_CONFIGURATIONS Debug)
737       set_property(TARGET Vulkan::glslang-genericcodegen
738         PROPERTY
739           IMPORTED_LOCATION_DEBUG "${Vulkan_glslang-genericcodegen_DEBUG_LIBRARY}")
740     endif()
741   endif()
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
748       PROPERTY
749         INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
750     if(Vulkan_glslang_LIBRARY)
751       set_property(TARGET Vulkan::glslang APPEND
752         PROPERTY
753           IMPORTED_CONFIGURATIONS Release)
754       set_property(TARGET Vulkan::glslang
755         PROPERTY
756           IMPORTED_LOCATION_RELEASE "${Vulkan_glslang_LIBRARY}")
757     endif()
758     if(Vulkan_glslang_DEBUG_LIBRARY)
759       set_property(TARGET Vulkan::glslang APPEND
760         PROPERTY
761           IMPORTED_CONFIGURATIONS Debug)
762       set_property(TARGET Vulkan::glslang
763         PROPERTY
764           IMPORTED_LOCATION_DEBUG "${Vulkan_glslang_DEBUG_LIBRARY}")
765     endif()
766     target_link_libraries(Vulkan::glslang
767       INTERFACE
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>
776     )
777   endif()
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
782       PROPERTY
783         INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
784     if(Vulkan_shaderc_combined_LIBRARY)
785       set_property(TARGET Vulkan::shaderc_combined APPEND
786         PROPERTY
787           IMPORTED_CONFIGURATIONS Release)
788       set_property(TARGET Vulkan::shaderc_combined
789         PROPERTY
790           IMPORTED_LOCATION_RELEASE "${Vulkan_shaderc_combined_LIBRARY}")
791     endif()
792     if(Vulkan_shaderc_combined_DEBUG_LIBRARY)
793       set_property(TARGET Vulkan::shaderc_combined APPEND
794         PROPERTY
795           IMPORTED_CONFIGURATIONS Debug)
796       set_property(TARGET Vulkan::shaderc_combined
797         PROPERTY
798           IMPORTED_LOCATION_DEBUG "${Vulkan_shaderc_combined_DEBUG_LIBRARY}")
799     endif()
801     if(UNIX)
802       find_package(Threads REQUIRED)
803       target_link_libraries(Vulkan::shaderc_combined
804         INTERFACE
805           Threads::Threads)
806     endif()
807   endif()
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
812       PROPERTY
813         INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
814     if(Vulkan_SPIRV-Tools_LIBRARY)
815       set_property(TARGET Vulkan::SPIRV-Tools APPEND
816         PROPERTY
817           IMPORTED_CONFIGURATIONS Release)
818       set_property(TARGET Vulkan::SPIRV-Tools
819         PROPERTY
820           IMPORTED_LOCATION_RELEASE "${Vulkan_SPIRV-Tools_LIBRARY}")
821     endif()
822     if(Vulkan_SPIRV-Tools_DEBUG_LIBRARY)
823       set_property(TARGET Vulkan::SPIRV-Tools APPEND
824         PROPERTY
825           IMPORTED_CONFIGURATIONS Debug)
826       set_property(TARGET Vulkan::SPIRV-Tools
827         PROPERTY
828           IMPORTED_LOCATION_DEBUG "${Vulkan_SPIRV-Tools_DEBUG_LIBRARY}")
829     endif()
830   endif()
832   if(Vulkan_volk_LIBRARY AND NOT TARGET Vulkan::volk)
833     add_library(Vulkan::volk STATIC IMPORTED)
834     set_property(TARGET Vulkan::volk
835             PROPERTY
836               INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
837     set_property(TARGET Vulkan::volk APPEND
838             PROPERTY
839               IMPORTED_CONFIGURATIONS Release)
840     set_property(TARGET Vulkan::volk APPEND
841             PROPERTY
842               IMPORTED_LOCATION_RELEASE "${Vulkan_volk_LIBRARY}")
844     if (NOT WIN32)
845       set_property(TARGET Vulkan::volk APPEND
846               PROPERTY
847                 IMPORTED_LINK_INTERFACE_LIBRARIES dl)
848     endif()
849   endif()
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
854       PROPERTY
855         INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
856     set_property(TARGET Vulkan::dxc_lib APPEND
857       PROPERTY
858         IMPORTED_CONFIGURATIONS Release)
859     set_property(TARGET Vulkan::dxc_lib APPEND
860       PROPERTY
861         IMPORTED_LOCATION_RELEASE "${Vulkan_dxc_LIBRARY}")
862   endif()
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}")
867   endif()
869 endif()
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
875       PROPERTIES
876         INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_MoltenVK_INCLUDE_DIR}"
877         IMPORTED_LOCATION "${Vulkan_MoltenVK_LIBRARY}"
878     )
879   endif()
880 endif()
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)
887 cmake_policy(POP)