cmake : How to change file permissions when instal

2019-04-07 08:44发布

问题:

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
)

回答1:

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
)