[CMake] How to set execute permissions on a CMake-configured file at cmake time?

Alan W. Irwin irwin at beluga.phys.uvic.ca
Fri Oct 18 05:04:45 EDT 2013


I currently control the execution permission bits on CMake-configured
files by setting those same bits on the "*.in" file that is the
configuration template for the configured file.  (I assume from
experience that CMake configuration simply copies the permission bits
of the template file to the configured file, but I don't think that is
documented anywhere).

Anyhow, this solution for setting the execution permissions bits is
clumsy and also is a technical error since the template file is
never meant to be executed.  In fact, the CMake-based fundamental
build system for PLplot installs a second CMake-based build system that
helps to build and test the installed PLplot example files.  And
rpmlint rightly complains about the execute permissions in
the *.in template files that are part of that second build system.

So I prefer to not have the execute permissions set for the template
files, but the execute permissions should be set for the corresponding
configured files at cmake time when those files are configured.  But
the configure_file command says nothing about permissions.  So is
there some other cmake logic I can use to accomplish that trick
at cmake time?

I suppose I could use execute_process with COMMAND set to chmod for
Unix platforms that support chmod and permissions, but that is a bit
messy, and I would prefer a pure CMake approach for setting
permissions of configured files at cmake time if one is available.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list