MantisBT - CMake
View Issue Details
0014522CMakeCPackpublic2013-10-29 12:052016-06-10 14:31
Mark Stijnman 
Kitware Robot 
normalminoralways
closedmoved 
CMake 2.8.12 
 
0014522: CPACK_NSIS_DEFINES doesn't work in component-based installer
I need to add some options to my NSIS installer, and noticed in the NSIS.template.in there is a variable CPACK_NSIS_DEFINES that looked suitable. Even though it doesn't appear to be documented, I've found mentions online of users who have used this variable for similar purposes (for example http://www.cmake.org/pipermail/cmake/2009-April/028592.html [^] and http://public.kitware.com/Bug/view.php?id=5939 [^]), so apparently this used to work. However, it doesn't use for my project. When I tried to create a minimal example, it worked again. Turns out that the problem only shows up when you use a component-based installer. In that case, the contents of the CPACK_NSIS_DEFINES variable don't make it into the project.nsi file at all. If I check the source code in cmCPackNSISGenerator.cxx, I see that its value is overwritten in function PackageFiles when components are present.
Use the following as a CMakeLists.txt file:
--- CMakeLists.txt begin

cmake_minimum_required(VERSION 2.8)

project(cpack_nsis_defines_test)
set(test_file "${CMAKE_CURRENT_BINARY_DIR}/test.txt")
file(WRITE ${test_file} "test")
install(FILES ${test_file} DESTINATION . COMPONENT test)
set(CPACK_COMPONENTS_ALL test)
set(CPACK_NSIS_DEFINES " !define MUI_WELCOMEPAGE_TITLE_3LINES")
include(CPack)

--- CMakeLists.txt end

If you build the PACKAGE target, and run the installer, you will notice that the MUI_WELCOMEPAGE_TITLE_3LINES didn't have any effect. If you check the project.nsi file that is generated, you see that the MUI_WELCOMEPAGE_TITLE_3LINES option is not there. If you comment out the "CPACK_COMPONENTS_ALL" line, it will work as expected.
The issue can be fixed by modifying the PackageFile function such that any old value of CPACK_NSIS_DEFINES is stored in the "defines" variable first, before new values are appended to it. A patch is attached.
patch
patch cpack_nsis_defines_fix.patch (938) 2013-10-29 12:05
https://public.kitware.com/Bug/file/4929/cpack_nsis_defines_fix.patch
Issue History
2013-10-29 12:05Mark StijnmanNew Issue
2013-10-29 12:05Mark StijnmanFile Added: cpack_nsis_defines_fix.patch
2013-10-31 05:13Mark StijnmanTag Attached: patch
2014-11-01 02:59Kai PastorNote Added: 0037126
2016-06-10 14:29Kitware RobotNote Added: 0042406
2016-06-10 14:29Kitware RobotStatusnew => resolved
2016-06-10 14:29Kitware RobotResolutionopen => moved
2016-06-10 14:29Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0037126)
Kai Pastor   
2014-11-01 02:59   
I would like to see this, too. Please solve this bug as proposed, and make CPACK_NSIS_DEFINES a documented variable. Alternatively, provide a documented CPACK_NSIS_EXTRA_DEFINES (similar to CPACK_NSIS_EXTRA_INSTALL_COMMANDS).

(I use this hook to deal with installing to 64 bit systems, i.e. as a workaround for issues related to http://public.kitware.com/Bug/view.php?id=9094 [^])
(0042406)
Kitware Robot   
2016-06-10 14:29   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.