CMake-CPack包安装路径噩梦 [英] CMake-CPack Package Installation Path Nightmare
问题描述
CMake-CPack 让我沮丧了将近一周.
I've been frustrated by the the CMake-CPack for almost one week.
不好的是 CMake-CPack 在线文档没有很好地记录这部分.
The bad thing is the CMake-CPack online documentation does not document this part well.
谷歌搜索后,我发现要使用这个变量:
After googling, I found this variables to use:
CPACK_PACKAGING_PREFIX # NOT documented
CMAKE_INSTALL_PREFIX # Documented, but the behavior seems weird
CPACK_INSTALL_PREFIX # NOT documented
CPACK_PACKAGE_INSTALL_DIRECTORY # Documented, but this variable does NOT work as the online document described
CPACK_PACKAGING_INSTALL_PREFIX # NOT documented
我要做的是:使用 fakeroot make package
打包一个 Debian 包,当该包由 sudo dpkg -i MyProgramPackageName
安装时,将其安装到 /usr/local
,带有一个子目录 MyProgramPackageName
.也就是说,所有文件都应该安装在/usr/local/MyProgramPackageName-V.1.2.3
下.
What I am trying to do is: package a Debian package using fakeroot make package
, when the package is installed by sudo dpkg -i MyProgramPackageName
, install it to /usr/local
, with a subdirectory MyProgramPackageName
. That is, all files should be installed under /usr/local/MyProgramPackageName-V.1.2.3
.
我一直在尝试(CMake 2.8.3 和 CMake 2.8.5)调整这些变量.我尝试了很多组合,但都失败了.
I've been trying (CMake 2.8.3 and CMake 2.8.5) to tune these variables. I tried so many combinations, but failed.
成功的唯一方法是:
Set(CPACK_PACKAGING_INSTALL_PREFIX /usr/local/MyProgramPackageName-V.1.2.3)
但是这个变量甚至没有记录,并且无法保证行为.如果您对我的问题感到困惑,请告诉我何时使用 CPACK_PACKAGE_INSTALL_DIRECTORY
?因为关于这个变量的文档描述非常吸引人,这确实是我想要的,但我就是无法让它工作.
But this variable is NOT even documented, and the behavior cannot be guaranteed. If you are confused with my question, please advise me when to use CPACK_PACKAGE_INSTALL_DIRECTORY
? because the documentation description about this variable is really attractive, and it is really what I want, but I just could not make it working.
请给我建议.
彼得
推荐答案
我没有找到任何支持这一点的文档,但我确实找到了一些错误报告和电子邮件存档,似乎表明以下是你应该做的正在做:
I didn't find any documentation to support this, but I did find some bug reports and email archives that seem to suggest that the following is what you should be doing:
set(CPACK_SET_DESTDIR true)
set(CPACK_INSTALL_PREFIX /opt/MySuperAwesomePrefix-v.1.2.3)
如果未设置 CPACK_INSTALL_PREFIX,则默认为 CMAKE_INSTALL_PREFIX.现在 install(... DESTINATION dest)
的相对路径将在您的包文件中以 CPACK_INSTALL_PREFIX/dest 结束.这在我尝试生成 deb 文件时有效.
If CPACK_INSTALL_PREFIX is not set, it will default to CMAKE_INSTALL_PREFIX. Now relative paths from install(... DESTINATION dest)
will end up as CPACK_INSTALL_PREFIX/dest inside your package file. This worked when I tried to generate a deb file.
这篇关于CMake-CPack包安装路径噩梦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!