2023-10-05 23:19:03 +00:00
|
|
|
cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
|
2023-09-25 00:48:10 +00:00
|
|
|
project(VulkanBootstrap
|
|
|
|
LANGUAGES CXX
|
|
|
|
DESCRIPTION "A Vulkan utility library to ease the initialization steps in Vulkan")
|
2020-01-30 08:15:10 +00:00
|
|
|
|
2023-02-15 17:16:24 +00:00
|
|
|
option(VK_BOOTSTRAP_DISABLE_WARNINGS "Disable warnings during compilation" OFF)
|
2021-04-18 20:09:32 +00:00
|
|
|
option(VK_BOOTSTRAP_WERROR "Enable warnings as errors during compilation" OFF)
|
|
|
|
|
2021-09-06 20:37:49 +00:00
|
|
|
add_library(vk-bootstrap-vulkan-headers INTERFACE)
|
2021-03-02 03:59:49 +00:00
|
|
|
|
|
|
|
set(VK_BOOTSTRAP_VULKAN_HEADER_DIR "" CACHE STRING "Specify the location of the Vulkan-Headers include directory.")
|
|
|
|
mark_as_advanced(VK_BOOTSTRAP_VULKAN_HEADER_DIR)
|
|
|
|
|
2022-02-16 04:29:05 +00:00
|
|
|
include(gen/CurrentBuildVulkanVersion.cmake)
|
|
|
|
|
2021-03-02 03:59:49 +00:00
|
|
|
if(NOT "${VK_BOOTSTRAP_VULKAN_HEADER_DIR}" STREQUAL "")
|
2023-09-25 00:48:10 +00:00
|
|
|
target_include_directories(vk-bootstrap-vulkan-headers INTERFACE $<BUILD_INTERFACE:${VK_BOOTSTRAP_VULKAN_HEADER_DIR}>)
|
2021-03-02 03:59:49 +00:00
|
|
|
else ()
|
2023-09-25 00:48:10 +00:00
|
|
|
find_package(Vulkan QUIET)
|
2021-03-02 03:59:49 +00:00
|
|
|
|
2023-09-25 00:48:10 +00:00
|
|
|
if(${Vulkan_INCLUDE_DIR} STREQUAL "Vulkan_INCLUDE_DIR-NOTFOUND")
|
|
|
|
include(FetchContent)
|
|
|
|
FetchContent_Declare(
|
|
|
|
VulkanHeaders
|
|
|
|
GIT_REPOSITORY https://github.com/KhronosGroup/Vulkan-Headers
|
|
|
|
GIT_TAG ${VK_BOOTSTRAP_SOURCE_HEADER_VERSION_GIT_TAG}
|
|
|
|
)
|
|
|
|
FetchContent_MakeAvailable(VulkanHeaders)
|
|
|
|
target_link_libraries(vk-bootstrap-vulkan-headers INTERFACE Vulkan::Headers)
|
|
|
|
else()
|
|
|
|
set_target_properties(vk-bootstrap-vulkan-headers PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${Vulkan_INCLUDE_DIR})
|
|
|
|
endif()
|
2021-03-01 22:21:45 +00:00
|
|
|
endif()
|
2020-01-30 08:15:10 +00:00
|
|
|
|
2023-09-25 00:48:10 +00:00
|
|
|
add_library(vk-bootstrap STATIC src/VkBootstrap.h src/VkBootstrap.cpp src/VkBootstrapDispatch.h)
|
2020-03-25 18:15:36 +00:00
|
|
|
add_library(vk-bootstrap::vk-bootstrap ALIAS vk-bootstrap)
|
2020-01-30 08:15:10 +00:00
|
|
|
|
2020-03-26 16:40:47 +00:00
|
|
|
add_library(vk-bootstrap-compiler-warnings INTERFACE)
|
2020-05-14 12:20:46 +00:00
|
|
|
|
|
|
|
# Determine whether we're compiling with clang++
|
|
|
|
string(FIND "${CMAKE_CXX_COMPILER}" "clang++" VK_BOOTSTRAP_COMPILER_CLANGPP)
|
|
|
|
if(VK_BOOTSTRAP_COMPILER_CLANGPP GREATER -1)
|
2023-09-25 00:48:10 +00:00
|
|
|
set(VK_BOOTSTRAP_COMPILER_CLANGPP 1)
|
2020-05-14 12:20:46 +00:00
|
|
|
else()
|
2023-09-25 00:48:10 +00:00
|
|
|
set(VK_BOOTSTRAP_COMPILER_CLANGPP 0)
|
2020-05-14 12:20:46 +00:00
|
|
|
endif()
|
|
|
|
|
2023-02-15 16:55:36 +00:00
|
|
|
if(NOT VK_BOOTSTRAP_DISABLE_WARNINGS)
|
2023-09-25 00:48:10 +00:00
|
|
|
target_compile_options(vk-bootstrap-compiler-warnings
|
2021-04-18 20:09:32 +00:00
|
|
|
INTERFACE
|
|
|
|
$<$<OR:$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>,${VK_BOOTSTRAP_COMPILER_CLANGPP}>:
|
2023-02-15 16:55:36 +00:00
|
|
|
-Wall
|
|
|
|
-Wextra
|
|
|
|
-Wconversion
|
|
|
|
-Wsign-conversion>
|
2021-04-18 20:09:32 +00:00
|
|
|
$<$<CXX_COMPILER_ID:MSVC>:
|
2023-02-15 16:55:36 +00:00
|
|
|
/W4>
|
2021-04-18 20:09:32 +00:00
|
|
|
)
|
2023-02-15 16:55:36 +00:00
|
|
|
|
2023-09-25 00:48:10 +00:00
|
|
|
if(VK_BOOTSTRAP_WERROR)
|
|
|
|
target_compile_options(vk-bootstrap-compiler-warnings
|
2023-02-15 16:55:36 +00:00
|
|
|
INTERFACE
|
|
|
|
$<$<OR:$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>,${VK_BOOTSTRAP_COMPILER_CLANGPP}>:
|
|
|
|
-pedantic-errors>
|
|
|
|
$<$<CXX_COMPILER_ID:MSVC>:
|
|
|
|
/WX>
|
|
|
|
)
|
2023-09-25 00:48:10 +00:00
|
|
|
endif()
|
2021-04-18 20:09:32 +00:00
|
|
|
endif()
|
|
|
|
|
2021-03-01 17:34:23 +00:00
|
|
|
target_include_directories(vk-bootstrap PUBLIC
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
|
|
|
|
$<INSTALL_INTERFACE:include>)
|
2020-03-26 16:40:47 +00:00
|
|
|
target_link_libraries(vk-bootstrap
|
2023-09-25 00:48:10 +00:00
|
|
|
PRIVATE
|
2021-03-01 17:28:56 +00:00
|
|
|
vk-bootstrap-compiler-warnings
|
2021-09-06 20:37:49 +00:00
|
|
|
vk-bootstrap-vulkan-headers
|
2021-03-01 17:28:56 +00:00
|
|
|
${CMAKE_DL_LIBS})
|
2021-03-01 17:27:11 +00:00
|
|
|
target_compile_features(vk-bootstrap PUBLIC cxx_std_14)
|
2020-03-07 08:44:34 +00:00
|
|
|
|
2021-03-01 17:34:23 +00:00
|
|
|
include(GNUInstallDirs)
|
2021-10-30 21:39:40 +00:00
|
|
|
install(FILES src/VkBootstrap.h src/VkBootstrapDispatch.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
2023-09-25 00:48:10 +00:00
|
|
|
install(TARGETS
|
|
|
|
vk-bootstrap
|
|
|
|
vk-bootstrap-compiler-warnings
|
|
|
|
vk-bootstrap-vulkan-headers
|
|
|
|
EXPORT
|
|
|
|
vk-bootstrap-targets)
|
2021-03-01 17:34:23 +00:00
|
|
|
|
2022-08-30 16:42:35 +00:00
|
|
|
# By default, we want to only build tests if this repo is built standalone, but still should be configurable by the user
|
|
|
|
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
|
|
|
set(VK_BOOTSTRAP_TEST_DEFAULT_VALUE ON)
|
|
|
|
else()
|
|
|
|
set(VK_BOOTSTRAP_TEST_DEFAULT_VALUE OFF)
|
|
|
|
endif()
|
|
|
|
option(VK_BOOTSTRAP_TEST "Test Vk-Bootstrap with glfw and Catch2" ${VK_BOOTSTRAP_TEST_DEFAULT_VALUE})
|
2020-06-08 23:30:29 +00:00
|
|
|
|
2022-08-30 16:42:35 +00:00
|
|
|
if(VK_BOOTSTRAP_TEST)
|
2023-10-03 22:22:02 +00:00
|
|
|
enable_testing()
|
2020-03-26 16:40:47 +00:00
|
|
|
add_subdirectory(ext)
|
|
|
|
add_subdirectory(tests)
|
|
|
|
add_subdirectory(example)
|
2020-03-25 18:15:36 +00:00
|
|
|
endif ()
|