[Cmake-commits] CMake branch, next, updated. v3.8.0-rc2-369-gfddee0f

Kitware Robot kwrobot at kitware.com
Fri Mar 3 14:05:03 EST 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  fddee0f94de26cd9540becfca7ad81716023f767 (commit)
       via  de21e3afaad243f15577d8bc1b20a76c563680d7 (commit)
       via  c3eb88e23d958676dd7bd3435d2005341a4caca3 (commit)
       via  ef4e1e86441b515c60b4a1dfcf1c1e5e66ca1d76 (commit)
       via  28878dbdd49dce43a15a98062696af30f26800cf (commit)
       via  59dd1e390e1fdc1391cd81c08a300716a8a6c10c (commit)
       via  614917f70e292763b14b1c388e92714bac31fa9c (commit)
       via  505ed4e76f3043cdb5d45effc4791455136560df (commit)
       via  eae0b2823cb000db9a78881a517538a8a7fb7286 (commit)
       via  c511576c620ecbc614591722ad1b381c8a7d2528 (commit)
       via  4ef593ed4940229437dbbad7707a6461846318f8 (commit)
       via  bdec46b75eb93427aafb70d2d5e9d6601fda26a4 (commit)
       via  c52eecc303f8cb3de406d788914a2071cef4e60f (commit)
       via  86e4fcadd5edc38a9291366de61ca9fe63eae4f8 (commit)
       via  04ecb9a1df0ec91c1e6eb0eefb3719b84ac85dab (commit)
       via  f9531b373f27367ac0d8c4beae474768b7745b59 (commit)
       via  100723035ac228187e60f549dd38c8f89c447b40 (commit)
       via  09be79c707ac6999ebad689bcf83b2cbcd3cd4a2 (commit)
       via  1ee20805d3b0ed67dad7c2835d673c98961736ef (commit)
       via  5ce0b3e7ce885931c2ffdf04c0a9ffc69a91e2f4 (commit)
      from  e7e939058d568a7aac9952386057fc869c240a9e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fddee0f94de26cd9540becfca7ad81716023f767
commit fddee0f94de26cd9540becfca7ad81716023f767
Merge: de21e3a c3eb88e
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Fri Mar 3 18:58:53 2017 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Fri Mar 3 13:58:57 2017 -0500

    Stage topic 'working-directory-fixes'
    
    Topic-id: 22824
    Topic-url: https://gitlab.kitware.com/cmake/cmake/merge_requests/540


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=de21e3afaad243f15577d8bc1b20a76c563680d7
commit de21e3afaad243f15577d8bc1b20a76c563680d7
Merge: e7e9390 ef4e1e8
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Fri Mar 3 18:55:51 2017 +0000
Commit:     Kitware Robot <kwrobot at kitware.com>
CommitDate: Fri Mar 3 13:55:55 2017 -0500

    Stage topic 'autogen_common'
    
    Topic-id: 22843
    Topic-url: https://gitlab.kitware.com/cmake/cmake/merge_requests/543


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c3eb88e23d958676dd7bd3435d2005341a4caca3
commit c3eb88e23d958676dd7bd3435d2005341a4caca3
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Wed Apr 6 14:23:55 2016 -0400
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Fri Mar 3 09:56:21 2017 -0500

    cmWorkingDirectory: use the new class
    
    These functions just need to change the directory for a block of code
    and then go back to the caller's expected location. Use
    cmWorkingDirectory to ensure that all return paths are handled.

diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx
index 9d9cd66..cc01b0c 100644
--- a/Source/CPack/cmCPackArchiveGenerator.cxx
+++ b/Source/CPack/cmCPackArchiveGenerator.cxx
@@ -7,6 +7,7 @@
 #include "cmCPackLog.h"
 #include "cmGeneratedFileStream.h"
 #include "cmSystemTools.h"
+#include "cmWorkingDirectory.h"
 
 #include <map>
 #include <ostream>
@@ -37,9 +38,8 @@ int cmCPackArchiveGenerator::addOneComponentToArchive(
   // Add the files of this component to the archive
   std::string localToplevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
   localToplevel += "/" + component->Name;
-  std::string dir = cmSystemTools::GetCurrentWorkingDirectory();
   // Change to local toplevel
-  cmSystemTools::ChangeDirectory(localToplevel);
+  cmWorkingDirectory workdir(localToplevel);
   std::string filePrefix;
   if (this->IsOn("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY")) {
     filePrefix = this->GetOption("CPACK_PACKAGE_FILE_NAME");
@@ -64,8 +64,6 @@ int cmCPackArchiveGenerator::addOneComponentToArchive(
       return 0;
     }
   }
-  // Go back to previous dir
-  cmSystemTools::ChangeDirectory(dir);
   return 1;
 }
 
@@ -227,8 +225,7 @@ int cmCPackArchiveGenerator::PackageFiles()
   // CASE 3 : NON COMPONENT package.
   DECLARE_AND_OPEN_ARCHIVE(packageFileNames[0], archive);
   std::vector<std::string>::const_iterator fileIt;
-  std::string dir = cmSystemTools::GetCurrentWorkingDirectory();
-  cmSystemTools::ChangeDirectory(toplevel);
+  cmWorkingDirectory workdir(toplevel);
   for (fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
     // Get the relative path to the file
     std::string rp =
@@ -241,7 +238,6 @@ int cmCPackArchiveGenerator::PackageFiles()
       return 0;
     }
   }
-  cmSystemTools::ChangeDirectory(dir);
   // The destructor of cmArchiveWrite will close and finish the write
   return 1;
 }
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index e1a4a2a..f6ea8cf 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -16,6 +16,7 @@
 #include "cmGlobalGenerator.h"
 #include "cmMakefile.h"
 #include "cmStateSnapshot.h"
+#include "cmWorkingDirectory.h"
 #include "cmXMLSafe.h"
 #include "cm_auto_ptr.hxx"
 #include "cmake.h"
@@ -383,7 +384,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
         goToDir += "/" + subdir;
         cmCPackLogger(cmCPackLog::LOG_DEBUG, "Change dir to: " << goToDir
                                                                << std::endl);
-        cmSystemTools::ChangeDirectory(goToDir);
+        cmWorkingDirectory workdir(goToDir);
         for (symlinkedIt = symlinkedFiles.begin();
              symlinkedIt != symlinkedFiles.end(); ++symlinkedIt) {
           cmCPackLogger(cmCPackLog::LOG_DEBUG, "Will create a symlink: "
@@ -408,7 +409,6 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
         }
         cmCPackLogger(cmCPackLog::LOG_DEBUG, "Going back to: " << curDir
                                                                << std::endl);
-        cmSystemTools::ChangeDirectory(curDir);
       }
     }
   }
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx
index 6780a0e..6f81429 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.cxx
+++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx
@@ -6,6 +6,7 @@
 #include "cmCTestTestHandler.h"
 #include "cmGlobalGenerator.h"
 #include "cmSystemTools.h"
+#include "cmWorkingDirectory.h"
 #include "cmake.h"
 
 #include <cmsys/Process.h>
@@ -42,7 +43,7 @@ int cmCTestBuildAndTestHandler::ProcessHandler()
 int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring,
                                          std::ostringstream& out,
                                          std::string& cmakeOutString,
-                                         std::string& cwd, cmake* cm)
+                                         cmake* cm)
 {
   unsigned int k;
   std::vector<std::string> args;
@@ -85,8 +86,6 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring,
   if (cm->Run(args) != 0) {
     out << "Error: cmake execution failed\n";
     out << cmakeOutString << "\n";
-    // return to the original directory
-    cmSystemTools::ChangeDirectory(cwd);
     if (outstring) {
       *outstring = out.str();
     } else {
@@ -99,8 +98,6 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring,
     if (cm->Run(args) != 0) {
       out << "Error: cmake execution failed\n";
       out << cmakeOutString << "\n";
-      // return to the original directory
-      cmSystemTools::ChangeDirectory(cwd);
       if (outstring) {
         *outstring = out.str();
       } else {
@@ -199,13 +196,12 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
   double clock_start = cmSystemTools::GetTime();
 
   // make sure the binary dir is there
-  std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
   out << "Internal cmake changing into directory: " << this->BinaryDir
       << std::endl;
   if (!cmSystemTools::FileIsDirectory(this->BinaryDir)) {
     cmSystemTools::MakeDirectory(this->BinaryDir.c_str());
   }
-  cmSystemTools::ChangeDirectory(this->BinaryDir);
+  cmWorkingDirectory workdir(this->BinaryDir);
 
   if (this->BuildNoCMake) {
     // Make the generator available for the Build call below.
@@ -217,7 +213,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
     cm.LoadCache(this->BinaryDir);
   } else {
     // do the cmake step, no timeout here since it is not a sub process
-    if (this->RunCMake(outstring, out, cmakeOutString, cwd, &cm)) {
+    if (this->RunCMake(outstring, out, cmakeOutString, &cm)) {
       return 1;
     }
   }
@@ -304,8 +300,6 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
     } else {
       cmCTestLog(this->CTest, ERROR_MESSAGE, out.str());
     }
-    // return to the original directory
-    cmSystemTools::ChangeDirectory(cwd);
     return 1;
   }
 
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.h b/Source/CTest/cmCTestBuildAndTestHandler.h
index 5885738..af082a3 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.h
+++ b/Source/CTest/cmCTestBuildAndTestHandler.h
@@ -46,7 +46,7 @@ protected:
   ///! Run CMake and build a test and then run it as a single test.
   int RunCMakeAndTest(std::string* output);
   int RunCMake(std::string* outstring, std::ostringstream& out,
-               std::string& cmakeOutString, std::string& cwd, cmake* cm);
+               std::string& cmakeOutString, cmake* cm);
 
   std::string Output;
 
diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx
index ead1c26..120c5d9 100644
--- a/Source/CTest/cmCTestCoverageHandler.cxx
+++ b/Source/CTest/cmCTestCoverageHandler.cxx
@@ -12,6 +12,7 @@
 #include "cmParseJacocoCoverage.h"
 #include "cmParsePHPCoverage.h"
 #include "cmSystemTools.h"
+#include "cmWorkingDirectory.h"
 #include "cmXMLWriter.h"
 #include "cmake.h"
 
@@ -969,9 +970,8 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
 
   std::string testingDir = this->CTest->GetBinaryDir() + "/Testing";
   std::string tempDir = testingDir + "/CoverageInfo";
-  std::string currentDirectory = cmSystemTools::GetCurrentWorkingDirectory();
   cmSystemTools::MakeDirectory(tempDir.c_str());
-  cmSystemTools::ChangeDirectory(tempDir);
+  cmWorkingDirectory workdir(tempDir);
 
   int gcovStyle = 0;
 
@@ -1294,7 +1294,6 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
     }
   }
 
-  cmSystemTools::ChangeDirectory(currentDirectory);
   return file_count;
 }
 
@@ -1340,7 +1339,6 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
     return 0;
   }
   std::string testingDir = this->CTest->GetBinaryDir();
-  std::string currentDirectory = cmSystemTools::GetCurrentWorkingDirectory();
 
   std::set<std::string> missingFiles;
 
@@ -1362,7 +1360,7 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
     cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "." << std::flush,
                        this->Quiet);
     std::string fileDir = cmSystemTools::GetFilenamePath(*it);
-    cmSystemTools::ChangeDirectory(fileDir);
+    cmWorkingDirectory workdir(fileDir);
     std::string command = "\"" + lcovCommand + "\" " + lcovExtraFlags + " ";
 
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
@@ -1552,7 +1550,6 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
     }
   }
 
-  cmSystemTools::ChangeDirectory(currentDirectory);
   return file_count;
 }
 
@@ -1591,13 +1588,8 @@ bool cmCTestCoverageHandler::FindLCovFiles(std::vector<std::string>& files)
   gl.RecurseOff(); // No need of recurse if -prof_dir${BUILD_DIR} flag is
                    // used while compiling.
   gl.RecurseThroughSymlinksOff();
-  std::string prevBinaryDir;
   std::string buildDir = this->CTest->GetCTestConfiguration("BuildDirectory");
-  if (cmSystemTools::ChangeDirectory(buildDir)) {
-    cmCTestLog(this->CTest, ERROR_MESSAGE, "Error changing directory to "
-                 << buildDir << std::endl);
-    return false;
-  }
+  cmWorkingDirectory workdir(buildDir);
 
   // Run profmerge to merge all *.dyn files into dpi files
   if (!cmSystemTools::RunSingleCommand("profmerge")) {
@@ -1605,11 +1597,9 @@ bool cmCTestCoverageHandler::FindLCovFiles(std::vector<std::string>& files)
     return false;
   }
 
-  prevBinaryDir = cmSystemTools::GetCurrentWorkingDirectory();
-
   // DPI file should appear in build directory
   std::string daGlob;
-  daGlob = prevBinaryDir;
+  daGlob = buildDir;
   daGlob += "/*.dpi";
   cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
                      "   looking for dpi files in: " << daGlob << std::endl,
diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx
index 2a67d47..c99e450 100644
--- a/Source/CTest/cmCTestHandlerCommand.cxx
+++ b/Source/CTest/cmCTestHandlerCommand.cxx
@@ -6,6 +6,7 @@
 #include "cmCTestGenericHandler.h"
 #include "cmMakefile.h"
 #include "cmSystemTools.h"
+#include "cmWorkingDirectory.h"
 #include "cmake.h"
 
 #include <sstream>
@@ -216,8 +217,7 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args,
       handler->SetSubmitIndex(atoi(this->Values[ct_SUBMIT_INDEX]));
     }
   }
-  std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory();
-  cmSystemTools::ChangeDirectory(
+  cmWorkingDirectory workdir(
     this->CTest->GetCTestConfiguration("BuildDirectory"));
   int res = handler->ProcessHandler();
   if (this->Values[ct_RETURN_VALUE] && *this->Values[ct_RETURN_VALUE]) {
@@ -243,7 +243,6 @@ bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args,
     this->Makefile->AddDefinition(this->Values[ct_CAPTURE_CMAKE_ERROR],
                                   returnString);
   }
-  cmSystemTools::ChangeDirectory(current_dir);
   return true;
 }
 
diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx
index c1724ab..ff465ab 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.cxx
+++ b/Source/CTest/cmCTestMultiProcessHandler.cxx
@@ -7,6 +7,7 @@
 #include "cmCTestScriptHandler.h"
 #include "cmCTestTestHandler.h"
 #include "cmSystemTools.h"
+#include "cmWorkingDirectory.h"
 
 #include <algorithm>
 #include <cmsys/FStream.hxx>
@@ -138,8 +139,7 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test)
     }
   }
 
-  std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory();
-  cmSystemTools::ChangeDirectory(this->Properties[test]->Directory);
+  cmWorkingDirectory workdir(this->Properties[test]->Directory);
 
   // Lock the resources we'll be using
   this->LockResources(test);
@@ -166,7 +166,6 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test)
     this->Failed->push_back(this->Properties[test]->Name);
     delete testRun;
   }
-  cmSystemTools::ChangeDirectory(current_dir);
 }
 
 void cmCTestMultiProcessHandler::LockResources(int index)
@@ -683,9 +682,7 @@ void cmCTestMultiProcessHandler::PrintTestList()
     count++;
     cmCTestTestHandler::cmCTestTestProperties& p = *it->second;
 
-    // push working dir
-    std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory();
-    cmSystemTools::ChangeDirectory(p.Directory);
+    cmWorkingDirectory workdir(p.Directory);
 
     cmCTestRunTest testRun(this->TestHandler);
     testRun.SetIndex(p.Index);
@@ -724,8 +721,6 @@ void cmCTestMultiProcessHandler::PrintTestList()
     cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, " ", this->Quiet);
     cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, p.Name << std::endl,
                        this->Quiet);
-    // pop working dir
-    cmSystemTools::ChangeDirectory(current_dir);
   }
 
   cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, std::endl
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx
index ac1644f..f148f30 100644
--- a/Source/CTest/cmCTestRunTest.cxx
+++ b/Source/CTest/cmCTestRunTest.cxx
@@ -7,6 +7,7 @@
 #include "cmCTestTestHandler.h"
 #include "cmProcess.h"
 #include "cmSystemTools.h"
+#include "cmWorkingDirectory.h"
 
 #include <cmConfigure.h>
 #include <cm_curl.h>
@@ -270,14 +271,11 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
     *this->TestHandler->LogFile << "Test time = " << buf << std::endl;
   }
 
-  // Set the working directory to the tests directory
-  std::string oldpath = cmSystemTools::GetCurrentWorkingDirectory();
-  cmSystemTools::ChangeDirectory(this->TestProperties->Directory);
-
-  this->DartProcessing();
-
-  // restore working directory
-  cmSystemTools::ChangeDirectory(oldpath);
+  // Set the working directory to the tests directory to process Dart files.
+  {
+    cmWorkingDirectory workdir(this->TestProperties->Directory);
+    this->DartProcessing();
+  }
 
   // if this is doing MemCheck then all the output needs to be put into
   // Output since that is what is parsed by cmCTestMemCheckHandler
@@ -356,11 +354,8 @@ bool cmCTestRunTest::StartAgain()
   }
   this->RunAgain = false; // reset
   // change to tests directory
-  std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory();
-  cmSystemTools::ChangeDirectory(this->TestProperties->Directory);
+  cmWorkingDirectory workdir(this->TestProperties->Directory);
   this->StartTest(this->TotalNumberOfTests);
-  // change back
-  cmSystemTools::ChangeDirectory(current_dir);
   return true;
 }
 
diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx
index 5e5119d..cc399b0 100644
--- a/Source/CTest/cmCTestSubmitHandler.cxx
+++ b/Source/CTest/cmCTestSubmitHandler.cxx
@@ -19,6 +19,7 @@
 #include "cmState.h"
 #include "cmSystemTools.h"
 #include "cmThirdParty.h"
+#include "cmWorkingDirectory.h"
 #include "cmXMLParser.h"
 #include "cmake.h"
 
@@ -1519,7 +1520,6 @@ int cmCTestSubmitHandler::ProcessHandler()
 #endif
   } else if (dropMethod == "scp") {
     std::string url;
-    std::string oldWorkingDirectory;
     if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty()) {
       url += this->CTest->GetCTestConfiguration("DropSiteUser") + "@";
     }
@@ -1528,19 +1528,16 @@ int cmCTestSubmitHandler::ProcessHandler()
 
     // change to the build directory so that we can uses a relative path
     // on windows since scp dosn't support "c:" a drive in the path
