CMake: Added separate Vulkan-Hpp
target alongside Vulkan-HppModule
with propagating compile definitions
#528
+121
−28
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
Vulkan-Hpp
headers have numerous compile definitions for configuration, which can of course be done manually, but it is much nicer to have actual support for them in CMake viaoption()
.This is particularly true for the C++20 module, which requires compile definitions at the configure stage due to the lack of preprocessor stuff with
#include
.Projects relying on Vulkan (e.g. the VulkanMemoryAllocator) can also consume these propagating compile definitions to not have to define them multiple times.
To this end, I made some changes to the
CMakeLists.txt
, similar to what is now in theVulkan-Hpp
repository, to provide three separate targets with consolidated naming:Vulkan-Headers ALIAS Vulkan::Headers
: Same as before, so it will not break anything.Vulkan-Hpp ALIAS Vulkan::Hpp
: Separated fromVulkan-Headers
, as to provide isolated compile definitions for this C++ target, even though it shares the same interface include directory as the C target.Vulkan-HppModule ALIAS Vulkan::HppModule
: ConsumesVulkan-Hpp
and its compile definitions. Adjusted naming to match the names of the repository and other targets. Added errors for mismatching compilers (previously warning) and CMake versions. Added ability to build the C++20 module withimport std;
(as this is still a very experimental feature for most compilers, I have not updated the compiler requirements for it).Currently, the
VK_NO_PROTOTYPERS
andVULKAN_HPP_DISPATCH_LOADER_DYNAMIC
options are separated as per their respective compile definitions, but it might make sense to consolidate both into a single option to enable the respective C/C++ flag in the two targets.