1

Is it possible to include an NSIS script from CMake that uses CPack together with NSIS? It appears that I'm limited to only a few commands (doc), but some commands suggest that there is a way to include the whole NSIS script, particulary:

CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS,
CPACK_NSIS_EXTRA_INSTALL_COMMANDS,
CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS

However, when I try to call these commands:

SET(CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS "!include extra_preinstall.nsh")

Nothing happens. (Excluding /NONFATAL throws an error, so presumably the script cannot be found.)

Checking basic functionality:

SET(CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS "MessageBox MB_OK \\\"Hello world!\\\"")

Doesn't do anything with the installer.

Why doesn't a Hello World button appear? Why is the script file not found (even though I put it on every level of CMake hiearchy)?

4
  • Years ago I just modified the NSIS script that comes with CMake to add the features I needed.
    – drescherjm
    Commented Jun 8, 2017 at 16:34
  • I looked into that, which affirmed my feeling, that there MUST be a way to include an external NSIS script.
    – Vilda
    Commented Jun 8, 2017 at 16:36
  • I name my replacement NSIS script as NSIS.template.in and put it in my local modules folder that is added via the command list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake/External/Modules)
    – drescherjm
    Commented Jun 8, 2017 at 17:03
  • @drescherjm I've resolved this slightly differently. Thanks anyway! :)
    – Vilda
    Commented Jun 8, 2017 at 17:30

1 Answer 1

2

Preinstall doesn't mean that it's executed before the install section, so you actually have to click "install", then the command is executed. The same goes for Install and Uninstall.

As for including external scripts: including with absolute path solves everything. If absolute path is not available, it can be easily obtained using CMake tools.

Not the answer you're looking for? Browse other questions tagged or ask your own question.