CMake rpm在/etc/init.d中安装文件 [英] CMake rpm installing a file in /etc/init.d
问题描述
我想在
/etc/init.d目录中安装文件
I want to install a file in /etc/init.d directory
我已经编写了代码
INSTALL(FILES ${CMAKE_SOURCE_DIR}/app/script/appd DESTINATION /etc/init.d/appd)
但是当我使用cmake运行打包代码时出现错误
but when I run packing code using cmake I get error
CMake Error at /home/vivek/workspace/app/build/standalone/cmake_install.cmake:54 (FILE):
file cannot create directory: /etc/init.d/appd. Maybe need
administrative privileges.
如何设置cmake在/etc/init.d目录中安装文件?
How can I set cmake to install a file inside /etc/init.d directory ?
推荐答案
您可以执行此操作,但是您可能需要明确设置:
You can do this, but you may need to explicitly set:
set(CPACK_SET_DESTDIR ON)
在以下条件之前:
include(CPack)
in您的CMakeLists.txt文件。 (您仅需要针对2.8.3之前的CMake / CPack上的旧版本执行此操作)
in your CMakeLists.txt file. (You will need to do this only for older versions on CMake/CPack, prior to 2.8.3)
执行此操作的原因是您指定了一个全路径名,作为已安装文件之一的目的地。为了在打包阶段正确执行此操作,CPack需要在其 make install调用中使用DESTDIR环境变量。
The reason you need to do this is that you are specifying a full path name as the DESTINATION of one of your installed files. In order to do that properly in the packing phase, CPack needs to use a DESTDIR environment variable in its "make install" call.
我们并没有自动执行此操作
We didn't do this automatically by default for backwards compatibility reasons.
但是后来,此错误已在2.8.3版中修复,因此可以透明且自动地使用使用完整路径名的安装规则来完成此错误。 :
But then, this bug was fixed in version 2.8.3 so that it could be done transparently and automatically with install rules that use full path names:
http:/ /public.kitware.com/Bug/view.php?id=7000
希望您可以使用CPACK_SET_DESTDIR将rpm包设为ON,或者使用包含自动修复程序的最新版本的CMake / CPack。
Hopefully, you can use either CPACK_SET_DESTDIR to ON for your rpm packages, OR use a more recent version of CMake/CPack that includes the automatic fix.
这篇关于CMake rpm在/etc/init.d中安装文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!