Mark vk-bootstrap as static & cleanup CMake

Marks the main vk-bootstrap library as a static library.

Removes unnecessary code, adds a language & description to the project
field.
This commit is contained in:
Charles Giessen 2023-09-24 18:48:10 -06:00 committed by Charles Giessen
parent 83ef1035bf
commit f6006041c6
3 changed files with 39 additions and 37 deletions

View File

@ -1,5 +1,7 @@
cmake_minimum_required(VERSION 3.10 FATAL_ERROR) cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
project(VulkanBootstrap) project(VulkanBootstrap
LANGUAGES CXX
DESCRIPTION "A Vulkan utility library to ease the initialization steps in Vulkan")
option(VK_BOOTSTRAP_DISABLE_WARNINGS "Disable warnings during compilation" OFF) option(VK_BOOTSTRAP_DISABLE_WARNINGS "Disable warnings during compilation" OFF)
option(VK_BOOTSTRAP_WERROR "Enable warnings as errors during compilation" OFF) option(VK_BOOTSTRAP_WERROR "Enable warnings as errors during compilation" OFF)
@ -12,25 +14,25 @@ mark_as_advanced(VK_BOOTSTRAP_VULKAN_HEADER_DIR)
include(gen/CurrentBuildVulkanVersion.cmake) include(gen/CurrentBuildVulkanVersion.cmake)
if(NOT "${VK_BOOTSTRAP_VULKAN_HEADER_DIR}" STREQUAL "") if(NOT "${VK_BOOTSTRAP_VULKAN_HEADER_DIR}" STREQUAL "")
target_include_directories(vk-bootstrap-vulkan-headers INTERFACE $<BUILD_INTERFACE:${VK_BOOTSTRAP_VULKAN_HEADER_DIR}>) target_include_directories(vk-bootstrap-vulkan-headers INTERFACE $<BUILD_INTERFACE:${VK_BOOTSTRAP_VULKAN_HEADER_DIR}>)
else () else ()
find_package(Vulkan QUIET) find_package(Vulkan QUIET)
if(${Vulkan_INCLUDE_DIR} STREQUAL "Vulkan_INCLUDE_DIR-NOTFOUND") if(${Vulkan_INCLUDE_DIR} STREQUAL "Vulkan_INCLUDE_DIR-NOTFOUND")
include(FetchContent) include(FetchContent)
FetchContent_Declare( FetchContent_Declare(
VulkanHeaders VulkanHeaders
GIT_REPOSITORY https://github.com/KhronosGroup/Vulkan-Headers GIT_REPOSITORY https://github.com/KhronosGroup/Vulkan-Headers
GIT_TAG ${VK_BOOTSTRAP_SOURCE_HEADER_VERSION_GIT_TAG} GIT_TAG ${VK_BOOTSTRAP_SOURCE_HEADER_VERSION_GIT_TAG}
) )
FetchContent_MakeAvailable(VulkanHeaders) FetchContent_MakeAvailable(VulkanHeaders)
target_link_libraries(vk-bootstrap-vulkan-headers INTERFACE Vulkan::Headers) target_link_libraries(vk-bootstrap-vulkan-headers INTERFACE Vulkan::Headers)
else() else()
set_target_properties(vk-bootstrap-vulkan-headers PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${Vulkan_INCLUDE_DIR}) set_target_properties(vk-bootstrap-vulkan-headers PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${Vulkan_INCLUDE_DIR})
endif() endif()
endif() endif()
add_library(vk-bootstrap src/VkBootstrap.h src/VkBootstrap.cpp src/VkBootstrapDispatch.h) add_library(vk-bootstrap STATIC src/VkBootstrap.h src/VkBootstrap.cpp src/VkBootstrapDispatch.h)
add_library(vk-bootstrap::vk-bootstrap ALIAS vk-bootstrap) add_library(vk-bootstrap::vk-bootstrap ALIAS vk-bootstrap)
add_library(vk-bootstrap-compiler-warnings INTERFACE) add_library(vk-bootstrap-compiler-warnings INTERFACE)
@ -38,13 +40,13 @@ add_library(vk-bootstrap-compiler-warnings INTERFACE)
# Determine whether we're compiling with clang++ # Determine whether we're compiling with clang++
string(FIND "${CMAKE_CXX_COMPILER}" "clang++" VK_BOOTSTRAP_COMPILER_CLANGPP) string(FIND "${CMAKE_CXX_COMPILER}" "clang++" VK_BOOTSTRAP_COMPILER_CLANGPP)
if(VK_BOOTSTRAP_COMPILER_CLANGPP GREATER -1) if(VK_BOOTSTRAP_COMPILER_CLANGPP GREATER -1)
set(VK_BOOTSTRAP_COMPILER_CLANGPP 1) set(VK_BOOTSTRAP_COMPILER_CLANGPP 1)
else() else()
set(VK_BOOTSTRAP_COMPILER_CLANGPP 0) set(VK_BOOTSTRAP_COMPILER_CLANGPP 0)
endif() endif()
if(NOT VK_BOOTSTRAP_DISABLE_WARNINGS) if(NOT VK_BOOTSTRAP_DISABLE_WARNINGS)
target_compile_options(vk-bootstrap-compiler-warnings target_compile_options(vk-bootstrap-compiler-warnings
INTERFACE INTERFACE
$<$<OR:$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>,${VK_BOOTSTRAP_COMPILER_CLANGPP}>: $<$<OR:$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>,${VK_BOOTSTRAP_COMPILER_CLANGPP}>:
-Wall -Wall
@ -55,22 +57,22 @@ if(NOT VK_BOOTSTRAP_DISABLE_WARNINGS)
/W4> /W4>
) )
if(VK_BOOTSTRAP_WERROR) if(VK_BOOTSTRAP_WERROR)
target_compile_options(vk-bootstrap-compiler-warnings target_compile_options(vk-bootstrap-compiler-warnings
INTERFACE INTERFACE
$<$<OR:$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>,${VK_BOOTSTRAP_COMPILER_CLANGPP}>: $<$<OR:$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>,${VK_BOOTSTRAP_COMPILER_CLANGPP}>:
-pedantic-errors> -pedantic-errors>
$<$<CXX_COMPILER_ID:MSVC>: $<$<CXX_COMPILER_ID:MSVC>:
/WX> /WX>
) )
endif() endif()
endif() endif()
target_include_directories(vk-bootstrap PUBLIC target_include_directories(vk-bootstrap PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:include>) $<INSTALL_INTERFACE:include>)
target_link_libraries(vk-bootstrap target_link_libraries(vk-bootstrap
PRIVATE PRIVATE
vk-bootstrap-compiler-warnings vk-bootstrap-compiler-warnings
vk-bootstrap-vulkan-headers vk-bootstrap-vulkan-headers
${CMAKE_DL_LIBS}) ${CMAKE_DL_LIBS})
@ -78,11 +80,12 @@ target_compile_features(vk-bootstrap PUBLIC cxx_std_14)
include(GNUInstallDirs) include(GNUInstallDirs)
install(FILES src/VkBootstrap.h src/VkBootstrapDispatch.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install(FILES src/VkBootstrap.h src/VkBootstrapDispatch.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(TARGETS vk-bootstrap vk-bootstrap-compiler-warnings vk-bootstrap-vulkan-headers install(TARGETS
EXPORT vk-bootstrap-targets vk-bootstrap
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} vk-bootstrap-compiler-warnings
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} vk-bootstrap-vulkan-headers
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) EXPORT
vk-bootstrap-targets)
# By default, we want to only build tests if this repo is built standalone, but still should be configurable by the user # 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) if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)