-    oldWorkingDirectory = cmSystemTools::GetCurrentWorkingDirectory();
-    cmSystemTools::ChangeDirectory(buildDirectory);
+    cmWorkingDirectory workdir(buildDirectory);
 
     if (!this->SubmitUsingSCP(this->CTest->GetCTestConfiguration("ScpCommand"),
                               "Testing/" + this->CTest->GetCurrentTag(), files,
                               prefix, url)) {
-      cmSystemTools::ChangeDirectory(oldWorkingDirectory);
       cmCTestLog(this->CTest, ERROR_MESSAGE,
                  "   Problems when submitting via SCP" << std::endl);
       ofs << "   Problems when submitting via SCP" << std::endl;
       return -1;
     }
-    cmSystemTools::ChangeDirectory(oldWorkingDirectory);
     cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
                        "   Submission successful" << std::endl, this->Quiet);
     ofs << "   Submission successful" << std::endl;
@@ -1550,22 +1547,18 @@ int cmCTestSubmitHandler::ProcessHandler()
 
     // change to the build directory so that we can uses a relative path
     // on windows since scp dosn't support "c:" a drive in the path
-    std::string oldWorkingDirectory =
-      cmSystemTools::GetCurrentWorkingDirectory();
-    cmSystemTools::ChangeDirectory(buildDirectory);
+    cmWorkingDirectory workdir(buildDirectory);
     cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
                        "   Change directory: " << buildDirectory << std::endl,
                        this->Quiet);
 
     if (!this->SubmitUsingCP("Testing/" + this->CTest->GetCurrentTag(), files,
                              prefix, location)) {
-      cmSystemTools::ChangeDirectory(oldWorkingDirectory);
       cmCTestLog(this->CTest, ERROR_MESSAGE,
                  "   Problems when submitting via CP" << std::endl);
       ofs << "   Problems when submitting via cp" << std::endl;
       return -1;
     }
-    cmSystemTools::ChangeDirectory(oldWorkingDirectory);
     cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
                        "   Submission successful" << std::endl, this->Quiet);
     ofs << "   Submission successful" << std::endl;
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index 6175e50..9d22065 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -27,6 +27,7 @@
 #include "cmState.h"
 #include "cmStateSnapshot.h"
 #include "cmSystemTools.h"
+#include "cmWorkingDirectory.h"
 #include "cmXMLWriter.h"
 #include "cm_auto_ptr.hxx"
 #include "cm_utf8.h"
@@ -86,22 +87,24 @@ bool cmCTestSubdirCommand::InitialPass(std::vector<std::string> const& args,
       // No subdirectory? So what...
       continue;
     }
-    cmSystemTools::ChangeDirectory(fname);
-    const char* testFilename;
-    if (cmSystemTools::FileExists("CTestTestfile.cmake")) {
-      // does the CTestTestfile.cmake exist ?
-      testFilename = "CTestTestfile.cmake";
-    } else if (cmSystemTools::FileExists("DartTestfile.txt")) {
-      // does the DartTestfile.txt exist ?
-      testFilename = "DartTestfile.txt";
-    } else {
-      // No CTestTestfile? Who cares...
-      continue;
+    bool readit = false;
+    {
+      cmWorkingDirectory workdir(fname);
+      const char* testFilename;
+      if (cmSystemTools::FileExists("CTestTestfile.cmake")) {
+        // does the CTestTestfile.cmake exist ?
+        testFilename = "CTestTestfile.cmake";
+      } else if (cmSystemTools::FileExists("DartTestfile.txt")) {
+        // does the DartTestfile.txt exist ?
+        testFilename = "DartTestfile.txt";
+      } else {
+        // No CTestTestfile? Who cares...
+        continue;
+      }
+      fname += "/";
+      fname += testFilename;
+      readit = this->Makefile->ReadDependentFile(fname.c_str());
     }
-    fname += "/";
-    fname += testFilename;
-    bool readit = this->Makefile->ReadDependentFile(fname.c_str());
-    cmSystemTools::ChangeDirectory(cwd);
     if (!readit) {
       std::string m = "Could not find include file: ";
       m += fname;
@@ -109,7 +112,6 @@ bool cmCTestSubdirCommand::InitialPass(std::vector<std::string> const& args,
       return false;
     }
   }
-  cmSystemTools::ChangeDirectory(cwd);
   return true;
 }
 
@@ -149,9 +151,7 @@ bool cmCTestAddSubdirectoryCommand::InitialPass(
     return false;
   }
 
-  std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
-  cmSystemTools::ChangeDirectory(cwd);
-  std::string fname = cwd;
+  std::string fname = cmSystemTools::GetCurrentWorkingDirectory();
   fname += "/";
   fname += args[0];
 
@@ -159,23 +159,23 @@ bool cmCTestAddSubdirectoryCommand::InitialPass(
     // No subdirectory? So what...
     return true;
   }
-  cmSystemTools::ChangeDirectory(fname);
-  const char* testFilename;
-  if (cmSystemTools::FileExists("CTestTestfile.cmake")) {
-    // does the CTestTestfile.cmake exist ?
-    testFilename = "CTestTestfile.cmake";
-  } else if (cmSystemTools::FileExists("DartTestfile.txt")) {
-    // does the DartTestfile.txt exist ?
-    testFilename = "DartTestfile.txt";
-  } else {
-    // No CTestTestfile? Who cares...
-    cmSystemTools::ChangeDirectory(cwd);
-    return true;
+  bool readit = false;
+  {
+    const char* testFilename;
+    if (cmSystemTools::FileExists("CTestTestfile.cmake")) {
+      // does the CTestTestfile.cmake exist ?
+      testFilename = "CTestTestfile.cmake";
+    } else if (cmSystemTools::FileExists("DartTestfile.txt")) {
+      // does the DartTestfile.txt exist ?
+      testFilename = "DartTestfile.txt";
+    } else {
+      // No CTestTestfile? Who cares...
+      return true;
+    }
+    fname += "/";
+    fname += testFilename;
+    readit = this->Makefile->ReadDependentFile(fname.c_str());
   }
-  fname += "/";
-  fname += testFilename;
-  bool readit = this->Makefile->ReadDependentFile(fname.c_str());
-  cmSystemTools::ChangeDirectory(cwd);
   if (!readit) {
     std::string m = "Could not find include file: ";
     m += fname;
diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx
index c189419..b8c76b9 100644
--- a/Source/cmDepends.cxx
+++ b/Source/cmDepends.cxx
@@ -7,6 +7,7 @@
 #include "cmLocalGenerator.h"
 #include "cmMakefile.h"
 #include "cmSystemTools.h"
+#include "cmWorkingDirectory.h"
 
 #include <cmsys/FStream.hxx>
 #include <sstream>
@@ -75,13 +76,7 @@ bool cmDepends::Check(const char* makeFile, const char* internalFile,
                       std::map<std::string, DependencyVector>& validDeps)
 {
   // Dependency checks must be done in proper working directory.
-  std::string oldcwd = ".";
-  if (this->CompileDirectory != ".") {
-    // Get the CWD but do not call CollapseFullPath because
-    // we only need it to cd back, and the form does not matter
-    oldcwd = cmSystemTools::GetCurrentWorkingDirectory(false);
-    cmSystemTools::ChangeDirectory(this->CompileDirectory);
-  }
+  cmWorkingDirectory workdir(this->CompileDirectory);
 
   // Check whether dependencies must be regenerated.
   bool okay = true;
@@ -93,11 +88,6 @@ bool cmDepends::Check(const char* makeFile, const char* internalFile,
     okay = false;
   }
 
-  // Restore working directory.
-  if (oldcwd != ".") {
-    cmSystemTools::ChangeDirectory(oldcwd);
-  }
-
   return okay;
 }
 
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index b6b7d9e..1f5e624 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -42,6 +42,7 @@
 #include "cmStateDirectory.h"
 #include "cmStateTypes.h"
 #include "cmVersion.h"
+#include "cmWorkingDirectory.h"
 #include "cmake.h"
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
@@ -1763,8 +1764,7 @@ int cmGlobalGenerator::Build(const std::string& /*unused*/,
   /**
    * Run an executable command and put the stdout in output.
    */
-  std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
-  cmSystemTools::ChangeDirectory(bindir);
+  cmWorkingDirectory workdir(bindir);
   output += "Change Dir: ";
   output += bindir;
   output += "\n";
@@ -1804,8 +1804,6 @@ int cmGlobalGenerator::Build(const std::string& /*unused*/,
       output += *outputPtr;
       output += "\nGenerator: execution of make clean failed.\n";
 
-      // return to the original directory
-      cmSystemTools::ChangeDirectory(cwd);
       return 1;
     }
     output += *outputPtr;
@@ -1828,8 +1826,6 @@ int cmGlobalGenerator::Build(const std::string& /*unused*/,
     output += "\nGenerator: execution of make failed. Make command was: " +
       makeCommandStr + "\n";
 
-    // return to the original directory
-    cmSystemTools::ChangeDirectory(cwd);
     return 1;
   }
   output += *outputPtr;
@@ -1842,7 +1838,6 @@ int cmGlobalGenerator::Build(const std::string& /*unused*/,
     retVal = 1;
   }
 
-  cmSystemTools::ChangeDirectory(cwd);
   return retVal;
 }
 
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index c75d101..204fd8f 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -36,6 +36,7 @@
 #include "cmTest.h"
 #include "cmTestGenerator.h" // IWYU pragma: keep
 #include "cmVersion.h"
+#include "cmWorkingDirectory.h"
 #include "cm_auto_ptr.hxx"
 #include "cmake.h"
 
@@ -3147,8 +3148,7 @@ int cmMakefile::TryCompile(const std::string& srcdir,
 
   // change to the tests directory and run cmake
   // use the cmake object instead of calling cmake
-  std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
-  cmSystemTools::ChangeDirectory(bindir);
+  cmWorkingDirectory workdir(bindir);
 
   // make sure the same generator is used
   // use this program as the cmake to be run, it should not
@@ -3162,8 +3162,6 @@ int cmMakefile::TryCompile(const std::string& srcdir,
                          this->GetGlobalGenerator()->GetName() +
                          "' could not be created.");
     cmSystemTools::SetFatalErrorOccured();
-    // return to the original directory
-    cmSystemTools::ChangeDirectory(cwd);
     this->IsSourceFileTryCompile = false;
     return 1;
   }
@@ -3227,8 +3225,6 @@ int cmMakefile::TryCompile(const std::string& srcdir,
     this->IssueMessage(cmake::FATAL_ERROR,
                        "Failed to configure test project build system.");
     cmSystemTools::SetFatalErrorOccured();
-    // return to the original directory
-    cmSystemTools::ChangeDirectory(cwd);
     this->IsSourceFileTryCompile = false;
     return 1;
   }
@@ -3237,8 +3233,6 @@ int cmMakefile::TryCompile(const std::string& srcdir,
     this->IssueMessage(cmake::FATAL_ERROR,
                        "Failed to generate test project build system.");
     cmSystemTools::SetFatalErrorOccured();
-    // return to the original directory
-    cmSystemTools::ChangeDirectory(cwd);
     this->IsSourceFileTryCompile = false;
     return 1;
   }
@@ -3247,7 +3241,6 @@ int cmMakefile::TryCompile(const std::string& srcdir,
   int ret = this->GetGlobalGenerator()->TryCompile(
     srcdir, bindir, projectName, targetName, fast, output, this);
 
-  cmSystemTools::ChangeDirectory(cwd);
   this->IsSourceFileTryCompile = false;
   return ret;
 }
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index b2384cd..3af3be6 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -23,6 +23,7 @@
 #include "cmTargetLinkLibraryType.h"
 #include "cmUtils.hxx"
 #include "cmVersionConfig.h"
+#include "cmWorkingDirectory.h"
 #include "cm_auto_ptr.hxx"
 
 #if defined(CMAKE_BUILD_WITH_CMAKE)
@@ -2199,24 +2200,23 @@ int cmake::GetSystemInformation(std::vector<std::string>& args)
     resultFile += "/__cmake_systeminformation/results.txt";
   }
 
-  // now run cmake on the CMakeLists file
-  cmSystemTools::ChangeDirectory(destPath);
-  std::vector<std::string> args2;
-  args2.push_back(args[0]);
-  args2.push_back(destPath);
-  std::string resultArg = "-DRESULT_FILE=";
-  resultArg += resultFile;
-  args2.push_back(resultArg);
-  int res = this->Run(args2, false);
+  {
+    // now run cmake on the CMakeLists file
+    cmWorkingDirectory workdir(destPath);
+    std::vector<std::string> args2;
+    args2.push_back(args[0]);
+    args2.push_back(destPath);
+    std::string resultArg = "-DRESULT_FILE=";
+    resultArg += resultFile;
+    args2.push_back(resultArg);
+    int res = this->Run(args2, false);
 
-  if (res != 0) {
-    std::cerr << "Error: --system-information failed on internal CMake!\n";
-    return res;
+    if (res != 0) {
+      std::cerr << "Error: --system-information failed on internal CMake!\n";
+      return res;
+    }
   }
 
-  // change back to the original directory
-  cmSystemTools::ChangeDirectory(cwd);
-
   // echo results to stdout if needed
   if (writeToStdout) {
     FILE* fin = cmsys::SystemTools::Fopen(resultFile, "r");

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ef4e1e86441b515c60b4a1dfcf1c1e5e66ca1d76
commit ef4e1e86441b515c60b4a1dfcf1c1e5e66ca1d76
Author:     Sebastian Holtermann <sebholt at xwmw.org>
AuthorDate: Fri Mar 3 15:27:14 2017 +0100
Commit:     Sebastian Holtermann <sebholt at xwmw.org>
CommitDate: Fri Mar 3 15:27:14 2017 +0100

    Autogen: Test: Delay after timestamp fix

diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt
index 4dbf6cf..030b098 100644
--- a/Tests/QtAutogen/CMakeLists.txt
+++ b/Tests/QtAutogen/CMakeLists.txt
@@ -155,6 +155,7 @@ set(timeformat "%Y%j%H%M%S")
 file(TIMESTAMP "${binFile}" timeBegin "${timeformat}")
 
 # Change file content and rebuild
+execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1)
 configure_file(mocRerun/test1b.h.in mocRerun/test1.h COPYONLY)
 execute_process(COMMAND "${CMAKE_COMMAND}" --build .
   WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mocRerun"
@@ -167,7 +168,7 @@ endif()
 # Compare timestamps
 file(TIMESTAMP "${binFile}" timeStep1 "${timeformat}")
 if (NOT timeStep1 GREATER timeBegin)
-  message(SEND_ERROR "file1 (${binFile}) should have changed in the first step!")
+  message(SEND_ERROR "File (${binFile}) should have changed in the first step!")
 endif()
 
 # -- Test
@@ -289,16 +290,16 @@ if (NOT QT_TEST_VERSION STREQUAL 4)
   file(TIMESTAMP "${plDFile}" plDAfter "${timeformat}")
 
   if (plAAfter GREATER plABefore)
-    message(SEND_ERROR "file (${plAFile}) should not have changed!")
+    message(SEND_ERROR "File (${plAFile}) should not have changed!")
   endif()
   if (plBAfter GREATER plBBefore)
-    message(SEND_ERROR "file (${plBFile}) should not have changed!")
+    message(SEND_ERROR "File (${plBFile}) should not have changed!")
   endif()
   if (NOT plCAfter GREATER plCBefore)
-    message(SEND_ERROR "file (${plCFile}) should have changed!")
+    message(SEND_ERROR "File (${plCFile}) should have changed!")
   endif()
   if (NOT plDAfter GREATER plDBefore)
-    message(SEND_ERROR "file (${plDFile}) should have changed!")
+    message(SEND_ERROR "File (${plDFile}) should have changed!")
   endif()
 
   # Test custom macro
@@ -311,10 +312,10 @@ if (NOT QT_TEST_VERSION STREQUAL 4)
   file(TIMESTAMP "${plCFile}" plCAfter "${timeformat}")
   file(TIMESTAMP "${plDFile}" plDAfter "${timeformat}")
   if (NOT plCAfter GREATER plCBefore)
-    message(SEND_ERROR "file (${plCFile}) should have changed!")
+    message(SEND_ERROR "File (${plCFile}) should have changed!")
   endif()
   if (NOT plDAfter GREATER plDBefore)
-    message(SEND_ERROR "file (${plDFile}) should have changed!")
+    message(SEND_ERROR "File (${plDFile}) should have changed!")
   endif()
 
 endif()

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=28878dbdd49dce43a15a98062696af30f26800cf
commit 28878dbdd49dce43a15a98062696af30f26800cf
Author:     Sebastian Holtermann <sebholt at xwmw.org>
AuthorDate: Thu Mar 2 19:16:24 2017 +0100
Commit:     Sebastian Holtermann <sebholt at xwmw.org>
CommitDate: Thu Mar 2 21:51:30 2017 +0100

    Autogen: Test: Add mocDepends test

diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt
index 93ce1db..4dbf6cf 100644
--- a/Tests/QtAutogen/CMakeLists.txt
+++ b/Tests/QtAutogen/CMakeLists.txt
@@ -238,6 +238,10 @@ target_link_libraries(skipRccB ${QT_LIBRARIES})
 add_subdirectory(sameName)
 
 # -- Test
+# Tests AUTOMOC with generated sources
+add_subdirectory(mocDepends)
+
+# -- Test
 # Tests various include moc patterns
 add_subdirectory(mocIncludeStrict)
 
diff --git a/Tests/QtAutogen/mocDepends/CMakeLists.txt b/Tests/QtAutogen/mocDepends/CMakeLists.txt
new file mode 100644
index 0000000..8a5ae5b
--- /dev/null
+++ b/Tests/QtAutogen/mocDepends/CMakeLists.txt
@@ -0,0 +1,45 @@
+cmake_minimum_required(VERSION 3.7)
+project(mocDepends)
+
+if (QT_TEST_VERSION STREQUAL 4)
+  find_package(Qt4 REQUIRED)
+  set(QT_CORE_TARGET Qt4::QtCore)
+else()
+  if (NOT QT_TEST_VERSION STREQUAL 5)
+    message(SEND_ERROR "Invalid Qt version specified.")
+  endif()
+
+  find_package(Qt5Core REQUIRED)
+  set(QT_CORE_TARGET Qt5::Core)
+endif()
+
+include_directories(${CMAKE_CURRENT_BINARY_DIR})
+
+# -- Test 1 using generated header
+# This tests the dependency of AUTOMOC of test1 to the generated object.hpp
+add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/object.hpp
+                   COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/invalid.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/object.hpp
+                   COMMAND ${CMAKE_COMMAND} -E sleep 3
+                   COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/object.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/object.hpp
+                   )
+
+add_executable(test1 test1.cpp
+  ${CMAKE_CURRENT_BINARY_DIR}/object.hpp
+)
+target_link_libraries(test1 ${QT_CORE_TARGET})
+set_target_properties(test1 PROPERTIES AUTOMOC TRUE)
+
+# -- Test 2 using generated library
+# This tests the dependency of AUTOMOC of test2 to the generated simpleLib.hpp
+# which belongs to a linked library of test2
+add_custom_command(OUTPUT simpleLib.hpp simpleLib.cpp
+                   COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/invalid.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/simpleLib.hpp
+                   COMMAND ${CMAKE_COMMAND} -E sleep 3
+                   COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/simpleLib.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/simpleLib.hpp
+                   COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/simpleLib.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/simpleLib.cpp
+                   )
+add_library(SimpleLib SHARED simpleLib.hpp simpleLib.cpp)
+
+add_executable(test2 test2.cpp )
+target_link_libraries(test2 SimpleLib ${QT_CORE_TARGET})
+set_target_properties(test2 PROPERTIES AUTOMOC TRUE)
diff --git a/Tests/QtAutogen/mocDepends/invalid.hpp.in b/Tests/QtAutogen/mocDepends/invalid.hpp.in
new file mode 100644
index 0000000..854d9a1
--- /dev/null
+++ b/Tests/QtAutogen/mocDepends/invalid.hpp.in
@@ -0,0 +1 @@
+#ifndef
diff --git a/Tests/QtAutogen/mocDepends/object.hpp.in b/Tests/QtAutogen/mocDepends/object.hpp.in
new file mode 100644
index 0000000..f364f7c
--- /dev/null
+++ b/Tests/QtAutogen/mocDepends/object.hpp.in
@@ -0,0 +1,14 @@
+#ifndef OBJECT_HPP
+#define OBJECT_HPP
+
+#include <QObject>
+
+class Object : public QObject
+{
+  Q_OBJECT
+public:
+  Q_SLOT
+  void aSlot(){};
+};
+
+#endif
diff --git a/Tests/QtAutogen/mocDepends/simpleLib.cpp.in b/Tests/QtAutogen/mocDepends/simpleLib.cpp.in
new file mode 100644
index 0000000..fa33bd3
--- /dev/null
+++ b/Tests/QtAutogen/mocDepends/simpleLib.cpp.in
@@ -0,0 +1,9 @@
+#include "simpleLib.hpp"
+
+SimpleLib::SimpleLib()
+{
+}
+
+SimpleLib::~SimpleLib()
+{
+}
diff --git a/Tests/QtAutogen/mocDepends/simpleLib.hpp.in b/Tests/QtAutogen/mocDepends/simpleLib.hpp.in
new file mode 100644
index 0000000..758f1f6
--- /dev/null
+++ b/Tests/QtAutogen/mocDepends/simpleLib.hpp.in
@@ -0,0 +1,11 @@
+#ifndef SIMPLE_LIB_H
+#define SIMPLE_LIB_H
+
+class SimpleLib
+{
+public:
+  SimpleLib();
+  ~SimpleLib();
+};
+
+#endif
diff --git a/Tests/QtAutogen/mocDepends/test1.cpp b/Tests/QtAutogen/mocDepends/test1.cpp
new file mode 100644
index 0000000..92c259c
--- /dev/null
+++ b/Tests/QtAutogen/mocDepends/test1.cpp
@@ -0,0 +1,9 @@
+
+#include "object.hpp"
+
+int main()
+{
+  Object obj;
+
+  return 0;
+}
diff --git a/Tests/QtAutogen/mocDepends/test2.cpp b/Tests/QtAutogen/mocDepends/test2.cpp
new file mode 100644
index 0000000..155b19b
--- /dev/null
+++ b/Tests/QtAutogen/mocDepends/test2.cpp
@@ -0,0 +1,10 @@
+
+#include "test2.hpp"
+
+int main()
+{
+  SimpleLib obj;
+  LObject lobject;
+
+  return 0;
+}
diff --git a/Tests/QtAutogen/mocDepends/test2.hpp b/Tests/QtAutogen/mocDepends/test2.hpp
new file mode 100644
index 0000000..0125f07
--- /dev/null
+++ b/Tests/QtAutogen/mocDepends/test2.hpp
@@ -0,0 +1,16 @@
+#ifndef TEST2_HPP
+#define TEST2_HPP
+
+#include "simpleLib.hpp"
+#include <QObject>
+
+// This object triggers the AUTOMOC on this file
+class LObject : public QObject
+{
+  Q_OBJECT
+public:
+  Q_SLOT
+  void aSlot(){};
+};
+
+#endif

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=59dd1e390e1fdc1391cd81c08a300716a8a6c10c
commit 59dd1e390e1fdc1391cd81c08a300716a8a6c10c
Author:     Sebastian Holtermann <sebholt at xwmw.org>
AuthorDate: Thu Mar 2 18:16:54 2017 +0100
Commit:     Sebastian Holtermann <sebholt at xwmw.org>
CommitDate: Thu Mar 2 21:51:30 2017 +0100

    Autogen: Test: Add generated qrc file to rccDepends test

diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt
index ca7e1dc..93ce1db 100644
--- a/Tests/QtAutogen/CMakeLists.txt
+++ b/Tests/QtAutogen/CMakeLists.txt
@@ -101,7 +101,7 @@ list(GET target1List 0 binFile)
 set(timeformat "%Y%j%H%M%S")
 file(TIMESTAMP "${binFile}" timeBegin "${timeformat}")
 
-# Touch qrc input file and rebuild
+# Touch first qrc input file and rebuild
 execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change.
 execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${CMAKE_CURRENT_BINARY_DIR}/rccDepends/res1/input.txt")
 execute_process(COMMAND "${CMAKE_COMMAND}" --build .
@@ -111,11 +111,26 @@ execute_process(COMMAND "${CMAKE_COMMAND}" --build .
 if (rccDepends_result)
   message(SEND_ERROR "Second build of rccDepends failed.")
 endif()
-
 # Compare timestamps
 file(TIMESTAMP "${binFile}" timeStep1 "${timeformat}")
 if (NOT timeStep1 GREATER timeBegin)
-  message(SEND_ERROR "file1 (${binFile}) should have changed in the first step!")
+  message(SEND_ERROR "File (${binFile}) should have changed in the first step!")
+endif()
+
+# Touch second qrc input file and rebuild
+execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change.
+execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${CMAKE_CURRENT_BINARY_DIR}/rccDepends/res2/input.txt")
+execute_process(COMMAND "${CMAKE_COMMAND}" --build .
+  WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/rccDepends"
+  RESULT_VARIABLE rccDepends_result
+)
+if (rccDepends_result)
+  message(SEND_ERROR "Third build of rccDepends failed.")
+endif()
+# Compare timestamps
+file(TIMESTAMP "${binFile}" timeStep2 "${timeformat}")
+if (NOT timeStep2 GREATER timeStep1)
+  message(SEND_ERROR "File (${binFile}) should have changed in the second step!")
 endif()
 
 # -- Test
diff --git a/Tests/QtAutogen/rccDepends/CMakeLists.txt b/Tests/QtAutogen/rccDepends/CMakeLists.txt
index 6fa5752..082b285 100644
--- a/Tests/QtAutogen/rccDepends/CMakeLists.txt
+++ b/Tests/QtAutogen/rccDepends/CMakeLists.txt
@@ -15,12 +15,21 @@ else()
   set(QT_CORE_TARGET Qt5::Core)
 endif()
 
+configure_file(res/input1.txt.in res1/input.txt @ONLY)
+configure_file(res/input2.txt.in res2/input.txt @ONLY)
+# Configure time generated qrc file
 configure_file(res1.qrc.in res1.qrc @ONLY)
-configure_file(res1/input.txt.in res1/input.txt @ONLY)
+# Dependency generated qrc file
+add_custom_command(OUTPUT res2.qrc
+                   COMMAND ${CMAKE_COMMAND} -E sleep 3
+                   COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/res2.qrc.in ${CMAKE_CURRENT_BINARY_DIR}/res2.qrc
+                   )
+
 
 add_executable(test_res1
   test_res1.cpp
   ${CMAKE_CURRENT_BINARY_DIR}/res1.qrc
+  ${CMAKE_CURRENT_BINARY_DIR}/res2.qrc
 )
 target_link_libraries(test_res1 ${QT_CORE_TARGET})
 add_custom_command(TARGET test_res1 POST_BUILD COMMAND
diff --git a/Tests/QtAutogen/rccDepends/res1/input.txt.in b/Tests/QtAutogen/rccDepends/res/input1.txt.in
similarity index 100%
rename from Tests/QtAutogen/rccDepends/res1/input.txt.in
rename to Tests/QtAutogen/rccDepends/res/input1.txt.in
diff --git a/Tests/QtAutogen/rccDepends/res/input2.txt.in b/Tests/QtAutogen/rccDepends/res/input2.txt.in
new file mode 100644
index 0000000..08e14b7
--- /dev/null
+++ b/Tests/QtAutogen/rccDepends/res/input2.txt.in
@@ -0,0 +1 @@
+Res2 input.
diff --git a/Tests/QtAutogen/rccDepends/res2.qrc.in b/Tests/QtAutogen/rccDepends/res2.qrc.in
new file mode 100644
index 0000000..18b916a
--- /dev/null
+++ b/Tests/QtAutogen/rccDepends/res2.qrc.in
@@ -0,0 +1,5 @@
+<RCC>
+    <qresource prefix="/">
+        <file>res2/input.txt</file>
+    </qresource>
+</RCC>

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=614917f70e292763b14b1c388e92714bac31fa9c
commit 614917f70e292763b14b1c388e92714bac31fa9c
Author:     Sebastian Holtermann <sebholt at xwmw.org>
AuthorDate: Thu Mar 2 17:50:34 2017 +0100
Commit:     Sebastian Holtermann <sebholt at xwmw.org>
CommitDate: Thu Mar 2 21:51:30 2017 +0100

    Autogen: Test: Add generated file to moc rerun test

diff --git a/Tests/QtAutogen/mocRerun/CMakeLists.txt b/Tests/QtAutogen/mocRerun/CMakeLists.txt
index ca0eedf..cbd3364 100644
--- a/Tests/QtAutogen/mocRerun/CMakeLists.txt
+++ b/Tests/QtAutogen/mocRerun/CMakeLists.txt
@@ -17,13 +17,19 @@ set(CMAKE_AUTOMOC ON)
 set(CMAKE_AUTORCC ON)
 
 configure_file(test1a.h.in test1.h COPYONLY)
+# Generated source file
+add_custom_command(OUTPUT main.cpp
+                   COMMAND ${CMAKE_COMMAND} -E sleep 3
+                   COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/main.cpp
+                   )
 
 add_executable(test1
   ${CMAKE_CURRENT_BINARY_DIR}/test1.h
-  test1.cpp
+  ${CMAKE_CURRENT_BINARY_DIR}/main.cpp
   res1.qrc
   )
 target_include_directories(test1 PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
 target_link_libraries(test1 ${QT_CORE_TARGET})
+# Write target name to text file
 add_custom_command(TARGET test1 POST_BUILD COMMAND
   ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:test1>" > target1.txt)
diff --git a/Tests/QtAutogen/mocRerun/main.cpp.in b/Tests/QtAutogen/mocRerun/main.cpp.in
new file mode 100644
index 0000000..b37ff61
--- /dev/null
+++ b/Tests/QtAutogen/mocRerun/main.cpp.in
@@ -0,0 +1,18 @@
+#include "test1.h"
+
+class Test2 : public QObject
+{
+  Q_OBJECT
+public slots:
+  void onTst1() {}
+};
+
+int main()
+{
+  Test1 test1;
+  Test2 test2;
+
+  return 0;
+}
+
+#include "main.moc"
diff --git a/Tests/QtAutogen/mocRerun/test1.cpp b/Tests/QtAutogen/mocRerun/test1.cpp
deleted file mode 100644
index 4316a91..0000000
--- a/Tests/QtAutogen/mocRerun/test1.cpp
+++ /dev/null
@@ -1,5 +0,0 @@
-#include "test1.h"
-int main()
-{
-  return 0;
-}
diff --git a/Tests/QtAutogen/mocRerun/test1a.h.in b/Tests/QtAutogen/mocRerun/test1a.h.in
index fee2c09..a335046 100644
--- a/Tests/QtAutogen/mocRerun/test1a.h.in
+++ b/Tests/QtAutogen/mocRerun/test1a.h.in
@@ -1,8 +1,8 @@
 #include <QObject>
-class test1 : public QObject
+class Test1 : public QObject
 {
   Q_OBJECT
- public slots:
-   void onTst1() {}
-   void onTst2() {}
+public slots:
+  void onTst1() {}
+  void onTst2() {}
 };
diff --git a/Tests/QtAutogen/mocRerun/test1b.h.in b/Tests/QtAutogen/mocRerun/test1b.h.in
index 6531d10..6128eeb 100644
--- a/Tests/QtAutogen/mocRerun/test1b.h.in
+++ b/Tests/QtAutogen/mocRerun/test1b.h.in
@@ -1,7 +1,7 @@
 #include <QObject>
-class test1 : public QObject
+class Test1 : public QObject
 {
   Q_OBJECT
- public slots:
-   void onTst1() {}
+public slots:
+  void onTst1() {}
 };

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=505ed4e76f3043cdb5d45effc4791455136560df
commit 505ed4e76f3043cdb5d45effc4791455136560df
Author:     Sebastian Holtermann <sebholt at xwmw.org>
AuthorDate: Thu Mar 2 17:26:11 2017 +0100
Commit:     Sebastian Holtermann <sebholt at xwmw.org>
CommitDate: Thu Mar 2 21:51:30 2017 +0100

    Autogen: Test: Add timestamp comparison to moc rerun test

diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt
index bf40166..ca7e1dc 100644
--- a/Tests/QtAutogen/CMakeLists.txt
+++ b/Tests/QtAutogen/CMakeLists.txt
@@ -95,25 +95,27 @@ if (NOT RCC_DEPENDS)
   message(SEND_ERROR "Initial build of rccDepends failed. Output: ${output}")
 endif()
 
-file(STRINGS "${CMAKE_CURRENT_BINARY_DIR}/rccDepends/info_file.txt" qrc_files)
-
-list(GET qrc_files 0 qrc_file1)
-
+# Get name and timestamp of the output binary
+file(STRINGS "${CMAKE_CURRENT_BINARY_DIR}/rccDepends/target1.txt" target1List)
+list(GET target1List 0 binFile)
 set(timeformat "%Y%j%H%M%S")
+file(TIMESTAMP "${binFile}" timeBegin "${timeformat}")
 
-file(TIMESTAMP "${qrc_file1}" file1_before "${timeformat}")
-
+# Touch qrc input file and rebuild
 execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change.
 execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${CMAKE_CURRENT_BINARY_DIR}/rccDepends/res1/input.txt")
-
 execute_process(COMMAND "${CMAKE_COMMAND}" --build .
   WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/rccDepends"
+  RESULT_VARIABLE rccDepends_result
 )
+if (rccDepends_result)
+  message(SEND_ERROR "Second build of rccDepends failed.")
+endif()
 
-file(TIMESTAMP "${qrc_file1}" file1_step1 "${timeformat}")
-
-if (NOT file1_step1 GREATER file1_before)
-  message(SEND_ERROR "file1 (${qrc_file1}) should have changed in the first step!")
+# Compare timestamps
+file(TIMESTAMP "${binFile}" timeStep1 "${timeformat}")
+if (NOT timeStep1 GREATER timeBegin)
+  message(SEND_ERROR "file1 (${binFile}) should have changed in the first step!")
 endif()
 
 # -- Test
@@ -131,16 +133,28 @@ if (NOT MOC_RERUN)
   message(SEND_ERROR "Initial build of mocRerun failed. Output: ${output}")
 endif()
 
-configure_file(mocRerun/test1b.h.in mocRerun/test1.h COPYONLY)
+# Get name and timestamp of the output binary
+file(STRINGS "${CMAKE_CURRENT_BINARY_DIR}/mocRerun/target1.txt" target1List)
+list(GET target1List 0 binFile)
+set(timeformat "%Y%j%H%M%S")
+file(TIMESTAMP "${binFile}" timeBegin "${timeformat}")
 
+# Change file content and rebuild
+configure_file(mocRerun/test1b.h.in mocRerun/test1.h COPYONLY)
 execute_process(COMMAND "${CMAKE_COMMAND}" --build .
   WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mocRerun"
-  RESULT_VARIABLE automoc_rerun_result
+  RESULT_VARIABLE mocRerun_result
   )
-if (automoc_rerun_result)
+if (mocRerun_result)
   message(SEND_ERROR "Second build of mocRerun failed.")
 endif()
 
+# Compare timestamps
+file(TIMESTAMP "${binFile}" timeStep1 "${timeformat}")
+if (NOT timeStep1 GREATER timeBegin)
+  message(SEND_ERROR "file1 (${binFile}) should have changed in the first step!")
+endif()
+
 # -- Test
 # Test for SKIP_AUTOMOC and SKIP_AUTOGEN on an AUTOMOC enabled target
 qtx_wrap_cpp(skipMocWrapMoc
diff --git a/Tests/QtAutogen/mocRerun/CMakeLists.txt b/Tests/QtAutogen/mocRerun/CMakeLists.txt
index efe936e..ca0eedf 100644
--- a/Tests/QtAutogen/mocRerun/CMakeLists.txt
+++ b/Tests/QtAutogen/mocRerun/CMakeLists.txt
@@ -25,3 +25,5 @@ add_executable(test1
   )
 target_include_directories(test1 PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
 target_link_libraries(test1 ${QT_CORE_TARGET})
+add_custom_command(TARGET test1 POST_BUILD COMMAND
+  ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:test1>" > target1.txt)
diff --git a/Tests/QtAutogen/rccDepends/CMakeLists.txt b/Tests/QtAutogen/rccDepends/CMakeLists.txt
index c983420..6fa5752 100644
--- a/Tests/QtAutogen/rccDepends/CMakeLists.txt
+++ b/Tests/QtAutogen/rccDepends/CMakeLists.txt
@@ -24,4 +24,4 @@ add_executable(test_res1
 )
 target_link_libraries(test_res1 ${QT_CORE_TARGET})
 add_custom_command(TARGET test_res1 POST_BUILD COMMAND
-  ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:test_res1>" > info_file.txt)
+  ${CMAKE_COMMAND} -E echo "$<TARGET_FILE:test_res1>" > target1.txt)

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=eae0b2823cb000db9a78881a517538a8a7fb7286
commit eae0b2823cb000db9a78881a517538a8a7fb7286
Author:     Sebastian Holtermann <sebholt at xwmw.org>
AuthorDate: Thu Mar 2 17:13:41 2017 +0100
Commit:     Sebastian Holtermann <sebholt at xwmw.org>
CommitDate: Thu Mar 2 21:51:30 2017 +0100

    Autogen: Test: Rename automoc_rerun test to mocRerun

diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt
index 4b84486..bf40166 100644
--- a/Tests/QtAutogen/CMakeLists.txt
+++ b/Tests/QtAutogen/CMakeLists.txt
@@ -119,26 +119,26 @@ endif()
 # -- Test
 # Ensure a repeated build succeeds when a header containing a QObject changes
 try_compile(MOC_RERUN
-  "${CMAKE_CURRENT_BINARY_DIR}/automoc_rerun"
-  "${CMAKE_CURRENT_SOURCE_DIR}/automoc_rerun"
-  automoc_rerun
+  "${CMAKE_CURRENT_BINARY_DIR}/mocRerun"
+  "${CMAKE_CURRENT_SOURCE_DIR}/mocRerun"
+  mocRerun
   CMAKE_FLAGS "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
               "-DQT_TEST_VERSION=${QT_TEST_VERSION}"
               "-DCMAKE_PREFIX_PATH=${Qt_PREFIX_DIR}"
   OUTPUT_VARIABLE output
 )
 if (NOT MOC_RERUN)
-  message(SEND_ERROR "Initial build of automoc_rerun failed. Output: ${output}")
+  message(SEND_ERROR "Initial build of mocRerun failed. Output: ${output}")
 endif()
 
-configure_file(automoc_rerun/test1.h.in2 automoc_rerun/test1.h COPYONLY)
+configure_file(mocRerun/test1b.h.in mocRerun/test1.h COPYONLY)
 
 execute_process(COMMAND "${CMAKE_COMMAND}" --build .
-  WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/automoc_rerun"
+  WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mocRerun"
   RESULT_VARIABLE automoc_rerun_result
   )
 if (automoc_rerun_result)
-  message(SEND_ERROR "Second build of automoc_rerun failed.")
+  message(SEND_ERROR "Second build of mocRerun failed.")
 endif()
 
 # -- Test
diff --git a/Tests/QtAutogen/automoc_rerun/CMakeLists.txt b/Tests/QtAutogen/mocRerun/CMakeLists.txt
similarity index 88%
rename from Tests/QtAutogen/automoc_rerun/CMakeLists.txt
rename to Tests/QtAutogen/mocRerun/CMakeLists.txt
index 92a682b..efe936e 100644
--- a/Tests/QtAutogen/automoc_rerun/CMakeLists.txt
+++ b/Tests/QtAutogen/mocRerun/CMakeLists.txt
@@ -1,5 +1,5 @@
 cmake_minimum_required(VERSION 3.7)
-project(automoc_rerun CXX)
+project(mocRerun CXX)
 
 if (QT_TEST_VERSION STREQUAL 4)
   find_package(Qt4 REQUIRED)
@@ -16,7 +16,7 @@ endif()
 set(CMAKE_AUTOMOC ON)
 set(CMAKE_AUTORCC ON)
 
-configure_file(test1.h.in1 test1.h COPYONLY)
+configure_file(test1a.h.in test1.h COPYONLY)
 
 add_executable(test1
   ${CMAKE_CURRENT_BINARY_DIR}/test1.h
diff --git a/Tests/QtAutogen/automoc_rerun/input.txt b/Tests/QtAutogen/mocRerun/input.txt
similarity index 100%
rename from Tests/QtAutogen/automoc_rerun/input.txt
rename to Tests/QtAutogen/mocRerun/input.txt
diff --git a/Tests/QtAutogen/automoc_rerun/res1.qrc b/Tests/QtAutogen/mocRerun/res1.qrc
similarity index 100%
rename from Tests/QtAutogen/automoc_rerun/res1.qrc
rename to Tests/QtAutogen/mocRerun/res1.qrc
diff --git a/Tests/QtAutogen/automoc_rerun/test1.cpp b/Tests/QtAutogen/mocRerun/test1.cpp
similarity index 100%
rename from Tests/QtAutogen/automoc_rerun/test1.cpp
rename to Tests/QtAutogen/mocRerun/test1.cpp
diff --git a/Tests/QtAutogen/automoc_rerun/test1.h.in1 b/Tests/QtAutogen/mocRerun/test1a.h.in
similarity index 100%
rename from Tests/QtAutogen/automoc_rerun/test1.h.in1
rename to Tests/QtAutogen/mocRerun/test1a.h.in
diff --git a/Tests/QtAutogen/automoc_rerun/test1.h.in2 b/Tests/QtAutogen/mocRerun/test1b.h.in
similarity index 100%
rename from Tests/QtAutogen/automoc_rerun/test1.h.in2
rename to Tests/QtAutogen/mocRerun/test1b.h.in

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c511576c620ecbc614591722ad1b381c8a7d2528
commit c511576c620ecbc614591722ad1b381c8a7d2528
Author:     Sebastian Holtermann <sebholt at xwmw.org>
AuthorDate: Thu Mar 2 17:07:53 2017 +0100
Commit:     Sebastian Holtermann <sebholt at xwmw.org>
CommitDate: Thu Mar 2 21:51:30 2017 +0100

    Autogen: Test: Rename autorcc_depends test to rccDepends

diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt
index 4960472..4b84486 100644
--- a/Tests/QtAutogen/CMakeLists.txt
+++ b/Tests/QtAutogen/CMakeLists.txt
@@ -83,19 +83,19 @@ target_compile_features(empty PRIVATE ${QT_COMPILE_FEATURES})
 # -- Test
 # When a file listed in a .qrc file changes the target must be rebuilt
 try_compile(RCC_DEPENDS
-  "${CMAKE_CURRENT_BINARY_DIR}/autorcc_depends"
-  "${CMAKE_CURRENT_SOURCE_DIR}/autorcc_depends"
-  autorcc_depends
+  "${CMAKE_CURRENT_BINARY_DIR}/rccDepends"
+  "${CMAKE_CURRENT_SOURCE_DIR}/rccDepends"
+  rccDepends
   CMAKE_FLAGS "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
               "-DQT_TEST_VERSION=${QT_TEST_VERSION}"
               "-DCMAKE_PREFIX_PATH=${Qt_PREFIX_DIR}"
   OUTPUT_VARIABLE output
 )
 if (NOT RCC_DEPENDS)
-  message(SEND_ERROR "Initial build of autorcc_depends failed. Output: ${output}")
+  message(SEND_ERROR "Initial build of rccDepends failed. Output: ${output}")
 endif()
 
-file(STRINGS "${CMAKE_CURRENT_BINARY_DIR}/autorcc_depends/info_file.txt" qrc_files)
+file(STRINGS "${CMAKE_CURRENT_BINARY_DIR}/rccDepends/info_file.txt" qrc_files)
 
 list(GET qrc_files 0 qrc_file1)
 
@@ -104,10 +104,10 @@ set(timeformat "%Y%j%H%M%S")
 file(TIMESTAMP "${qrc_file1}" file1_before "${timeformat}")
 
 execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 1) # Ensure that the timestamp will change.
-execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${CMAKE_CURRENT_BINARY_DIR}/autorcc_depends/res1/input.txt")
+execute_process(COMMAND "${CMAKE_COMMAND}" -E touch "${CMAKE_CURRENT_BINARY_DIR}/rccDepends/res1/input.txt")
 
 execute_process(COMMAND "${CMAKE_COMMAND}" --build .
-  WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/autorcc_depends"
+  WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/rccDepends"
 )
 
 file(TIMESTAMP "${qrc_file1}" file1_step1 "${timeformat}")
diff --git a/Tests/QtAutogen/autorcc_depends/CMakeLists.txt b/Tests/QtAutogen/rccDepends/CMakeLists.txt
similarity index 96%
rename from Tests/QtAutogen/autorcc_depends/CMakeLists.txt
rename to Tests/QtAutogen/rccDepends/CMakeLists.txt
index 7b51e11..c983420 100644
--- a/Tests/QtAutogen/autorcc_depends/CMakeLists.txt
+++ b/Tests/QtAutogen/rccDepends/CMakeLists.txt
@@ -1,5 +1,5 @@
 cmake_minimum_required(VERSION 3.7)
-project(autorcc_depends)
+project(rccDepends)
 
 set(CMAKE_AUTORCC ON)
 
diff --git a/Tests/QtAutogen/autorcc_depends/res1.qrc.in b/Tests/QtAutogen/rccDepends/res1.qrc.in
similarity index 100%
rename from Tests/QtAutogen/autorcc_depends/res1.qrc.in
rename to Tests/QtAutogen/rccDepends/res1.qrc.in
diff --git a/Tests/QtAutogen/autorcc_depends/res1/input.txt.in b/Tests/QtAutogen/rccDepends/res1/input.txt.in
similarity index 100%
rename from Tests/QtAutogen/autorcc_depends/res1/input.txt.in
rename to Tests/QtAutogen/rccDepends/res1/input.txt.in
diff --git a/Tests/QtAutogen/autorcc_depends/test_res1.cpp b/Tests/QtAutogen/rccDepends/test_res1.cpp
similarity index 100%
rename from Tests/QtAutogen/autorcc_depends/test_res1.cpp
rename to Tests/QtAutogen/rccDepends/test_res1.cpp

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4ef593ed4940229437dbbad7707a6461846318f8
commit 4ef593ed4940229437dbbad7707a6461846318f8
Author:     Sebastian Holtermann <sebholt at xwmw.org>
AuthorDate: Thu Mar 2 19:39:50 2017 +0100
Commit:     Sebastian Holtermann <sebholt at xwmw.org>
CommitDate: Thu Mar 2 21:51:29 2017 +0100

    Autogen: Error return when a scan file is not readable

diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index 2510066..c9b650a 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -125,13 +125,19 @@ static bool FileNameIsUnique(const std::string& filePath,
   return true;
 }
 
-static std::string ReadAll(const std::string& filename)
+static bool ReadAll(std::string& content, const std::string& filename)
 {
-  cmsys::ifstream file(filename.c_str());
-  std::ostringstream stream;
-  stream << file.rdbuf();
-  file.close();
-  return stream.str();
+  bool success = false;
+  {
+    cmsys::ifstream ifs(filename.c_str());
+    if (ifs) {
+      std::ostringstream osst;
+      osst << ifs.rdbuf();
+      content = osst.str();
+      success = true;
+    }
+  }
+  return success;
 }
 
 /**
@@ -682,8 +688,10 @@ bool cmQtAutoGenerators::RunAutogen()
       uicHeaderFiles.insert(headerName);
     }
   }
-  this->ParseHeaders(mocHeaderFiles, uicHeaderFiles, mocsIncluded,
-                     mocsNotIncluded, mocDepends, uisIncluded);
+  if (!this->ParseHeaders(mocHeaderFiles, uicHeaderFiles, mocsIncluded,
+                          mocsNotIncluded, mocDepends, uisIncluded)) {
+    return false;
+  };
 
   // Generate files
   if (!this->MocGenerateAll(mocsIncluded, mocsNotIncluded, mocDepends)) {
@@ -799,23 +807,29 @@ bool cmQtAutoGenerators::ParseSourceFile(
   std::map<std::string, std::set<std::string> >& mocDepends,
   std::map<std::string, std::vector<std::string> >& uisIncluded, bool relaxed)
 {
-  bool success = true;
-  const std::string contentText = ReadAll(absFilename);
-  if (contentText.empty()) {
-    std::ostringstream ost;
-    ost << "AutoGen: Warning: " << absFilename << "\n"
-        << "The file is empty\n";
-    this->LogWarning(ost.str());
-  } else {
-    // Parse source contents for MOC
-    if (success && !this->MocSkip(absFilename)) {
-      success = this->MocParseSourceContent(absFilename, contentText,
-                                            mocsIncluded, mocDepends, relaxed);
-    }
-    // Parse source contents for UIC
-    if (success && !this->UicSkip(absFilename)) {
-      this->UicParseContent(absFilename, contentText, uisIncluded);
+  std::string contentText;
+  bool success = ReadAll(contentText, absFilename);
+  if (success) {
+    if (!contentText.empty()) {
+      // Parse source contents for MOC
+      if (success && !this->MocSkip(absFilename)) {
+        success = this->MocParseSourceContent(
+          absFilename, contentText, mocsIncluded, mocDepends, relaxed);
+      }
+      // Parse source contents for UIC
+      if (success && !this->UicSkip(absFilename)) {
+        this->UicParseContent(absFilename, contentText, uisIncluded);
+      }
+    } else {
+      std::ostringstream ost;
+      ost << "AutoGen: Warning: The file is empty:\n"
+          << Quoted(absFilename) << "\n";
+      this->LogWarning(ost.str());
     }
+  } else {
+    std::ostringstream ost;
+    ost << "AutoGen: Error: Could not read file:\n" << Quoted(absFilename);
+    this->LogError(ost.str());
   }
   return success;
 }
@@ -1078,7 +1092,7 @@ void cmQtAutoGenerators::SearchHeadersForSourceFile(
   }
 }
 
-void cmQtAutoGenerators::ParseHeaders(
+bool cmQtAutoGenerators::ParseHeaders(
   const std::set<std::string>& mocHeaderFiles,
   const std::set<std::string>& uicHeaderFiles,
   const std::map<std::string, std::string>& mocsIncluded,
@@ -1086,6 +1100,7 @@ void cmQtAutoGenerators::ParseHeaders(
   std::map<std::string, std::set<std::string> >& mocDepends,
   std::map<std::string, std::vector<std::string> >& uisIncluded)
 {
+  bool success = true;
   // Merged header files list to read files only once
   std::set<std::string> headerFiles;
   headerFiles.insert(mocHeaderFiles.begin(), mocHeaderFiles.end());
@@ -1094,20 +1109,28 @@ void cmQtAutoGenerators::ParseHeaders(
   for (std::set<std::string>::const_iterator hIt = headerFiles.begin();
        hIt != headerFiles.end(); ++hIt) {
     const std::string& headerName = *hIt;
-    const std::string contentText = ReadAll(headerName);
-
-    // Parse header content for MOC
-    if ((mocHeaderFiles.find(headerName) != mocHeaderFiles.end()) &&
-        (mocsIncluded.find(headerName) == mocsIncluded.end())) {
-      this->MocParseHeaderContent(headerName, contentText, mocsNotIncluded,
-                                  mocDepends);
-    }
-
-    // Parse header content for UIC
-    if (uicHeaderFiles.find(headerName) != uicHeaderFiles.end()) {
-      this->UicParseContent(headerName, contentText, uisIncluded);
+    std::string contentText;
+    if (ReadAll(contentText, headerName)) {
+      // Parse header content for MOC
+      if ((mocHeaderFiles.find(headerName) != mocHeaderFiles.end()) &&
+          (mocsIncluded.find(headerName) == mocsIncluded.end())) {
+        this->MocParseHeaderContent(headerName, contentText, mocsNotIncluded,
+                                    mocDepends);
+      }
+      // Parse header content for UIC
+      if (uicHeaderFiles.find(headerName) != uicHeaderFiles.end()) {
+        this->UicParseContent(headerName, contentText, uisIncluded);
+      }
+    } else {
+      std::ostringstream ost;
+      ost << "AutoGen: Error: Could not read header file:\n"
+          << Quoted(headerName);
+      this->LogError(ost.str());
+      success = false;
+      break;
     }
   }
+  return success;
 }
 
 bool cmQtAutoGenerators::MocGenerateAll(
@@ -1190,8 +1213,12 @@ bool cmQtAutoGenerators::MocGenerateAll(
 
   // Check if the content of moc_compilation.cpp changed
   {
-    const std::string oldContents = ReadAll(this->MocCppFilenameAbs);
-    mocCompChanged = (oldContents != automocSource);
+    std::string oldContents;
+    if (ReadAll(oldContents, this->MocCppFilenameAbs)) {
+      mocCompChanged = (oldContents != automocSource);
+    } else {
+      mocCompChanged = true;
+    }
   }
 
   bool success = true;
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
index 3bff2b2..00fa0c7 100644
--- a/Source/cmQtAutoGenerators.h
+++ b/Source/cmQtAutoGenerators.h
@@ -78,7 +78,7 @@ private:
                                   std::set<std::string>& mocHeaderFiles,
                                   std::set<std::string>& uicHeaderFiles) const;
 
-  void ParseHeaders(
+  bool ParseHeaders(
     const std::set<std::string>& mocHeaderFiles,
     const std::set<std::string>& uicHeaderFiles,
     const std::map<std::string, std::string>& mocsIncluded,

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bdec46b75eb93427aafb70d2d5e9d6601fda26a4
commit bdec46b75eb93427aafb70d2d5e9d6601fda26a4
Author:     Sebastian Holtermann <sebholt at xwmw.org>
AuthorDate: Thu Mar 2 16:26:26 2017 +0100
Commit:     Sebastian Holtermann <sebholt at xwmw.org>
CommitDate: Thu Mar 2 21:51:29 2017 +0100

    Autogen: Add AUTOMOC/UIC support for generated source files
    
    Closes #16186
    Closes #14379

diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx
index 2829c8a..5ee0982 100644
--- a/Source/cmQtAutoGeneratorInitializer.cxx
+++ b/Source/cmQtAutoGeneratorInitializer.cxx
@@ -45,6 +45,11 @@ static void utilCopyTargetProperty(cmTarget* destinationTarget,
   }
 }
 
+inline static bool PropertyEnabled(cmSourceFile* sourceFile, const char* key)
+{
+  return cmSystemTools::IsOn(sourceFile->GetPropertyForUser(key));
+}
+
 static std::string GetSafeProperty(cmGeneratorTarget const* target,
                                    const char* key)
 {
@@ -150,18 +155,12 @@ static void AcquireScanFiles(cmGeneratorTarget const* target,
         !(fileType == cmSystemTools::HEADER_FILE_FORMAT)) {
       continue;
     }
-    if (cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"))) {
-      continue;
-    }
     const std::string absFile =
       cmsys::SystemTools::GetRealPath(sf->GetFullPath());
     // Skip flags
-    const bool skipAll =
-      cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOGEN"));
-    const bool mocSkip =
-      skipAll || cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOMOC"));
-    const bool uicSkip =
-      skipAll || cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOUIC"));
+    const bool skipAll = PropertyEnabled(sf, "SKIP_AUTOGEN");
+    const bool mocSkip = skipAll || PropertyEnabled(sf, "SKIP_AUTOMOC");
+    const bool uicSkip = skipAll || PropertyEnabled(sf, "SKIP_AUTOUIC");
     // Add file name to skip lists.
     // Do this even when the file is not added to the sources/headers lists
     // because the file name may be extracted from an other file when
@@ -478,8 +477,8 @@ static void RccSetupAutoTarget(cmGeneratorTarget const* target,
        fileIt != srcFiles.end(); ++fileIt) {
     cmSourceFile* sf = *fileIt;
     if ((sf->GetExtension() == "qrc") &&
-        !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOGEN")) &&
-        !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC"))) {
+        !PropertyEnabled(sf, "SKIP_AUTOGEN") &&
+        !PropertyEnabled(sf, "SKIP_AUTORCC")) {
       const std::string absFile =
         cmsys::SystemTools::GetRealPath(sf->GetFullPath());
       // qrc file
@@ -488,7 +487,7 @@ static void RccSetupAutoTarget(cmGeneratorTarget const* target,
       {
         std::string entriesList = "{";
         // Read input file list only for non generated .qrc files.
-        if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"))) {
+        if (!PropertyEnabled(sf, "GENERATED")) {
           std::string error;
           std::vector<std::string> files;
           if (cmQtAutoGeneratorCommon::RccListInputs(
@@ -555,7 +554,8 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
     cmSystemTools::CollapseFullPath("", makefile->GetCurrentBinaryDirectory());
   const std::string qtMajorVersion = GetQtMajorVersion(target);
   const std::string rccCommand = RccGetExecutable(target, qtMajorVersion);
-  std::vector<std::string> autogenOutputFiles;
+  std::vector<std::string> autogenDepends;
+  std::vector<std::string> autogenProvides;
 
   // Remove old settings on cleanup
   {
@@ -565,31 +565,6 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
                              false);
   }
 
-  // Create autogen target build directory and add it to the clean files
-  cmSystemTools::MakeDirectory(autogenBuildDir);
-  makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES",
-                           autogenBuildDir.c_str(), false);
-
-  if (mocEnabled || uicEnabled) {
-    // Create autogen target includes directory and
-    // add it to the origin target INCLUDE_DIRECTORIES
-    const std::string incsDir = autogenBuildDir + "include";
-    cmSystemTools::MakeDirectory(incsDir);
-    target->AddIncludeDirectory(incsDir, true);
-  }
-
-  if (mocEnabled) {
-    // Register moc compilation file as generated
-    autogenOutputFiles.push_back(autogenBuildDir + "moc_compilation.cpp");
-  }
-
-  // Initialize autogen target dependencies
-  std::vector<std::string> depends;
-  if (const char* autogenDepends =
-        target->GetProperty("AUTOGEN_TARGET_DEPENDS")) {
-    cmSystemTools::ExpandListArgument(autogenDepends, depends);
-  }
-
   // Compose command lines
   cmCustomCommandLines commandLines;
   {
@@ -628,6 +603,24 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
     autogenComment = "Automatic " + tools + " for target " + target->GetName();
   }
 
+  // Create autogen target build directory and add it to the clean files
+  cmSystemTools::MakeDirectory(autogenBuildDir);
+  makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES",
+                           autogenBuildDir.c_str(), false);
+
+  // Create autogen target includes directory and
+  // add it to the origin target INCLUDE_DIRECTORIES
+  if (mocEnabled || uicEnabled) {
+    const std::string incsDir = autogenBuildDir + "include";
+    cmSystemTools::MakeDirectory(incsDir);
+    target->AddIncludeDirectory(incsDir, true);
+  }
+
+  // Register moc compilation file as generated
+  if (mocEnabled) {
+    autogenProvides.push_back(autogenBuildDir + "moc_compilation.cpp");
+  }
+
 #if defined(_WIN32) && !defined(__CYGWIN__)
   bool usePRE_BUILD = false;
   cmGlobalGenerator* gg = lg->GetGlobalGenerator();
@@ -639,71 +632,95 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
     // This also works around a VS 11 bug that may skip updating the target:
     //  https://connect.microsoft.com/VisualStudio/feedback/details/769495
     usePRE_BUILD = vsgg->GetVersion() >= cmGlobalVisualStudioGenerator::VS7;
-    if (usePRE_BUILD) {
-      // If the autogen target depends on an other target
-      // don't use PRE_BUILD
-      for (std::vector<std::string>::iterator it = depends.begin();
-           it != depends.end(); ++it) {
-        if (!makefile->FindTargetToUse(it->c_str())) {
-          usePRE_BUILD = false;
-          break;
-        }
-      }
-    }
   }
 #endif
 
-  if (rccEnabled) {
+  // Initialize autogen target dependencies
+  if (const char* deps = target->GetProperty("AUTOGEN_TARGET_DEPENDS")) {
+    cmSystemTools::ExpandListArgument(deps, autogenDepends);
+  }
+  // Add link library targets to the autogen dependencies
+  {
+    const cmTarget::LinkLibraryVectorType& libVec =
+      target->Target->GetOriginalLinkLibraries();
+    for (cmTarget::LinkLibraryVectorType::const_iterator it = libVec.begin();
+         it != libVec.end(); ++it) {
+      const std::string& libName = it->first;
+      if (makefile->FindTargetToUse(libName) != CM_NULLPTR) {
+        autogenDepends.push_back(libName);
+      }
+    }
+  }
+  {
     cmFilePathChecksum fpathCheckSum(makefile);
+    // Iterate over all source files
     std::vector<cmSourceFile*> srcFiles;
     target->GetConfigCommonSourceFiles(srcFiles);
     for (std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
          fileIt != srcFiles.end(); ++fileIt) {
       cmSourceFile* sf = *fileIt;
-      if (sf->GetExtension() == "qrc" &&
-          !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOGEN")) &&
-          !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC"))) {
-        {
+      if (!PropertyEnabled(sf, "SKIP_AUTOGEN")) {
+        const std::string ext = sf->GetExtension();
+        // Add generated file that will be scanned by moc or uic to
+        // the dependencies
+        if (mocEnabled || uicEnabled) {
+          const cmSystemTools::FileFormat fileType =
+            cmSystemTools::GetFileFormat(ext.c_str());
+          if ((fileType == cmSystemTools::CXX_FILE_FORMAT) ||
+              (fileType == cmSystemTools::HEADER_FILE_FORMAT)) {
+            if (PropertyEnabled(sf, "GENERATED")) {
+              if ((mocEnabled && !PropertyEnabled(sf, "SKIP_AUTOMOC")) ||
+                  (uicEnabled && !PropertyEnabled(sf, "SKIP_AUTOUIC"))) {
+                autogenDepends.push_back(
+                  cmsys::SystemTools::GetRealPath(sf->GetFullPath()));
+              }
+            }
+          }
+        }
+        // Process rcc enabled files
+        if (rccEnabled && (ext == "qrc") &&
+            !PropertyEnabled(sf, "SKIP_AUTORCC")) {
           const std::string absFile =
             cmsys::SystemTools::GetRealPath(sf->GetFullPath());
 
-          // Run cmake again when .qrc file changes
-          makefile->AddCMakeDependFile(absFile);
-
-          std::string rccOutputFile = autogenBuildDir;
-          rccOutputFile += fpathCheckSum.getPart(absFile);
-          rccOutputFile += "/qrc_";
-          rccOutputFile +=
-            cmsys::SystemTools::GetFilenameWithoutLastExtension(absFile);
-          rccOutputFile += ".cpp";
-
-          // Add rcc output file to origin target sources
-          cmSourceFile* gf = makefile->GetOrCreateSource(rccOutputFile, true);
-          gf->SetProperty("SKIP_AUTOGEN", "On");
-          target->AddSource(rccOutputFile);
-          // Register rcc output file as generated
-          autogenOutputFiles.push_back(rccOutputFile);
+          // Compose rcc output file name
+          {
+            std::string rccOut = autogenBuildDir;
+            rccOut += fpathCheckSum.getPart(absFile);
+            rccOut += "/qrc_";
+            rccOut +=
+              cmsys::SystemTools::GetFilenameWithoutLastExtension(absFile);
+            rccOut += ".cpp";
+
+            // Register rcc output file as generated
+            autogenProvides.push_back(rccOut);
+
+            // Add rcc output file to origin target sources
+            cmSourceFile* gf = makefile->GetOrCreateSource(rccOut, true);
+            gf->SetProperty("SKIP_AUTOGEN", "On");
+            target->AddSource(rccOut);
+          }
 
-          if (lg->GetGlobalGenerator()->GetName() == "Ninja"
-#if defined(_WIN32) && !defined(__CYGWIN__)
-              || usePRE_BUILD
-#endif
-              ) {
-            if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"))) {
-              {
-                std::string error;
-                if (!cmQtAutoGeneratorCommon::RccListInputs(
-                      qtMajorVersion, rccCommand, absFile, depends, &error)) {
-                  cmSystemTools::Error(error.c_str());
-                }
-              }
+          if (PropertyEnabled(sf, "GENERATED")) {
+            // Add generated qrc file to the dependencies
+            autogenDepends.push_back(absFile);
+          } else {
+            // Run cmake again when .qrc file changes
+            makefile->AddCMakeDependFile(absFile);
+
+            // Add the qrc input files to the dependencies
+            std::string error;
+            if (!cmQtAutoGeneratorCommon::RccListInputs(
+                  qtMajorVersion, rccCommand, absFile, autogenDepends,
+                  &error)) {
+              cmSystemTools::Error(error.c_str());
+            }
 #if defined(_WIN32) && !defined(__CYGWIN__)
-              // Cannot use PRE_BUILD because the resource files themselves
-              // may not be sources within the target so VS may not know the
-              // target needs to re-build at all.
-              usePRE_BUILD = false;
+            // Cannot use PRE_BUILD because the resource files themselves
+            // may not be sources within the target so VS may not know the
+            // target needs to re-build at all.
+            usePRE_BUILD = false;
 #endif
-            }
           }
         }
       }
@@ -712,12 +729,21 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
   if (usePRE_BUILD) {
+    // If the autogen target depends on an other target don't use PRE_BUILD
+    for (std::vector<std::string>::iterator it = autogenDepends.begin();
+         it != autogenDepends.end(); ++it) {
+      if (makefile->FindTargetToUse(*it) != CM_NULLPTR) {
+        usePRE_BUILD = false;
+        break;
+      }
+    }
+  }
+  if (usePRE_BUILD) {
     // Add the pre-build command directly to bypass the OBJECT_LIBRARY
     // rejection in cmMakefile::AddCustomCommandToTarget because we know
     // PRE_BUILD will work for an OBJECT_LIBRARY in this specific case.
     std::vector<std::string> no_output;
-    std::vector<std::string> no_byproducts;
-    cmCustomCommand cc(makefile, no_output, no_byproducts, depends,
+    cmCustomCommand cc(makefile, no_output, autogenProvides, autogenDepends,
                        commandLines, autogenComment.c_str(),
                        workingDirectory.c_str());
     cc.SetEscapeOldStyle(false);
@@ -728,7 +754,7 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
   {
     cmTarget* autogenTarget = makefile->AddUtilityCommand(
       autogenTargetName, true, workingDirectory.c_str(),
-      /*byproducts=*/autogenOutputFiles, depends, commandLines, false,
+      /*byproducts=*/autogenProvides, autogenDepends, commandLines, false,
       autogenComment.c_str());
 
     cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg);

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c52eecc303f8cb3de406d788914a2071cef4e60f
commit c52eecc303f8cb3de406d788914a2071cef4e60f
Author:     Sebastian Holtermann <sebholt at xwmw.org>
AuthorDate: Thu Mar 2 14:32:33 2017 +0100
Commit:     Sebastian Holtermann <sebholt at xwmw.org>
CommitDate: Thu Mar 2 21:51:29 2017 +0100

    Autogen: Initializer cleanups

diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx
index 2b53982..2829c8a 100644
--- a/Source/cmQtAutoGeneratorInitializer.cxx
+++ b/Source/cmQtAutoGeneratorInitializer.cxx
@@ -129,18 +129,17 @@ static void AddDefinitionEscaped(cmMakefile* makefile, const char* key,
     key, cmOutputConverter::EscapeForCMake(cmJoin(values, ";")).c_str());
 }
 
-static void SetupSourceFiles(cmGeneratorTarget const* target,
+static void AcquireScanFiles(cmGeneratorTarget const* target,
                              std::vector<std::string>& mocUicSources,
                              std::vector<std::string>& mocUicHeaders,
                              std::vector<std::string>& mocSkipList,
                              std::vector<std::string>& uicSkipList)
 {
-  std::vector<cmSourceFile*> srcFiles;
-  target->GetConfigCommonSourceFiles(srcFiles);
-
   const bool mocTarget = target->GetPropertyAsBool("AUTOMOC");
   const bool uicTarget = target->GetPropertyAsBool("AUTOUIC");
 
+  std::vector<cmSourceFile*> srcFiles;
+  target->GetConfigCommonSourceFiles(srcFiles);
   for (std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
        fileIt != srcFiles.end(); ++fileIt) {
     cmSourceFile* sf = *fileIt;
@@ -478,47 +477,44 @@ static void RccSetupAutoTarget(cmGeneratorTarget const* target,
   for (std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
        fileIt != srcFiles.end(); ++fileIt) {
     cmSourceFile* sf = *fileIt;
-    if (sf->GetExtension() == "qrc") {
-      const bool skip =
-        cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOGEN")) ||
-        cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC"));
-      if (!skip) {
-        const std::string absFile =
-          cmsys::SystemTools::GetRealPath(sf->GetFullPath());
-        // qrc file
-        _rcc_files.push_back(absFile);
-        // qrc file entries
-        {
-          std::string entriesList = "{";
-          // Read input file list only for non generated .qrc files.
-          if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"))) {
-            std::string error;
-            std::vector<std::string> files;
-            if (cmQtAutoGeneratorCommon::RccListInputs(
-                  qtMajorVersion, rccCommand, absFile, files, &error)) {
-              entriesList += cmJoin(files, cmQtAutoGeneratorCommon::listSep);
-            } else {
-              cmSystemTools::Error(error.c_str());
-            }
+    if ((sf->GetExtension() == "qrc") &&
+        !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOGEN")) &&
+        !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC"))) {
+      const std::string absFile =
+        cmsys::SystemTools::GetRealPath(sf->GetFullPath());
+      // qrc file
+      _rcc_files.push_back(absFile);
+      // qrc file entries
+      {
+        std::string entriesList = "{";
+        // Read input file list only for non generated .qrc files.
+        if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"))) {
+          std::string error;
+          std::vector<std::string> files;
+          if (cmQtAutoGeneratorCommon::RccListInputs(
+                qtMajorVersion, rccCommand, absFile, files, &error)) {
+            entriesList += cmJoin(files, cmQtAutoGeneratorCommon::listSep);
+          } else {
+            cmSystemTools::Error(error.c_str());
           }
-          entriesList += "}";
-          _rcc_inputs.push_back(entriesList);
         }
-        // rcc options for this qrc file
-        {
-          // Merged target and file options
-          std::vector<std::string> rccOptions(rccOptionsTarget);
-          if (const char* prop = sf->GetProperty("AUTORCC_OPTIONS")) {
-            std::vector<std::string> optsVec;
-            cmSystemTools::ExpandListArgument(prop, optsVec);
-            RccMergeOptions(rccOptions, optsVec, qtMajorVersion5);
-          }
-          // Only store non empty options lists
-          if (!rccOptions.empty()) {
-            rccFileFiles.push_back(absFile);
-            rccFileOptions.push_back(
-              cmJoin(rccOptions, cmQtAutoGeneratorCommon::listSep));
-          }
+        entriesList += "}";
+        _rcc_inputs.push_back(entriesList);
+      }
+      // rcc options for this qrc file
+      {
+        // Merged target and file options
+        std::vector<std::string> rccOptions(rccOptionsTarget);
+        if (const char* prop = sf->GetProperty("AUTORCC_OPTIONS")) {
+          std::vector<std::string> optsVec;
+          cmSystemTools::ExpandListArgument(prop, optsVec);
+          RccMergeOptions(rccOptions, optsVec, qtMajorVersion5);
+        }
+        // Only store non empty options lists
+        if (!rccOptions.empty()) {
+          rccFileFiles.push_back(absFile);
+          rccFileOptions.push_back(
+            cmJoin(rccOptions, cmQtAutoGeneratorCommon::listSep));
         }
       }
     }
@@ -550,6 +546,9 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
   cmMakefile* makefile = target->Target->GetMakefile();
 
   // Create a custom target for running generators at buildtime
+  const bool mocEnabled = target->GetPropertyAsBool("AUTOMOC");
+  const bool uicEnabled = target->GetPropertyAsBool("AUTOUIC");
+  const bool rccEnabled = target->GetPropertyAsBool("AUTORCC");
   const std::string autogenTargetName = GetAutogenTargetName(target);
   const std::string autogenBuildDir = GetAutogenTargetBuildDir(target);
   const std::string workingDirectory =
@@ -571,8 +570,7 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
   makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES",
                            autogenBuildDir.c_str(), false);
 
-  if (target->GetPropertyAsBool("AUTOMOC") ||
-      target->GetPropertyAsBool("AUTOUIC")) {
+  if (mocEnabled || uicEnabled) {
     // Create autogen target includes directory and
     // add it to the origin target INCLUDE_DIRECTORIES
     const std::string incsDir = autogenBuildDir + "include";
@@ -580,7 +578,7 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
     target->AddIncludeDirectory(incsDir, true);
   }
 
-  if (target->GetPropertyAsBool("AUTOMOC")) {
+  if (mocEnabled) {
     // Register moc compilation file as generated
     autogenOutputFiles.push_back(autogenBuildDir + "moc_compilation.cpp");
   }
@@ -608,13 +606,13 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
   std::string autogenComment;
   {
     std::vector<std::string> toolNames;
-    if (target->GetPropertyAsBool("AUTOMOC")) {
+    if (mocEnabled) {
       toolNames.push_back("MOC");
     }
-    if (target->GetPropertyAsBool("AUTOUIC")) {
+    if (uicEnabled) {
       toolNames.push_back("UIC");
     }
-    if (target->GetPropertyAsBool("AUTORCC")) {
+    if (rccEnabled) {
       toolNames.push_back("RCC");
     }
 
@@ -655,7 +653,7 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
   }
 #endif
 
-  if (target->GetPropertyAsBool("AUTORCC")) {
+  if (rccEnabled) {
     cmFilePathChecksum fpathCheckSum(makefile);
     std::vector<cmSourceFile*> srcFiles;
     target->GetConfigCommonSourceFiles(srcFiles);
@@ -767,38 +765,37 @@ void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget(
   std::map<std::string, std::string> configMocDefines;
   std::map<std::string, std::string> configUicOptions;
   {
-    // create a custom target for running generators at buildtime:
+    const bool mocEnabled = target->GetPropertyAsBool("AUTOMOC");
+    const bool uicEnabled = target->GetPropertyAsBool("AUTOUIC");
+    const bool rccEnabled = target->GetPropertyAsBool("AUTORCC");
     const std::string autogenTargetName = GetAutogenTargetName(target);
     const std::string qtMajorVersion = GetQtMajorVersion(target);
 
-    AddDefinitionEscaped(makefile, "_autogen_target_name", autogenTargetName);
-    AddDefinitionEscaped(makefile, "_origin_target_name", target->GetName());
-    AddDefinitionEscaped(makefile, "_qt_version_major", qtMajorVersion);
-
     std::vector<std::string> _sources;
     std::vector<std::string> _headers;
-    std::vector<std::string> mocSkipList;
-    std::vector<std::string> uicSkipList;
 
-    if (target->GetPropertyAsBool("AUTOMOC") ||
-        target->GetPropertyAsBool("AUTOUIC") ||
-        target->GetPropertyAsBool("AUTORCC")) {
-      SetupSourceFiles(target, _sources, _headers, mocSkipList, uicSkipList);
+    if (mocEnabled || uicEnabled || rccEnabled) {
+      std::vector<std::string> mocSkipList;
+      std::vector<std::string> uicSkipList;
+      AcquireScanFiles(target, _sources, _headers, mocSkipList, uicSkipList);
+      if (mocEnabled) {
+        MocSetupAutoTarget(target, autogenTargetName, qtMajorVersion,
+                           mocSkipList, configMocIncludes, configMocDefines);
+      }
+      if (uicEnabled) {
+        UicSetupAutoTarget(target, qtMajorVersion, uicSkipList,
+                           configUicOptions);
+      }
+      if (rccEnabled) {
+        RccSetupAutoTarget(target, qtMajorVersion);
+      }
     }
+
+    AddDefinitionEscaped(makefile, "_autogen_target_name", autogenTargetName);
+    AddDefinitionEscaped(makefile, "_origin_target_name", target->GetName());
+    AddDefinitionEscaped(makefile, "_qt_version_major", qtMajorVersion);
     AddDefinitionEscaped(makefile, "_sources", _sources);
     AddDefinitionEscaped(makefile, "_headers", _headers);
-
-    if (target->GetPropertyAsBool("AUTOMOC")) {
-      MocSetupAutoTarget(target, autogenTargetName, qtMajorVersion,
-                         mocSkipList, configMocIncludes, configMocDefines);
-    }
-    if (target->GetPropertyAsBool("AUTOUIC")) {
-      UicSetupAutoTarget(target, qtMajorVersion, uicSkipList,
-                         configUicOptions);
-    }
-    if (target->GetPropertyAsBool("AUTORCC")) {
-      RccSetupAutoTarget(target, qtMajorVersion);
-    }
   }
 
   // Generate config file

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=86e4fcadd5edc38a9291366de61ca9fe63eae4f8
commit 86e4fcadd5edc38a9291366de61ca9fe63eae4f8
Author:     Sebastian Holtermann <sebholt at xwmw.org>
AuthorDate: Thu Mar 2 14:06:02 2017 +0100
Commit:     Sebastian Holtermann <sebholt at xwmw.org>
CommitDate: Thu Mar 2 21:51:29 2017 +0100

    Autogen: Add support for generated .qrc files

diff --git a/Source/cmQtAutoGeneratorCommon.cxx b/Source/cmQtAutoGeneratorCommon.cxx
index 5146b1a..dcd61a3 100644
--- a/Source/cmQtAutoGeneratorCommon.cxx
+++ b/Source/cmQtAutoGeneratorCommon.cxx
@@ -24,47 +24,62 @@ static std::string utilStripCR(std::string const& line)
 /// @brief Reads the resource files list from from a .qrc file - Qt4 version
 /// @return True if the .qrc file was successfully parsed
 static bool RccListInputsQt4(const std::string& fileName,
-                             std::vector<std::string>& files)
+                             std::vector<std::string>& files,
+                             std::string* errorMessage)
 {
-  // Qrc file directory
-  std::string qrcDir(cmsys::SystemTools::GetFilenamePath(fileName));
-  if (!qrcDir.empty()) {
-    qrcDir += '/';
-  }
-
-  // Read file into string
+  bool allGood = true;
+  // Read qrc file content into string
   std::string qrcContents;
   {
-    std::ostringstream stream;
-    stream << cmsys::ifstream(fileName).rdbuf();
-    qrcContents = stream.str();
+    cmsys::ifstream ifs(fileName.c_str());
+    if (ifs) {
+      std::ostringstream osst;
+      osst << ifs.rdbuf();
+      qrcContents = osst.str();
+    } else {
+      if (errorMessage != CM_NULLPTR) {
+        std::ostringstream ost;
+        ost << "AutoRcc: Error: Rcc file not readable:\n"
+            << cmQtAutoGeneratorCommon::Quoted(fileName) << "\n";
+        *errorMessage = ost.str();
+      }
+      allGood = false;
+    }
   }
-
-  cmsys::RegularExpression fileMatchRegex("(<file[^<]+)");
-  cmsys::RegularExpression fileReplaceRegex("(^<file[^>]*>)");
-
-  size_t offset = 0;
-  while (fileMatchRegex.find(qrcContents.c_str() + offset)) {
-    std::string qrcEntry = fileMatchRegex.match(1);
-    offset += qrcEntry.size();
-    {
-      fileReplaceRegex.find(qrcEntry);
-      std::string tag = fileReplaceRegex.match(1);
-      qrcEntry = qrcEntry.substr(tag.size());
+  if (allGood) {
+    // qrc file directory
+    std::string qrcDir(cmsys::SystemTools::GetFilenamePath(fileName));
+    if (!qrcDir.empty()) {
+      qrcDir += '/';
     }
-    if (!cmSystemTools::FileIsFullPath(qrcEntry.c_str())) {
-      qrcEntry = qrcDir + qrcEntry;
+
+    cmsys::RegularExpression fileMatchRegex("(<file[^<]+)");
+    cmsys::RegularExpression fileReplaceRegex("(^<file[^>]*>)");
+
+    size_t offset = 0;
+    while (fileMatchRegex.find(qrcContents.c_str() + offset)) {
+      std::string qrcEntry = fileMatchRegex.match(1);
+      offset += qrcEntry.size();
+      {
+        fileReplaceRegex.find(qrcEntry);
+        std::string tag = fileReplaceRegex.match(1);
+        qrcEntry = qrcEntry.substr(tag.size());
+      }
+      if (!cmSystemTools::FileIsFullPath(qrcEntry.c_str())) {
+        qrcEntry = qrcDir + qrcEntry;
+      }
+      files.push_back(qrcEntry);
     }
-    files.push_back(qrcEntry);
   }
-  return true;
+  return allGood;
 }
 
 /// @brief Reads the resource files list from from a .qrc file - Qt5 version
 /// @return True if the .qrc file was successfully parsed
 static bool RccListInputsQt5(const std::string& rccCommand,
                              const std::string& fileName,
-                             std::vector<std::string>& files)
+                             std::vector<std::string>& files,
+                             std::string* errorMessage)
 {
   if (rccCommand.empty()) {
     cmSystemTools::Error("AutoRcc: Error: rcc executable not available\n");
@@ -104,11 +119,14 @@ static bool RccListInputsQt5(const std::string& rccCommand,
                                       CM_NULLPTR, cmSystemTools::OUTPUT_NONE);
   }
   if (!result || retVal) {
-    std::ostringstream err;
-    err << "AUTOGEN: error: Rcc list process for " << fileName << " failed:\n"
-        << rccStdOut << "\n"
-        << rccStdErr << std::endl;
-    cmSystemTools::Error(err.str().c_str());
+    if (errorMessage != CM_NULLPTR) {
+      std::ostringstream ost;
+      ost << "AutoRcc: Error: Rcc list process for " << fileName
+          << " failed:\n"
+          << rccStdOut << "\n"
+          << rccStdErr << "\n";
+      *errorMessage = ost.str();
+    }
     return false;
   }
 
@@ -134,10 +152,12 @@ static bool RccListInputsQt5(const std::string& rccCommand,
 
         std::string::size_type pos = eline.find(searchString);
         if (pos == std::string::npos) {
-          std::ostringstream err;
-          err << "AUTOGEN: error: Rcc lists unparsable output " << eline
-              << std::endl;
-          cmSystemTools::Error(err.str().c_str());
+          if (errorMessage != CM_NULLPTR) {
+            std::ostringstream ost;
+            ost << "AutoRcc: Error: Rcc lists unparsable output:\n"
+                << cmQtAutoGeneratorCommon::Quoted(eline) << "\n";
+            *errorMessage = ost.str();
+          }
           return false;
         }
         pos += searchString.length();
@@ -154,13 +174,42 @@ static bool RccListInputsQt5(const std::string& rccCommand,
 
 const char* cmQtAutoGeneratorCommon::listSep = "@LSEP@";
 
+std::string cmQtAutoGeneratorCommon::Quoted(const std::string& text)
+{
+  static const char* rep[18] = { "\\", "\\\\", "\"", "\\\"", "\a", "\\a",
+                                 "\b", "\\b",  "\f", "\\f",  "\n", "\\n",
+                                 "\r", "\\r",  "\t", "\\t",  "\v", "\\v" };
+
+  std::string res = text;
+  for (const char* const* it = cmArrayBegin(rep); it != cmArrayEnd(rep);
+       it += 2) {
+    cmSystemTools::ReplaceString(res, *it, *(it + 1));
+  }
+  res = '"' + res;
+  res += '"';
+  return res;
+}
+
 bool cmQtAutoGeneratorCommon::RccListInputs(const std::string& qtMajorVersion,
                                             const std::string& rccCommand,
                                             const std::string& fileName,
-                                            std::vector<std::string>& files)
+                                            std::vector<std::string>& files,
+                                            std::string* errorMessage)
 {
-  if (qtMajorVersion == "4") {
-    return RccListInputsQt4(fileName, files);
+  bool allGood = false;
+  if (cmsys::SystemTools::FileExists(fileName.c_str())) {
+    if (qtMajorVersion == "4") {
+      allGood = RccListInputsQt4(fileName, files, errorMessage);
+    } else {
+      allGood = RccListInputsQt5(rccCommand, fileName, files, errorMessage);
+    }
+  } else {
+    if (errorMessage != CM_NULLPTR) {
+      std::ostringstream ost;
+      ost << "AutoRcc: Error: Rcc file does not exist:\n"
+          << cmQtAutoGeneratorCommon::Quoted(fileName) << "\n";
+      *errorMessage = ost.str();
+    }
   }
-  return RccListInputsQt5(rccCommand, fileName, files);
+  return allGood;
 }
diff --git a/Source/cmQtAutoGeneratorCommon.h b/Source/cmQtAutoGeneratorCommon.h
index 48abacb..ee97b71 100644
--- a/Source/cmQtAutoGeneratorCommon.h
+++ b/Source/cmQtAutoGeneratorCommon.h
@@ -17,13 +17,18 @@ public:
   static const char* listSep;
 
 public:
+  /// @brief Returns a the string escaped and enclosed in quotes
+  ///
+  static std::string Quoted(const std::string& text);
+
   /// @brief Reads the resource files list from from a .qrc file
   /// @arg fileName Must be the absolute path of the .qrc file
   /// @return True if the rcc file was successfully parsed
   static bool RccListInputs(const std::string& qtMajorVersion,
                             const std::string& rccCommand,
                             const std::string& fileName,
-                            std::vector<std::string>& files);
+                            std::vector<std::string>& files,
+                            std::string* errorMessage = CM_NULLPTR);
 };
 
 #endif
diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx
index 0f29e02..2b53982 100644
--- a/Source/cmQtAutoGeneratorInitializer.cxx
+++ b/Source/cmQtAutoGeneratorInitializer.cxx
@@ -490,13 +490,15 @@ static void RccSetupAutoTarget(cmGeneratorTarget const* target,
         // qrc file entries
         {
           std::string entriesList = "{";
+          // Read input file list only for non generated .qrc files.
           if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"))) {
+            std::string error;
             std::vector<std::string> files;
             if (cmQtAutoGeneratorCommon::RccListInputs(
-                  qtMajorVersion, rccCommand, absFile, files)) {
+                  qtMajorVersion, rccCommand, absFile, files, &error)) {
               entriesList += cmJoin(files, cmQtAutoGeneratorCommon::listSep);
             } else {
-              return;
+              cmSystemTools::Error(error.c_str());
             }
           }
           entriesList += "}";
@@ -690,8 +692,13 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
 #endif
               ) {
             if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"))) {
-              cmQtAutoGeneratorCommon::RccListInputs(
-                qtMajorVersion, rccCommand, absFile, depends);
+              {
+                std::string error;
+                if (!cmQtAutoGeneratorCommon::RccListInputs(
+                      qtMajorVersion, rccCommand, absFile, depends, &error)) {
+                  cmSystemTools::Error(error.c_str());
+                }
+              }
 #if defined(_WIN32) && !defined(__CYGWIN__)
               // Cannot use PRE_BUILD because the resource files themselves
               // may not be sources within the target so VS may not know the
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index 4d14e99..2510066 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -37,23 +37,9 @@ static const char* SettingsKeyRcc = "AM_RCC_OLD_SETTINGS";
 
 // -- Static functions
 
-/**
- * @brief Returns a the string escaped and enclosed in quotes
- */
-static std::string Quoted(const std::string& text)
+inline static std::string Quoted(const std::string& text)
 {
-  static const char* rep[18] = { "\\", "\\\\", "\"", "\\\"", "\a", "\\a",
-                                 "\b", "\\b",  "\f", "\\f",  "\n", "\\n",
-                                 "\r", "\\r",  "\t", "\\t",  "\v", "\\v" };
-
-  std::string res = text;
-  for (const char* const* it = cmArrayBegin(rep); it != cmArrayEnd(rep);
-       it += 2) {
-    cmSystemTools::ReplaceString(res, *it, *(it + 1));
-  }
-  res = '"' + res;
-  res += '"';
-  return res;
+  return cmQtAutoGeneratorCommon::Quoted(text);
 }
 
 static void InfoGet(cmMakefile* makefile, const char* key, std::string& value)
@@ -403,7 +389,8 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(
       } else {
         this->LogError(
           "AutoMoc: Error: AUTOMOC_DEPEND_FILTERS list size is not "
-          "a multiple of 2");
+          "a multiple of 2 in:\n" +
+          Quoted(filename));
         return false;
       }
     }
@@ -431,8 +418,8 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(
         }
       } else {
         this->LogError(
-          "AutoGen: Error: Uic files/options lists size missmatch in: " +
-          filename);
+          "AutoGen: Error: Uic files/options lists size missmatch in:\n" +
+          Quoted(filename));
         return false;
       }
     }
@@ -447,7 +434,7 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(
       std::vector<std::string> rccOptionsVec;
       InfoGet(makefile, "AM_RCC_OPTIONS_FILES", rccFilesVec);
       InfoGet(makefile, "AM_RCC_OPTIONS_OPTIONS", rccOptionsVec);
-      if (rccFilesVec.size() != rccOptionsVec.size()) {
+      if (rccFilesVec.size() == rccOptionsVec.size()) {
         for (std::vector<std::string>::iterator
                fileIt = rccFilesVec.begin(),
                optionIt = rccOptionsVec.begin();
@@ -459,8 +446,8 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(
         }
       } else {
         this->LogError(
-          "AutoGen: Error: RCC files/options lists size missmatch in: " +
-          filename);
+          "AutoGen: Error: RCC files/options lists size missmatch in:\n" +
+          Quoted(filename));
         return false;
       }
     }
@@ -484,8 +471,8 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(
         }
       } else {
         this->LogError(
-          "AutoGen: Error: RCC sources/inputs lists size missmatch in: " +
-          filename);
+          "AutoGen: Error: RCC sources/inputs lists size missmatch in:\n" +
+          Quoted(filename));
         return false;
       }
     }
@@ -1574,13 +1561,30 @@ bool cmQtAutoGenerators::RccGenerateFile(const std::string& rccInputFile,
     // Test if the resources list file is newer than build file
     generateRcc = FileAbsentOrOlder(rccBuildFile, rccInputFile);
     if (!generateRcc) {
-      // Test if any resource file is newer than the build file
-      const std::vector<std::string>& files = this->RccInputs[rccInputFile];
-      for (std::vector<std::string>::const_iterator it = files.begin();
-           it != files.end(); ++it) {
-        if (FileAbsentOrOlder(rccBuildFile, *it)) {
-          generateRcc = true;
-          break;
+      // Acquire input file list
+      std::vector<std::string> readFiles;
+      const std::vector<std::string>* files = &this->RccInputs[rccInputFile];
+      if (files->empty()) {
+        // Read input file list from qrc file
+        std::string error;
+        if (cmQtAutoGeneratorCommon::RccListInputs(
+              this->QtMajorVersion, this->RccExecutable, rccInputFile,
+              readFiles, &error)) {
+          files = &readFiles;
+        } else {
+          files = CM_NULLPTR;
+          this->LogError(error);
+          this->RunRccFailed = true;
+        }
+      }
+      // Test if any input file is newer than the build file
+      if (files != CM_NULLPTR) {
+        for (std::vector<std::string>::const_iterator it = files->begin();
+             it != files->end(); ++it) {
+          if (FileAbsentOrOlder(rccBuildFile, *it)) {
+            generateRcc = true;
+            break;
+          }
         }
       }
     }

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=04ecb9a1df0ec91c1e6eb0eefb3719b84ac85dab
commit 04ecb9a1df0ec91c1e6eb0eefb3719b84ac85dab
Author:     Sebastian Holtermann <sebholt at xwmw.org>
AuthorDate: Thu Mar 2 12:32:47 2017 +0100
Commit:     Sebastian Holtermann <sebholt at xwmw.org>
CommitDate: Thu Mar 2 16:39:38 2017 +0100

    Autogen: Embrace qrc file lists in braces in AutogenInfo.cmake
    
    This allows empty .qrc files in any list position.

diff --git a/Source/cmQtAutoGeneratorCommon.cxx b/Source/cmQtAutoGeneratorCommon.cxx
index c42f71d..5146b1a 100644
--- a/Source/cmQtAutoGeneratorCommon.cxx
+++ b/Source/cmQtAutoGeneratorCommon.cxx
@@ -152,7 +152,7 @@ static bool RccListInputsQt5(const std::string& rccCommand,
 
 // - Class definitions
 
-const char* cmQtAutoGeneratorCommon::listSep = "@list_sep@";
+const char* cmQtAutoGeneratorCommon::listSep = "@LSEP@";
 
 bool cmQtAutoGeneratorCommon::RccListInputs(const std::string& qtMajorVersion,
                                             const std::string& rccCommand,
diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx
index 151f39c..0f29e02 100644
--- a/Source/cmQtAutoGeneratorInitializer.cxx
+++ b/Source/cmQtAutoGeneratorInitializer.cxx
@@ -489,16 +489,17 @@ static void RccSetupAutoTarget(cmGeneratorTarget const* target,
         _rcc_files.push_back(absFile);
         // qrc file entries
         {
-          std::string entriesList;
+          std::string entriesList = "{";
           if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"))) {
             std::vector<std::string> files;
             if (cmQtAutoGeneratorCommon::RccListInputs(
                   qtMajorVersion, rccCommand, absFile, files)) {
-              entriesList = cmJoin(files, cmQtAutoGeneratorCommon::listSep);
+              entriesList += cmJoin(files, cmQtAutoGeneratorCommon::listSep);
             } else {
               return;
             }
           }
+          entriesList += "}";
           _rcc_inputs.push_back(entriesList);
         }
         // rcc options for this qrc file
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index bc9c511..4d14e99 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -441,49 +441,53 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(
   // - Rcc
   if (this->RccEnabled()) {
     InfoGet(makefile, "AM_RCC_SOURCES", this->RccSources);
+    // File options
     {
       std::vector<std::string> rccFilesVec;
       std::vector<std::string> rccOptionsVec;
       InfoGet(makefile, "AM_RCC_OPTIONS_FILES", rccFilesVec);
       InfoGet(makefile, "AM_RCC_OPTIONS_OPTIONS", rccOptionsVec);
       if (rccFilesVec.size() != rccOptionsVec.size()) {
+        for (std::vector<std::string>::iterator
+               fileIt = rccFilesVec.begin(),
+               optionIt = rccOptionsVec.begin();
+             fileIt != rccFilesVec.end(); ++fileIt, ++optionIt) {
+          // Replace item separator
+          cmSystemTools::ReplaceString(*optionIt,
+                                       cmQtAutoGeneratorCommon::listSep, ";");
+          this->RccOptions[*fileIt] = *optionIt;
+        }
+      } else {
         this->LogError(
           "AutoGen: Error: RCC files/options lists size missmatch in: " +
           filename);
         return false;
       }
-      for (std::vector<std::string>::iterator fileIt = rccFilesVec.begin(),
-                                              optionIt = rccOptionsVec.begin();
-           fileIt != rccFilesVec.end(); ++fileIt, ++optionIt) {
-        cmSystemTools::ReplaceString(*optionIt,
-                                     cmQtAutoGeneratorCommon::listSep, ";");
-        this->RccOptions[*fileIt] = *optionIt;
-      }
     }
+    // File lists
     {
       std::vector<std::string> rccInputLists;
       InfoGet(makefile, "AM_RCC_INPUTS", rccInputLists);
-
-      // qrc files in the end of the list may have been empty
-      if (rccInputLists.size() < this->RccSources.size()) {
-        rccInputLists.resize(this->RccSources.size());
-      }
-      if (this->RccSources.size() != rccInputLists.size()) {
+      if (this->RccSources.size() == rccInputLists.size()) {
+        for (std::vector<std::string>::iterator
+               fileIt = this->RccSources.begin(),
+               inputIt = rccInputLists.begin();
+             fileIt != this->RccSources.end(); ++fileIt, ++inputIt) {
+          // Remove braces
+          *inputIt = inputIt->substr(1, inputIt->size() - 2);
+          // Replace item separator
+          cmSystemTools::ReplaceString(*inputIt,
+                                       cmQtAutoGeneratorCommon::listSep, ";");
+          std::vector<std::string> rccInputFiles;
+          cmSystemTools::ExpandListArgument(*inputIt, rccInputFiles);
+          this->RccInputs[*fileIt] = rccInputFiles;
+        }
+      } else {
         this->LogError(
           "AutoGen: Error: RCC sources/inputs lists size missmatch in: " +
           filename);
         return false;
       }
-      for (std::vector<std::string>::iterator
-             fileIt = this->RccSources.begin(),
-             inputIt = rccInputLists.begin();
-           fileIt != this->RccSources.end(); ++fileIt, ++inputIt) {
-        cmSystemTools::ReplaceString(*inputIt,
-                                     cmQtAutoGeneratorCommon::listSep, ";");
-        std::vector<std::string> rccInputFiles;
-        cmSystemTools::ExpandListArgument(*inputIt, rccInputFiles);
-        this->RccInputs[*fileIt] = rccInputFiles;
-      }
     }
   }
 

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f9531b373f27367ac0d8c4beae474768b7745b59
commit f9531b373f27367ac0d8c4beae474768b7745b59
Author:     Sebastian Holtermann <sebholt at xwmw.org>
AuthorDate: Tue Feb 28 12:34:35 2017 +0100
Commit:     Sebastian Holtermann <sebholt at xwmw.org>
CommitDate: Thu Mar 2 16:39:38 2017 +0100

    Autogen: Remove unused variables

diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx
index 3a7951a..151f39c 100644
--- a/Source/cmQtAutoGeneratorInitializer.cxx
+++ b/Source/cmQtAutoGeneratorInitializer.cxx
@@ -135,15 +135,12 @@ static void SetupSourceFiles(cmGeneratorTarget const* target,
                              std::vector<std::string>& mocSkipList,
                              std::vector<std::string>& uicSkipList)
 {
-  cmMakefile* makefile = target->Target->GetMakefile();
-
   std::vector<cmSourceFile*> srcFiles;
   target->GetConfigCommonSourceFiles(srcFiles);
 
   const bool mocTarget = target->GetPropertyAsBool("AUTOMOC");
   const bool uicTarget = target->GetPropertyAsBool("AUTOUIC");
 
-  cmFilePathChecksum fpathCheckSum(makefile);
   for (std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
        fileIt != srcFiles.end(); ++fileIt) {
     cmSourceFile* sf = *fileIt;

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=100723035ac228187e60f549dd38c8f89c447b40
commit 100723035ac228187e60f549dd38c8f89c447b40
Author:     Sebastian Holtermann <sebholt at xwmw.org>
AuthorDate: Tue Feb 28 12:08:26 2017 +0100
Commit:     Sebastian Holtermann <sebholt at xwmw.org>
CommitDate: Thu Mar 2 16:39:38 2017 +0100

    Autogen: Add cmQtAutogeneratorCommon class with shared types and functions

diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 76b98fc..5f2cbc3 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -344,6 +344,8 @@ set(SRCS
   cmPropertyDefinitionMap.h
   cmPropertyMap.cxx
   cmPropertyMap.h
+  cmQtAutoGeneratorCommon.cxx
+  cmQtAutoGeneratorCommon.h
   cmQtAutoGeneratorInitializer.cxx
   cmQtAutoGeneratorInitializer.h
   cmQtAutoGenerators.cxx
diff --git a/Source/cmQtAutoGeneratorCommon.cxx b/Source/cmQtAutoGeneratorCommon.cxx
new file mode 100644
index 0000000..c42f71d
--- /dev/null
+++ b/Source/cmQtAutoGeneratorCommon.cxx
@@ -0,0 +1,166 @@
+/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
+   file Copyright.txt or https://cmake.org/licensing for details.  */
+#include "cmQtAutoGeneratorCommon.h"
+#include "cmAlgorithms.h"
+#include "cmSystemTools.h"
+
+#include <cmsys/FStream.hxx>
+#include <cmsys/RegularExpression.hxx>
+
+#include <sstream>
+
+// - Static functions
+
+static std::string utilStripCR(std::string const& line)
+{
+  // Strip CR characters rcc may have printed (possibly more than one!).
+  std::string::size_type cr = line.find('\r');
+  if (cr != line.npos) {
+    return line.substr(0, cr);
+  }
+  return line;
+}
+
+/// @brief Reads the resource files list from from a .qrc file - Qt4 version
+/// @return True if the .qrc file was successfully parsed
+static bool RccListInputsQt4(const std::string& fileName,
+                             std::vector<std::string>& files)
+{
+  // Qrc file directory
+  std::string qrcDir(cmsys::SystemTools::GetFilenamePath(fileName));
+  if (!qrcDir.empty()) {
+    qrcDir += '/';
+  }
+
+  // Read file into string
+  std::string qrcContents;
+  {
+    std::ostringstream stream;
+    stream << cmsys::ifstream(fileName).rdbuf();
+    qrcContents = stream.str();
+  }
+
+  cmsys::RegularExpression fileMatchRegex("(<file[^<]+)");
+  cmsys::RegularExpression fileReplaceRegex("(^<file[^>]*>)");
+
+  size_t offset = 0;
+  while (fileMatchRegex.find(qrcContents.c_str() + offset)) {
+    std::string qrcEntry = fileMatchRegex.match(1);
+    offset += qrcEntry.size();
+    {
+      fileReplaceRegex.find(qrcEntry);
+      std::string tag = fileReplaceRegex.match(1);
+      qrcEntry = qrcEntry.substr(tag.size());
+    }
+    if (!cmSystemTools::FileIsFullPath(qrcEntry.c_str())) {
+      qrcEntry = qrcDir + qrcEntry;
+    }
+    files.push_back(qrcEntry);
+  }
+  return true;
+}
+
+/// @brief Reads the resource files list from from a .qrc file - Qt5 version
+/// @return True if the .qrc file was successfully parsed
+static bool RccListInputsQt5(const std::string& rccCommand,
+                             const std::string& fileName,
+                             std::vector<std::string>& files)
+{
+  if (rccCommand.empty()) {
+    cmSystemTools::Error("AutoRcc: Error: rcc executable not available\n");
+    return false;
+  }
+
+  // Read rcc features
+  bool hasDashDashList = false;
+  {
+    std::vector<std::string> command;
+    command.push_back(rccCommand);
+    command.push_back("--help");
+    std::string rccStdOut;
+    std::string rccStdErr;
+    int retVal = 0;
+    bool result =
+      cmSystemTools::RunSingleCommand(command, &rccStdOut, &rccStdErr, &retVal,
+                                      CM_NULLPTR, cmSystemTools::OUTPUT_NONE);
+    if (result && retVal == 0 &&
+        rccStdOut.find("--list") != std::string::npos) {
+      hasDashDashList = true;
+    }
+  }
+
+  // Run rcc list command
+  bool result = false;
+  int retVal = 0;
+  std::string rccStdOut;
+  std::string rccStdErr;
+  {
+    std::vector<std::string> command;
+    command.push_back(rccCommand);
+    command.push_back(hasDashDashList ? "--list" : "-list");
+    command.push_back(fileName);
+    result =
+      cmSystemTools::RunSingleCommand(command, &rccStdOut, &rccStdErr, &retVal,
+                                      CM_NULLPTR, cmSystemTools::OUTPUT_NONE);
+  }
+  if (!result || retVal) {
+    std::ostringstream err;
+    err << "AUTOGEN: error: Rcc list process for " << fileName << " failed:\n"
+        << rccStdOut << "\n"
+        << rccStdErr << std::endl;
+    cmSystemTools::Error(err.str().c_str());
+    return false;
+  }
+
+  // Parse rcc std output
+  {
+    std::istringstream ostr(rccStdOut);
+    std::string oline;
+    while (std::getline(ostr, oline)) {
+      oline = utilStripCR(oline);
+      if (!oline.empty()) {
+        files.push_back(oline);
+      }
+    }
+  }
+  // Parse rcc error output
+  {
+    std::istringstream estr(rccStdErr);
+    std::string eline;
+    while (std::getline(estr, eline)) {
+      eline = utilStripCR(eline);
+      if (cmHasLiteralPrefix(eline, "RCC: Error in")) {
+        static std::string searchString = "Cannot find file '";
+
+        std::string::size_type pos = eline.find(searchString);
+        if (pos == std::string::npos) {
+          std::ostringstream err;
+          err << "AUTOGEN: error: Rcc lists unparsable output " << eline
+              << std::endl;
+          cmSystemTools::Error(err.str().c_str());
+          return false;
+        }
+        pos += searchString.length();
+        std::string::size_type sz = eline.size() - pos - 1;
+        files.push_back(eline.substr(pos, sz));
+      }
+    }
+  }
+
+  return true;
+}
+
+// - Class definitions
+
+const char* cmQtAutoGeneratorCommon::listSep = "@list_sep@";
+
+bool cmQtAutoGeneratorCommon::RccListInputs(const std::string& qtMajorVersion,
+                                            const std::string& rccCommand,
+                                            const std::string& fileName,
+                                            std::vector<std::string>& files)
+{
+  if (qtMajorVersion == "4") {
+    return RccListInputsQt4(fileName, files);
+  }
+  return RccListInputsQt5(rccCommand, fileName, files);
+}
diff --git a/Source/cmQtAutoGeneratorCommon.h b/Source/cmQtAutoGeneratorCommon.h
new file mode 100644
index 0000000..48abacb
--- /dev/null
+++ b/Source/cmQtAutoGeneratorCommon.h
@@ -0,0 +1,29 @@
+/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
+   file Copyright.txt or https://cmake.org/licensing for details.  */
+#ifndef cmQtAutoGeneratorCommon_h
+#define cmQtAutoGeneratorCommon_h
+
+#include <cmConfigure.h> // IWYU pragma: keep
+#include <string>
+#include <vector>
+
+class cmGeneratorTarget;
+class cmLocalGenerator;
+
+class cmQtAutoGeneratorCommon
+{
+  // - Types and statics
+public:
+  static const char* listSep;
+
+public:
+  /// @brief Reads the resource files list from from a .qrc file
+  /// @arg fileName Must be the absolute path of the .qrc file
+  /// @return True if the rcc file was successfully parsed
+  static bool RccListInputs(const std::string& qtMajorVersion,
+                            const std::string& rccCommand,
+                            const std::string& fileName,
+                            std::vector<std::string>& files);
+};
+
+#endif
diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx
index a45b3d5..3a7951a 100644
--- a/Source/cmQtAutoGeneratorInitializer.cxx
+++ b/Source/cmQtAutoGeneratorInitializer.cxx
@@ -1,6 +1,7 @@
 /* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmQtAutoGeneratorInitializer.h"
+#include "cmQtAutoGeneratorCommon.h"
 
 #include "cmAlgorithms.h"
 #include "cmCustomCommandLines.h"
@@ -44,16 +45,6 @@ static void utilCopyTargetProperty(cmTarget* destinationTarget,
   }
 }
 
-static std::string utilStripCR(std::string const& line)
-{
-  // Strip CR characters rcc may have printed (possibly more than one!).
-  std::string::size_type cr = line.find('\r');
-  if (cr != line.npos) {
-    return line.substr(0, cr);
-  }
-  return line;
-}
-
 static std::string GetSafeProperty(cmGeneratorTarget const* target,
                                    const char* key)
 {
@@ -361,7 +352,8 @@ static void UicSetupAutoTarget(
           uiFileFiles.push_back(absFile);
           {
             std::string opts = sf->GetProperty("AUTOUIC_OPTIONS");
-            cmSystemTools::ReplaceString(opts, ";", "@list_sep@");
+            cmSystemTools::ReplaceString(opts, ";",
+                                         cmQtAutoGeneratorCommon::listSep);
             uiFileOptions.push_back(opts);
           }
         }
@@ -469,146 +461,12 @@ static void RccMergeOptions(std::vector<std::string>& opts,
   opts.insert(opts.end(), extraOpts.begin(), extraOpts.end());
 }
 
-/// @brief Reads the resource files list from from a .qrc file - Qt5 version
-/// @return True if the .qrc file was successfully parsed
-static bool RccListInputsQt5(cmSourceFile* sf, cmGeneratorTarget const* target,
-                             std::vector<std::string>& depends)
-{
-  const std::string rccCommand = RccGetExecutable(target, "5");
-  if (rccCommand.empty()) {
-    cmSystemTools::Error("AUTOGEN: error: rcc executable not available\n");
-    return false;
-  }
-
-  bool hasDashDashList = false;
-  // Read rcc features
-  {
-    std::vector<std::string> command;
-    command.push_back(rccCommand);
-    command.push_back("--help");
-    std::string rccStdOut;
-    std::string rccStdErr;
-    int retVal = 0;
-    bool result =
-      cmSystemTools::RunSingleCommand(command, &rccStdOut, &rccStdErr, &retVal,
-                                      CM_NULLPTR, cmSystemTools::OUTPUT_NONE);
-    if (result && retVal == 0 &&
-        rccStdOut.find("--list") != std::string::npos) {
-      hasDashDashList = true;
-    }
-  }
-  // Run rcc list command
-  std::vector<std::string> command;
-  command.push_back(rccCommand);
-  command.push_back(hasDashDashList ? "--list" : "-list");
-
-  std::string absFile = cmsys::SystemTools::GetRealPath(sf->GetFullPath());
-  command.push_back(absFile);
-
-  std::string rccStdOut;
-  std::string rccStdErr;
-  int retVal = 0;
-  bool result =
-    cmSystemTools::RunSingleCommand(command, &rccStdOut, &rccStdErr, &retVal,
-                                    CM_NULLPTR, cmSystemTools::OUTPUT_NONE);
-  if (!result || retVal) {
-    std::ostringstream err;
-    err << "AUTOGEN: error: Rcc list process for " << sf->GetFullPath()
-        << " failed:\n"
-        << rccStdOut << "\n"
-        << rccStdErr << std::endl;
-    cmSystemTools::Error(err.str().c_str());
-    return false;
-  }
-
-  // Parse rcc list output
-  {
-    std::istringstream ostr(rccStdOut);
-    std::string oline;
-    while (std::getline(ostr, oline)) {
-      oline = utilStripCR(oline);
-      if (!oline.empty()) {
-        depends.push_back(oline);
-      }
-    }
-  }
-
-  {
-    std::istringstream estr(rccStdErr);
-    std::string eline;
-    while (std::getline(estr, eline)) {
-      eline = utilStripCR(eline);
-      if (cmHasLiteralPrefix(eline, "RCC: Error in")) {
-        static std::string searchString = "Cannot find file '";
-
-        std::string::size_type pos = eline.find(searchString);
-        if (pos == std::string::npos) {
-          std::ostringstream err;
-          err << "AUTOGEN: error: Rcc lists unparsable output " << eline
-              << std::endl;
-          cmSystemTools::Error(err.str().c_str());
-          return false;
-        }
-        pos += searchString.length();
-        std::string::size_type sz = eline.size() - pos - 1;
-        depends.push_back(eline.substr(pos, sz));
-      }
-    }
-  }
-
-  return true;
-}
-
-/// @brief Reads the resource files list from from a .qrc file - Qt4 version
-/// @return True if the .qrc file was successfully parsed
-static bool RccListInputsQt4(cmSourceFile* sf,
-                             std::vector<std::string>& depends)
-{
-  // Read file into string
-  std::string qrcContents;
-  {
-    std::ostringstream stream;
-    stream << cmsys::ifstream(sf->GetFullPath().c_str()).rdbuf();
-    qrcContents = stream.str();
-  }
-
-  cmsys::RegularExpression fileMatchRegex("(<file[^<]+)");
-  cmsys::RegularExpression fileReplaceRegex("(^<file[^>]*>)");
-
-  size_t offset = 0;
-  while (fileMatchRegex.find(qrcContents.c_str() + offset)) {
-    std::string qrcEntry = fileMatchRegex.match(1);
-    offset += qrcEntry.size();
-    {
-      fileReplaceRegex.find(qrcEntry);
-      std::string tag = fileReplaceRegex.match(1);
-      qrcEntry = qrcEntry.substr(tag.size());
-    }
-    if (!cmSystemTools::FileIsFullPath(qrcEntry.c_str())) {
-      qrcEntry = sf->GetLocation().GetDirectory() + "/" + qrcEntry;
-    }
-    depends.push_back(qrcEntry);
-  }
-  return true;
-}
-
-/// @brief Reads the resource files list from from a .qrc file
-/// @return True if the rcc file was successfully parsed
-static bool RccListInputs(const std::string& qtMajorVersion, cmSourceFile* sf,
-                          cmGeneratorTarget const* target,
-                          std::vector<std::string>& depends)
-{
-  if (qtMajorVersion == "5") {
-    return RccListInputsQt5(sf, target, depends);
-  }
-  return RccListInputsQt4(sf, depends);
-}
-
 static void RccSetupAutoTarget(cmGeneratorTarget const* target,
                                const std::string& qtMajorVersion)
 {
   cmMakefile* makefile = target->Target->GetMakefile();
   const bool qtMajorVersion5 = (qtMajorVersion == "5");
+  const std::string rccCommand = RccGetExecutable(target, qtMajorVersion);
   std::vector<std::string> _rcc_files;
   std::vector<std::string> _rcc_inputs;
   std::vector<std::string> rccFileFiles;
@@ -636,9 +494,10 @@ static void RccSetupAutoTarget(cmGeneratorTarget const* target,
         {
           std::string entriesList;
           if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"))) {
-            std::vector<std::string> depends;
-            if (RccListInputs(qtMajorVersion, sf, target, depends)) {
-              entriesList = cmJoin(depends, "@list_sep@");
+            std::vector<std::string> files;
+            if (cmQtAutoGeneratorCommon::RccListInputs(
+                  qtMajorVersion, rccCommand, absFile, files)) {
+              entriesList = cmJoin(files, cmQtAutoGeneratorCommon::listSep);
             } else {
               return;
             }
@@ -657,19 +516,19 @@ static void RccSetupAutoTarget(cmGeneratorTarget const* target,
           // Only store non empty options lists
           if (!rccOptions.empty()) {
             rccFileFiles.push_back(absFile);
-            rccFileOptions.push_back(cmJoin(rccOptions, "@list_sep@"));
+            rccFileOptions.push_back(
+              cmJoin(rccOptions, cmQtAutoGeneratorCommon::listSep));
           }
         }
       }
     }
   }
 
+  AddDefinitionEscaped(makefile, "_qt_rcc_executable", rccCommand);
   AddDefinitionEscaped(makefile, "_rcc_files", _rcc_files);
   AddDefinitionEscaped(makefile, "_rcc_inputs", _rcc_inputs);
   AddDefinitionEscaped(makefile, "_rcc_options_files", rccFileFiles);
   AddDefinitionEscaped(makefile, "_rcc_options_options", rccFileOptions);
-  AddDefinitionEscaped(makefile, "_qt_rcc_executable",
-                       RccGetExecutable(target, qtMajorVersion));
 }
 
 void cmQtAutoGeneratorInitializer::InitializeAutogenSources(
@@ -696,6 +555,7 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
   const std::string workingDirectory =
     cmSystemTools::CollapseFullPath("", makefile->GetCurrentBinaryDirectory());
   const std::string qtMajorVersion = GetQtMajorVersion(target);
+  const std::string rccCommand = RccGetExecutable(target, qtMajorVersion);
   std::vector<std::string> autogenOutputFiles;
 
   // Remove old settings on cleanup
@@ -825,20 +685,22 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
           target->AddSource(rccOutputFile);
           // Register rcc output file as generated
           autogenOutputFiles.push_back(rccOutputFile);
-        }
-        if (lg->GetGlobalGenerator()->GetName() == "Ninja"
+
+          if (lg->GetGlobalGenerator()->GetName() == "Ninja"
 #if defined(_WIN32) && !defined(__CYGWIN__)
-            || usePRE_BUILD
+              || usePRE_BUILD
 #endif
-            ) {
-          if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"))) {
-            RccListInputs(qtMajorVersion, sf, target, depends);
+              ) {
+            if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"))) {
+              cmQtAutoGeneratorCommon::RccListInputs(
+                qtMajorVersion, rccCommand, absFile, depends);
 #if defined(_WIN32) && !defined(__CYGWIN__)
-            // Cannot use PRE_BUILD because the resource files themselves
-            // may not be sources within the target so VS may not know the
-            // target needs to re-build at all.
-            usePRE_BUILD = false;
+              // Cannot use PRE_BUILD because the resource files themselves
+              // may not be sources within the target so VS may not know the
+              // target needs to re-build at all.
+              usePRE_BUILD = false;
 #endif
+            }
           }
         }
       }
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index c83f9a9..bc9c511 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -1,6 +1,7 @@
 /* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cmQtAutoGenerators.h"
+#include "cmQtAutoGeneratorCommon.h"
 
 #include <algorithm>
 #include <assert.h>
@@ -178,7 +179,7 @@ static std::string JoinOptionsMap(
   for (std::map<std::string, std::string>::const_iterator it = opts.begin();
        it != opts.end(); ++it) {
     if (it != opts.begin()) {
-      result += "@list_sep@";
+      result += cmQtAutoGeneratorCommon::listSep;
     }
     result += it->first;
     result += "===";
@@ -424,7 +425,8 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(
                fileIt = uicFilesVec.begin(),
                optionIt = uicOptionsVec.begin();
              fileIt != uicFilesVec.end(); ++fileIt, ++optionIt) {
-          cmSystemTools::ReplaceString(*optionIt, "@list_sep@", ";");
+          cmSystemTools::ReplaceString(*optionIt,
+                                       cmQtAutoGeneratorCommon::listSep, ";");
           this->UicOptions[*fileIt] = *optionIt;
         }
       } else {
@@ -453,7 +455,8 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(
       for (std::vector<std::string>::iterator fileIt = rccFilesVec.begin(),
                                               optionIt = rccOptionsVec.begin();
            fileIt != rccFilesVec.end(); ++fileIt, ++optionIt) {
-        cmSystemTools::ReplaceString(*optionIt, "@list_sep@", ";");
+        cmSystemTools::ReplaceString(*optionIt,
+                                     cmQtAutoGeneratorCommon::listSep, ";");
         this->RccOptions[*fileIt] = *optionIt;
       }
     }
@@ -475,7 +478,8 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(
              fileIt = this->RccSources.begin(),
              inputIt = rccInputLists.begin();
            fileIt != this->RccSources.end(); ++fileIt, ++inputIt) {
-        cmSystemTools::ReplaceString(*inputIt, "@list_sep@", ";");
+        cmSystemTools::ReplaceString(*inputIt,
+                                     cmQtAutoGeneratorCommon::listSep, ";");
         std::vector<std::string> rccInputFiles;
         cmSystemTools::ExpandListArgument(*inputIt, rccInputFiles);
         this->RccInputs[*fileIt] = rccInputFiles;

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=09be79c707ac6999ebad689bcf83b2cbcd3cd4a2
commit 09be79c707ac6999ebad689bcf83b2cbcd3cd4a2
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Wed Apr 6 14:03:28 2016 -0400
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Wed Mar 1 14:30:18 2017 -0500

    cmWorkingDirectory: add class for changing the workdir

diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 76b98fc..e47a2eb 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -381,6 +381,8 @@ set(SRCS
   cmVariableWatch.h
   cmVersion.cxx
   cmVersion.h
+  cmWorkingDirectory.cxx
+  cmWorkingDirectory.h
   cmXMLParser.cxx
   cmXMLParser.h
   cmXMLSafe.cxx
diff --git a/Source/cmWorkingDirectory.cxx b/Source/cmWorkingDirectory.cxx
new file mode 100644
index 0000000..99c9ba8
--- /dev/null
+++ b/Source/cmWorkingDirectory.cxx
@@ -0,0 +1,24 @@
+/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
+   file Copyright.txt or https://cmake.org/licensing for details.  */
+#include "cmWorkingDirectory.h"
+
+#include "cmSystemTools.h"
+
+cmWorkingDirectory::cmWorkingDirectory(std::string const& newdir)
+{
+  this->OldDir = cmSystemTools::GetCurrentWorkingDirectory();
+  cmSystemTools::ChangeDirectory(newdir);
+}
+
+cmWorkingDirectory::~cmWorkingDirectory()
+{
+  this->Pop();
+}
+
+void cmWorkingDirectory::Pop()
+{
+  if (!this->OldDir.empty()) {
+    cmSystemTools::ChangeDirectory(this->OldDir);
+    this->OldDir.clear();
+  }
+}
diff --git a/Source/cmWorkingDirectory.h b/Source/cmWorkingDirectory.h
new file mode 100644
index 0000000..091781e
--- /dev/null
+++ b/Source/cmWorkingDirectory.h
@@ -0,0 +1,23 @@
+/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
+   file Copyright.txt or https://cmake.org/licensing for details.  */
+#ifndef cmWorkingDirectory_h
+#define cmWorkingDirectory_h
+
+#include <string>
+
+/** \class cmWorkingDirectory
+ * \brief An RAII class to manipulate the working directory.
+ */
+class cmWorkingDirectory
+{
+public:
+  cmWorkingDirectory(std::string const& newdir);
+  ~cmWorkingDirectory();
+
+  void Pop();
+
+private:
+  std::string OldDir;
+};
+
+#endif
diff --git a/bootstrap b/bootstrap
index 8063edb..4f58365 100755
--- a/bootstrap
+++ b/bootstrap
@@ -404,6 +404,7 @@ CMAKE_CXX_SOURCES="\
   cmUnsetCommand \
   cmVersion \
   cmWhileCommand \
+  cmWorkingDirectory \
   cmake  \
   cmakemain \
   cmcmd  \

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1ee20805d3b0ed67dad7c2835d673c98961736ef
commit 1ee20805d3b0ed67dad7c2835d673c98961736ef
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Wed Apr 6 14:26:00 2016 -0400
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Wed Mar 1 13:34:41 2017 -0500

    cmCTest, cmCTestCoverageHandler: remove cwd dance
    
    The working directory changes here didn't really accomplish anything.

diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx
index 989c096..ead1c26 100644
--- a/Source/CTest/cmCTestCoverageHandler.cxx
+++ b/Source/CTest/cmCTestCoverageHandler.cxx
@@ -1646,11 +1646,7 @@ int cmCTestCoverageHandler::HandleTracePyCoverage(
 
   std::string testingDir = this->CTest->GetBinaryDir() + "/Testing";
   std::string tempDir = testingDir + "/CoverageInfo";
-  std::string currentDirectory = cmSystemTools::GetCurrentWorkingDirectory();
   cmSystemTools::MakeDirectory(tempDir.c_str());
-  cmSystemTools::ChangeDirectory(tempDir);
-
-  cmSystemTools::ChangeDirectory(currentDirectory);
 
   std::vector<std::string>::iterator fileIt;
   int file_count = 0;
@@ -1737,7 +1733,6 @@ int cmCTestCoverageHandler::HandleTracePyCoverage(
     }
     ++file_count;
   }
-  cmSystemTools::ChangeDirectory(currentDirectory);
   return file_count;
 }
 
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 559275e..e6e50e9 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -1122,7 +1122,6 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output,
     if (log) {
       *log << "* Run internal CTest" << std::endl;
     }
-    std::string oldpath = cmSystemTools::GetCurrentWorkingDirectory();
 
     CM_AUTO_PTR<cmSystemTools::SaveRestoreEnvironment> saveEnv;
     if (modifyEnv) {
@@ -1137,7 +1136,6 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output,
     if (log && output) {
       *log << *output;
     }
-    cmSystemTools::ChangeDirectory(oldpath);
     if (output) {
       cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
                  "Internal cmCTest object used to run test." << std::endl

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5ce0b3e7ce885931c2ffdf04c0a9ffc69a91e2f4
commit 5ce0b3e7ce885931c2ffdf04c0a9ffc69a91e2f4
Author:     Ben Boeckel <ben.boeckel at kitware.com>
AuthorDate: Wed Apr 6 14:22:43 2016 -0400
Commit:     Ben Boeckel <ben.boeckel at kitware.com>
CommitDate: Wed Mar 1 13:34:07 2017 -0500

    OSXScriptLauncher: remove unused variable

diff --git a/Source/CPack/OSXScriptLauncher.cxx b/Source/CPack/OSXScriptLauncher.cxx
index b159e64..aeabde9 100644
--- a/Source/CPack/OSXScriptLauncher.cxx
+++ b/Source/CPack/OSXScriptLauncher.cxx
@@ -20,7 +20,6 @@
 int main(int argc, char* argv[])
 {
   // if ( cmsys::SystemTools::FileExists(
-  std::string cwd = cmsys::SystemTools::GetCurrentWorkingDirectory();
   cmsys::ofstream ofs("/tmp/output.txt");
 
   CFStringRef fileName;

-----------------------------------------------------------------------

Summary of changes:
 Source/CMakeLists.txt                              |    4 +
 Source/CPack/OSXScriptLauncher.cxx                 |    1 -
 Source/CPack/cmCPackArchiveGenerator.cxx           |   10 +-
 Source/CPack/cmCPackGenerator.cxx                  |    4 +-
 Source/CTest/cmCTestBuildAndTestHandler.cxx        |   14 +-
 Source/CTest/cmCTestBuildAndTestHandler.h          |    2 +-
 Source/CTest/cmCTestCoverageHandler.cxx            |   25 +-
 Source/CTest/cmCTestHandlerCommand.cxx             |    5 +-
 Source/CTest/cmCTestMultiProcessHandler.cxx        |   11 +-
 Source/CTest/cmCTestRunTest.cxx                    |   19 +-
 Source/CTest/cmCTestSubmitHandler.cxx              |   13 +-
 Source/CTest/cmCTestTestHandler.cxx                |   70 +--
 Source/cmCTest.cxx                                 |    2 -
 Source/cmDepends.cxx                               |   14 +-
 Source/cmGlobalGenerator.cxx                       |    9 +-
 Source/cmMakefile.cxx                              |   11 +-
 Source/cmQtAutoGeneratorCommon.cxx                 |  215 +++++++++
 Source/cmQtAutoGeneratorCommon.h                   |   34 ++
 Source/cmQtAutoGeneratorInitializer.cxx            |  472 ++++++++------------
 Source/cmQtAutoGenerators.cxx                      |  225 ++++++----
 Source/cmQtAutoGenerators.h                        |    2 +-
 Source/cmWorkingDirectory.cxx                      |   24 +
 Source/cmWorkingDirectory.h                        |   23 +
 Source/cmake.cxx                                   |   30 +-
 Tests/QtAutogen/CMakeLists.txt                     |   98 ++--
 Tests/QtAutogen/automoc_rerun/test1.cpp            |    5 -
 Tests/QtAutogen/automoc_rerun/test1.h.in1          |    8 -
 Tests/QtAutogen/automoc_rerun/test1.h.in2          |    7 -
 Tests/QtAutogen/mocDepends/CMakeLists.txt          |   45 ++
 Tests/QtAutogen/mocDepends/invalid.hpp.in          |    1 +
 Tests/QtAutogen/mocDepends/object.hpp.in           |   14 +
 Tests/QtAutogen/mocDepends/simpleLib.cpp.in        |    9 +
 Tests/QtAutogen/mocDepends/simpleLib.hpp.in        |   11 +
 Tests/QtAutogen/mocDepends/test1.cpp               |    9 +
 Tests/QtAutogen/mocDepends/test2.cpp               |   10 +
 Tests/QtAutogen/mocDepends/test2.hpp               |   16 +
 .../{automoc_rerun => mocRerun}/CMakeLists.txt     |   14 +-
 .../{automoc_rerun => mocRerun}/input.txt          |    0
 Tests/QtAutogen/mocRerun/main.cpp.in               |   18 +
 .../QtAutogen/{automoc_rerun => mocRerun}/res1.qrc |    0
 Tests/QtAutogen/mocRerun/test1a.h.in               |    8 +
 Tests/QtAutogen/mocRerun/test1b.h.in               |    7 +
 .../{autorcc_depends => rccDepends}/CMakeLists.txt |   15 +-
 .../input.txt.in => rccDepends/res/input1.txt.in}  |    0
 Tests/QtAutogen/rccDepends/res/input2.txt.in       |    1 +
 .../{autorcc_depends => rccDepends}/res1.qrc.in    |    0
 .../res1.qrc => rccDepends/res2.qrc.in}            |    2 +-
 .../{autorcc_depends => rccDepends}/test_res1.cpp  |    0
 bootstrap                                          |    1 +
 49 files changed, 940 insertions(+), 598 deletions(-)
 create mode 100644 Source/cmQtAutoGeneratorCommon.cxx
 create mode 100644 Source/cmQtAutoGeneratorCommon.h
 create mode 100644 Source/cmWorkingDirectory.cxx
 create mode 100644 Source/cmWorkingDirectory.h
 delete mode 100644 Tests/QtAutogen/automoc_rerun/test1.cpp
 delete mode 100644 Tests/QtAutogen/automoc_rerun/test1.h.in1
 delete mode 100644 Tests/QtAutogen/automoc_rerun/test1.h.in2
 create mode 100644 Tests/QtAutogen/mocDepends/CMakeLists.txt
 create mode 100644 Tests/QtAutogen/mocDepends/invalid.hpp.in
 create mode 100644 Tests/QtAutogen/mocDepends/object.hpp.in
 create mode 100644 Tests/QtAutogen/mocDepends/simpleLib.cpp.in
 create mode 100644 Tests/QtAutogen/mocDepends/simpleLib.hpp.in
 create mode 100644 Tests/QtAutogen/mocDepends/test1.cpp
 create mode 100644 Tests/QtAutogen/mocDepends/test2.cpp
 create mode 100644 Tests/QtAutogen/mocDepends/test2.hpp
 rename Tests/QtAutogen/{automoc_rerun => mocRerun}/CMakeLists.txt (51%)
 rename Tests/QtAutogen/{automoc_rerun => mocRerun}/input.txt (100%)
 create mode 100644 Tests/QtAutogen/mocRerun/main.cpp.in
 copy Tests/QtAutogen/{automoc_rerun => mocRerun}/res1.qrc (100%)
 create mode 100644 Tests/QtAutogen/mocRerun/test1a.h.in
 create mode 100644 Tests/QtAutogen/mocRerun/test1b.h.in
 rename Tests/QtAutogen/{autorcc_depends => rccDepends}/CMakeLists.txt (51%)
 rename Tests/QtAutogen/{autorcc_depends/res1/input.txt.in => rccDepends/res/input1.txt.in} (100%)
 create mode 100644 Tests/QtAutogen/rccDepends/res/input2.txt.in
 rename Tests/QtAutogen/{autorcc_depends => rccDepends}/res1.qrc.in (100%)
 rename Tests/QtAutogen/{automoc_rerun/res1.qrc => rccDepends/res2.qrc.in} (61%)
 rename Tests/QtAutogen/{autorcc_depends => rccDepends}/test_res1.cpp (100%)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list