Reputation: 15152
I would like to turn on the setuid
bit for a program I'm installing using install(TARGETS...
in cmake
.
I can do this using the PERMISSIONS
clause and specify SETUID
. But when I do this, I lose all the default permissions unless I specify all of those, too.
For example, if this were bash, it would be like running chmod u=s,g=,o= file
instead of chmod u+s file
-- all the existing permissions are turned off instead of just masking in the one permission you want to add.
Is there a mechanism in cmake
to add a permission to an installed target without repeating all the default permissions?
Upvotes: 0
Views: 2480
Reputation: 66061
CMake has no other ways for set permissions for installed files except PERMISSIONS option for install
command. But there are many ways for simplify permissions settings.
For example, you can define variable, contained default permissions set:
set(PROGRAM_PERMISSIONS_DEFAULT
OWNER_WRITE OWNER_READ OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
and use it as base for add new permissions:
install(TARGETS myexe ... PERMISSIONS ${PROGRAM_PERMISSIONS_DEFAULT} SETUID)
If some set of permissions is used in many places, you can define variable, contained that set, and use it when needed:
set(PROGRAM_PERMISSIONS_BY_ROOT ${PROGRAM_PERMISSIONS_DEFAULT} SETUID)
...
install(TARGETS myexe ... PERMISSIONS ${PROGRAM_PERMISSIONS_BY_ROOT})
Upvotes: 3