[CMake] How to work around permission deficiencies of file(GENERATE...)? (was cmp0026, file(GENERATE...), and configure_file)

David Cole DLRdave at aol.com
Wed Apr 29 20:36:49 EDT 2015


It seems like a reasonable feature request to me to ask for
file(GENERATE to support a similar or sub-set of permissions related
options which other file subcommands already provide:

    [FILE_PERMISSIONS <permissions>...]
    [NO_SOURCE_PERMISSIONS] [USE_SOURCE_PERMISSIONS]

Doesn't seem like it should be that hard to add support incrementally
for that feature...


D



On Wed, Apr 29, 2015 at 7:18 PM, Alan W. Irwin
<irwin at beluga.phys.uvic.ca> wrote:
> While attempting to use the configure_file_generate function discussed
> in a recent thread here, I discovered a permission deficiency of the
> file(GENERATE ...) command which was that permissions are not copied
> from input file to output file like they are with configure_file.
>
> @CMake developers: was this treatment of permissions by design or is
> this a bug in the implementation of the file(GENERATE...) command that
> you are willing to fix?
>
> Here is my initial (non-working) attempt to work around this issue
> in my configure_file_generate function.
>
> [...]
>   # Configure generator expressions.
>   # N.B. these ${output_file} results will only be available
>   # at generate time.
>   file(GENERATE
>     OUTPUT ${output_file}
>     INPUT ${intermediate_file}
>     )
>
>   if(UNIX OR MSYS)
>     # This covers all platforms which have permissions,
>     # i.e., Unix, Cygwin, and MSYS platforms.
>
>     # Work around bad permission semantics of file(GENERATE...) which
>     # does not copy permissions from input file.  Note this --reference
>     # syntax is probably a non-posix extension of the GNU version of chmod.
>     # So this will silently fail to change permissions
>     # on platforms without access to the GNU version of chmod.
>     execute_process(
>       COMMAND chmod --reference=${intermediate_file} ${output_file}
>       )
>   endif(UNIX OR MSYS)
>
> Obviously this workaround does not currently work since
> execute_process occurs at configure time rather than generate time as
> can be seen from these results:
>
> software at raven> ls -l examples/tk/tk01*
> -rw-r--r-- 1 software software 3692 Apr 29 15:45 examples/tk/tk01
> -rwxr-xr-x 1 software software 3658 Apr 29 15:45 examples/tk/tk01_cf_only*
>
> where the first file (with bad permissions) is the ${output_file} and
> the second file the ${intermediate_file} used in the
> configure_file_generate function.
>
> Is there any method I can use at generate time to change permissions
> on the OUTPUT file generated by file(GENERATE...), e.g., is there any
> way I can force execute_process to work at generate time?
>
> Of course, I could fix permissions at build time, but that is a big
> maintenance issue trying to keep track of every file processed by
> configure_file_generate so I would far prefer to change the
> permissions at generate time within the configure_file_generate
> function.
>
> 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
> __________________________
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake


More information about the CMake mailing list