Add macOS app icon build and bundle plist

Adds macOS-specific CMake packaging for app icons by compiling the Icon Composer `.icon` asset with `xcrun actool` into `MacOSIcon.icns` and `Assets.car`, then wiring those outputs into app bundles after build. Also introduces a dedicated `mac-Info.plist.in` template and sets bundle metadata/icon keys on macOS targets so the app uses the generated icon resources correctly.
This commit is contained in:
2026-07-28 10:29:22 +12:00
parent f43a116d1c
commit 67eedf2fca
2 changed files with 95 additions and 0 deletions
+53
View File
@@ -102,6 +102,36 @@ if(OS_LINUX)
FIND_LINUX_LIBRARIES("X11") FIND_LINUX_LIBRARIES("X11")
endif() endif()
# Compile Icon Composer .icon into Assets.car + .icns for macOS app bundles.
if(OS_MACOSX)
set(NEBULA_MAC_ICON_SOURCE "${CMAKE_SOURCE_DIR}/assets/images/branding/MacOSIcon.icon")
set(NEBULA_MAC_ICON_OUTDIR "${CMAKE_BINARY_DIR}/generated/MacOSIcon")
set(NEBULA_MAC_ICON_ICNS "${NEBULA_MAC_ICON_OUTDIR}/MacOSIcon.icns")
set(NEBULA_MAC_ICON_CAR "${NEBULA_MAC_ICON_OUTDIR}/Assets.car")
set(NEBULA_MAC_ICON_PARTIAL "${NEBULA_MAC_ICON_OUTDIR}/partial.plist")
add_custom_command(
OUTPUT "${NEBULA_MAC_ICON_ICNS}" "${NEBULA_MAC_ICON_CAR}"
COMMAND ${CMAKE_COMMAND} -E make_directory "${NEBULA_MAC_ICON_OUTDIR}"
COMMAND xcrun actool
"${NEBULA_MAC_ICON_SOURCE}"
--compile "${NEBULA_MAC_ICON_OUTDIR}"
--platform macosx
--minimum-deployment-target "${CMAKE_OSX_DEPLOYMENT_TARGET}"
--app-icon MacOSIcon
--output-partial-info-plist "${NEBULA_MAC_ICON_PARTIAL}"
DEPENDS
"${NEBULA_MAC_ICON_SOURCE}/icon.json"
"${NEBULA_MAC_ICON_SOURCE}/Assets/Nebula-Favicon.png"
COMMENT "Compiling MacOSIcon.icon for app bundle"
VERBATIM
)
add_custom_target(NebulaMacAppIcon DEPENDS
"${NEBULA_MAC_ICON_ICNS}"
"${NEBULA_MAC_ICON_CAR}"
)
endif()
function(add_nebula_app_target nebula_target entry_source) function(add_nebula_app_target nebula_target entry_source)
if(OS_WINDOWS) if(OS_WINDOWS)
add_executable(${nebula_target} WIN32 add_executable(${nebula_target} WIN32
@@ -180,6 +210,29 @@ function(add_nebula_app_target nebula_target entry_source)
set(NEBULA_HELPER_OUTPUT_NAME "${nebula_target} Helper") set(NEBULA_HELPER_OUTPUT_NAME "${nebula_target} Helper")
string(TOLOWER "${nebula_target}" NEBULA_HELPER_BUNDLE_NAME) string(TOLOWER "${nebula_target}" NEBULA_HELPER_BUNDLE_NAME)
set_target_properties(${nebula_target} PROPERTIES
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_SOURCE_DIR}/cmake/mac-Info.plist.in"
MACOSX_BUNDLE_BUNDLE_NAME "${nebula_target}"
MACOSX_BUNDLE_GUI_IDENTIFIER "com.nebula.browser.${nebula_target}"
MACOSX_BUNDLE_BUNDLE_VERSION "1.0"
MACOSX_BUNDLE_SHORT_VERSION_STRING "1.0"
MACOSX_BUNDLE_LONG_VERSION_STRING "1.0"
MACOSX_BUNDLE_COPYRIGHT "Nebula Browser"
)
add_dependencies(${nebula_target} NebulaMacAppIcon)
add_custom_command(TARGET ${nebula_target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory
"${NEBULA_APP}/Contents/Resources"
COMMAND ${CMAKE_COMMAND} -E copy
"${NEBULA_MAC_ICON_ICNS}"
"${NEBULA_APP}/Contents/Resources/MacOSIcon.icns"
COMMAND ${CMAKE_COMMAND} -E copy
"${NEBULA_MAC_ICON_CAR}"
"${NEBULA_APP}/Contents/Resources/Assets.car"
COMMENT "Installing MacOSIcon into ${nebula_target}.app"
VERBATIM
)
COPY_MAC_FRAMEWORK( COPY_MAC_FRAMEWORK(
"${nebula_target}" "${nebula_target}"
"${CEF_BINARY_DIR_RELEASE}" "${CEF_BINARY_DIR_RELEASE}"
+42
View File
@@ -0,0 +1,42 @@
<?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>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
<key>CFBundleGetInfoString</key>
<string>${MACOSX_BUNDLE_INFO_STRING}</string>
<key>CFBundleIconFile</key>
<string>MacOSIcon</string>
<key>CFBundleIconName</key>
<string>MacOSIcon</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>LSMinimumSystemVersion</key>
<string>12.0</string>
<key>NSHumanReadableCopyright</key>
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSSupportsAutomaticGraphicsSwitching</key>
<true/>
</dict>
</plist>