Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating an installer using CMake + CPack + Wix

Summary:

How to generate Wix installer with CMake/CPack?

Details:

I am trying to generate an installer out from a project that uses Wix, but apparently, cmake/cpack insist to use nsis, for example, from the repo https://github.com/ngladitz/cmake-wix-testsuite I picked the first example "basic" folder with the following contents for CMakeLists.txt

add_executable(hw hw.cpp)
install(TARGETS hw DESTINATION bin)

install(FILES hw.cpp DESTINATION src)

set(CPACK_WIX_UPGRADE_GUID "F9AAAAE2-D6AF-4EA4-BF46-B3E265400CC7")

include(CPack)

After generating the cmake:

cd <basic-root-folder>
mkdir MY_BUILD
cd MY_BUILD
cmake ..

I tried to run the package.vcxproj generated with

msbuild package.vcxproj

and got the error

"C:\src\Samples\CPack\cmake-wix-testsuite-master\basic\MY_BUILD\PACKAGE.vcxproj " (default target) (1) -> (PostBuildEvent target) -> EXEC : CPack error : Cannot find NSIS compiler makensis: likely it is not ins talled, or not in your PATH [C:\src\Samples\CPack\cmake-wix-testsuite-master\ba sic\MY_BUILD\PACKAGE.vcxproj]

So it looks like it insist in using the NSIS generator.

like image 931
Fernando Gonzalez Sanchez Avatar asked Apr 20 '15 17:04

Fernando Gonzalez Sanchez


2 Answers

Simply add following line before include(CPack)

set(CPACK_GENERATOR WIX)

like image 183
TingQian LI Avatar answered Sep 22 '22 07:09

TingQian LI


You can also do this:

cmake ..
cpack -G WIX

By default, CPack uses the NSIS Generator on Windows.

like image 23
Andrey G.A Avatar answered Sep 22 '22 07:09

Andrey G.A