MantisBT - CMake
View Issue Details
0015416CMakeCMakepublic2015-02-24 04:042015-11-02 09:13
Gunnar Roth 
 
normalminoralways
closedfixed 
WindowsWindows 7
CMake 3.1.2 
CMake 3.3CMake 3.3 
0015416: AutogenInfo.cmake broken when Modules/AutogenInfo.cmake.in is read-only
we are using TFS from Microsoft as version control system, TFS does set the readonly flag on all non checked out files. we have cmake checked in so everybody gets the right version of it when building our software ( we also maintain some modifications to cmake).
the problem is that cmake does not remove readonly flag from its *.in files when copying, so modification fails.

our current workaround is that we do a
EXECUTE_PROCESS( COMMAND cmd /C attrib /S -R "${CMAKE_ROOT}/Modules/*.in" ERROR_QUIET)

but i would like it better, if cmake would be aware of files having readonly attribut set and remove that when copying the file.

regards,
Gunnar
No tags attached.
Issue History
2015-02-24 04:04Gunnar RothNew Issue
2015-02-24 09:00Brad KingNote Added: 0038049
2015-02-25 05:27Gunnar RothNote Added: 0038061
2015-02-25 09:51Brad KingNote Added: 0038065
2015-03-20 10:18Brad KingNote Added: 0038263
2015-03-20 10:24Brad KingSummarycmake does not remove readonly flag from its *.in files when copying, so modification fails. => AutogenInfo.cmake broken when Modules/AutogenInfo.cmake.in is read-only
2015-03-20 10:39Brad KingNote Added: 0038264
2015-03-20 10:39Brad KingStatusnew => resolved
2015-03-20 10:39Brad KingResolutionopen => fixed
2015-03-20 10:39Brad KingFixed in Version => CMake 3.3
2015-03-20 10:39Brad KingTarget Version => CMake 3.3
2015-11-02 09:13Robert MaynardNote Added: 0039739
2015-11-02 09:13Robert MaynardStatusresolved => closed

Notes
(0038049)
Brad King   
2015-02-24 09:00   
There are many parts of CMake that copy files. Please post instructions for the use case in question.
(0038061)
Gunnar Roth   
2015-02-25 05:27   
well in our case we get an error when creating a qt 5 project using automoc feature and create vs 2012 solutions and vcxprojs.
the error message is CMake Error: Internal CMake error when trying to open file: E:/TIA/bld/WM5_HmiIL_Proto_RenderHost/HmiGui/VS/WIN32-VS11-32/src/GfxQtRH/CMakeFiles/GfxQtRH_automoc.dir//AutogenInfo.cmake for writing.

that is because AutogenInfo.cmake is read only. It is read only because the source file cmake\share\cmake-3.2\Modules\AutogenInfo.cmake.in is also read only for the reason i mentioned above.
But that would probably happen for any other *.in file in Modules dir.
(0038065)
Brad King   
2015-02-25 09:51   
This can trigger for anything using configure_file() in CMake code or through internal C++ APIs within CMake. The command always preserves the permission of the .in file in the output file. The trouble comes when replacing it on future updates.

I think the low-level code for this is here:

 http://www.cmake.org/gitweb?p=cmake.git;a=blob;f=Source/kwsys/SystemTools.cxx;hb=v3.1.3#l2260 [^]

We already try to remove read-only files. The RemoveFile method:

 http://www.cmake.org/gitweb?p=cmake.git;a=blob;f=Source/kwsys/SystemTools.cxx;hb=v3.1.3#l2575 [^]

already tries to remove read-only permission before removing the file.

Someone will need to dig deeper to understand why it doesn't work.
(0038263)
Brad King   
2015-03-20 10:18   
Relevant mailing list thread:

 AutogenInfo.cmake With Read-Only Modules
 http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/12745 [^]
(0038264)
Brad King   
2015-03-20 10:39   
The mailing list thread in 0015416:0038263 revealed that this is specific to AutgenInfo because we configure it and then append to it. Fixed:

 QtAutogen: Ensure write access to AutogenInfo.cmake
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=610464c1 [^]
(0039739)
Robert Maynard   
2015-11-02 09:13   
Closing resolved issues that have not been updated in more than 4 months.