CMake-CPack包安装路径噩梦
我对 CMake-CPack 感到沮丧近一周了。
不好的是 CMake-CPack 在线文档没有很好地记录这一部分。
谷歌搜索后,我发现这个变量可以使用:
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
我想做的是:当通过sudo dpkg -i MyProgramPackageNamefakeroot make package
打包Debian软件包code>,将其安装到 /usr/local
,并有一个子目录 MyProgramPackageName
。也就是说,所有文件都应安装在 /usr/local/MyProgramPackageName-V.1.2.3
下。
我一直在尝试(CMake 2.8.3 和 CMake 2.8.5)调整这些变量。我尝试了很多组合,但都失败了。
唯一成功的方法是:
Set(CPACK_PACKAGING_INSTALL_PREFIX /usr/local/MyProgramPackageName-V.1.2.3)
但是这个变量甚至没有记录,并且无法保证行为。如果您对我的问题感到困惑,请告诉我何时使用CPACK_PACKAGE_INSTALL_DIRECTORY
?因为关于这个变量的文档描述非常有吸引力,而且它确实是我想要的,但我就是无法让它工作。
请告诉我。
彼得
I've been frustrated by the the CMake-CPack for almost one week.
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
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
.
I've been trying (CMake 2.8.3 and CMake 2.8.5) to tune these variables. I tried so many combinations, but failed.
The only way succeeded is:
Set(CPACK_PACKAGING_INSTALL_PREFIX /usr/local/MyProgramPackageName-V.1.2.3)
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.
Please advise me.
Peter
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我没有找到任何文档来支持这一点,但我确实找到了一些错误报告和电子邮件档案,它们似乎表明您应该执行以下操作:
如果未设置 CPACK_INSTALL_PREFIX,则它将默认为 CMAKE_INSTALL_PREFIX。现在,来自
install(... DESTINATION dest)
的相对路径最终将在包文件中显示为 CPACK_INSTALL_PREFIX/dest 。当我尝试生成 deb 文件时,这有效。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:
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.CPACK 使用的路径取自 CMakeLists.txt 文件中的 INSTALL 指令。这允许结果包镜像“make install”将执行的操作。这使 CPACK 配置保持在最低限度。
因此,从示例 CMakeLists.txt 文件中:
这将安装到 /usr/bin 或 /usr/local/bin。如果您想将其放在子目录中,可以在此处执行:
或完全不同的目录:
The paths used by the CPACK are taken from the INSTALL directives in your CMakeLists.txt files. This allows the result package to mirror what a 'make install' would do. This keeps the CPACK configuration to a minimum.
So, from an example CMakeLists.txt file:
This will install to /usr/bin or /usr/local/bin. If you wanted to place it in a subdirectory you could do it here:
Or entirely different directory:
因此,当前的 cmake 3.31 CPACK_PACKAGING_INSTALL_PREFIX 适合我MacOs(我还没有检查Linux),例如:
正确放置我的包文件
So with current cmake 3.31 CPACK_PACKAGING_INSTALL_PREFIX is what works for me on MacOs (I have yet to check on Linux), for instance:
Properly place my package files