Functions for streamlining the creation of macOS application bundles (.app
files), including icon management, code signing, and more.
Locates the codesign
command-line utility required for code signing macOS applications.
find_codesign(<result>)
An output variable where the path to the codesign tool will be stored.
Locates the iconutil
command-line utility used for manipulating macOS icon sets (.icns
files).
find_iconutil(<result>)
An output variable where the path to the iconutil tool will be stored.
Generates a macOS Entitlements.plist
file for specifying special permissions required by the application.
add_macos_entitlements(
<target>
[DESTINATION <path>]
ENTITLEMENTS <entitlement...>
)
The name of the CMake target to create.
The location to save the generated Entitlements.plist
. Defaults to "Entitlements.plist"
in the build directory.
A list of entitlement keys to be included.
Creates a macOS icon set (.icns
file) from a collection of image files.
add_macos_iconset(
[DESTINATION <path>]
ICONS [<path> 16|32|64|128|256|512 1x|2x]...
[DEPENDS <target...>]
)
The name of the CMake target to create.
The output location for the .icns
file. Defaults to "icon.icns"
in the build directory.
A sequence of arguments specifying:
-
<path>
: Path to the image file. -
<size>
: Size of the icon variant (e.g., 16, 32, 128) -
<scale>
: Scale factor (e.g., 1x, 2x)
Generates the Info.plist
file with macOS application metadata.
add_macos_bundle_info(
<target>
[DESTINATION <path>]
NAME <string>
VERSION <string>
DISPLAY_NAME <string>
PUBLISHER_DISPLAY_NAME <string>
IDENTIFIER <identifier>
CATEGORY <string>
[TARGET <target>]
[EXECUTABLE <path>]
)
The name of the CMake target to create.
Specifies the location to save the Info.plist
file. Defaults to "Info.plist"
in the build directory.
The name of the application.
The semantic version of the application.
The name displayed to users. Defaults to "${NAME}"
.
The name of the publisher.
A unique bundle identifier for the application.
Category for the app in the macOS App Store or Finder.
An existing CMake target representing the main application executable.
Path to the application executable. Use if not providing the TARGET
option.
The core function to create a complete macOS application bundle (.app
file).
add_macos_bundle(
<target>
DESTINATION <path>
[INFO <path>]
[ICON <path>]
[TARGET <target>]
[EXECUTABLE <path>]
[RESOURCES [FILE|DIR <from> <to>]...]
[DEPENDS <target...>]
)
The name of the CMake target to create for the macOS application.
The desired output path for the generated application bundle.
Path to an Info.plist
file. Defaults to "Info.plist"
in the build directory.
Path to a .icns
file containing the application icon. Defaults to "icon.icns"
in the build directory.
Name of a CMake target representing the core executable of the application.
Direct path to the application executable. Use if not providing TARGET
.
A list of additional resources to include in the app bundle.
Copies a single file from <from>
to <to>
location within the Resources
directory of the bundle.
Copies an entire directory from <from>
to <to>
within the Resources
directory of the bundle.
A list of CMake targets on which the bundle creation process depends.
Code signs a macOS application or bundle, enhancing security.
code_sign_macos(
<target>
[PATH <path>]
[TARGET <target>]
[ENTITLEMENTS <path>]
IDENTITY <string>
[KEYCHAIN <string>]
[DEPENDS <target...>]
)
The name of the CMake target to create.
The path to the macOS application bundle or executable to be signed.
A CMake target representing the application to be signed. Alternative to providing PATH
.
The path to an Entitlements.plist
file specifying permissions for the application. Defaults to "Entitlements.plist"
in the build directory.
The code signing identity to use.
The path to the keychain containing the code signing certificate and private key.
Apache-2.0