CMake-CPack包安装路径噩梦

发布于 2024-11-25 01:42:41 字数 1075 浏览 1 评论 0原文

我对 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

只等公子 2024-12-02 01:42:41

我没有找到任何文档来支持这一点,但我确实找到了一些错误报告和电子邮件档案,它们似乎表明您应该执行以下操作:

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 文件时,这有效。

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)

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.

小傻瓜 2024-12-02 01:42:41

CPACK 使用的路径取自 CMakeLists.txt 文件中的 INSTALL 指令。这允许结果包镜像“make install”将执行的操作。这使 CPACK 配置保持在最低限度。

因此,从示例 CMakeLists.txt 文件中:

INSTALL(TARGETS ${APPLICATION} DESTINATION bin)

这将安装到 /usr/bin 或 /usr/local/bin。如果您想将其放在子目录中,可以在此处执行:

INSTALL(TARGETS ${APPLICATION} DESTINATION bin/myappdir)

或完全不同的目录:

INSTALL(TARGETS ${APPLICATION} DESTINATION /opt/foo/bar)

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:

INSTALL(TARGETS ${APPLICATION} DESTINATION bin)

This will install to /usr/bin or /usr/local/bin. If you wanted to place it in a subdirectory you could do it here:

INSTALL(TARGETS ${APPLICATION} DESTINATION bin/myappdir)

Or entirely different directory:

INSTALL(TARGETS ${APPLICATION} DESTINATION /opt/foo/bar)
穿越时光隧道 2024-12-02 01:42:41

因此,当前的 cmake 3.31 CPACK_PACKAGING_INSTALL_PREFIX 适合我MacOs(我还没有检查Linux),例如:

set(CPACK_PACKAGING_INSTALL_PREFIX "/Users/Shared/Autodesk/ApplicationAddins/application-plugin-name")

正确放置我的包文件

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:

set(CPACK_PACKAGING_INSTALL_PREFIX "/Users/Shared/Autodesk/ApplicationAddins/application-plugin-name")

Properly place my package files

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文