【发布时间】:2019-01-15 12:30:42
【问题描述】:
我正在尝试在 Mac 上创建系统范围的服务,使用 CMake 进行构建,使用 CPack 生成包。存储库很大,所以我创建了一个较小的版本来测试它。事实证明,我不知道如何打包具有绝对路径作为目的地的东西。
这是 CMake 代码:
install(PROGRAMS ${CMAKE_BINARY_DIR}/hello
DESTINATION "/var/local/hello"
COMPONENT TS
)
install(PROGRAMS com.hello.world.plist
DESTINATION "/Library/LaunchDaemons/"
COMPONENT TS
)
这是 cpack 的输出
mac-mini-2:build melanoholly$ cpack ..
CPack: Create package using productbuild
CPack: Install projects
CPack: - Run preinstall target for: testingPack
CPack: - Install project: testingPack
CMake Error at /Users/salvobit/sandbox/cpack-example-mac-daemon/build/cmake_install.cmake:44 (file):
file cannot create directory: /var/local/hello. Maybe need administrative
privileges.
CMake Error at /Users/salvobit/sandbox/cpack-example-mac-daemon/build/cmake_install.cmake:56 (file):
file INSTALL cannot copy file
"/Users/salvobit/sandbox/cpack-example-mac-daemon/com.hello.world.plist" to
"/Library/LaunchDaemons/com.hello.world.plist".
CPack Error: Error when generating package: testingPack
如果我以 root 身份运行 cpack,生成的包是空的。
有人可以告诉我如何解决这个问题吗?
我使用3.13.0-rc2版本的CMake。
【问题讨论】:
-
据我所知,CPack 不喜欢absolute 安装路径。不要在
install命令的 DESTINATION 选项中使用绝对路径。