Skip to content

Commit

Permalink
Fix for vcpkg usage. (#15)
Browse files Browse the repository at this point in the history
* Enable test only if VKU_ENABLE_TEST flag set to ON.

* WIP: fix CI.

* libstdc++ does not support {:?} format specifier.
  • Loading branch information
stripe2933 authored Aug 19, 2024
1 parent 1a75039 commit 818f90f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 41 deletions.
47 changes: 15 additions & 32 deletions .github/workflows/CMakeUserPresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@
"version": 6,
"configurePresets": [
{
"name": "clang-libstdcxx",
"displayName": "Clang + libstdc++",
"name": "ci-test",
"hidden": true,
"inherits": "vcpkg",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"VKU_ENABLE_TEST": "ON"
}
},
{
"name": "clang",
"inherits": "ci-test",
"cacheVariables": {
"CMAKE_C_COMPILER": "/usr/bin/clang-18",
"CMAKE_CXX_COMPILER": "/usr/bin/clang++-18"
},
Expand All @@ -19,24 +25,16 @@
{
"name": "clang-libcxx",
"displayName": "Clang + libc++",
"inherits": "vcpkg",
"inherits": "clang",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_C_COMPILER": "/usr/bin/clang-18",
"CMAKE_CXX_COMPILER": "/usr/bin/clang++-18",
"CMAKE_CXX_FLAGS": "-stdlib=libc++",
"CMAKE_EXE_LINKER_FLAGS": "-stdlib=libc++ -lc++abi"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
}
},
{
"name": "msvc",
"displayName": "MSVC",
"inherits": "vcpkg",
"inherits": "ci-test",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
Expand All @@ -46,31 +44,16 @@
],
"buildPresets": [
{
"name": "clang-libstdcxx",
"configurePreset": "clang-libstdcxx",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
}
"name": "clang",
"configurePreset": "clang"
},
{
"name": "clang-libcxx",
"configurePreset": "clang-libcxx",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
}
"configurePreset": "clang-libcxx"
},
{
"name": "msvc",
"configurePreset": "msvc",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
"configurePreset": "msvc"
}
]
}
4 changes: 2 additions & 2 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ jobs:
- name: Configure
run: |
mv .github/workflows/CMakeUserPresets.json .
cmake --preset=${{ matrix.use_std_module == 'ON' && 'clang-libcxx' || 'clang-libstdcxx' }} \
cmake --preset=${{ matrix.use_std_module == 'ON' && 'clang-libcxx' || 'clang' }} \
-DCMAKE_BUILD_TYPE=${{ matrix.build }} \
-DVKU_USE_STD_MODULE=${{ matrix.use_std_module }}
- name: Install
run: cmake --build --preset=${{ matrix.use_std_module == 'ON' && 'clang-libcxx' || 'clang-libstdcxx' }} --target install
run: cmake --build --preset=${{ matrix.use_std_module == 'ON' && 'clang-libcxx' || 'clang' }} --target install
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ endif()
option(VKU_USE_STD_MODULE "Use the standard library module for compilation.")
option(VKU_USE_SHADERC "Add runtime GLSL compilation feature by shaderc.")
option(VKU_DEFAULT_DYNAMIC_DISPATCHER "Use the vk::DispatchLoaderDynamic as the default dispatcher.")
option(VKU_ENABLE_TEST "Enable the test targets.")

# ----------------
# External dependencies.
Expand Down Expand Up @@ -103,7 +104,7 @@ add_library(${PROJECT_NAME}::vku ALIAS vku)
# Tests.
# --------------------

if (PROJECT_IS_TOP_LEVEL)
if (VKU_ENABLE_TEST)
enable_testing()
add_subdirectory(test)
endif()
Expand Down
12 changes: 6 additions & 6 deletions interface/Gpu.cppm
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace vku {
}
catch (const std::runtime_error &e) {
if (verbose) {
std::println(std::cerr, "Physical device {:?} rejected because it failed to get the request queue families: {}", deviceName, e.what());
std::println(std::cerr, "Physical device \"{}\" rejected because it failed to get the request queue families: {}", deviceName, e.what());
}
return 0;
}
Expand All @@ -88,9 +88,9 @@ namespace vku {
std::vector<std::string_view> unavailableExtensions;
std::ranges::set_difference(deviceExtensionNames, availableExtensionNames, std::back_inserter(unavailableExtensions));
#if __cpp_lib_format_ranges >= 202207L
std::println(std::cerr, "Physical device {:?} rejected because it lacks the following device extensions: {::s}", deviceName, unavailableExtensions);
std::println(std::cerr, "Physical device \"{}\" rejected because it lacks the following device extensions: {::s}", deviceName, unavailableExtensions);
#else
std::print(std::cerr, "Physical device {:?} rejected because it lacks the following device extensions: [", deviceName);
std::print(std::cerr, "Physical device \"{}\" rejected because it lacks the following device extensions: [", deviceName);
for (std::size_t i = 0; i < unavailableExtensions.size(); ++i) {
if (i == unavailableExtensions.size() - 1) {
std::println(std::cerr, "{}]", unavailableExtensions[i]);
Expand Down Expand Up @@ -168,9 +168,9 @@ namespace vku {
if (!unavailableFeatures.empty()) {
if (verbose) {
#if __cpp_lib_format_ranges >= 202207L
std::println(std::cerr, "Physical device {:?} rejected because it lacks the following physical device features: {::s}", deviceName, unavailableFeatures);
std::println(std::cerr, "Physical device \"{}\" rejected because it lacks the following physical device features: {::s}", deviceName, unavailableFeatures);
#else
std::print(std::cerr, "Physical device {:?} rejected because it lacks the following physical device features: [", deviceName);
std::print(std::cerr, "Physical device \"{}\" rejected because it lacks the following physical device features: [", deviceName);
for (std::size_t i = 0; i < unavailableFeatures.size(); ++i) {
if (i == unavailableFeatures.size() - 1) {
std::println(std::cerr, "{}]", unavailableFeatures[i]);
Expand All @@ -193,7 +193,7 @@ namespace vku {
score += properties.limits.maxImageDimension2D;

if (verbose) {
std::println(std::cerr, "Physical device {:?} accepted (score={}).", deviceName, score);
std::println(std::cerr, "Physical device \"{}\" accepted (score={}).", deviceName, score);
}
return score;
}
Expand Down

0 comments on commit 818f90f

Please sign in to comment.