Alex Rivera | Logout

Creating Windows Desktop Icon in CMake + CPack + NSIS

Asked 2010-04-14T20:24:16.643
12

I'm using NSIS package generator in CMake 2.8.1 to distribute a Qt application. Everything is working fine... except the use of CPACK_CREATE_DESKTOP_LINKS to create a desktop link to the application.

I've looked through the CMake source (including it's own "bootstrap" installation definition for windows), and as far as I can tell I'm doing the same thing.

Here's the relevant section of my CMakeLists.txt file.


set(CPACK_GENERATOR NSIS)
set(CPACK_NSIS_PACKAGE_NAME "${EWS_APP_NAME}")
set(CPACK_NSIS_DISPLAY_NAME "${EWS_APP_NAME}")
set(CPACK_NSIS_CONTACT "${EWS_EMAIL}")
set(CPACK_PACKAGE_EXECUTABLES "${EXE_TARGET_NAME}" "${EWS_APP_NAME}")
set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CMAKE_PROJECT_NAME}-${EWS_VERSION}")

# this works
set(CPACK_NSIS_MENU_LINKS "${EWS_WEBSITE}" "Homepage for ${EWS_APP_NAME}")

# this doesn't
set(CPACK_CREATE_DESKTOP_LINKS "${EXE_TARGET_NAME}")

# Icon in the add/remove control panel. Must be an .exe file 
set(CPACK_NSIS_INSTALLED_ICON_NAME bin\\\\${EXE_TARGET_NAME}.exe)

set(CPACK_NSIS_URL_INFO_ABOUT "${EWS_WEBSITE}")
set(CPACK_NSIS_HELP_LINK "${EWS_WEBSITE}")

Any ideas or debugging tips are appreciated!

Edit
Report

1 Answer

7

One work-around I figured out is to use CPACK_NSIS_EXTRA_INSTALL_COMMANDS and CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS to insert the link creation/deletion commands directly.

set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "
    CreateShortCut \\\"$DESKTOP\\\\${EWS_APP_NAME}.lnk\\\" \\\"$INSTDIR\\\\bin\\\\${EXE_TARGET_NAME}.exe\\\"
")

set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "
    Delete \\\"$DESKTOP\\\\${EWS_APP_NAME}.lnk\\\"
")

I'd much rather use the more general (and cross-platform?) CPACK_CREATE_DESKTOP_LINKS setting, so any followup ideas are appreciated. But this works in a pinch.

answered 2010-04-15T02:38:59.180

Your Answer