Skip to content

Commit f235198

Browse files
committed
Add Clang support and enhance C++20 module configuration in workflow and CMake setup
- Introduced `clang` installation in CI workflow for improved C++20 module support. - Updated CMake workflow to use Clang as the default compiler and enabled C++ module dependency scanning globally. - Refined target configurations by adding explicit module source files and consolidating module scanning settings.
1 parent 4c35e20 commit f235198

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

.github/workflows/workflow.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ jobs:
4545
libtinyobjloader-dev \
4646
libstb-dev \
4747
cmake \
48-
ninja-build
48+
ninja-build \
49+
clang
4950
# Build and install yaml-cpp from source
5051
git clone https://github.com/jbeder/yaml-cpp.git
5152
cd yaml-cpp
@@ -193,7 +194,14 @@ jobs:
193194
- name: Configure CMake (Unix)
194195
working-directory: ${{github.workspace}}/attachments
195196
if: runner.os != 'Windows'
196-
run: cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
197+
run: |
198+
# Use Clang for better C++20 module support
199+
export CC=clang
200+
export CXX=clang++
201+
202+
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release \
203+
-DCMAKE_CXX_SCAN_FOR_MODULES=ON \
204+
-DCMAKE_CXX_FLAGS="-std=c++20"
197205
198206
- name: Build
199207
working-directory: ${{github.workspace}}/attachments

attachments/CMakeLists.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
cmake_minimum_required (VERSION 3.29)
22

3+
# Enable C++ module dependency scanning
4+
set(CMAKE_CXX_SCAN_FOR_MODULES ON)
5+
36
project (VulkanTutorial)
47

58
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake")
@@ -25,7 +28,6 @@ target_link_libraries(VulkanCppModule
2528
)
2629

2730
set_target_properties(VulkanCppModule PROPERTIES CXX_STANDARD 20)
28-
set_target_properties(VulkanCppModule PROPERTIES CXX_SCAN_FOR_MODULES ON)
2931

3032
target_sources(VulkanCppModule
3133
PUBLIC
@@ -36,6 +38,12 @@ target_sources(VulkanCppModule
3638
"${Vulkan_INCLUDE_DIR}/vulkan/vulkan.cppm"
3739
)
3840

41+
# Add the vulkan.cppm file directly as a source file
42+
target_sources(VulkanCppModule
43+
PRIVATE
44+
"${Vulkan_INCLUDE_DIR}/vulkan/vulkan.cppm"
45+
)
46+
3947
find_package (tinyobjloader REQUIRED)
4048

4149
find_package (PkgConfig)
@@ -101,7 +109,6 @@ function (add_chapter CHAPTER_NAME)
101109
set_target_properties (${CHAPTER_NAME} PROPERTIES
102110
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CHAPTER_NAME})
103111
set_target_properties (${CHAPTER_NAME} PROPERTIES CXX_STANDARD 20)
104-
set_target_properties (${CHAPTER_NAME} PROPERTIES CXX_SCAN_FOR_MODULES ON)
105112
target_link_libraries (${CHAPTER_NAME} Vulkan::cppm glfw)
106113
target_include_directories (${CHAPTER_NAME} PRIVATE ${STB_INCLUDEDIR})
107114

0 commit comments

Comments
 (0)