Skip to content

Commit 0e4d8f6

Browse files
committed
Added explanation for cmake macros
1 parent 448b1af commit 0e4d8f6

1 file changed

Lines changed: 21 additions & 3 deletions

File tree

en/02_Development_environment.adoc

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ This will allow other projects that distribute via Find*.cmake to be placed
114114
in that same folder. See the accompanying link:/attachments/CMakeLists.txt[CMakeLists.txt]
115115
for an example of a working project.
116116

117-
Vulkan has support for C{pp} modules which became available with c{pp}20. A
117+
Vulkan has support for C{pp} modules which became available with C{pp}20. A
118118
large advantage of C{pp} modules is they give all the benefits of C{pp} without
119119
the overhead long compile times. To do this, the .cppm file must be compiled
120120
for your target device. This tutorial serves as an example of taking
@@ -158,9 +158,27 @@ The VulkanCppModule target only needs to be defined once, then add it to the
158158
dependency of your consuming project, and it will be built automatically, and
159159
you won't need to also add Vulkan::Vulkan to your project.
160160

161-
[,cmake]
162161
----
163-
target_link_libraries (${PROJECT_NAME} Vulkan::cppm)
162+
The `VulkanCppModule` target only needs to be defined once. You can then add it to the
163+
dependencies of your consuming project, and it will be built automatically.
164+
You won't need to manually link `Vulkan::Vulkan` — `Vulkan::cppm` handles that internally.
165+
166+
Two compile-time macros are important in this setup:
167+
168+
* `VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1`::
169+
Enables dynamic dispatching of Vulkan functions in Vulkan-Hpp.
170+
This means you'll use `vk::DispatchLoaderDynamic` and manually pass in the function loader
171+
at runtime (via `vkGetInstanceProcAddr` or similar), giving you more control over how Vulkan functions are resolved.
172+
173+
* `VULKAN_HPP_NO_STRUCT_CONSTRUCTORS=1`::
174+
Disables the default C++ constructors for Vulkan-Hpp structs, making them behave more like plain C structs.
175+
You'll need to initialize fields manually, which can be better for clarity or compatibility with existing C-style code.
176+
177+
To consume the module in your own project, simply link it like this:
178+
179+
[.cmake]
180+
----
181+
target_link_libraries(${PROJECT_NAME} Vulkan::cppm)
164182
----
165183
166184
That is all that is required to add Vulkan to any project.

0 commit comments

Comments
 (0)