-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
143 lines (127 loc) · 4.65 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
cmake_minimum_required(VERSION 3.28)
if (VKU_USE_STD_MODULE)
# Enable CMake's experimental standard library module support.
cmake_minimum_required(VERSION 3.30)
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "0e5b6991-d74f-4b3d-a41c-cf096e0b2508")
endif()
project(vku
LANGUAGES CXX
DESCRIPTION "A set of Vulkan utilities based on RAII idiom and Modern C++ features."
VERSION 0.1.0
)
set(CMAKE_CXX_STANDARD 23)
if (VKU_USE_STD_MODULE)
set(CMAKE_CXX_MODULE_STD 1)
endif()
# ----------------
# Project options.
# ----------------
option(VKU_USE_STD_MODULE "Use the standard library module for compilation.")
option(VKU_USE_SHADERC "Add runtime GLSL compilation feature by shaderc.")
option(VKU_DEFAULT_DYNAMIC_DISPATCHER "Use the vk::DispatchLoaderDynamic as the default dispatcher.")
option(VKU_ENABLE_TEST "Enable the test targets.")
# ----------------
# External dependencies.
# ----------------
find_package(Vulkan 1.3.256 REQUIRED)
find_package(VulkanMemoryAllocator CONFIG REQUIRED)
find_package(VulkanMemoryAllocator-Hpp CONFIG REQUIRED)
if (VKU_USE_SHADERC)
find_package(Vulkan COMPONENTS shaderc_combined REQUIRED)
endif()
# ----------------
# Project targets.
# ----------------
add_library(vku)
target_sources(vku PUBLIC
FILE_SET CXX_MODULES
BASE_DIRS ${Vulkan_INCLUDE_DIRS} .
FILES
${Vulkan_INCLUDE_DIRS}/vulkan/vulkan.cppm
extlibs/module-ports/vk_mem_alloc.cppm
interface/mod.cppm
interface/buffers/mod.cppm
interface/buffers/AllocatedBuffer.cppm
interface/buffers/Buffer.cppm
interface/buffers/MappedBuffer.cppm
interface/commands.cppm
interface/constants.cppm
interface/debugging.cppm
interface/descriptors/mod.cppm
interface/descriptors/DescriptorSetLayout.cppm
interface/descriptors/DescriptorSet.cppm
interface/descriptors/PoolSizes.cppm
interface/details/concepts.cppm
interface/details/container/OnDemandCounterStorage.cppm
interface/details/functional.cppm
interface/details/to_string.cppm
interface/details/tuple.cppm
interface/Gpu.cppm
interface/images/mod.cppm
interface/images/AllocatedImage.cppm
interface/images/Image.cppm
interface/pipelines/mod.cppm
interface/pipelines/Shader.cppm
interface/queue.cppm
interface/rendering/mod.cppm
interface/rendering/Attachment.cppm
interface/rendering/AttachmentGroup.cppm
interface/rendering/AttachmentGroupBase.cppm
interface/rendering/MsaaAttachment.cppm
interface/rendering/MsaaAttachmentGroup.cppm
interface/utils/mod.cppm
interface/utils/RefHolder.cppm
)
target_compile_features(vku PUBLIC cxx_std_${CMAKE_CXX_STANDARD})
target_link_libraries(vku PUBLIC
Vulkan::Vulkan
GPUOpen::VulkanMemoryAllocator
VulkanMemoryAllocator-Hpp::VulkanMemoryAllocator-Hpp
$<$<BOOL:${VKU_USE_SHADERC}>:Vulkan::shaderc_combined>
)
target_compile_definitions(vku PUBLIC
$<$<BOOL:${VKU_USE_STD_MODULE}>:VKU_USE_STD_MODULE>
$<$<BOOL:${VKU_USE_SHADERC}>:VKU_USE_SHADERC>
$<$<BOOL:${MSVC}>:VULKAN_HPP_NO_SMART_HANDLE VK_NO_PROTOTYPES> # See https://github.com/KhronosGroup/Vulkan-Hpp/blob/main/README.md#c20-named-module for the details.
$<$<PLATFORM_ID:Darwin>:VK_ENABLE_BETA_EXTENSIONS> # For VK_KHR_portability_subset availability.
$<$<BOOL:${VKU_DEFAULT_DYNAMIC_DISPATCHER}>:VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1 VMA_STATIC_VULKAN_FUNCTIONS=0 VMA_DYNAMIC_VULKAN_FUNCTIONS=1>
)
# For usage consistency with FetchContent and find_package.
add_library(${PROJECT_NAME}::vku ALIAS vku)
# --------------------
# Tests.
# --------------------
if (VKU_ENABLE_TEST)
enable_testing()
add_subdirectory(test)
endif()
# --------------------
# Installation.
# --------------------
include(GNUInstallDirs)
install(
TARGETS vku
EXPORT "${PROJECT_NAME}Targets"
FILE_SET CXX_MODULES DESTINATION module/${PROJECT_NAME}
)
install(
EXPORT "${PROJECT_NAME}Targets"
DESTINATION cmake/${PROJECT_NAME}
NAMESPACE ${PROJECT_NAME}::
)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion # Change this to SameMinorVersion when reach to the version 1.0.
)
configure_package_config_file(
cmake/config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION cmake/${PROJECT_NAME}
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION cmake/${PROJECT_NAME}
)