Browse Source

modules: make our own FindVulkan.cmake.

With blackjack and actually working properly on all platforms.
Seriously, did nobody ever try to use the vanilla version on Mac or MSYS
since it was added several years ago in CMake 3.7?
pull/461/head
Vladimír Vondruš 6 years ago
parent
commit
87381d1744
  1. 8
      doc/namespaces.dox
  2. 1
      modules/FindMagnum.cmake
  3. 87
      modules/FindVulkan.cmake
  4. 5
      src/Magnum/Vk/CMakeLists.txt

8
doc/namespaces.dox

@ -582,9 +582,11 @@ Additional plugins and utilities are built separately. See particular
C++14 wrappers and helpers for Vulkan development.
This library is built if `WITH_VK` is enabled when building Magnum. To use this
library with CMake, request the `Vk` component of the `Magnum` package and link
to the `Magnum::Vk` target:
This library is depends on [Vulkan](https://www.khronos.org/vulkan/) and is
built if `WITH_VK` is enabled when building Magnum. To use this library with
CMake, put [FindVulkan.cmake](https://github.com/mosra/magnum/blob/master/modules/FindVulkan.cmake)
into your `modules/` directory, request the `Vk` component of the `Magnum`
package and link to the `Magnum::Vk` target:
@code{.cmake}
find_package(Magnum REQUIRED Vk)

1
modules/FindMagnum.cmake

@ -880,7 +880,6 @@ foreach(_component ${Magnum_FIND_COMPONENTS})
# Vk library
elseif(_component STREQUAL Vk)
set(Vulkan_INCLUDE_DIR ${MAGNUM_INCLUDE_DIR}/MagnumExternal/Vulkan)
find_package(Vulkan REQUIRED)
set_property(TARGET Magnum::${_component} APPEND PROPERTY
INTERFACE_LINK_LIBRARIES Vulkan::Vulkan)

87
modules/FindVulkan.cmake

@ -0,0 +1,87 @@
#.rst:
# Find Vulkan
# -----------
#
# Finds the Vulkan library. This module defines:
#
# Vulkan_FOUND - True if Vulkan library is found
# Vulkan::Vulkan - Vulkan imported target
#
# Additionally these variables are defined for internal usage:
#
# Vulkan_LIBRARY - Vulkan library
#
# Please note this find module is tailored especially for the needs of Magnum.
# In particular, it doesn't look for Vulkan includes as Magnum has its own,
# generated using flextGL.
#
#
# This file is part of Magnum.
#
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019,
# 2020 Vladimír Vondruš <mosra@centrum.cz>
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
# LunarG SDK on Windows. Same as in CMake's vanilla FindVulkan.cmake in 3.18.
if(WIN32)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
find_library(Vulkan_LIBRARY
NAMES vulkan-1
HINTS
"$ENV{VULKAN_SDK}/Lib"
"$ENV{VULKAN_SDK}/Bin"
)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
find_library(Vulkan_LIBRARY
NAMES vulkan-1
HINTS
"$ENV{VULKAN_SDK}/Lib32"
"$ENV{VULKAN_SDK}/Bin32")
endif()
endif()
# Other distributions / systems
find_library(Vulkan_LIBRARY
NAMES
# Linux
vulkan
# MSYS packages have libvulkan.dll
libvulkan
# MoltenVK (installed by Homebrew). Specified after (lib)vulkan because
# the official loader is preferred, however MoltenVK alone works as
# well: https://www.lunarg.com/benefits-of-the-vulkan-macos-sdk/
MoltenVK
PATHS
"$ENV{VULKAN_SDK}/lib")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Vulkan DEFAULT_MSG Vulkan_LIBRARY)
if(NOT TARGET Vulkan::Vulkan)
add_library(Vulkan::Vulkan UNKNOWN IMPORTED)
set_property(TARGET Vulkan::Vulkan PROPERTY
IMPORTED_LOCATION ${Vulkan_LIBRARY})
endif()
mark_as_advanced(Vulkan_LIBRARY)

5
src/Magnum/Vk/CMakeLists.txt

@ -24,11 +24,6 @@
# DEALINGS IN THE SOFTWARE.
#
# CMake has FindVulkan since 3.7
cmake_minimum_required(VERSION 3.7)
# We don't need system-wide includes
set(Vulkan_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/src/MagnumExternal/Vulkan)
find_package(Vulkan REQUIRED)
set(MagnumVk_SRCS )

Loading…
Cancel
Save