Skip to content

Commit

Permalink
macOS setup and copy required shared libraries to the application.
Browse files Browse the repository at this point in the history
  • Loading branch information
stripe2933 committed Feb 21, 2025
1 parent c5e9e70 commit 2d61455
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:

- name: Install build dependencies (macOS)
if: ${{ runner.os == 'macOS' }}
run: brew install llvm ninja autoconf automake libtool nasm shaderc
run: brew install llvm ninja autoconf automake libtool nasm shaderc molten-vk

- name: Install build dependencies (Linux)
if: ${{ runner.os == 'Linux' }}
Expand Down Expand Up @@ -82,6 +82,7 @@ jobs:
with:
name: ${{ runner.os }}_${{ runner.arch }}
path: |
build/vk-gltf-viewer
build/vk-gltf-viewer.exe
build/vk-gltf-viewer.app
build/vk-gltf-viewer
build/*.dll
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ target_sources(vk-gltf-viewer_asset PUBLIC
)
add_library(vk-gltf-viewer::asset ALIAS vk-gltf-viewer_asset)

add_executable(vk-gltf-viewer WIN32
add_executable(vk-gltf-viewer WIN32 MACOSX_BUNDLE
impl.cpp
impl/control/AppWindow.cpp
impl/control/ImGuiTaskCollector.cpp
Expand Down Expand Up @@ -229,6 +229,16 @@ if (UNIX AND NOT APPLE) # Linux?
endif()
endif()

if (APPLE)
set_target_properties(vk-gltf-viewer PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/cmake/MacOSXBundleInfo.plist.in)

find_package(Vulkan COMPONENTS MoltenVK REQUIRED)
set(APP_BUNDLE_CONTENTS_DIR "${CMAKE_CURRENT_BINARY_DIR}/vk-gltf-viewer.app/Contents")
add_custom_command(TARGET vk-gltf-viewer POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${APP_BUNDLE_CONTENTS_DIR}/Frameworks
&& ${CMAKE_COMMAND} -E copy ${Vulkan_LIBRARY} ${Vulkan_MoltenVK_LIBRARY} ${APP_BUNDLE_CONTENTS_DIR}/Frameworks
&& install_name_tool -add_rpath "@executable_path/../Frameworks/" "${APP_BUNDLE_CONTENTS_DIR}/MacOS/vk-gltf-viewer")
endif()

# --------------------
# Shader compilation.
Expand Down
16 changes: 16 additions & 0 deletions cmake/MacOSXBundleInfo.plist.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSHighResolutionCapable</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>© 2025 LEE KYOUNGHEON</string>
<key>CFBundleVersion</key>
<string>0.1.0</string>
<key>CFBundleName</key>
<string>Vulkan glTF Viewer</string>
<key>CFBundleIdentifier</key>
<string>com.leekyoungheon.vkgltfviewer</string>
</dict>
</plist>

0 comments on commit 2d61455

Please sign in to comment.