• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2# file Copyright.txt or https://cmake.org/licensing for details.
3
4#.rst:
5# FindVulkan
6# ----------
7#
8# Try to find Vulkan
9#
10# IMPORTED Targets
11# ^^^^^^^^^^^^^^^^
12#
13# This module defines :prop_tgt:`IMPORTED` target ``Vulkan::Vulkan``, if
14# Vulkan has been found.
15#
16# Result Variables
17# ^^^^^^^^^^^^^^^^
18#
19# This module defines the following variables::
20#
21#   Vulkan_FOUND          - True if Vulkan was found
22#   Vulkan_INCLUDE_DIRS   - include directories for Vulkan
23#   Vulkan_LIBRARIES      - link against this library to use Vulkan
24#
25# The module will also define two cache variables::
26#
27#   Vulkan_INCLUDE_DIR    - the Vulkan include directory
28#   Vulkan_LIBRARY        - the path to the Vulkan library
29#
30
31if(WIN32)
32  find_path(Vulkan_INCLUDE_DIR
33    NAMES vulkan/vulkan.h
34    PATHS
35      "$ENV{VULKAN_SDK}/Include"
36    )
37
38  if(CMAKE_SIZEOF_VOID_P EQUAL 8)
39    find_library(Vulkan_LIBRARY
40      NAMES vulkan-1
41      PATHS
42        "$ENV{VULKAN_SDK}/Lib"
43        "$ENV{VULKAN_SDK}/Bin"
44        )
45  elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
46    find_library(Vulkan_LIBRARY
47      NAMES vulkan-1
48      PATHS
49        "$ENV{VULKAN_SDK}/Lib32"
50        "$ENV{VULKAN_SDK}/Bin32"
51        NO_SYSTEM_ENVIRONMENT_PATH
52        )
53  endif()
54else()
55    find_path(Vulkan_INCLUDE_DIR
56      NAMES vulkan/vulkan.h
57      PATHS
58        "$ENV{VULKAN_SDK}/include")
59    find_library(Vulkan_LIBRARY
60      NAMES vulkan
61      PATHS
62        "$ENV{VULKAN_SDK}/lib")
63endif()
64
65set(Vulkan_LIBRARIES ${Vulkan_LIBRARY})
66set(Vulkan_INCLUDE_DIRS ${Vulkan_INCLUDE_DIR})
67
68include(FindPackageHandleStandardArgs)
69find_package_handle_standard_args(Vulkan
70  DEFAULT_MSG
71  Vulkan_LIBRARY Vulkan_INCLUDE_DIR)
72
73mark_as_advanced(Vulkan_INCLUDE_DIR Vulkan_LIBRARY)
74
75if(Vulkan_FOUND AND NOT TARGET Vulkan::Vulkan)
76  add_library(Vulkan::Vulkan UNKNOWN IMPORTED)
77  set_target_properties(Vulkan::Vulkan PROPERTIES
78    IMPORTED_LOCATION "${Vulkan_LIBRARIES}"
79    INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}")
80endif()
81