[CMake] How to work around permission deficiencies of file(GENERATE...)?

Alan W. Irwin irwin at beluga.phys.uvic.ca
Thu Apr 30 15:16:20 EDT 2015


On 2015-04-30 19:54+0200 Stephen Kelly wrote:

> Alan W. Irwin wrote:
>
>> However, until that is implemented (or configure_file(GENERATE ...) is
>> implemented with the usual configure_file permission semantics which
>> just copies the permissions of the source file) I need a method of
>> setting file permissions at generate time.  Is there currently _any_
>> way to do that under CMake?
>
> Yes, CMake 3.2 uses the permissions of the input file if present:
>
> http://www.cmake.org/gitweb?p=cmake.git;a=commitdiff;h=81afbbc0
>
> I recommend trying that for your use, and if it works, I think setting
> CMP0026 to OLD for CMake >= 3.0 && < 3.2 would be ok.

Hi Steve:

I tried 3.2 (actually 3.2.1) and indeed permissions problems for my
configure_file_generate function were solved for that case.  So thanks
for anticipating that change was needed, and it appears I finally have
a way forward with CMP0026 NEW for CMake 3.2 and above which is a big
relief to me!

In the meanwhile our CMake minimum version is going to be 3.0.2
probably for the next two years or so.  (Our rule of thumb is we
update the minimum version of CMake to whatever Debian stable [= the
just-released Debian Jessie] supplies so that most of our Linux users
will not have to build a CMake version for themselves.) But instead of
reverting all of the CMP0026 changes I have made, I plan to
temporarily add a custom target in my configure_file_generate function
called WORKAROUND_CMP0026_NEW_<OUTPUT_FILE_NAME> to make the necessary
permission changes for the CMake >= 3.0 && < 3.2 case, and then add a
dependency on that target where needed in the rest of our build
system.  This approach makes all this cruft easy to remove once we
eventually bump our minimum version of CMake to 3.2.

I am philosophical about all these complications with CMP0026 NEW.  It
is just the nature of the software beast that changes like CMP0026 NEW
take a while to get right, and I am pleased you are moving in the
right direction with changes like your commit above.  But please keep
in mind that the configure_file_generate function approach is itself a
temporary workaround, and for CMake users who need to configure files
that include generator expressions, a much cleaner approach will be
possible if CMake developers implement a configure_file(... GENERATE
...) signature which configures generator expression items (and also
configures all other items at generate time that configure_file
without the GENERATE option configures at configure time).
And if you do decide to implement something like that, I would be
happy to test it for you.

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