Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cmake : How to change file permissions when installing?

I have a file with 660 flags set, but I want to install it with 700 flags set.

How do I do it? How to change the file permission, without changing the permissions of the source file?


My install command is this :

install(
    FILES common.sh
    DESTINATION /rootfs/usr/bin
)

and this is what I tried (but it doesn't work) :

install(
    FILES common.sh
    FILE_PERMISSIONS "600"
    DESTINATION /rootfs/usr/bin
)
like image 587
BЈовић Avatar asked Oct 16 '13 09:10

BЈовић


People also ask

How do I specify the install directory in CMake?

The installation directory is usually left at its default, which is /usr/local . Installing software here ensures that it is automatically available to users. It is possible to specify a different installation directory by adding -DCMAKE_INSTALL_PREFIX=/path/to/install/dir to the CMake command line.

Can CMake install dependencies?

Dependencies do not necessarily have to be pre-built in order to use them with CMake. They can be built from sources as part of the main project. The FetchContent module provides functionality to download content (typically sources, but can be anything) and add it to the main project if the dependency also uses CMake.

What does install in CMake do?

CMake provides the install command to specify how a project is to be installed. This command is invoked by a project in the CMakeLists file and tells CMake how to generate installation scripts. The scripts are executed at install time to perform the actual installation of files.


1 Answers

There is no FILE_PERMISSIONS argument in install(FILES ...). Use PERMISSIONS instead:

install(
    FILES common.sh
    PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
    DESTINATION /rootfs/usr/bin
)
like image 143
Fraser Avatar answered Oct 16 '22 01:10

Fraser