CPack:如何执行多个CPACK_NSIS_EXTRA_INSTALL_COMMANDS?

时间:2015-07-03 09:18:50

标签: cmake nsis cpack

我正在使用CMake 2.8.11.2,CPack和NSIS编写安装程序。我来到了需要调用像MSVCR这样的子安装程序的地步。这是我的CMakeLists.txt的样子:

set(CPACK_GENERATOR NSIS)
list ( APPEND CPACK_NSIS_EXTRA_INSTALL_COMMANDS " ExecWait ./tmp/vcredist_x64.exe")
list ( APPEND CPACK_NSIS_EXTRA_INSTALL_COMMANDS " ExecWait ./tmp/some-other-installer.exe")
list ( APPEND CPACK_NSIS_EXTRA_INSTALL_COMMANDS " RMDir /r ./tmp/")
INCLUDE(CPack)

但是,生成的.nsi文件包含以下(单行)

ExecWait ./tmp/vcredist_x64.exe; ExecWait ./tmp/some-other-installer.exe; RMDir /r ./tmp/

导致错误“ExecWait在生成包时需要1-2个参数,得到6个”。

如何正确地将多个额外命令传递给NSIS?

1 个答案:

答案 0 :(得分:5)

要添加多个命令,需要将CPACK_NSIS_EXTRA_INSTALL_COMMANDS设置为多行字符串:

list ( APPEND CPACK_NSIS_EXTRA_INSTALL_COMMANDS ...
...
string (REPLACE ";" "\n" CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}")
include(CPack)