[CMake] CPack - Windows 7 x64

David Cole david.cole at kitware.com
Tue Jan 3 21:33:15 EST 2012


On Tue, Jan 3, 2012 at 8:05 PM, Nicholas Yue <yue.nicholas at gmail.com> wrote:
>
> Hi,
>
>    I am building and installing full 64bit applications and libraries.
>
>    When I package it up as an installer via NSIS, it installs to "C:\Program Files (x86)\"
>
>    What CPACK_ variables do I need to inform cpack that it should be installed in "C:\Program Files\"
>
> Regards
>
> --
> Nicholas Yue
> Graphics - RenderMan, Houdini, Visualization, OpenGL, HDF5
> Custom Dev - C++ porting, OSX, Linux, Windows
> http://au.linkedin.com/in/nicholasyue
>
> --
>
> 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



What version of CMake/CPack are you using?

As long as it's recent enough (2.8.4 or later), you can use code like
this, which CMake itself uses:

(from the CMake source tree, top level, file CMakeCPack.cmake)

  # Installers for 32- vs. 64-bit CMake:
  #  - Root install directory (displayed to end user at installer-run time)
  #  - "NSIS package/display name" (text used in the installer GUI)
  #  - Registry key used to store info about the installation
  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()

The main line to answer your direct question is:
    SET(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64")

This literal string gets used in the NSIS input, and then it is the
one that interprets that as "C:\Program Files" on a Win64
installation.

Just do something like that before including CPack, and it should do the trick.


HTH,
David


More information about the CMake mailing list