cmake:设置mac osx应用程序的图标 [英] cmake: set icon for a mac osx app

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

问题描述

使用cmake环境安装Mac OSX应用程序,我想在安装过程中设置和安装图标

installing a Mac OSX app using cmake environment, I want to set and install the icon in 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目录中安装任何内容(资源dir甚至没有得到安装的应用程序文件夹中创建

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>

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

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?

感谢您的回答.....

Thanks for your answers.....

推荐答案

要将icns文件复制到Resources文件夹,您需要在其上设置一个源属性。

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 osx应用程序的图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