i’m trying to customize a NSIS installer generated via CPack.
Specifically, we do not need shortcuts and a custom install location, since the location of the to-be-installed files is fixed, and choosing a custom location for the uninstaller isn’t really necessary either- we’d like to make the installation process as seamless as possible.
I haven’t found any CMake / CPack variables to control this behaviour, therefore i turned to changing the NSIS-installer code directly.
I found out that the following is necessary to achieve our desired behaviour:
Abort skips the page, the
!define MUI_PAGE_CUSTOMFUNCTION_PRE skipPage just before the insertion of the macro calls the function after the opening of the page)
... Function skipPage Abort FunctionEnd ... !insertmacro MUI_PAGE_WELCOME !define MUI_PAGE_CUSTOMFUNCTION_PRE skipPage !insertmacro MUI_PAGE_DIRECTORY ... !define MUI_PAGE_CUSTOMFUNCTION_PRE skipPage !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER
However, i don’t know how to effectively and portably change the installer script in the cpack step.
Of course, i could simply modify the template file located in the cmake-modules folder, but i really dont want to do that.
My thought was that at some point the template from the modules-folder must be translated into the actual file that is used for generating the installer- at this point i could modify the script using
However, it seems that the points in time i can execute custom cmake scripts simply do not allow for this kind of modification:
CPACK_INSTALL_SCRIPTS: At this time the template isn’t translated into the actual installer script yet.
CPACK_PRE_BUILD_SCRIPTS: Same as above
CPACK_POST_BUILD_SCRIPTS: Here the installer is already generated.
I know that there are the
CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS and others, which would probably allow me to introduce the
skipPage function, but i also need to add lines at very specific places in the file too, and i don’t see any way of doing so using the other NSIS CPack-variables
So to sum up, i need to execute a script right after the NSIS installer template is translated- is there anything different i could try here?
All the best,