CMake:CPackNSISAdvancedTips: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
(Remove leading space rectangles from preformatted blocks)
(Replace content with link to new CMake community wiki)
 
Line 1: Line 1:
=CPack NSIS Advanced Tips=
{{CMake/Template/Moved}}
Those who are comfortable with both CMake/CPack and NSIS may wish to customize their own NSIS scripts to pass through CPack.


==NSIS script file creation==
This page has moved [https://gitlab.kitware.com/cmake/community/wikis/doc/cpack/NSISAdvancedTips here].
When CPack uses the NSIS generator, it reads the following files from the modules path:
<pre>
NSIS.template.in
NSIS.InstallOptions.ini.in
</pre>
 
CPack fills in the variables and outputs it to this directory:
<pre>
${CMAKE_BINARY_DIR}\_CPack_Packages\${CPACK_TOPLEVEL_TAG}\${CPACK_GENERATOR}\
</pre>
 
Both files get their name changed to
<pre>
Project.nsi
NSIS.InstallOptions.ini
</pre>
 
To start work on a custom NSIS script, simply create a file (or copy) into your module path (e.g. CPACK_MODULE_PATH) called NSIS.template.in.  CPack will automatically use your path over the default one.
 
'''NOTE:''' It may be tempting to create custom Install options using NSIS.InstallOptions.ini.in, but it is '''NOT''' recommended.  CPack uses this file to provide the option of modifying the PATH environment variable.  Modifying this file or the references to it within NSIS.template.in may render this option useless.  If custom InstallOptions files are desired, read the next section.
 
==Integrating Custom InstallOptions files ==
At first glance, integrating a custom option file appears to be difficult, since CPack copies 2 specific files to a separate generated directory.  However, integration is really quite simple.
 
With the NSIS.template.in, look for the Function .onInit  Within this function insert the following line:
<pre>
!insertmacro INSTALLOPTIONS_EXTRACT_AS "@MY_PATH_TO_FILE@\@MY_FILENAME@" "@MY_FILENAME@"
</pre>
 
Next, look for a section that says ReserveFile.  Again, just add the line:
<pre>
ReserveFile "@MY_PATH_TO_FILE@\@MY_FILENAME@"
</pre>
 
Don't forget to define MY_PATH_TO_FILE and MY_FILENAME in either your CPackConfig file or your CMakeLists.txt
 
Now, @MY_FILENAME@ can be referenced directly anywhere in the script.
 
{{CMake/Template/Footer}}

Latest revision as of 15:40, 30 April 2018


The CMake community Wiki has moved to the Kitware GitLab Instance.

This page has moved here.