View File

@ -1,21 +1,21 @@
add_executable(vk-bootstrap-triangle triangle.cpp) add_executable(vk-bootstrap-triangle triangle.cpp)
target_link_libraries(vk-bootstrap-triangle target_link_libraries(vk-bootstrap-triangle
PRIVATE PRIVATE
glfw glfw
vk-bootstrap vk-bootstrap
vk-bootstrap-compiler-warnings vk-bootstrap-compiler-warnings
vk-bootstrap-vulkan-headers) vk-bootstrap-vulkan-headers)
target_include_directories(vk-bootstrap-triangle PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) #path to build directory for shaders target_include_directories(vk-bootstrap-triangle PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) # path to build directory for shaders
add_custom_command( add_custom_command(
TARGET vk-bootstrap-triangle TARGET vk-bootstrap-triangle
POST_BUILD POST_BUILD
COMMAND COMMAND
${CMAKE_COMMAND} -E copy_directory ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/example/shaders ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/example/shaders ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}) DEPENDS ${CMAKE_CURRENT_BINARY_DIR})
configure_file ( configure_file (
"${PROJECT_SOURCE_DIR}/example/example_config.h.in" "${PROJECT_SOURCE_DIR}/example/example_config.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/example_config.h" "${CMAKE_CURRENT_BINARY_DIR}/example_config.h"
) )

View File

@ -8,7 +8,6 @@ option(CATCH_ENABLE_WERROR "" OFF)
option(CATCH_INSTALL_DOCS "" OFF) option(CATCH_INSTALL_DOCS "" OFF)
option(CATCH_INSTALL_HELPERS "" OFF) option(CATCH_INSTALL_HELPERS "" OFF)
option(CATCH_INSTALL_EXTRAS "" ON) option(CATCH_INSTALL_EXTRAS "" ON)
set_property(GLOBAL PROPERTY CTEST_TARGETS_ADDED 1) #remove Catch2 target spam
include(FetchContent) include(FetchContent)
FetchContent_Declare( FetchContent_Declare(