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屋!