From 67eedf2fcacdb39b57eb2143a3c70732b552647d Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 28 Jul 2026 10:29:22 +1200 Subject: [PATCH] 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. --- CMakeLists.txt | 53 +++++++++++++++++++++++++++++++++++++++++ cmake/mac-Info.plist.in | 42 ++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 cmake/mac-Info.plist.in diff --git a/CMakeLists.txt b/CMakeLists.txt index e911832..1c52a31 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,6 +102,36 @@ if(OS_LINUX) FIND_LINUX_LIBRARIES("X11") 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) if(OS_WINDOWS) 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") 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( "${nebula_target}" "${CEF_BINARY_DIR_RELEASE}" diff --git a/cmake/mac-Info.plist.in b/cmake/mac-Info.plist.in new file mode 100644 index 0000000..910018d --- /dev/null +++ b/cmake/mac-Info.plist.in @@ -0,0 +1,42 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${MACOSX_BUNDLE_EXECUTABLE_NAME} + CFBundleGetInfoString + ${MACOSX_BUNDLE_INFO_STRING} + CFBundleIconFile + MacOSIcon + CFBundleIconName + MacOSIcon + CFBundleIdentifier + ${MACOSX_BUNDLE_GUI_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleLongVersionString + ${MACOSX_BUNDLE_LONG_VERSION_STRING} + CFBundleName + ${MACOSX_BUNDLE_BUNDLE_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + ${MACOSX_BUNDLE_SHORT_VERSION_STRING} + CFBundleSignature + ???? + CFBundleVersion + ${MACOSX_BUNDLE_BUNDLE_VERSION} + CSResourcesFileMapped + + LSMinimumSystemVersion + 12.0 + NSHumanReadableCopyright + ${MACOSX_BUNDLE_COPYRIGHT} + NSPrincipalClass + NSApplication + NSSupportsAutomaticGraphicsSwitching + + +