Skip to content

Commit

Permalink
Use Xcode for macOS builds (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbatalov committed May 1, 2023
1 parent fcf8a87 commit d6a7446
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 17 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,28 +213,34 @@ jobs:
uses: actions/cache@v3
with:
path: build
key: macos-cmake-v3
key: macos-cmake-v4

- name: Configure
run: |
cmake \
-B build \
-D CMAKE_BUILD_TYPE=RelWithDebInfo \
-G Xcode \
-D CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY='' \
# EOL
- name: Build
run: |
cmake \
--build build \
--config RelWithDebInfo \
-j $(sysctl -n hw.physicalcpu) \
--target package \
# EOL
- name: Pack
run: |
cd build
cpack -C RelWithDebInfo
- name: Upload
uses: actions/upload-artifact@v3
with:
name: fallout2-ce-macos.dmg
path: build/fallout2-ce.dmg
path: build/Fallout II Community Edition.dmg
retention-days: 7

windows:
Expand Down
33 changes: 21 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -318,16 +318,30 @@ if(APPLE)
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "com.alexbatalov.fallout2-ce"
XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2"
)

set(MACOSX_BUNDLE_BUNDLE_NAME "${EXECUTABLE_NAME}")
set(MACOSX_BUNDLE_DISPLAY_NAME "Fallout 2")
else()
set_target_properties(${EXECUTABLE_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_SOURCE_DIR}/os/macos/Info.plist")
target_sources(${EXECUTABLE_NAME} PUBLIC "os/macos/fallout2-ce.icns")
set_source_files_properties("os/macos/fallout2-ce.icns" PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
set(RESOURCES
"os/macos/fallout2-ce.icns"
)

target_sources(${EXECUTABLE_NAME} PUBLIC ${RESOURCES})
set_source_files_properties(${RESOURCES} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")

set_target_properties(${EXECUTABLE_NAME} PROPERTIES
OUTPUT_NAME "Fallout II Community Edition"
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_SOURCE_DIR}/os/macos/Info.plist"
XCODE_ATTRIBUTE_EXECUTABLE_NAME "${EXECUTABLE_NAME}"
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "com.alexbatalov.fallout2-ce"
)

set(MACOSX_BUNDLE_ICON_FILE "fallout2-ce.icns")
set(MACOSX_BUNDLE_BUNDLE_NAME "Fallout II: Community Edition")
set(MACOSX_BUNDLE_DISPLAY_NAME "Fallout II")
endif()

set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.alexbatalov.fallout2-ce")
set(MACOSX_BUNDLE_BUNDLE_NAME "${EXECUTABLE_NAME}")
set(MACOSX_BUNDLE_DISPLAY_NAME "Fallout 2")
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "1.2.0")
set(MACOSX_BUNDLE_BUNDLE_VERSION "1.2.0")
endif()
Expand Down Expand Up @@ -360,22 +374,17 @@ if(APPLE)
set(CPACK_ARCHIVE_FILE_EXTENSION "ipa")
else()
install(TARGETS ${EXECUTABLE_NAME} DESTINATION .)
install(CODE "
include(BundleUtilities)
fixup_bundle(${CMAKE_BINARY_DIR}/${MACOSX_BUNDLE_BUNDLE_NAME}.app \"\" \"\")
"
COMPONENT Runtime)

if (CPACK_BUNDLE_APPLE_CERT_APP)
install(CODE "
execute_process(COMMAND codesign --deep --force --options runtime --sign \"${CPACK_BUNDLE_APPLE_CERT_APP}\" ${CMAKE_BINARY_DIR}/${MACOSX_BUNDLE_BUNDLE_NAME}.app)
execute_process(COMMAND codesign --deep --force --options runtime --sign \"${CPACK_BUNDLE_APPLE_CERT_APP}\" ${CMAKE_BINARY_DIR}/Fallout II Community Edition.app)
"
COMPONENT Runtime)
endif()

set(CPACK_GENERATOR "DragNDrop")
set(CPACK_DMG_DISABLE_APPLICATIONS_SYMLINK ON)
set(CPACK_PACKAGE_FILE_NAME "fallout2-ce")
set(CPACK_PACKAGE_FILE_NAME "Fallout II Community Edition")
endif()

include(CPack)
Expand Down
4 changes: 3 additions & 1 deletion os/macos/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>${MACOSX_BUNDLE_DISPLAY_NAME}</string>
<key>CFBundleExecutable</key>
Expand All @@ -28,6 +28,8 @@
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
<key>NSHighResolutionCapable</key>
<string>True</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.role-playing-games</string>
<key>LSMinimumSystemVersion</key>
<string>10.11</string>
<key>SDL_FILESYSTEM_BASE_DIR_TYPE</key>
Expand Down

0 comments on commit d6a7446

Please sign in to comment.