Is there a cross-platform way to set the application icon with CMake? I am using Cmake 3.0.2 with Qt 5.4.
In the Qt documentation a method is shown but it is not cross-platform.
CMake doesn't handle this for you.
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.
Maybe you are shipping a Windows installer, too, perhaps based on the NSIS. Then you should probably specify this in your .nsi
as well.
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.
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