FindVulkan.cmake 2.2 KB

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