Skip to content

Commit 44d666a

Browse files
authored
Artifacts (#63)
* Update cmake-multi-platform.yml * Try to copy more files * set library and archive directories * Update CMakeLists.txt * try this * Update cmake-multi-platform.yml * Update cmake-multi-platform.yml * Update cmake-multi-platform.yml * removed non working stuff * Update CMakeLists.txt * fix mac link * try this * Revert "try this" This reverts commit 6bde3ca. * Update cmake-multi-platform.yml * Update cmake-multi-platform.yml * Update cmake-multi-platform.yml * Revert "Update cmake-multi-platform.yml" This reverts commit 13c862d. * enable mac support for vulkan * Update cmake-multi-platform.yml * use LTS ubuntu for wider support * Update cmake-multi-platform.yml * Update cmake-multi-platform.yml * release * Update cmake-multi-platform.yml * Update cmake-multi-platform.yml
1 parent 26d4a69 commit 44d666a

File tree

4 files changed

+114
-7
lines changed

4 files changed

+114
-7
lines changed

.github/workflows/cmake-multi-platform.yml

+68-5
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ jobs:
2222
#
2323
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
2424
matrix:
25-
os: [ubuntu-latest, windows-latest, macos-latest]
25+
os: ['ubuntu-22.04', windows-latest, macos-latest]
2626
build_type: [Release]
2727
c_compiler: [gcc, clang, cl]
2828
include:
2929
- os: windows-latest
3030
c_compiler: cl
3131
cpp_compiler: cl
32-
- os: ubuntu-latest
32+
- os: 'ubuntu-22.04'
3333
c_compiler: gcc
3434
cpp_compiler: g++
35-
- os: ubuntu-latest
35+
- os: 'ubuntu-22.04'
3636
c_compiler: clang
3737
cpp_compiler: clang++
3838
- os: macos-latest
@@ -43,7 +43,7 @@ jobs:
4343
c_compiler: gcc
4444
- os: windows-latest
4545
c_compiler: clang
46-
- os: ubuntu-latest
46+
- os: 'ubuntu-22.04'
4747
c_compiler: cl
4848
- os: macos-latest
4949
c_compiler: gcc
@@ -61,7 +61,7 @@ jobs:
6161
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
6262
6363
- name: Install dependencies (Ubuntu)
64-
if: ${{ matrix.os == 'ubuntu-latest' }}
64+
if: ${{ matrix.os == 'ubuntu-22.04' }}
6565
run: |
6666
sudo apt-get update
6767
sudo apt-get install -y libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev libwayland-dev libxkbcommon-dev libgl1-mesa-dev
@@ -88,3 +88,66 @@ jobs:
8888
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
8989
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
9090
run: ctest --build-config ${{ matrix.build_type }}
91+
92+
- name: Copy Shared Libraries
93+
shell: bash
94+
run: |
95+
if [ "$RUNNER_OS" == "Linux" ]; then
96+
cp -L $VULKAN_SDK/lib/libvulkan* ${{ steps.strings.outputs.build-output-dir }}/bin/
97+
98+
cp -L /usr/lib/x86_64-linux-gnu/libstdc++.so.6 ${{ steps.strings.outputs.build-output-dir }}/bin/
99+
cp -L /lib/x86_64-linux-gnu/libgcc_s.so.1 ${{ steps.strings.outputs.build-output-dir }}/bin/
100+
101+
elif [ "$RUNNER_OS" == "macOS" ]; then
102+
cp $VULKAN_SDK/lib/libMoltenVK.dylib ${{ steps.strings.outputs.build-output-dir }}/bin/
103+
cp $VULKAN_SDK/lib/libvulkan.* ${{ steps.strings.outputs.build-output-dir }}/bin/
104+
fi
105+
106+
- name: Upload Artifacts
107+
uses: actions/upload-artifact@v4
108+
with:
109+
name: ${{ matrix.os }}-${{ matrix.c_compiler }}-binaries
110+
path: |
111+
${{ steps.strings.outputs.build-output-dir }}/bin
112+
retention-days: 5
113+
114+
release:
115+
needs: build
116+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
117+
runs-on: ubuntu-latest
118+
permissions:
119+
contents: write
120+
steps:
121+
- uses: actions/checkout@v4
122+
123+
- name: Get version from CMakeLists.txt
124+
id: get_version
125+
run: |
126+
VERSION=$(grep -oP 'project\([^)]*VERSION\s+\K[0-9.]+' CMakeLists.txt || echo "0.1.0")
127+
COMMIT_SHA="${{ github.sha }}"
128+
SHORT_SHA="${COMMIT_SHA:0:7}"
129+
echo "version=$VERSION-$SHORT_SHA" >> $GITHUB_OUTPUT
130+
echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
131+
132+
- name: Download all artifacts
133+
uses: actions/download-artifact@v4
134+
with:
135+
path: artifacts
136+
137+
- name: List downloaded artifacts
138+
run: find artifacts -type f | sort
139+
140+
- name: Create Release
141+
id: create_release
142+
uses: softprops/[email protected]
143+
env:
144+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
145+
with:
146+
name: Release ${{ steps.get_version.outputs.version }} (${{ steps.get_version.outputs.date }})
147+
tag_name: v${{ steps.get_version.outputs.version }}
148+
draft: false
149+
prerelease: false
150+
generate_release_notes: true
151+
files: |
152+
artifacts/**/*.zip
153+
artifacts/**/*.tar.gz

CMakeLists.txt

+30-1
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,47 @@ option(VulkanProject_BUILD_TESTS "Enable building tests for VulkanProject" OFF)
44

55
project(VulkanProject)
66

7+
if(APPLE)
8+
enable_language(OBJC)
9+
endif()
10+
711
set(CMAKE_CXX_STANDARD 23)
812

913
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
1014
set(VulkanProject_BUILD_TESTS ON)
1115

16+
# Executables
1217
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
1318
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin)
1419
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/bin)
20+
21+
# Libraries (Shared and Static)
22+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
23+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin)
24+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/bin)
25+
26+
# Archive (Static Libraries)
27+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
28+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin)
29+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/bin)
1530
endif()
1631

