Skip to content

Commit

Permalink
Create Cemu .app bundle for macOS (#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
emiyl committed Oct 23, 2022
1 parent 028b3f7 commit 8f67493
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 18 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ jobs:
with:
name: cemu-bin-windows-x64
path: ./bin/Cemu.exe


build-macos:
runs-on: macos-12
steps:
Expand Down Expand Up @@ -213,19 +215,28 @@ jobs:
run: |
mkdir build
cd build
cmake .. ${{ env.BUILD_FLAGS }} -DCMAKE_BUILD_TYPE=${{ env.BUILD_MODE }} -DCMAKE_C_COMPILER=/usr/local/opt/llvm@14/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm@14/bin/clang++ -G Ninja
cmake .. ${{ env.BUILD_FLAGS }} -DCMAKE_BUILD_TYPE=${{ env.BUILD_MODE }} -DPORTABLE=OFF -DMACOS_BUNDLE=ON -DCMAKE_C_COMPILER=/usr/local/opt/llvm@14/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm@14/bin/clang++ -G Ninja
- name: "Build Cemu"
run: |
cmake --build build
- name: Prepare artifact
if: ${{ inputs.deploymode == 'release' }}
run: chmod a+x bin/Cemu_release && mv bin/Cemu_release bin/Cemu
run: |
mkdir bin/Cemu_app
mv bin/Cemu_release.app bin/Cemu_app/Cemu.app
mv bin/Cemu_app/Cemu.app/Contents/MacOS/Cemu_release bin/Cemu_app/Cemu.app/Contents/MacOS/Cemu
sed -i '' 's/Cemu_release/Cemu/g' bin/Cemu_app/Cemu.app/Contents/Info.plist
chmod a+x bin/Cemu_app/Cemu.app/Contents/MacOS/Cemu
ln -s /Applications bin/Cemu_app/Applications
hdiutil create ./bin/tmp.dmg -ov -volname "Cemu" -fs HFS+ -srcfolder "./bin/Cemu_app"
hdiutil convert ./bin/tmp.dmg -format UDZO -o bin/Cemu.dmg
rm bin/tmp.dmg
- name: Upload artifact
uses: actions/upload-artifact@v3
if: ${{ inputs.deploymode == 'release' }}
with:
name: cemu-bin-macos-x64
path: ./bin/Cemu
path: ./bin/Cemu.dmg
8 changes: 1 addition & 7 deletions .github/workflows/deploy_experimental_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,7 @@ jobs:
rm -r ./${{ env.CEMU_FOLDER_NAME }}
- name: Create release from macos-bin
run: |
ls ./
ls ./bin/
cp -R ./bin ./${{ env.CEMU_FOLDER_NAME }}
mv cemu-bin-macos-x64/Cemu ./${{ env.CEMU_FOLDER_NAME }}/Cemu
zip -9 -r upload/cemu-${{ env.CEMU_VERSION }}-macos-12-x64.zip ${{ env.CEMU_FOLDER_NAME }}
rm -r ./${{ env.CEMU_FOLDER_NAME }}
run: cp cemu-bin-macos-x64/Cemu.dmg upload/cemu-${{ env.CEMU_VERSION }}-macos-12-x64.dmg

- name: Create release
run: |
Expand Down
8 changes: 1 addition & 7 deletions .github/workflows/deploy_stable_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,7 @@ jobs:
rm -r ./${{ env.CEMU_FOLDER_NAME }}
- name: Create release from macos-bin
run: |
ls ./
ls ./bin/
cp -R ./bin ./${{ env.CEMU_FOLDER_NAME }}
mv cemu-bin-macos-x64/Cemu ./${{ env.CEMU_FOLDER_NAME }}/Cemu
zip -9 -r upload/cemu-${{ env.CEMU_VERSION }}-macos-12-x64.zip ${{ env.CEMU_FOLDER_NAME }}
rm -r ./${{ env.CEMU_FOLDER_NAME }}
run: cp cemu-bin-macos-x64/Cemu.dmg upload/cemu-${{ env.CEMU_VERSION }}-macos-12-x64.dmg

- name: Create release
run: |
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.21.1)

