CPack NSIS,为Windows生成安装程序 [英] CPack NSIS, generate installer for Windows

查看:290
本文介绍了CPack NSIS,为Windows生成安装程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在VS项目中运行数据包生成器,由于在安装目标和文件时使用了绝对路径,因此在编译时会崩溃。

I´m trying to run packet generator within a VS project, it crashes while compiling because of the use of absolute path on installation from Targets and Files.

 ABSOLUTE path INSTALL DESTINATION forbidden (by caller): ...

我检查了两次,所有安装目录都是相对的。我将很多变量设置为$ {PROJECT_BINARY_DIR}(应该是相对的)的子文件夹,例如:

I checked twice and all installation directories are relative. I set quite a lot of variables as sub-folders of ${PROJECT_BINARY_DIR} (which should be relative) such as:

set(INSTALL_DIR ${PROJECT_BINARY_DIR}/bin)
set(LIB_DIR ${PROJECT_BINARY_DIR}/bin/lib)
set(EXT_DIR ${PROJECT_BINARY_DIR}/bin/ext)
...

CMAKE / CPACK会将这些变量解释为绝对路径吗?
如果可以,是否有办法使CPack与这些变量一起正常工作?
当涉及子相对路径时,如何使用CPack?

does CMAKE/CPACK interpret those variables as absolute paths? If so, is there a way to make CPack working properly with those variables? How do I use CPack when sub-relative path are involved?

谢谢

推荐答案

好的,我知道,$ {PROJECT_BINARY_DIR}被解释为绝对路径,从该路径开始,所有子文件夹将被拒绝。

Ok I see, the ${PROJECT_BINARY_DIR} is interpreted as an ABSOLUTE path, from there all sub-folder of it will be rejected.

为避免此问题,我将安装变量放在if else块中,如果是打包的情况,则将使用相对文件夹,如下所示:

To avoid this problem I surrounded the install variables in if else blocks, and if it is the case of packaging then a relative folder will be used as follows:

if(PACK)
   set(INSTALL_DIR bin)
   set(LIB_DIR bin/lib)
   set(EXT_DIR /bin/ext)
   ...
else(PACK)
   set(INSTALL_DIR ${PROJECT_BINARY_DIR}/bin)
   set(LIB_DIR ${PROJECT_BINARY_DIR}/bin/lib)
   set(EXT_DIR ${PROJECT_BINARY_DIR}/bin/ext)
   ...
endif(PACK)

这可以解决它,但是它确实很脏,正在等待新的CPack版本上更好的功能。

this solves it, but it is really dirty, waiting for a better function on new CPack version.

ciao

这篇关于CPack NSIS,为Windows生成安装程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