harperville
harperville

Reputation: 7659

Change an existing file's permissions using cmake

I have a component that I install onto my Linux distro using cmake. There is a file on my machine on which I'd like to change permissions - I want to make it non-executable.

My use case is this:

There is a directory that contains several files. A process periodically executes all of the files in that directory if they are executable. When I install my program, I would like to make one of those files non-executable and drop my executable file(s) in that directory to be used by the system instead.

I found the file manipulation section in the cmake docs but the FILE_PERMISSIONS feature requires that I include a COPY or INSTALL of a file in order to use it.

How does one update file permissions on a file that already exists on the system? I haven't tried anything yet because I don't see any support for such a feature.

Honestly, this seems a little beyond cmake's reach (manipulating files outside of my project) so if there is an alternative way to solve this cleanly, I'm open to ideas. I'd like it to be tied to my existing application's installation procedure (hence my desire to utilize cmake).

Upvotes: 1

Views: 871

Answers (1)

arrowd
arrowd

Reputation: 34411

Write a shell script that changes permissions and run it during installation using install(CODE "execute_process(COMMAND \"yourscript.sh\")".

Upvotes: 2

Related Questions