Merge topic 'autogen-write-access'

610464c1 QtAutogen: Ensure write access to AutogenInfo.cmake (#15416)
This commit is contained in:
Brad King 2015-03-23 09:18:38 -04:00 committed by CMake Topic Stage
commit 114ddb072c
1 changed files with 14 additions and 0 deletions

View File

@ -22,6 +22,8 @@
# include "cmLocalVisualStudioGenerator.h"
#endif
#include <sys/stat.h>
#include <cmsys/Terminal.h>
#include <cmsys/ios/sstream>
#include <cmsys/FStream.hxx>
@ -582,6 +584,18 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target)
makefile->ConfigureFile(inputFile.c_str(), outputFile.c_str(),
false, true, false);
// Ensure we have write permission in case .in was read-only.
mode_t perm = 0;
#if defined(WIN32) && !defined(__CYGWIN__)
mode_t mode_write = S_IWRITE;
#else
mode_t mode_write = S_IWUSR;
#endif
cmSystemTools::GetPermissions(outputFile, perm);
if (!(perm & mode_write))
{
cmSystemTools::SetPermissions(outputFile, perm | mode_write);
}
if (!configDefines.empty()
|| !configIncludes.empty()
|| !configUicOptions.empty())