[CMake] CPack Windows default CPACK_NSIS_INSTALL_ROOT

Eric Noulard eric.noulard at gmail.com
Mon Jun 10 03:21:40 EDT 2013


2013/6/10 Hugh <h.sorby at auckland.ac.nz>:
> Hi,
>
> I am using CPack to package a 64 bit library using the NSIS CPack generator
> and I am getting the "C:\Program Files (x86)\" as the default
> CPACK_NSIS_INSTALL_ROOT value.  I was expecting to get "C:\Program Files\".
> Is this the expected behaviour?

I guess, this is the historical behavior.

CPACK_NSIS_INSTALL_ROOT is (indirectly) set to "$PROGRAMFILES" (have a
look in CPack.cmake).

This "PROGRAMFILES" variable is an NSIS var, whose value corresponds
to what you observed:
http://stackoverflow.com/questions/9087538/is-programfiles-a-constant-declared-in-nsis-or-is-it-the-environment-variable-r

You can do something like the following in your CMakeLists.txt:
  if(CMAKE_CL_64)
    set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64")
    set(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} (Win64)")
    set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CPACK_PACKAGE_NAME}
${CPACK_PACKAGE_VERSION} (Win64)")
  else()
    set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES")
    set(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
    set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CPACK_PACKAGE_NAME}
${CPACK_PACKAGE_VERSION}")
  endif()

This is an excerpt from CMakeCPack.cmake found in CMake source tree.

If this default behavior is buggy, then may be you can propose a
patch, explaining why this is buggy.

--
Erk
L'élection n'est pas la démocratie -- http://www.le-message.org


More information about the CMake mailing list