option(ENABLE_VCPKG "Enable the vcpkg package manager" ON)
option(PORTABLE "All data created and maintained by Cemu will be in the directory where the executable file is located" ON)
option(MACOS_BUNDLE "The executable when built on macOS will be created as an application bundle" OFF)
set(EXPERIMENTAL_VERSION "" CACHE STRING "") # used by CI script to set experimental version

if (EXPERIMENTAL_VERSION)
Expand Down
29 changes: 28 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,39 @@ endif()

set_property(TARGET CemuBin PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set_property(TARGET CemuBin PROPERTY WIN32_EXECUTABLE $<NOT:$<CONFIG:Debug>>)
set(OUTPUT_NAME "Cemu_$<LOWER_CASE:$<CONFIG>>")

if (MACOS_BUNDLE)
set_property(TARGET CemuBin PROPERTY MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/resource/MacOSXBundleInfo.plist.in")

set(RESOURCE_FILES "${CMAKE_SOURCE_DIR}/src/resource/cemu.icns")
target_sources(CemuBin PRIVATE "${RESOURCE_FILES}")

set(MACOSX_BUNDLE_CATEGORY "public.app-category.games")

set_target_properties(CemuBin PROPERTIES
MACOSX_BUNDLE true
RESOURCE "${RESOURCE_FILES}"
)

set(FOLDERS gameProfiles resources)
foreach(folder ${FOLDERS})
add_custom_command (TARGET CemuBin POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory "${CMAKE_SOURCE_DIR}/bin/${folder}" "${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/SharedSupport/${folder}")
endforeach(folder)

add_custom_command (TARGET CemuBin POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy "/usr/local/lib/libMoltenVK.dylib" "${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/Frameworks/libMoltenVK.dylib")

add_custom_command (TARGET CemuBin POST_BUILD
COMMAND bash -c "install_name_tool -add_rpath @executable_path/../Frameworks ${CMAKE_SOURCE_DIR}/bin/${OUTPUT_NAME}.app/Contents/MacOS/${OUTPUT_NAME}")
endif()

set_target_properties(CemuBin PROPERTIES
# multi-configuration generators will add a config subdirectory to RUNTIME_OUTPUT_DIRECTORY if no generator expression is used
# to get the same behavior everywhere we append an empty generator expression
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../bin/$<1:>"
OUTPUT_NAME "Cemu_$<LOWER_CASE:$<CONFIG>>"
OUTPUT_NAME "${OUTPUT_NAME}"
)

target_link_libraries(CemuBin PRIVATE
Expand Down
3 changes: 3 additions & 0 deletions src/gui/CemuApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ bool CemuApp::OnInit()
auto standardPaths = wxStandardPaths::Get();
#ifdef PORTABLE
fs::path exePath(standardPaths.GetExecutablePath().ToStdString());
#if MACOS_BUNDLE
exePath = exePath.parent_path().parent_path().parent_path();
#endif
user_data_path = config_path = cache_path = data_path = exePath.parent_path();
#else
SetAppName("Cemu");
Expand Down
36 changes: 36 additions & 0 deletions src/resource/MacOSXBundleInfo.plist.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
<key>CFBundleGetInfoString</key>
<string>${MACOSX_BUNDLE_INFO_STRING}</string>
<key>CFBundleIconFile</key>
<string>${MACOSX_BUNDLE_ICON_FILE}</string>
<key>CFBundleIdentifier</key>
<string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleLongVersionString</key>
<string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
<key>CFBundleName</key>
<string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
<key>LSApplicationCategoryType</key>
<string>${MACOSX_BUNDLE_CATEGORY}</string>
</dict>
</plist>
Binary file added src/resource/cemu.icns
Binary file not shown.

0 comments on commit 8f67493

Please sign in to comment.