CMake-CPack Package Installation Path Nightmare

扶醉桌前 提交于 2019-12-03 05:00:32

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.

Terrence

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)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!