Skip to content

Commit

Permalink
BUILD: Simplify macOS Info.plist generation.
Browse files Browse the repository at this point in the history
Also moves macOS related assets to dist/macOS similar to where
the AppImage dist files for Linux are kept.
  • Loading branch information
dsvensson committed Oct 21, 2024
1 parent 1ceecb5 commit da19f8e
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 37 deletions.
40 changes: 3 additions & 37 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ get_target_property(version_build git_version REVISION)
get_target_property(version_commit git_version COMMIT)

# macOS icon
set(macos_icon "${PROJECT_SOURCE_DIR}/misc/install/ezquake.icns")
set(macos_icon "${PROJECT_SOURCE_DIR}/dist/macOS/ezquake.icns")
set_source_files_properties(${macos_icon} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)

# Windows icon, and exe metadata
Expand Down Expand Up @@ -907,49 +907,15 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
XCODE_ATTRIBUTE_INFOPLIST_KEY_LSApplicationCategoryType "public.app-category.action-games"
XCODE_ATTRIBUTE_INFOPLIST_KEY_NSHumanReadableCopyright "GNU General Public License, version 2"
MACOSX_BUNDLE_ICON_FILE "ezquake"
XCODE_ATTRIBUTE_INFOPLIST_FILE "${PROJECT_SOURCE_DIR}/dist/macOS/MacOSXBundleInfo.plist.in"
)

if(ENABLE_SANDBOX)
set_target_properties(ezquake PROPERTIES
XCODE_ATTRIBUTE_ENABLE_APP_SANDBOX YES
XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME YES
XCODE_ATTRIBUTE_CODE_SIGN_INJECT_BASE_ENTITLEMENTS YES
XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "misc/install/ezquake.entitlements.plist"
XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "dist/macOS/ezquake.entitlements.plist"
)
endif()

add_custom_command(
TARGET ezquake POST_BUILD
COMMAND /usr/libexec/PlistBuddy
-c "Add :NSHighResolutionCapable bool YES"
"$<TARGET_FILE_DIR:ezquake>/../Info.plist"
)

# qw:// protocol support
add_custom_command(
TARGET ezquake POST_BUILD
COMMAND /usr/libexec/PlistBuddy
-c "Add :CFBundleURLTypes array"
-c "Add :CFBundleURLTypes:0 dict"
-c "Add :CFBundleURLTypes:0:CFBundleURLName string QW"
-c "Add :CFBundleURLTypes:0:CFBundleURLSchemes array"
-c "Add :CFBundleURLTypes:0:CFBundleURLSchemes:0 string qw"
"$<TARGET_FILE_DIR:ezquake>/../Info.plist"
)

# .mvd/.qwd/.dem file type support
add_custom_command(
TARGET ezquake POST_BUILD
COMMAND /usr/libexec/PlistBuddy
-c "Add :CFBundleDocumentTypes array"
-c "Add :CFBundleDocumentTypes:0 dict"
-c "Add :CFBundleDocumentTypes:0:CFBundleTypeName string \"Quake demo\""
-c "Add :CFBundleDocumentTypes:0:CFBundleTypeRole string Viewer"
-c "Add :CFBundleDocumentTypes:0:CFBundleTypeIconFile string ezquake.icns"
-c "Add :CFBundleDocumentTypes:0:CFBundleTypeExtensions array"
-c "Add :CFBundleDocumentTypes:0:CFBundleTypeExtensions: string mvd"
-c "Add :CFBundleDocumentTypes:0:CFBundleTypeExtensions: string qwd"
-c "Add :CFBundleDocumentTypes:0:CFBundleTypeExtensions: string dem"
"$<TARGET_FILE_DIR:ezquake>/../Info.plist"
)
endif()
64 changes: 64 additions & 0 deletions dist/macOS/MacOSXBundleInfo.plist.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?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>NSHighResolutionCapable</key>
<true/>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>QW</string>
<key>CFBundleURLSchemes</key>
<array>
<string>qw</string>
</array>
</dict>
</array>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>mvd</string>
<string>qwd</string>
<string>dem</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>ezquake.icns</string>
<key>CFBundleTypeName</key>
<string>Quake demo</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
</dict>
</array>
</dict>
</plist>
File renamed without changes.
File renamed without changes.

0 comments on commit da19f8e

Please sign in to comment.