本文介绍了cmake:为Mac OS X应用设置图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用cmake环境安装Mac OS X应用程序,我要设置和安装图标在安装过程中.

Installing a Mac OS X app using cmake environment, I want to set and install the iconin the process of installation.

因此,我尝试设置

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)

但是,这不起作用,它将完整的路径写入Info.plist,并什么都没有安装到Resources目录中(资源目录甚至没有得到在安装的应用文件夹中创建)

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 getcreated 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>

并手动创建Resources目录,将icns文件放入其中,

and create the Resources directory by hand, putting into there the icns File,

无论如何该图标都会出现在应用程序中.

the icon appears anyhow for the app.

如何解决此问题?起初也许是手工完成的,但是也可以在cmake上下文中完成?

How do I solve this problem? At first to do it by hand maybe, but also within the cmake context?

推荐答案

要将icns文件复制到资源"文件夹,您需要在其上设置源属性.

To copy the icns file to your Resources folder, you need to set a source property on it.

set_source_files_properties(myAppImage.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")

此外,我在某处读到plist中的字符串不需要.icns,所以

Also, I read somewhere that the string in the plist does not require the .icns, so

<string>myAppImage</string>

应该没事的.

这篇关于cmake:为Mac OS X应用设置图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 11:43