Linux – How do I create a desktop icon for a deb package created with CPack?

How do I create a desktop icon for a deb package created with CPack?… here is a solution to the problem.

How do I create a desktop icon for a deb package created with CPack?

I’m using CMake/CPack for my project.
On Windows, I use CPack with NSIS and everything is fine. But for Linux, I use CPack’s DEB generator and I’m having some problems. That said, I can’t find the right way to add icons to Gnome/KDE/etc’s menu. I know I can create the app.desktop file and put it in /usr/share/applications. But are there some other (recommended) ways to do this using CPack?

Solution

It seems that the best way (and actually not bad) is
Create a MyApp.desktop file and add the following to CMakeLists.txt:

INSTALL(FILES MyApp.desktop DESTINATION share/applications)

Related Problems and Solutions