2

我正在尝试使用 CMake 和 CPack 为我正在开发的应用程序创建和安装包(.deb 和 .rpm)。包创建得很好,但是在运行 dpkg -i mypackage.deb 后我没有在 KDE 菜单中获得条目。

以下是我正在执行的步骤:

摘自 CMakeLists.txt:

SET(CMAKE_INSTALL_PREFIX /opt/ddm)
SET(DDM_DESKTOP_DIR     ${CMAKE_INSTALL_PREFIX}/${DDM_DATA_SUBDIR}/applications/)
SET(DDM_PIXMAPS_DIR     ${CMAKE_INSTALL_PREFIX}/${DDM_DATA_SUBDIR}/pixmaps/)

INSTALL (FILES share/ddm.desktop DESTINATION ${DDM_DESKTOP_DIR})
INSTALL (FILES share/ddm.xml DESTINATION ${DDM_DESKTOP_DIR})

# Copy the ddm pixmap
INSTALL (FILES share/ddm.png DESTINATION ${DDM_PIXMAPS_DIR})

# try to set up the menu system
find_program(XDG-MIME_EXECUTABLE xdg-mime)
find_program(XDG-DESKTOP-MENU_EXECUTABLE xdg-desktop-menu)

INSTALL(CODE "
  execute_process(COMMAND ${XDG-MIME_EXECUTABLE} install --novendor ${DDM_DESKTOP_DIR}/ddm.xml)
  execute_process(COMMAND ${XDG-DESKTOP-MENU_EXECUTABLE} install --novendor ${DDM_DESKTOP_DIR}/ddm.desktop)
  execute_process(COMMAND ${XDG-MIME_EXECUTABLE} default ${DDM_DESKTOP_DIR}/ddm.desktop application/x-ddm-item)
  "
)
# Debian packages
INCLUDE (${CMAKE_MODULE_PATH}/DpkgBuild.cmake)
IF(DPKG_FOUND AND NOT WIN32)
    SET(CPACK_GENERATOR "DEB")
    SET(CPACK_DEBIAN_PACKAGE_NAME ${CPACK_PACKAGE_NAME})
    SET(CPACK_DEBIAN_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION})
    SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
    SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "${CPACK_PACKAGE_VENDOR} <${CPACK_PACKAGE_CONTACT}>")
    SET(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
    SET(CPACK_DEBIAN_PACKAGE_DEBUG ON)
    SET(CPACK_DEBIAN_PACKAGE_DEPENDS ${PACKAGE_REQUIRES})
    SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt4-gui ( >= 4.6 ), libqt4-xml ( >= 4.6 ), libqt4-sql-mysql, libmysqlclient18, libqt4-dbus, libqt4-network, libqt4-sql, libqt4-sql-mysql, libqt4-xml, libqtcore4, libqtgui4, libqtwebkit4") # Specify dependencies here
    SET(CPACK_SET_DESTDIR TRUE)
ENDIF(DPKG_FOUND AND NOT WIN32)

SET(CPACK_PACKAGE_EXECUTABLES "ddm" "DDM")
INCLUDE(CPack)

ddm.desktop 看起来像:

[Desktop Entry]
Version=0.1
Name=Database Deployment Manager
Comment=Database Deployment manager
Exec=/opt/ddm/bin/ddm %U
Icon=ddm
Terminal=false
Type=Application
Categories=Qt;Development
MimeType=application/x-ddm-item;
GenericName=Database Deployment Manager

ddm.xml 看起来像:

<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
 <mime-type type="application/x-ddm-item">
    <sub-class-of type="text/xml"/>
    <sub-class-of type="application/xml"/>
    <comment>Database Deployment Manager solution file</comment>
    <icon>ddm</icon>
    <glob pattern=".dmx" weight="50" />
    <magic priority="90">
          <match type="string" offset="2" value="!DOCTYPE DBM"/>
    </magic>
    <root-XML localName="ddm" />
  </mime-type>
 </mime-info>

现在发生的事情是,当我运行sudo make install应用程序时,应用程序会自行安装在菜单中(但没有图标),但是当我运行dpk -i package.deb应用程序时,应用程序会自行安装,但不会创建任何 kde 菜单条目......

知道我做错了什么吗?

4

1 回答 1

2

问题已解决:KDE 正在以下位置寻找图标和 .desktop 文件。

SET(DDM_DESKTOP_DIR     "/usr/share/applications/")
SET(DDM_PIXMAPS_DIR     "/usr/share/icons/")

这确实解决了问题。

于 2013-01-16T13:36:15.460 回答