使用CMake设置应用程序图标 [英] Setting the application icon with CMake

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

问题描述

是否可以通过CMake设置应用程序图标的跨平台方式?我正在Qt 5.4中使用Cmake 3.0.2。

Is there a cross-platform way to set the application icon with CMake? I am using Cmake 3.0.2 with Qt 5.4.

在Qt 文档中,一种方法是

In the Qt documentation a method is shown but it is not cross-platform.

推荐答案

CMake不能为您解决这个问题。

CMake doesn't handle this for you.

在某些平台上有几个应用程序图标。例如,在遵循FreeDesktop.org标准的类似UNIX的系统上(无论是KDE,Gnome,Unity,XFCE还是其他DE-du-jour,基本上都可以在Linux上看到今天可以看到的任何内容)。通过在应用程序的 .desktop 文件中设置适当的 Icon 条目。请参见 .desktop规范有关详细信息。这就是启动器的图标,某些DE(例如最近的Plasma)将使用它作为任务栏中的窗口图标,并带有适当的主题替代。

On some platforms are are several "application icons". For example, on a UNIX-like system which follows the FreeDesktop.org standards (essentially anything you can see today on Linux, no matter if it's KDE, Gnome, Unity, XFCE or some other DE-du-jour), this is done by setting an appropriate Icon entry in the application's .desktop file. See the .desktop spec for details. This is what gets shown as a launcher's icon, and some DEs such as the recent Plasma will use this for a window icon in the taskbar, with appropriate theme overrides.

也许您也正在交付Windows安装程序,也许基于NSIS。然后,您也应该在 .nsi 中指定它。

Maybe you are shipping a Windows installer, too, perhaps based on the NSIS. Then you should probably specify this in your .nsi as well.

实际的窗口图标是应该设置的也由程序员来完成。如您所见,在很多地方都可以设置应用程序图标。如果您正在寻找真实的示例,请查看Trojitá的源代码。寻找通过CMake进行的实际图标文件安装,NSIS代码,创建Windows RC文件,最后从C ++代码设置应用程序图标。

Actual window icons are something which should be set up by the programmer, too. As you can see, there's plenty of places where an "application icon" might be set. If you're looking for a real-world example, check out Trojitá's source code. Look for actual icon file installation through CMake, for the NSIS code, for creating a Windows RC file, and finally for setting the application icon from the C++ code.

这篇关于使用CMake设置应用程序图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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