[CMake] CPack : NSIS - registry key setting/over-riding

David Cole david.cole at kitware.com
Wed Apr 25 09:17:42 EDT 2012


On Wed, Apr 25, 2012 at 8:21 AM, Eric Noulard <eric.noulard at gmail.com> wrote:
> 2012/4/25 Nicholas Yue <yue.nicholas at gmail.com>:
>> Hi,
>>
>>  As part of my NSIS packaged installer, I need to register an
>> environment variable e.g. MYSOFTWARE_PATH
>>
>>  I see the variable CPACK_PACKAGE_INSTALL_REGISTRY_KEY but am unsure
>> about the syntax
>>
>>  I tried the following but it didn't work
>>
>>  SET ( CPACK_PACKAGE_INSTALL_REGISTRY_KEY
>>        "HKEY_CURRENT_USER\\\\Environment\\\\MYSOFTWARE_PATH C:\\\\MyApp"
>>        )
>
> The CMake provided NSIS template (Modules/NSIS.template.in) does:
>
> WriteRegStr SHCTX
> "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
> "" $INSTDIR
>
> so I bet you normally do:
> SET(CPACK_PACKAGE_VENDOR "Me")
> SET (CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${MYSOFTWARE_NAME}")
>
> and get "Software\me\MySoftware" installed in the registry.
>
> not quite what you want because SHCTX means:
> SHCTX or SHELL_CONTEXT, it will be replaced with HKLM if
> SetShellVarContext is set to all and with HKCU if SetShellVarContext
> is set to current.
> see:
> http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.2.14
>
>>  Do I have to create the registry key in the first place ? If so, can CPack do that ?
>
> I think you'll have to write your own "NSIS.template.in" and make CPack use it
> (put it in CMAKE_MODULE_PATH or CPACK_MODULE_PATH)
>
> --
> Erk
> Le gouvernement représentatif n'est pas la démocratie --
> http://www.le-message.org
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake

You could also write your own extra NSIS code and put it in the CPack
variables CPACK_NSIS_EXTRA_INSTALL_COMMANDS and
CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS. Those will be configured into the
NSIS template file.


HTH,
David


More information about the CMake mailing list