Skip to content

Commit cac8d99

Browse files
committed
Add USE_DIRECT_MODULE_IMPORT option to CMake for improved IDE support
- Introduced `USE_DIRECT_MODULE_IMPORT` toggle in CMake to allow direct use of `vulkan.cppm`. - Provides an alternative for resolving Intellisense issues in VS2022 and other IDEs.
1 parent d7b29d7 commit cac8d99

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

attachments/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@ cmake_minimum_required (VERSION 3.29)
33
# Enable C++ module dependency scanning
44
set(CMAKE_CXX_SCAN_FOR_MODULES ON)
55

6+
# Option to use direct module import instead of VulkanCppModule
7+
# Set this to ON if you're having intellisense issues with VS2022
8+
#
9+
# To enable this option, use one of the following methods:
10+
# 1. Command line: cmake -DUSE_DIRECT_MODULE_IMPORT=ON ..
11+
# 2. CMake GUI: Check the USE_DIRECT_MODULE_IMPORT option
12+
# 3. Edit CMakeCache.txt: Set USE_DIRECT_MODULE_IMPORT:BOOL=ON
13+
#
14+
# This option changes how the Vulkan C++ module is included in the project:
15+
# - When OFF (default): Uses a shared VulkanCppModule library that all projects link to
16+
# - When ON: Adds the vulkan.cppm module directly to each project, which can help with
17+
# intellisense in VS2022 and other IDEs that have issues with C++20 modules
18+
option(USE_DIRECT_MODULE_IMPORT "Use direct vulkan-hpp module import instead of VulkanCppModule" OFF)
19+
620
project (VulkanTutorial)
721

822
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake")
@@ -12,6 +26,7 @@ find_package (glm REQUIRED)
1226
find_package (Vulkan REQUIRED)
1327

1428
# set up Vulkan C++ module
29+
if(NOT USE_DIRECT_MODULE_IMPORT)
1530
add_library(VulkanCppModule)
1631
add_library(Vulkan::cppm ALIAS VulkanCppModule)
1732

@@ -43,6 +58,7 @@ target_sources(VulkanCppModule
4358
PRIVATE
4459
"${Vulkan_INCLUDE_DIR}/vulkan/vulkan.cppm"
4560
)
61+
endif()
4662

4763
find_package (tinyobjloader REQUIRED)
4864

0 commit comments

Comments
 (0)