1732
if (NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY)
18-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
33+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
34+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
35+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
36+
endif()
37+
38+
if(UNIX)
39+
# Set the install RPATH to find libraries relative to the installed executable
40+
if(APPLE)
41+
set(CMAKE_INSTALL_RPATH "@executable_path")
42+
else()
43+
set(CMAKE_INSTALL_RPATH "$ORIGIN")
44+
endif()
45+
46+
# Ensure that the build executable works like the installed one
47+
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
1948
endif()
2049

2150
if (MSVC)

source/components/Instance.cpp

+13-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ constexpr bool enableValidationLayers = false;
1111
constexpr bool enableValidationLayers = true;
1212
#endif
1313

14+
#ifdef __APPLE__
15+
#define IS_MAC 1
16+
#else
17+
#define IS_MAC 0
18+
#endif
19+
1420
Instance::Instance()
1521
{
1622
if (enableValidationLayers && !checkValidationLayerSupport())
@@ -24,7 +30,7 @@ Instance::Instance()
2430
.applicationVersion = VK_MAKE_VERSION(1, 0, 0),
2531
.pEngineName = "No Engine",
2632
.engineVersion = VK_MAKE_VERSION(1, 0, 0),
27-
.apiVersion = VK_API_VERSION_1_0
33+
.apiVersion = VK_API_VERSION_1_1
2834
};
2935

3036
const auto extensions = getRequiredExtensions();
@@ -38,6 +44,7 @@ Instance::Instance()
3844
const VkInstanceCreateInfo createInfo {
3945
.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
4046
.pNext = enableValidationLayers ? &debugCreateInfo : nullptr,
47+
.flags = IS_MAC ? VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR : 0,
4148
.pApplicationInfo = &appInfo,
4249
.enabledLayerCount = enableValidationLayers ? static_cast<uint32_t>(validationLayers.size()) : 0,
4350
.ppEnabledLayerNames = enableValidationLayers ? validationLayers.data() : nullptr,
@@ -103,5 +110,10 @@ std::vector<const char*> Instance::getRequiredExtensions()
103110
extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
104111
}
105112

113+
if constexpr (IS_MAC)
114+
{
115+
extensions.push_back("VK_KHR_portability_enumeration");
116+
}
117+
106118
return extensions;
107119
}

source/components/PhysicalDevice.h

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ class Instance;
1111

1212
constexpr std::array deviceExtensions {
1313
VK_KHR_SWAPCHAIN_EXTENSION_NAME
14+
#ifdef __APPLE__
15+
, "VK_KHR_portability_subset"
16+
#endif
1417
};
1518

1619
struct QueueFamilyIndices {

0 commit comments

Comments
 (0)