Vilda
Vilda

Reputation: 1793

Including NSIS script in CMake

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)?

Upvotes: 1

Views: 1655

Answers (1)

Vilda
Vilda

Reputation: 1793

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.

Upvotes: 2

Related Questions