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

Eric Noulard eric.noulard at gmail.com
Wed Apr 25 08:21:31 EDT 2012


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


More information about the CMake mailing list