Wednesday, July 3, 2013

Making 64-bit installers with CMake and NSIS

I was getting tired of my 64-bit programs getting installed by NSIS into the x86 folder under windows, just because the NSIS installer itself is 32-bit.

I started piecing the solution together from this bug report for CMake. NSIS has been ported to 64bit but the inclusion in CMake is only available in the latest release. So I had to get NSIS 64,  and latest version of CMake 2.8.11 and then make some modifications to CPack to enable the new 64-bit installer.


Change installer type to NSIS64: SET(CPACK_GENERATOR NSIS64) and re-package your application. Voila you get correct program file target location and here is a screenshot of the running application just for fun.
Some products such as PCL do a platform detection while building to suggest an install folder, using the snippet below. This method will also work if you don't feel like installing NSIS64.

if(CMAKE_CL_64)
    set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64")
    set(win_system_name win64)
 else(CMAKE_CL_64)
    set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES32")
    set(win_system_name win32)
 endif(CMAKE_CL_64)

No comments: