Skip to content

Commit

Permalink
VULKAN_HPP_ENABLE_STD_MODULE is determined by the definition of __cpp…
Browse files Browse the repository at this point in the history
…_lib_modules, therefore it shouldn't be declared by vku. Also, for consistent behavior, make vku also defines VKU_USE_STD_MODULE when it is unset and __cpp_lib_modules is defined. In order to do this, the header file is included.
  • Loading branch information
stripe2933 committed Sep 29, 2024
1 parent 0672581 commit 71a68c4
Show file tree
Hide file tree
Showing 34 changed files with 83 additions and 1 deletion.
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ endif()
# ----------------

add_library(vku)
target_include_directories(vku PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}>
)
target_sources(vku PUBLIC
FILE_SET CXX_MODULES
BASE_DIRS ${Vulkan_INCLUDE_DIRS} .
Expand Down Expand Up @@ -92,13 +96,17 @@ target_link_libraries(vku PUBLIC
$<$<BOOL:${VKU_USE_SHADERC}>:Vulkan::shaderc_combined>
)
target_compile_definitions(vku PUBLIC
$<$<BOOL:${VKU_USE_STD_MODULE}>:VKU_USE_STD_MODULE VULKAN_HPP_ENABLE_STD_MODULE>
$<$<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>
)

set_target_properties(vku PROPERTIES
PUBLIC_HEADER include/macros.hpp
)

# For usage consistency with FetchContent and find_package.
add_library(${PROJECT_NAME}::vku ALIAS vku)

Expand All @@ -119,6 +127,7 @@ include(GNUInstallDirs)
install(
TARGETS vku
EXPORT "${PROJECT_NAME}Targets"
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
FILE_SET CXX_MODULES DESTINATION module/${PROJECT_NAME}
)
install(
Expand Down
9 changes: 9 additions & 0 deletions include/macros.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

#include <version>

// If VKU_USE_STD_MODULE is not defined and standard library module is available, define it to enable the standard
// library module usage.
#if !defined(VKU_USE_STD_MODULE) && defined(__cpp_lib_modules)
#define VKU_USE_STD_MODULE
#endif
2 changes: 2 additions & 0 deletions interface/Gpu.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module;

#include <macros.hpp>

#include <version>
#ifndef VKU_USE_STD_MODULE
#include <cstdint>
Expand Down
2 changes: 2 additions & 0 deletions interface/buffers/AllocatedBuffer.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module;

#include <macros.hpp>

#ifndef VKU_USE_STD_MODULE
#include <tuple>
#include <utility>
Expand Down
2 changes: 2 additions & 0 deletions interface/buffers/Buffer.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module;

#include <macros.hpp>

#if !defined(VKU_USE_STD_MODULE) && defined(_MSC_VER)
#include <compare>
#endif
Expand Down
2 changes: 2 additions & 0 deletions interface/buffers/MappedBuffer.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module;

#include <macros.hpp>

#include <cassert>
#ifndef VKU_USE_STD_MODULE
#include <cstdint>
Expand Down
2 changes: 2 additions & 0 deletions interface/buffers/mod.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module;

#include <macros.hpp>

#if !defined(VKU_USE_STD_MODULE) && defined(_MSC_VER)
#include <compare>
#endif
Expand Down
2 changes: 2 additions & 0 deletions interface/commands.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module;

#include <macros.hpp>

#include <version>
#ifndef VKU_USE_STD_MODULE
#include <cstdint>
Expand Down
2 changes: 2 additions & 0 deletions interface/constants.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module;

#include <macros.hpp>

#if !defined(VKU_USE_STD_MODULE) && defined(_MSC_VER)
#include <compare>
#endif
Expand Down
2 changes: 2 additions & 0 deletions interface/debugging.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module;

#include <macros.hpp>

#ifndef VKU_USE_STD_MODULE
#include <source_location>
#endif
Expand Down
2 changes: 2 additions & 0 deletions interface/descriptors/DescriptorSet.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module;

#include <macros.hpp>

#ifndef VKU_USE_STD_MODULE
#include <cstdint>
#include <array>
Expand Down
2 changes: 2 additions & 0 deletions interface/descriptors/DescriptorSetLayout.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module;

#include <macros.hpp>

#include <cassert>
#ifndef VKU_USE_STD_MODULE
#include <cstdint>
Expand Down
2 changes: 2 additions & 0 deletions interface/descriptors/PoolSizes.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module;

#include <macros.hpp>

#ifndef VKU_USE_STD_MODULE
#include <cstdint>
#include <ranges>
Expand Down
2 changes: 2 additions & 0 deletions interface/descriptors/mod.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module;

#include <macros.hpp>

#if !defined(VKU_USE_STD_MODULE) && defined(_MSC_VER)
#include <compare>
#endif
Expand Down
2 changes: 2 additions & 0 deletions interface/details/concepts.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module;

#include <macros.hpp>

#ifndef VKU_USE_STD_MODULE
#include <concepts>
#include <tuple>
Expand Down
2 changes: 2 additions & 0 deletions interface/details/container/OnDemandCounterStorage.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module;

#include <macros.hpp>

#ifndef VKU_USE_STD_MODULE
#include <cstdint>
#include <deque>
Expand Down
2 changes: 2 additions & 0 deletions interface/details/ranges.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module;

#include <macros.hpp>

#include <version>
#ifndef VKU_USE_STD_MODULE
#include <cstdint>
Expand Down
2 changes: 2 additions & 0 deletions interface/details/to_string.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module;

#include <macros.hpp>

#ifndef VKU_USE_STD_MODULE
#include <format>
#include <source_location>
Expand Down
2 changes: 2 additions & 0 deletions interface/details/tuple.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module;

#include <macros.hpp>

#ifndef VKU_USE_STD_MODULE
#include <cstdint>
#include <tuple>
Expand Down
2 changes: 2 additions & 0 deletions interface/images/AllocatedImage.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module;

#include <macros.hpp>

#ifndef VKU_USE_STD_MODULE
#include <tuple>
#include <utility>
Expand Down
2 changes: 2 additions & 0 deletions interface/images/Image.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module;

#include <macros.hpp>

#include <cassert>
#ifndef VKU_USE_STD_MODULE
#include <cstdint>
Expand Down
2 changes: 2 additions & 0 deletions interface/images/mod.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module;

#include <macros.hpp>

#if !defined(VKU_USE_STD_MODULE) && defined(_MSC_VER)
#include <compare>
#endif
Expand Down
2 changes: 2 additions & 0 deletions interface/mod.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module;

#include <macros.hpp>

#if !defined(VKU_USE_STD_MODULE) && defined(_MSC_VER)
#include <compare>
#endif
Expand Down
2 changes: 2 additions & 0 deletions interface/pipelines/Shader.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module;

#include <macros.hpp>

#include <cerrno>
#ifndef VKU_USE_STD_MODULE
#include <cstdint>
Expand Down
2 changes: 2 additions & 0 deletions interface/pipelines/mod.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module;

#include <macros.hpp>

#ifndef VKU_USE_STD_MODULE
#include <cstdint>
#include <array>
Expand Down
2 changes: 2 additions & 0 deletions interface/queue.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module;

#include <macros.hpp>

#ifndef VKU_USE_STD_MODULE
#include <cstdint>
#include <optional>
Expand Down
2 changes: 2 additions & 0 deletions interface/rendering/Attachment.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module;

#include <macros.hpp>

#ifndef VKU_USE_STD_MODULE
#include <vector>
#ifdef _MSC_VER
Expand Down
2 changes: 2 additions & 0 deletions interface/rendering/AttachmentGroup.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module;

#include <macros.hpp>

#include <cassert>
#ifndef VKU_USE_STD_MODULE
#include <cstdint>
Expand Down
2 changes: 2 additions & 0 deletions interface/rendering/AttachmentGroupBase.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module;

#include <macros.hpp>

#ifndef VKU_USE_STD_MODULE
#include <concepts>
#include <forward_list>
Expand Down
2 changes: 2 additions & 0 deletions interface/rendering/MsaaAttachment.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module;

#include <macros.hpp>

#ifndef VKU_USE_STD_MODULE
#include <vector>
#ifdef _MSC_VER
Expand Down
2 changes: 2 additions & 0 deletions interface/rendering/MsaaAttachmentGroup.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module;

#include <macros.hpp>

#include <cassert>
#ifndef VKU_USE_STD_MODULE
#include <cstdint>
Expand Down
2 changes: 2 additions & 0 deletions interface/rendering/mod.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module;

#include <macros.hpp>

#if !defined(VKU_USE_STD_MODULE) && defined(_MSC_VER)
#include <compare>
#endif
Expand Down
2 changes: 2 additions & 0 deletions interface/utils/RefHolder.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module;

#include <macros.hpp>

#ifndef VKU_USE_STD_MODULE
#include <concepts>
#include <functional>
Expand Down
2 changes: 2 additions & 0 deletions interface/utils/mod.cppm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module;

#include <macros.hpp>

#include <cassert>
#ifndef VKU_USE_STD_MODULE
#include <cstdint>
Expand Down

0 comments on commit 71a68c4

Please sign in to comment.