Installing a Mac OS X app using cmake environment, I want to set and install the icon in the process of installation.
Therefore, I try to set
set( MACOSX_BUNDLE_ICON_FILE ${CMAKE_CURRENT_SOURCE_DIR}/images/myAopImage.icns )
ADD_EXECUTABLE(MYAPP MACOSX_BUNDLE ${MACOSX_BUNDLE_ICON_FILE} ${allSources})
#(I could set it in the source directory to any other path)
However, this does not work, it writes the complete path into the Info.plist, and installs nothing into the Resources directory (the resources dir even does not get created in the app folder which gets installed)
Anyhow, even if I put by hand into the Info.plist the information
<key>CFBundleIconFile</key>
<string>myAppImage.icns</string>
and create the Resources directory by hand, putting into there the icns File,
the icon appears anyhow for the app.
How do I solve this problem? At first to do it by hand maybe, but also within the cmake context?
There are two pieces to bundling the .icns file from CMake: adding the source file itself, and configuring it in the .plist. If you want to specify a path to your .icns file (e.g. because it is in a subdirectory), then these two properties will refer to the .icns file slightly differently:
# NOTE: Don't include the path in MACOSX_BUNDLE_ICON_FILE -- this is
# the property added to Info.plist
set(MACOSX_BUNDLE_ICON_FILE myAppImage.icns)
# And this part tells CMake where to find and install the file itself
set(myApp_ICON ${CMAKE_CURRENT_SOURCE_DIR}/images/myAppImage.icns)
set_source_files_properties(${myApp_ICON} PROPERTIES
MACOSX_PACKAGE_LOCATION "Resources")
add_executable(myApp MACOSX_BUNDLE ${myApp_ICON} ${allSources})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With