[Cmake-commits] CMake branch, next, updated. v3.5.2-1008-ge2559d1

Brad King brad.king at kitware.com
Tue Apr 19 13:13:56 EDT 2016


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  e2559d1d4c41819cb3e1f1353249b19f041e3732 (commit)
       via  840b830bc6a76afe207bc08ca164eaabb731acaf (commit)
       via  bc4c7751ab4ae28770f5bcf3595e632c40026be2 (commit)
       via  47e60bc5a09f5b3a71ce015025cd93af4270afb5 (commit)
       via  cf679ea8dcd04c1217cd7c664117439fdd370f10 (commit)
       via  3ea1d09082de6b5ed4fbb7f9be04a0172c01c0be (commit)
       via  8ced8bb95aee78ece751259f9cce23786fe4a1b2 (commit)
       via  95064a6d35c93557c9bb87bc8eeff8555d7295a2 (commit)
       via  7a73c404dd63aef0e68da9ef70ac706a6339c476 (commit)
      from  7faf4c230e2915fb670f395d981fa69ada9fc327 (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=e2559d1d4c41819cb3e1f1353249b19f041e3732
commit e2559d1d4c41819cb3e1f1353249b19f041e3732
Merge: 7faf4c2 840b830
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Tue Apr 19 13:13:55 2016 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Tue Apr 19 13:13:55 2016 -0400

    Merge topic 'autogen-cleanups' into next
    
    840b830b Autogen: Qrc processing: Generate single map with final input / output names
    bc4c7751 Autogen: Ui processing: Generate single map with final input / output names
    47e60bc5 Autogen: Split out UI file generation code to dedicated method
    cf679ea8 Autogen: Split out moc file generation code to dedicated method
    3ea1d090 Autogen: Rename method GenerateQrc{ => Files}
    8ced8bb9 Autogen: New logCommand method. It prints commands using std::cout.
    95064a6d Autogen: Rename header extension Join method to JoinExts
    7a73c404 Autogen: Use SystemTools string functions instead of rolling out own


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=840b830bc6a76afe207bc08ca164eaabb731acaf
commit 840b830bc6a76afe207bc08ca164eaabb731acaf
Author:     Sebastian Holtermann <sebholt at xwmw.org>
AuthorDate: Mon Apr 18 17:52:00 2016 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Apr 19 12:59:13 2016 -0400

    Autogen: Qrc processing: Generate single map with final input / output names

diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index b75868e..c07a0a6 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -1351,64 +1351,92 @@ bool cmQtAutoGenerators::InputFilesNewerThanQrc(const std::string& qrcFile,
 
 bool cmQtAutoGenerators::GenerateQrcFiles()
 {
+  // generate single map with input / output names
+  std::map<std::string, std::string> qrcGenMap;
   for(std::vector<std::string>::const_iterator si = this->RccSources.begin();
       si != this->RccSources.end(); ++si)
     {
-    std::string ext = cmsys::SystemTools::GetFilenameLastExtension(*si);
-
-    if (ext != ".qrc")
+    const std::string ext = cmsys::SystemTools::GetFilenameLastExtension(*si);
+    if (ext == ".qrc")
       {
-      continue;
+      std::string basename = cmsys::SystemTools::
+        GetFilenameWithoutLastExtension(*si);
+      std::string qrcOutputFile = "CMakeFiles/" + this->OriginTargetName
+        + ".dir/qrc_" + basename + ".cpp";
+      qrcGenMap[*si] = qrcOutputFile;
       }
-    std::vector<std::string> command;
-    command.push_back(this->RccExecutable);
+    }
 
-    std::string basename = cmsys::SystemTools::
-                                  GetFilenameWithoutLastExtension(*si);
+  // generate qrc files
+  for(std::map<std::string, std::string>::const_iterator
+      si = qrcGenMap.begin(); si != qrcGenMap.end(); ++si)
+    {
+    if (!this->GenerateQrc( si->first, si->second))
+      {
+      if (this->RunRccFailed)
+        {
+        return false;
+        }
+      }
+    }
+  return true;
+}
 
-    std::string rcc_output_file = this->Builddir
-                                + "CMakeFiles/" + this->OriginTargetName
-                                + ".dir/qrc_" + basename + ".cpp";
+bool cmQtAutoGenerators::GenerateQrc (
+  const std::string& qrcInputFile,
+  const std::string& qrcOutputFile )
+{
+  const std::string basename = cmsys::SystemTools::
+    GetFilenameWithoutLastExtension(qrcInputFile);
+  const ::std::string qrcBuildFile = this->Builddir + qrcOutputFile;
+
+  int sourceNewerThanQrc = 0;
+  bool generateQrc = !cmsys::SystemTools::FileTimeCompare(qrcInputFile,
+                                                          qrcBuildFile,
+                                                          &sourceNewerThanQrc);
+  generateQrc = generateQrc || (sourceNewerThanQrc >= 0);
+  generateQrc = generateQrc || this->InputFilesNewerThanQrc(qrcInputFile,
+                                                            qrcBuildFile);
+
+  if (this->GenerateAll || generateQrc)
+    {
+    std::string msg = "Generating ";
+    msg += qrcOutputFile;
+    cmSystemTools::MakefileColorEcho(cmsysTerminal_Color_ForegroundBlue
+                                     |cmsysTerminal_Color_ForegroundBold,
+                                     msg.c_str(), true, this->ColorOutput);
 
-    int sourceNewerThanQrc = 0;
-    bool generateQrc = !cmsys::SystemTools::FileTimeCompare(*si,
-                                                      rcc_output_file,
-                                                      &sourceNewerThanQrc);
-    generateQrc = generateQrc || (sourceNewerThanQrc >= 0);
-    generateQrc = generateQrc || this->InputFilesNewerThanQrc(*si,
-                                                          rcc_output_file);
+    std::vector<std::string> command;
+    command.push_back(this->RccExecutable);
 
-    if (this->GenerateAll || generateQrc)
+    std::map<std::string, std::string>::const_iterator optionIt
+      = this->RccOptions.find(qrcInputFile);
+    if (optionIt != this->RccOptions.end())
       {
-      std::map<std::string, std::string>::const_iterator optionIt
-              = this->RccOptions.find(*si);
-      if (optionIt != this->RccOptions.end())
-        {
-        cmSystemTools::ExpandListArgument(optionIt->second, command);
-        }
+      cmSystemTools::ExpandListArgument(optionIt->second, command);
+      }
 
-      command.push_back("-name");
-      command.push_back(basename);
-      command.push_back("-o");
-      command.push_back(rcc_output_file);
-      command.push_back(*si);
+    command.push_back("-name");
+    command.push_back(basename);
+    command.push_back("-o");
+    command.push_back(qrcBuildFile);
+    command.push_back(qrcInputFile);
 
-      if (this->Verbose)
-        {
-        this->LogCommand(command);
-        }
-      std::string output;
-      int retVal = 0;
-      bool result = cmSystemTools::RunSingleCommand(command, &output, &output,
-                                                    &retVal);
-      if (!result || retVal)
-        {
-        std::cerr << "AUTORCC: error: process for " << rcc_output_file <<
-                  " failed:\n" << output << std::endl;
-        this->RunRccFailed = true;
-        cmSystemTools::RemoveFile(rcc_output_file);
-        return false;
-        }
+    if (this->Verbose)
+      {
+      this->LogCommand(command);
+      }
+    std::string output;
+    int retVal = 0;
+    bool result = cmSystemTools::RunSingleCommand(command, &output, &output,
+                                                  &retVal);
+    if (!result || retVal)
+      {
+      std::cerr << "AUTORCC: error: process for " << qrcOutputFile <<
+        " failed:\n" << output << std::endl;
+      this->RunRccFailed = true;
+      cmSystemTools::RemoveFile(qrcBuildFile);
+      return false;
       }
     }
   return true;
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
index d532c21..68ab480 100644
--- a/Source/cmQtAutoGenerators.h
+++ b/Source/cmQtAutoGenerators.h
@@ -50,6 +50,8 @@ private:
                   const std::string& uiInputFile,
                   const std::string& uiOutputFile );
   bool GenerateQrcFiles();
+  bool GenerateQrc(const std::string& qrcInputFile,
+                   const std::string& qrcOutputFile);
   void ParseCppFile(const std::string& absFilename,
               const std::vector<std::string>& headerExtensions,
               std::map<std::string, std::string>& includedMocs,

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bc4c7751ab4ae28770f5bcf3595e632c40026be2
commit bc4c7751ab4ae28770f5bcf3595e632c40026be2
Author:     Sebastian Holtermann <sebholt at xwmw.org>
AuthorDate: Mon Apr 18 16:51:24 2016 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Apr 19 12:59:06 2016 -0400

    Autogen: Ui processing: Generate single map with final input / output names
    
    The single map allows name collision testing (in a later commit)

diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index 91bacce..b75868e 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -1221,13 +1221,38 @@ bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile,
 bool cmQtAutoGenerators::GenerateUiFiles(
       const std::map<std::string, std::vector<std::string> >& includedUis )
 {
+  // single map with input / output names
+  std::map<std::string, std::map<std::string, std::string> > uiGenMap;
   for(std::map<std::string, std::vector<std::string> >::const_iterator
       it = includedUis.begin(); it != includedUis.end(); ++it)
     {
-    for (std::vector<std::string>::const_iterator nit = it->second.begin();
-         nit != it->second.end(); ++nit)
+    // source file path
+    std::string sourcePath = cmsys::SystemTools::GetFilenamePath(it->first);
+    sourcePath += '/';
+    // insert new map for source file an use new reference
+    uiGenMap[it->first] = std::map<std::string, std::string>();
+    std::map<std::string, std::string>& sourceMap = uiGenMap[it->first];
+    for (std::vector<std::string>::const_iterator sit = it->second.begin();
+         sit != it->second.end();
+         ++sit)
       {
-      if (!this->GenerateUi(it->first, *nit) )
+      const std::string & uiFileName = *sit;
+      const std::string uiInputFile = sourcePath + uiFileName + ".ui";
+      const std::string uiOutputFile = "ui_" + uiFileName + ".h";
+      sourceMap[uiInputFile] = uiOutputFile;
+      }
+    }
+
+  // generate ui files
+  for(std::map<std::string, std::map<std::string, std::string> >::
+      const_iterator it = uiGenMap.begin(); it != uiGenMap.end(); ++it)
+    {
+    for(std::map<std::string, std::string>::const_iterator
+        sit = it->second.begin();
+        sit != it->second.end();
+        ++sit)
+      {
+      if (!this->GenerateUi(it->first, sit->first, sit->second) )
         {
         if (this->RunUicFailed)
           {
@@ -1242,27 +1267,24 @@ bool cmQtAutoGenerators::GenerateUiFiles(
 
 
 bool cmQtAutoGenerators::GenerateUi(const std::string& realName,
-                                    const std::string& uiFileName)
+                                    const std::string& uiInputFile,
+                                    const std::string& uiOutputFile)
 {
   if (!cmsys::SystemTools::FileExists(this->Builddir.c_str(), false))
     {
     cmsys::SystemTools::MakeDirectory(this->Builddir.c_str());
     }
 
-  const std::string path = cmsys::SystemTools::GetFilenamePath(
-                                                      realName) + '/';
-
-  std::string ui_output_file = "ui_" + uiFileName + ".h";
-  std::string ui_input_file = path + uiFileName + ".ui";
+  const ::std::string uiBuildFile = this->Builddir + uiOutputFile;
 
   int sourceNewerThanUi = 0;
-  bool success = cmsys::SystemTools::FileTimeCompare(ui_input_file,
-                                    this->Builddir + ui_output_file,
+  bool success = cmsys::SystemTools::FileTimeCompare(uiInputFile,
+                                                     uiBuildFile,
                                                      &sourceNewerThanUi);
   if (this->GenerateAll || !success || sourceNewerThanUi >= 0)
     {
     std::string msg = "Generating ";
-    msg += ui_output_file;
+    msg += uiOutputFile;
     cmSystemTools::MakefileColorEcho(cmsysTerminal_Color_ForegroundBlue
                                           |cmsysTerminal_Color_ForegroundBold,
                                       msg.c_str(), true, this->ColorOutput);
@@ -1272,7 +1294,7 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& realName,
 
     std::vector<std::string> opts = this->UicTargetOptions;
     std::map<std::string, std::string>::const_iterator optionIt
-            = this->UicOptions.find(ui_input_file);
+            = this->UicOptions.find(uiInputFile);
     if (optionIt != this->UicOptions.end())
       {
       std::vector<std::string> fileOpts;
@@ -1283,8 +1305,8 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& realName,
     command.insert(command.end(), opts.begin(), opts.end());
 
     command.push_back("-o");
-    command.push_back(this->Builddir + ui_output_file);
-    command.push_back(ui_input_file);
+    command.push_back(uiBuildFile);
+    command.push_back(uiInputFile);
 
     if (this->Verbose)
       {
@@ -1296,11 +1318,11 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& realName,
                                                   &retVal);
     if (!result || retVal)
       {
-      std::cerr << "AUTOUIC: error: process for " << ui_output_file <<
+      std::cerr << "AUTOUIC: error: process for " << uiOutputFile <<
                 " needed by\n \"" << realName << "\"\nfailed:\n" << output
                 << std::endl;
       this->RunUicFailed = true;
-      cmSystemTools::RemoveFile(ui_output_file);
+      cmSystemTools::RemoveFile(uiOutputFile);
       return false;
       }
     return true;
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
index cb2be4a..d532c21 100644
--- a/Source/cmQtAutoGenerators.h
+++ b/Source/cmQtAutoGenerators.h
@@ -46,7 +46,9 @@ private:
                    const std::string& mocFileName);
   bool GenerateUiFiles(
         const std::map<std::string, std::vector<std::string> >& includedUis );
-  bool GenerateUi(const std::string& realName, const std::string& uiFileName);
+  bool GenerateUi(const std::string& realName,
+                  const std::string& uiInputFile,
+                  const std::string& uiOutputFile );
   bool GenerateQrcFiles();
   void ParseCppFile(const std::string& absFilename,
               const std::vector<std::string>& headerExtensions,

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=47e60bc5a09f5b3a71ce015025cd93af4270afb5
commit 47e60bc5a09f5b3a71ce015025cd93af4270afb5
Author:     Sebastian Holtermann <sebholt at xwmw.org>
AuthorDate: Mon Apr 18 14:07:12 2016 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Apr 19 12:52:36 2016 -0400

    Autogen: Split out UI file generation code to dedicated method

diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index 7f7dbad..91bacce 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -595,20 +595,10 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile)
     {
     this->GenerateMocFiles ( includedMocs, notIncludedMocs );
     }
-
-  for(std::map<std::string, std::vector<std::string> >::const_iterator
-      it = includedUis.begin();
-      it != includedUis.end();
-      ++it)
+  if(!this->UicExecutable.empty())
     {
-    for (std::vector<std::string>::const_iterator nit = it->second.begin();
-        nit != it->second.end();
-        ++nit)
-      {
-      this->GenerateUi(it->first, *nit);
-      }
+    this->GenerateUiFiles ( includedUis );
     }
-
   if(!this->RccExecutable.empty())
     {
     this->GenerateQrcFiles();
@@ -1227,6 +1217,30 @@ bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile,
   return false;
 }
 
+
+bool cmQtAutoGenerators::GenerateUiFiles(
+      const std::map<std::string, std::vector<std::string> >& includedUis )
+{
+  for(std::map<std::string, std::vector<std::string> >::const_iterator
+      it = includedUis.begin(); it != includedUis.end(); ++it)
+    {
+    for (std::vector<std::string>::const_iterator nit = it->second.begin();
+         nit != it->second.end(); ++nit)
+      {
+      if (!this->GenerateUi(it->first, *nit) )
+        {
+        if (this->RunUicFailed)
+          {
+          return false;
+          }
+        }
+      }
+    }
+
+  return true;
+}
+
+
 bool cmQtAutoGenerators::GenerateUi(const std::string& realName,
                                     const std::string& uiFileName)
 {
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
index 51959be..cb2be4a 100644
--- a/Source/cmQtAutoGenerators.h
+++ b/Source/cmQtAutoGenerators.h
@@ -44,6 +44,8 @@ private:
               const std::map<std::string, std::string>& notIncludedMocs);
   bool GenerateMoc(const std::string& sourceFile,
                    const std::string& mocFileName);
+  bool GenerateUiFiles(
+        const std::map<std::string, std::vector<std::string> >& includedUis );
   bool GenerateUi(const std::string& realName, const std::string& uiFileName);
   bool GenerateQrcFiles();
   void ParseCppFile(const std::string& absFilename,

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cf679ea8dcd04c1217cd7c664117439fdd370f10
commit cf679ea8dcd04c1217cd7c664117439fdd370f10
Author:     Sebastian Holtermann <sebholt at xwmw.org>
AuthorDate: Mon Apr 18 13:46:28 2016 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Apr 19 12:51:26 2016 -0400

    Autogen: Split out moc file generation code to dedicated method

diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index 576de7a..7f7dbad 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -410,9 +410,11 @@ cmQtAutoGenerators::WriteOldMocDefinitionsFile(
 
 void cmQtAutoGenerators::Init()
 {
+  this->OutMocCppFilenameRel = this->TargetName;
+  this->OutMocCppFilenameRel += ".cpp";
+
   this->OutMocCppFilename = this->Builddir;
-  this->OutMocCppFilename += this->TargetName;
-  this->OutMocCppFilename += ".cpp";
+  this->OutMocCppFilename += this->OutMocCppFilenameRel;
 
   std::vector<std::string> cdefList;
   cmSystemTools::ExpandListArgument(this->MocCompileDefinitionsStr, cdefList);
@@ -589,14 +591,11 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile)
   std::map<std::string, std::string> notIncludedMocs;
   this->ParseHeaders(headerFiles, includedMocs, notIncludedMocs, includedUis);
 
-  // run moc on all the moc's that are #included in source files
-  for(std::map<std::string, std::string>::const_iterator
-                                                     it = includedMocs.begin();
-      it != includedMocs.end();
-      ++it)
+  if(!this->MocExecutable.empty())
     {
-    this->GenerateMoc(it->first, it->second);
+    this->GenerateMocFiles ( includedMocs, notIncludedMocs );
     }
+
   for(std::map<std::string, std::vector<std::string> >::const_iterator
       it = includedUis.begin();
       it != includedUis.end();
@@ -615,38 +614,11 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile)
     this->GenerateQrcFiles();
     }
 
-  std::stringstream outStream;
-  outStream << "/* This file is autogenerated, do not edit*/\n";
-
-  bool automocCppChanged = false;
-  if (notIncludedMocs.empty())
-    {
-    outStream << "enum some_compilers { need_more_than_nothing };\n";
-    }
-  else
-    {
-    // run moc on the remaining headers and include them in
-    // the _automoc.cpp file
-    for(std::map<std::string, std::string>::const_iterator
-                                                  it = notIncludedMocs.begin();
-        it != notIncludedMocs.end();
-        ++it)
-      {
-      bool mocSuccess = this->GenerateMoc(it->first, it->second);
-      if (mocSuccess)
-        {
-        automocCppChanged = true;
-        }
-      outStream << "#include \"" << it->second << "\"\n";
-      }
-    }
-
   if (this->RunMocFailed)
     {
     std::cerr << "moc failed..." << std::endl;
     return false;
     }
-
   if (this->RunUicFailed)
     {
     std::cerr << "uic failed..." << std::endl;
@@ -657,25 +629,6 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile)
     std::cerr << "rcc failed..." << std::endl;
     return false;
     }
-  outStream.flush();
-  std::string automocSource = outStream.str();
-  if (!automocCppChanged)
-    {
-    // compare contents of the _automoc.cpp file
-    const std::string oldContents = ReadAll(this->OutMocCppFilename);
-    if (oldContents == automocSource)
-      {
-      // nothing changed: don't touch the _automoc.cpp file
-      return true;
-      }
-    }
-
-  // source file that includes all remaining moc files (_automoc.cpp file)
-  cmsys::ofstream outfile;
-  outfile.open(this->OutMocCppFilename.c_str(),
-               std::ios::trunc);
-  outfile << automocSource;
-  outfile.close();
 
   return true;
 }
@@ -1119,6 +1072,102 @@ void cmQtAutoGenerators::ParseHeaders(const std::set<std::string>& absHeaders,
     }
 }
 
+
+bool cmQtAutoGenerators::GenerateMocFiles(
+                    const std::map<std::string, std::string>& includedMocs,
+                    const std::map<std::string, std::string>& notIncludedMocs )
+{
+  // generate moc files that are included by source files.
+  for(std::map<std::string, std::string>::const_iterator
+      it = includedMocs.begin(); it != includedMocs.end(); ++it)
+    {
+    if (!this->GenerateMoc(it->first, it->second))
+      {
+      if (this->RunMocFailed)
+        {
+        return false;
+        }
+      }
+    }
+
+  // generate moc files that are _not_ included by source files.
+  bool automocCppChanged = false;
+  for(std::map<std::string, std::string>::const_iterator
+      it = notIncludedMocs.begin(); it != notIncludedMocs.end(); ++it)
+    {
+    if (this->GenerateMoc(it->first, it->second))
+      {
+      automocCppChanged = true;
+      }
+    else
+      {
+      if (this->RunMocFailed)
+        {
+        return false;
+        }
+      }
+    }
+
+  // compose _automoc.cpp content
+  std::string automocSource;
+    {
+    std::stringstream outStream;
+    outStream << "/* This file is autogenerated, do not edit*/\n";
+    if( notIncludedMocs.empty() )
+      {
+      outStream << "enum some_compilers { need_more_than_nothing };\n";
+      }
+    else
+      {
+      for(std::map<std::string, std::string>::const_iterator
+          it = notIncludedMocs.begin();
+          it != notIncludedMocs.end();
+          ++it)
+        {
+        outStream << "#include \"" << it->second << "\"\n";
+        }
+      }
+    outStream.flush();
+    automocSource = outStream.str();
+    }
+
+  // check if we even need to update _automoc.cpp
+  if (!automocCppChanged)
+    {
+    // compare contents of the _automoc.cpp file
+    const std::string oldContents = ReadAll(this->OutMocCppFilename);
+    if (oldContents == automocSource)
+      {
+      // nothing changed: don't touch the _automoc.cpp file
+      if (this->Verbose)
+        {
+        std::cout << "AUTOGEN: " << this->OutMocCppFilenameRel
+          << " still up to date" << std::endl;
+        }
+      return true;
+      }
+    }
+
+  // actually write _automoc.cpp
+    {
+    std::string msg = "Generating ";
+    msg += this->OutMocCppFilenameRel;
+    cmSystemTools::MakefileColorEcho(cmsysTerminal_Color_ForegroundBlue
+                                     |cmsysTerminal_Color_ForegroundBold,
+                                     msg.c_str(), true, this->ColorOutput);
+    }
+    {
+    cmsys::ofstream outfile;
+    outfile.open(this->OutMocCppFilename.c_str(),
+                 std::ios::trunc);
+    outfile << automocSource;
+    outfile.close();
+    }
+
+  return true;
+}
+
+
 bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile,
                               const std::string& mocFileName)
 {
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
index 5b33d16..51959be 100644
--- a/Source/cmQtAutoGenerators.h
+++ b/Source/cmQtAutoGenerators.h
@@ -39,6 +39,9 @@ private:
   std::string MakeCompileSettingsString(cmMakefile* makefile);
 
   bool RunAutogen(cmMakefile* makefile);
+  bool GenerateMocFiles(
+              const std::map<std::string, std::string>& includedMocs,
+              const std::map<std::string, std::string>& notIncludedMocs);
   bool GenerateMoc(const std::string& sourceFile,
                    const std::string& mocFileName);
   bool GenerateUi(const std::string& realName, const std::string& uiFileName);
@@ -100,6 +103,7 @@ private:
   std::string CurrentCompileSettingsStr;
   std::string OldCompileSettingsStr;
 
+  std::string OutMocCppFilenameRel;
   std::string OutMocCppFilename;
   std::list<std::string> MocIncludes;
   std::list<std::string> MocDefinitions;

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3ea1d09082de6b5ed4fbb7f9be04a0172c01c0be
commit 3ea1d09082de6b5ed4fbb7f9be04a0172c01c0be
Author:     Sebastian Holtermann <sebholt at xwmw.org>
AuthorDate: Mon Apr 18 12:34:10 2016 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Apr 19 12:49:47 2016 -0400

    Autogen: Rename method GenerateQrc{ => Files}

diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index 65892fe..576de7a 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -612,7 +612,7 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile)
 
   if(!this->RccExecutable.empty())
     {
-    this->GenerateQrc();
+    this->GenerateQrcFiles();
     }
 
   std::stringstream outStream;
@@ -1264,7 +1264,7 @@ bool cmQtAutoGenerators::InputFilesNewerThanQrc(const std::string& qrcFile,
   return false;
 }
 
-bool cmQtAutoGenerators::GenerateQrc()
+bool cmQtAutoGenerators::GenerateQrcFiles()
 {
   for(std::vector<std::string>::const_iterator si = this->RccSources.begin();
       si != this->RccSources.end(); ++si)
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
index 408ca14..5b33d16 100644
--- a/Source/cmQtAutoGenerators.h
+++ b/Source/cmQtAutoGenerators.h
@@ -42,7 +42,7 @@ private:
   bool GenerateMoc(const std::string& sourceFile,
                    const std::string& mocFileName);
   bool GenerateUi(const std::string& realName, const std::string& uiFileName);
-  bool GenerateQrc();
+  bool GenerateQrcFiles();
   void ParseCppFile(const std::string& absFilename,
               const std::vector<std::string>& headerExtensions,
               std::map<std::string, std::string>& includedMocs,

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8ced8bb95aee78ece751259f9cce23786fe4a1b2
commit 8ced8bb95aee78ece751259f9cce23786fe4a1b2
Author:     Sebastian Holtermann <sebholt at xwmw.org>
AuthorDate: Mon Apr 18 12:02:28 2016 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Apr 19 12:49:22 2016 -0400

    Autogen: New logCommand method. It prints commands using std::cout.

diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index 19f6a38..65892fe 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -1159,13 +1159,7 @@ bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile,
 
     if (this->Verbose)
       {
-      for(std::vector<std::string>::const_iterator cmdIt = command.begin();
-          cmdIt != command.end();
-          ++cmdIt)
-        {
-        std::cout << *cmdIt << " ";
-        }
-      std::cout << std::endl;
+      this->LogCommand(command);
       }
 
     std::string output;
@@ -1231,13 +1225,7 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& realName,
 
     if (this->Verbose)
       {
-      for(std::vector<std::string>::const_iterator cmdIt = command.begin();
-          cmdIt != command.end();
-          ++cmdIt)
-        {
-        std::cout << *cmdIt << " ";
-        }
-      std::cout << std::endl;
+      this->LogCommand(command);
       }
     std::string output;
     int retVal = 0;
@@ -1322,13 +1310,7 @@ bool cmQtAutoGenerators::GenerateQrc()
 
       if (this->Verbose)
         {
-        for(std::vector<std::string>::const_iterator cmdIt = command.begin();
-            cmdIt != command.end();
-            ++cmdIt)
-          {
-          std::cout << *cmdIt << " ";
-          }
-        std::cout << std::endl;
+        this->LogCommand(command);
         }
       std::string output;
       int retVal = 0;
@@ -1347,6 +1329,27 @@ bool cmQtAutoGenerators::GenerateQrc()
   return true;
 }
 
+void cmQtAutoGenerators::LogCommand(const std::vector<std::string>& command)
+{
+  std::stringstream sbuf;
+  for(std::vector<std::string>::const_iterator cmdIt = command.begin();
+      cmdIt != command.end();
+      ++cmdIt)
+    {
+    if ( cmdIt != command.begin() )
+      {
+      sbuf << " ";
+      }
+    sbuf << *cmdIt;
+    }
+  sbuf.flush();
+  if ( !sbuf.str().empty() )
+    {
+    std::cout << sbuf.str();
+    std::cout << std::endl;
+    }
+}
+
 std::string cmQtAutoGenerators::JoinExts(const std::vector<std::string>& lst)
 {
     if (lst.empty())
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
index f9dd41c..408ca14 100644
--- a/Source/cmQtAutoGenerators.h
+++ b/Source/cmQtAutoGenerators.h
@@ -69,6 +69,7 @@ private:
 
   void Init();
 
+  void LogCommand(const std::vector<std::string>& command);
   std::string JoinExts(const std::vector<std::string>& lst);
 
   static void MergeUicOptions(std::vector<std::string> &opts,

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=95064a6d35c93557c9bb87bc8eeff8555d7295a2
commit 95064a6d35c93557c9bb87bc8eeff8555d7295a2
Author:     Sebastian Holtermann <sebholt at xwmw.org>
AuthorDate: Mon Apr 18 11:39:06 2016 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Apr 19 12:48:05 2016 -0400

    Autogen: Rename header extension Join method to JoinExts
    
    While at it, simplify the signature and avoid a trailing separator.

diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index ee40e7a..19f6a38 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -762,7 +762,7 @@ void cmQtAutoGenerators::ParseCppFile(const std::string& absFilename,
           std::cerr << "AUTOGEN: error: " << absFilename << ": The file "
                     << "includes the moc file \"" << currentMoc << "\", "
                     << "but could not find header \"" << basename
-                    << '{' << this->Join(headerExtensions, ',') << "}\" ";
+                    << '{' << this->JoinExts(headerExtensions) << "}\" ";
           if (mocSubDir.empty())
             {
             std::cerr << "in " << absPath << "\n" << std::endl;
@@ -937,7 +937,7 @@ void cmQtAutoGenerators::StrictParseCppFile(const std::string& absFilename,
           std::cerr << "AUTOGEN: error: " << absFilename << " The file "
                     << "includes the moc file \"" << currentMoc << "\", "
                     << "but could not find header \"" << basename
-                    << '{' << this->Join(headerExtensions, ',') << "}\" ";
+                    << '{' << this->JoinExts(headerExtensions) << "}\" ";
           if (mocSubDir.empty())
             {
             std::cerr << "in " << absPath << "\n" << std::endl;
@@ -1347,8 +1347,7 @@ bool cmQtAutoGenerators::GenerateQrc()
   return true;
 }
 
-std::string cmQtAutoGenerators::Join(const std::vector<std::string>& lst,
-                              char separator)
+std::string cmQtAutoGenerators::JoinExts(const std::vector<std::string>& lst)
 {
     if (lst.empty())
       {
@@ -1356,11 +1355,16 @@ std::string cmQtAutoGenerators::Join(const std::vector<std::string>& lst,
       }
 
     std::string result;
+    std::string separator = ",";
     for (std::vector<std::string>::const_iterator it = lst.begin();
          it != lst.end();
          ++it)
       {
-      result += "." + (*it) + separator;
+      if(it != lst.begin())
+        {
+        result += separator;
+        }
+      result += '.' + (*it);
       }
     result.erase(result.end() - 1);
     return result;
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
index d5a23ab..f9dd41c 100644
--- a/Source/cmQtAutoGenerators.h
+++ b/Source/cmQtAutoGenerators.h
@@ -69,7 +69,7 @@ private:
 
   void Init();
 
-  std::string Join(const std::vector<std::string>& lst, char separator);
+  std::string JoinExts(const std::vector<std::string>& lst);
 
   static void MergeUicOptions(std::vector<std::string> &opts,
                        const std::vector<std::string> &fileOpts, bool isQt5);

https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7a73c404dd63aef0e68da9ef70ac706a6339c476
commit 7a73c404dd63aef0e68da9ef70ac706a6339c476
Author:     Sebastian Holtermann <sebholt at xwmw.org>
AuthorDate: Mon Apr 18 11:22:00 2016 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Tue Apr 19 12:44:08 2016 -0400

    Autogen: Use SystemTools string functions instead of rolling out own

diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index ebe08b0..ee40e7a 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -464,7 +464,7 @@ void cmQtAutoGenerators::Init()
       std::list<std::string>::iterator it = this->MocIncludes.begin();
       while (it != this->MocIncludes.end())
         {
-        if (this->StartsWith(*it, binDir))
+        if (cmsys::SystemTools::StringStartsWith(*it, binDir.c_str()))
           {
           sortedMocIncludes.push_back(*it);
           it = this->MocIncludes.erase(it);
@@ -477,7 +477,7 @@ void cmQtAutoGenerators::Init()
       it = this->MocIncludes.begin();
       while (it != this->MocIncludes.end())
         {
-        if (this->StartsWith(*it, srcDir))
+        if (cmsys::SystemTools::StringStartsWith(*it, srcDir.c_str()))
           {
           sortedMocIncludes.push_back(*it);
           it = this->MocIncludes.erase(it);
@@ -1365,21 +1365,3 @@ std::string cmQtAutoGenerators::Join(const std::vector<std::string>& lst,
     result.erase(result.end() - 1);
     return result;
 }
-
-
-bool cmQtAutoGenerators::StartsWith(const std::string& str,
-                                    const std::string& with)
-{
-  return (str.substr(0, with.length()) == with);
-}
-
-
-bool cmQtAutoGenerators::EndsWith(const std::string& str,
-                                  const std::string& with)
-{
-  if (with.length() > (str.length()))
-    {
-    return false;
-    }
-  return (str.substr(str.length() - with.length(), with.length()) == with);
-}
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
index ab7b6ed..d5a23ab 100644
--- a/Source/cmQtAutoGenerators.h
+++ b/Source/cmQtAutoGenerators.h
@@ -70,8 +70,6 @@ private:
   void Init();
 
   std::string Join(const std::vector<std::string>& lst, char separator);
-  bool EndsWith(const std::string& str, const std::string& with);
-  bool StartsWith(const std::string& str, const std::string& with);
 
   static void MergeUicOptions(std::vector<std::string> &opts,
                        const std::vector<std::string> &fileOpts, bool isQt5);

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

Summary of changes:
 Source/cmQtAutoGenerators.cxx |  446 +++++++++++++++++++++++++----------------
 Source/cmQtAutoGenerators.h   |   19 +-
 2 files changed, 288 insertions(+), 177 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list