我试图在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如果我以根用户身份运行cpack,则生成的包是空的。
谁能告诉我怎么解决这个问题吗?
我使用3.13.0-rc2版本的CMake。
发布于 2019-02-05 08:53:22
解决这个问题的关键是将CMAKE_INSTALL_PREFIX指定为
set(CMAKE_INSTALL_PREFIX "/")当您这样做时,您可以在/var/中安装路径
install(PROGRAMS <binary>
DESTINATION "../var")https://stackoverflow.com/questions/54198929
复制相似问题