mirror of
https://github.com/charles-lunarg/vk-bootstrap.git
synced 2024-11-10 02:41:47 +00:00
4ae9513ff9
Previously, tests would always be enabled if the repo was the top level project, which isn't desireable for users. This alters the logic to, by default, only enabling tests when its a top level project, but still allowing users to *not* enable tests by setting VK_BOOTSTRAP_TEST to off.
97 lines
3.5 KiB
CMake
97 lines
3.5 KiB
CMake
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
|
|
project(VulkanBootstrap)
|
|
|
|
option(VK_BOOTSTRAP_WERROR "Enable warnings as errors during compilation" OFF)
|
|
|
|
add_library(vk-bootstrap-vulkan-headers INTERFACE)
|
|
|
|
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)
|
|
|
|
include(gen/CurrentBuildVulkanVersion.cmake)
|
|
|
|
if(NOT "${VK_BOOTSTRAP_VULKAN_HEADER_DIR}" STREQUAL "")
|
|
target_include_directories(vk-bootstrap-vulkan-headers INTERFACE $<BUILD_INTERFACE:${VK_BOOTSTRAP_VULKAN_HEADER_DIR}>)
|
|
else ()
|
|
find_package(Vulkan QUIET)
|
|
|
|
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()
|
|
endif()
|
|
|
|
add_library(vk-bootstrap src/VkBootstrap.h src/VkBootstrap.cpp src/VkBootstrapDispatch.h)
|
|
add_library(vk-bootstrap::vk-bootstrap ALIAS vk-bootstrap)
|
|
|
|
add_library(vk-bootstrap-compiler-warnings INTERFACE)
|
|
|
|
# Determine whether we're compiling with clang++
|
|
string(FIND "${CMAKE_CXX_COMPILER}" "clang++" VK_BOOTSTRAP_COMPILER_CLANGPP)
|
|
if(VK_BOOTSTRAP_COMPILER_CLANGPP GREATER -1)
|
|
set(VK_BOOTSTRAP_COMPILER_CLANGPP 1)
|
|
else()
|
|
set(VK_BOOTSTRAP_COMPILER_CLANGPP 0)
|
|
endif()
|
|
|
|
target_compile_options(vk-bootstrap-compiler-warnings
|
|
INTERFACE
|
|
$<$<OR:$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>,${VK_BOOTSTRAP_COMPILER_CLANGPP}>:
|
|
-Wall
|
|
-Wextra
|
|
-Wconversion
|
|
-Wsign-conversion>
|
|
$<$<CXX_COMPILER_ID:MSVC>:
|
|
/W4>
|
|
)
|
|
|
|
if(VK_BOOTSTRAP_WERROR)
|
|
target_compile_options(vk-bootstrap-compiler-warnings
|
|
INTERFACE
|
|
$<$<OR:$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>,${VK_BOOTSTRAP_COMPILER_CLANGPP}>:
|
|
-pedantic-errors>
|
|
$<$<CXX_COMPILER_ID:MSVC>:
|
|
/WX>
|
|
)
|
|
endif()
|
|
|
|
target_include_directories(vk-bootstrap PUBLIC
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
|
|
$<INSTALL_INTERFACE:include>)
|
|
target_link_libraries(vk-bootstrap
|
|
PRIVATE
|
|
vk-bootstrap-compiler-warnings
|
|
vk-bootstrap-vulkan-headers
|
|
${CMAKE_DL_LIBS})
|
|
target_compile_features(vk-bootstrap PUBLIC cxx_std_14)
|
|
|
|
include(GNUInstallDirs)
|
|
install(FILES src/VkBootstrap.h src/VkBootstrapDispatch.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
|
install(TARGETS vk-bootstrap vk-bootstrap-compiler-warnings vk-bootstrap-vulkan-headers
|
|
EXPORT vk-bootstrap-targets
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
|
|
|
# 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})
|
|
|
|
if(VK_BOOTSTRAP_TEST)
|
|
add_subdirectory(ext)
|
|
add_subdirectory(tests)
|
|
add_subdirectory(example)
|
|
endif ()
|