[Cmake-commits] CMake branch, next, updated. v2.8.6-1921-gdf19585

Alexander Neundorf neundorf at kde.org
Wed Nov 16 16:00:53 EST 2011


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  df195851e52948ca19019179718d08f68354daf9 (commit)
       via  e44ebd5f9b5eed18697dabbc4c1f570f60ded39c (commit)
       via  142317782842751dba4e68f016f3c89c692dc5ac (commit)
       via  f98e6151dc4d1bcc14373e423fcdd668f99ce07a (commit)
       via  69cf480cd65621d3db1390f78ef2d3cd1dddb5d8 (commit)
       via  81c43b4fb6e46430e730e2cb268c283e47995b78 (commit)
       via  72428228970b8b7da54a3c98a36eca6810c46bb5 (commit)
       via  d08bc32bc29078764fc44fd3809eeda527e7017f (commit)
      from  f971d858190fa56c79899de81d2415aa47c15fc1 (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 -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=df195851e52948ca19019179718d08f68354daf9
commit df195851e52948ca19019179718d08f68354daf9
Merge: f971d85 e44ebd5
Author:     Alexander Neundorf <neundorf at kde.org>
AuthorDate: Wed Nov 16 16:00:48 2011 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Wed Nov 16 16:00:48 2011 -0500

    Merge topic 'RestoreAutmocKDECompatibility' into next
    
    e44ebd5 automoc: another runtime optimization
    1423177 automoc: minor optimization
    f98e615 automoc: improved diagnostics
    69cf480 automoc: add more test cases
    81c43b4 automoc: handle the case when the developer includes the wrong mocfile
    7242822 automoc: rework the checking for the matching header, to give better warnings
    d08bc32 automoc: stricter checking for what file is included


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e44ebd5f9b5eed18697dabbc4c1f570f60ded39c
commit e44ebd5f9b5eed18697dabbc4c1f570f60ded39c
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Thu Nov 10 22:54:44 2011 +0100
Commit:     Alex Neundorf <neundorf at kde.org>
CommitDate: Thu Nov 10 22:54:44 2011 +0100

    automoc: another runtime optimization
    
    before doing the full regexp, try a simple strstr(), if this
    already fails, no need to do the regexp matching.
    
    Alex

diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx
index 343d51c..3d92a59 100644
--- a/Source/cmQtAutomoc.cxx
+++ b/Source/cmQtAutomoc.cxx
@@ -17,11 +17,26 @@
 #include "cmSourceFile.h"
 #include "cmSystemTools.h"
 
-# include <cmsys/Terminal.h>
+#include <cmsys/Terminal.h>
+
+#include <string.h>
 
 #include "cmQtAutomoc.h"
 
 
+static bool containsQ_OBJECT(const std::string& text)
+{
+  // this simple check is much much faster than the regexp
+  if (strstr(text.c_str(), "Q_OBJECT") == NULL)
+    {
+    return false;
+    }
+
+  cmsys::RegularExpression qObjectRegExp("[\n][ \t]*Q_OBJECT[^a-zA-Z0-9_]");
+  return qObjectRegExp.find(text);
+}
+
+
 cmQtAutomoc::cmQtAutomoc()
 :Verbose(cmsys::SystemTools::GetEnv("VERBOSE") != 0)
 ,ColorOutput(true)
@@ -527,7 +542,11 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
   std::string ownMocHeaderFile;
 
   std::string::size_type matchOffset = 0;
-  if (mocIncludeRegExp.find(contentsString))
+  // first a simply string check for "moc" is *much* faster than the regexp,
+  // and if the string search already fails, we don't have to try the
+  // expensive regexp
+  if ((strstr(contentsString.c_str(), "moc") != NULL)
+                                    && (mocIncludeRegExp.find(contentsString)))
     {
     // for every moc include in the file
     do
@@ -635,8 +654,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
   // But warn, since this is not how it is supposed to be used.
   if ((dotMocIncluded == false) && (mocUnderscoreIncluded == true))
     {
-    cmsys::RegularExpression qObjectRegExp("[\n][ \t]*Q_OBJECT[^a-zA-Z0-9_]");
-    if (qObjectRegExp.find(contentsString))
+    if (containsQ_OBJECT(contentsString))
       {
       std::cerr << "AUTOMOC: warning: " << absFilename << ": The file "
                 << "contains a Q_OBJECT macro, but does not include "
@@ -683,7 +701,6 @@ void cmQtAutomoc::ParseHeaders(const std::set<std::string>& absHeaders,
                         const std::map<std::string, std::string>& includedMocs,
                         std::map<std::string, std::string>& notIncludedMocs)
 {
-  cmsys::RegularExpression qObjectRegExp("[\n][ \t]*Q_OBJECT[^a-zA-Z0-9_]");
   for(std::set<std::string>::const_iterator hIt=absHeaders.begin();
       hIt!=absHeaders.end();
       ++hIt)
@@ -702,7 +719,7 @@ void cmQtAutomoc::ParseHeaders(const std::set<std::string>& absHeaders,
 
       const std::string currentMoc = "moc_" + basename + ".cpp";
       const std::string contents = this->ReadAll(headerName);
-      if (qObjectRegExp.find(contents))
+      if (containsQ_OBJECT(contents))
         {
         //std::cout << "header contains Q_OBJECT macro";
         notIncludedMocs[headerName] = currentMoc;

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=142317782842751dba4e68f016f3c89c692dc5ac
commit 142317782842751dba4e68f016f3c89c692dc5ac
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Thu Nov 10 22:41:48 2011 +0100
Commit:     Alex Neundorf <neundorf at kde.org>
CommitDate: Thu Nov 10 22:41:48 2011 +0100

    automoc: minor optimization
    
    Handing th std::string instead the char* to the find()
    reduces the time from 17 to 15 seconds (for a 1000 times loop of a
    relatively small file), which is around 10 percent.
    
    Alex

diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx
index 0714c84..343d51c 100644
--- a/Source/cmQtAutomoc.cxx
+++ b/Source/cmQtAutomoc.cxx
@@ -527,7 +527,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
   std::string ownMocHeaderFile;
 
   std::string::size_type matchOffset = 0;
-  if (mocIncludeRegExp.find(contentsString.c_str()))
+  if (mocIncludeRegExp.find(contentsString))
     {
     // for every moc include in the file
     do

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f98e6151dc4d1bcc14373e423fcdd668f99ce07a
commit f98e6151dc4d1bcc14373e423fcdd668f99ce07a
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Thu Nov 10 22:02:41 2011 +0100
Commit:     Alex Neundorf <neundorf at kde.org>
CommitDate: Thu Nov 10 22:12:03 2011 +0100

    automoc: improved diagnostics
    
    Error/warning messages now look like:
    AUTOMOC: (error|warning): <filename>: the actual text...
    
    Alex

diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx
index b715df6..0714c84 100644
--- a/Source/cmQtAutomoc.cxx
+++ b/Source/cmQtAutomoc.cxx
@@ -512,7 +512,8 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
   const std::string contentsString = this->ReadAll(absFilename);
   if (contentsString.empty())
     {
-    std::cerr << "AUTOMOC: empty source file: " << absFilename << std::endl;
+    std::cerr << "AUTOMOC: warning: " << absFilename << ": file is empty"
+              << std::endl;
     return;
     }
   const std::string absPath = cmsys::SystemTools::GetFilenamePath(
@@ -592,9 +593,9 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
           }
         else
           {
-          std::cerr << "AUTOMOC: The file \"" << absFilename
-                    << "\" includes the moc file \"" << currentMoc
-                    << "\", but could not find header \"" << basename
+          std::cerr << "AUTOMOC: error: " << absFilename << " The file "
+                    << "includes the moc file \"" << currentMoc << "\", "
+                    << "but could not find header \"" << basename
                     << '{' << this->Join(headerExtensions, ',') << "}\" ";
           if (mocSubDir.empty())
             {
@@ -613,8 +614,8 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
         {
         if (basename != scannedFileBasename)
           {
-          std::cerr << "AUTOMOC: The file \"" << absFilename
-                    << "\" includes the moc file \"" << currentMoc
+          std::cerr << "AUTOMOC: error: " << absFilename << ": The file "
+                    << "includes the moc file \"" << currentMoc
                     << "\", which seems to be the moc file from a different "
                     << "source file. This is not supported. "
                     << "Include \"" << scannedFileBasename << ".moc\" to run "
@@ -637,12 +638,12 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
     cmsys::RegularExpression qObjectRegExp("[\n][ \t]*Q_OBJECT[^a-zA-Z0-9_]");
     if (qObjectRegExp.find(contentsString))
       {
-      std::cerr << "AUTOMOC: The file \"" << absFilename
-                << "\" contains a Q_OBJECT macro, but does not include "
+      std::cerr << "AUTOMOC: warning: " << absFilename << ": The file "
+                << "contains a Q_OBJECT macro, but does not include "
                 << "\"" << scannedFileBasename << ".moc\", but instead includes "
                 << "\"" << ownMocUnderscoreFile  << "\". Running moc on "
                 << "\"" << absFilename << "\" ! Better include \""
-                << scannedFileBasename << ".moc\" to get a robust build."
+                << scannedFileBasename << ".moc\" for a robust build."
                 << std::endl;
       includedMocs[absFilename] = ownMocUnderscoreFile;
       includedMocs.erase(ownMocHeaderFile);
@@ -772,7 +773,7 @@ bool cmQtAutomoc::GenerateMoc(const std::string& sourceFile,
     bool result = cmSystemTools::RunSingleCommand(command, &output, &retVal);
     if (!result || retVal)
       {
-      std::cerr << "AUTOMOC: process for " << mocFilePath << " failed:\n"
+      std::cerr << "AUTOMOC: error: process for " << mocFilePath <<" failed:\n"
                 << output << std::endl;
       this->RunMocFailed = true;
       cmSystemTools::RemoveFile(mocFilePath.c_str());

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=69cf480cd65621d3db1390f78ef2d3cd1dddb5d8
commit 69cf480cd65621d3db1390f78ef2d3cd1dddb5d8
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Thu Nov 10 21:40:31 2011 +0100
Commit:     Alex Neundorf <neundorf at kde.org>
CommitDate: Thu Nov 10 22:12:03 2011 +0100

    automoc: add more test cases
    
    Alex

diff --git a/Tests/QtAutomoc/CMakeLists.txt b/Tests/QtAutomoc/CMakeLists.txt
index 01f6bea..9540e52 100644
--- a/Tests/QtAutomoc/CMakeLists.txt
+++ b/Tests/QtAutomoc/CMakeLists.txt
@@ -13,7 +13,7 @@ add_definitions(-DFOO)
 # create an executable and a library target, both requiring automoc:
 add_library(codeeditorLib STATIC codeeditor.cpp)
 
-add_executable(foo main.cpp calwidget.cpp foo.cpp)
+add_executable(foo main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp)
 
 set_target_properties(foo codeeditorLib PROPERTIES AUTOMOC TRUE)
 
diff --git a/Tests/QtAutomoc/bar.cpp b/Tests/QtAutomoc/bar.cpp
new file mode 100644
index 0000000..8be4815
--- /dev/null
+++ b/Tests/QtAutomoc/bar.cpp
@@ -0,0 +1,28 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2004-2011 Kitware, Inc.
+  Copyright 2011 Alexander Neundorf (neundorf at kde.org)
+
+  Distributed under the OSI-approved BSD License (the "License");
+  see accompanying file Copyright.txt for details.
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the License for more information.
+============================================================================*/
+
+#include "sub/bar.h"
+
+#include <stdio.h>
+
+Bar::Bar()
+:QObject()
+{
+}
+
+void Bar::doBar()
+{
+  printf("Hello bar !\n");
+}
+
+#include "sub/moc_bar.cpp"
diff --git a/Tests/QtAutomoc/blub.cpp b/Tests/QtAutomoc/blub.cpp
new file mode 100644
index 0000000..bd53972
--- /dev/null
+++ b/Tests/QtAutomoc/blub.cpp
@@ -0,0 +1,40 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2004-2011 Kitware, Inc.
+  Copyright 2011 Alexander Neundorf (neundorf at kde.org)
+
+  Distributed under the OSI-approved BSD License (the "License");
+  see accompanying file Copyright.txt for details.
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the License for more information.
+============================================================================*/
+
+#include "blub.h"
+
+#include <stdio.h>
+
+class BlubBlub : public QObject
+{
+  Q_OBJECT
+  public:
+    BlubBlub():QObject() {}
+  public slots:
+    int getValue() const { return 13; }
+};
+
+Blub::Blub()
+{
+}
+
+
+void Blub::blubber()
+{
+  BlubBlub bb;
+  printf("Blub blub %d ! \n", bb.getValue());
+}
+
+// test the case that the wrong moc-file is included, it should
+// actually be "blub.moc"
+#include "moc_blub.cpp"
diff --git a/Tests/QtAutomoc/blub.h b/Tests/QtAutomoc/blub.h
new file mode 100644
index 0000000..1967bc1
--- /dev/null
+++ b/Tests/QtAutomoc/blub.h
@@ -0,0 +1,26 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2004-2011 Kitware, Inc.
+  Copyright 2011 Alexander Neundorf (neundorf at kde.org)
+
+  Distributed under the OSI-approved BSD License (the "License");
+  see accompanying file Copyright.txt for details.
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the License for more information.
+============================================================================*/
+
+#ifndef BLUB_H
+#define BLUB_H
+
+#include <QObject>
+
+class Blub
+{
+  public:
+    Blub();
+    void blubber();
+};
+
+#endif
diff --git a/Tests/QtAutomoc/main.cpp b/Tests/QtAutomoc/main.cpp
index b7cfb41..58e2a19 100644
--- a/Tests/QtAutomoc/main.cpp
+++ b/Tests/QtAutomoc/main.cpp
@@ -43,6 +43,8 @@
 #include "codeeditor.h"
 #include "calwidget.h"
 #include "foo.h"
+#include "blub.h"
+#include "sub/bar.h"
 
 int main(int argv, char **args)
 {
@@ -58,5 +60,11 @@ int main(int argv, char **args)
   Foo foo;
   foo.doFoo();
 
+  Blub b;
+  b.blubber();
+
+  Bar bar;
+  bar.doBar();
+
   return app.exec();
 }
diff --git a/Tests/QtAutomoc/sub/bar.h b/Tests/QtAutomoc/sub/bar.h
new file mode 100644
index 0000000..db56b8e
--- /dev/null
+++ b/Tests/QtAutomoc/sub/bar.h
@@ -0,0 +1,28 @@
+/*============================================================================
+  CMake - Cross Platform Makefile Generator
+  Copyright 2004-2011 Kitware, Inc.
+  Copyright 2011 Alexander Neundorf (neundorf at kde.org)
+
+  Distributed under the OSI-approved BSD License (the "License");
+  see accompanying file Copyright.txt for details.
+
+  This software is distributed WITHOUT ANY WARRANTY; without even the
+  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+  See the License for more information.
+============================================================================*/
+
+#ifndef BAR_H
+#define BAR_H
+
+#include <QObject>
+
+class Bar : public QObject
+{
+  Q_OBJECT
+  public:
+    Bar();
+  public slots:
+    void doBar();
+};
+
+#endif

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=81c43b4fb6e46430e730e2cb268c283e47995b78
commit 81c43b4fb6e46430e730e2cb268c283e47995b78
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Thu Nov 10 21:30:06 2011 +0100
Commit:     Alex Neundorf <neundorf at kde.org>
CommitDate: Thu Nov 10 22:12:03 2011 +0100

    automoc: handle the case when the developer includes the wrong mocfile
    
    There are multiple/many places in KDE where the developer includes
    moc_foo.cpp, and expects moc to run on foo.cpp, instead of foo.h.
    He should use foo.moc, but right now this is handled by automoc4,
    so we must stay compatible. So support this too, but warn about
    it.
    
    Alex

diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx
index 3dc515e..b715df6 100644
--- a/Source/cmQtAutomoc.cxx
+++ b/Source/cmQtAutomoc.cxx
@@ -520,6 +520,11 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
   const std::string scannedFileBasename = cmsys::SystemTools::
                                   GetFilenameWithoutLastExtension(absFilename);
 
+  bool dotMocIncluded = false;
+  bool mocUnderscoreIncluded = false;
+  std::string ownMocUnderscoreFile;
+  std::string ownMocHeaderFile;
+
   std::string::size_type matchOffset = 0;
   if (mocIncludeRegExp.find(contentsString.c_str()))
     {
@@ -578,6 +583,12 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
         if (!headerToMoc.empty())
           {
           includedMocs[headerToMoc] = currentMoc;
+          if (basename == scannedFileBasename)
+            {
+            mocUnderscoreIncluded = true;
+            ownMocUnderscoreFile = currentMoc;
+            ownMocHeaderFile = headerToMoc;
+            }
           }
         else
           {
@@ -611,11 +622,33 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
           ::exit(EXIT_FAILURE);
           }
         includedMocs[absFilename] = currentMoc;
+        dotMocIncluded = true;
         }
       matchOffset += mocIncludeRegExp.end();
       } while(mocIncludeRegExp.find(contentsString.c_str() + matchOffset));
     }
 
+  // In this case, check whether the scanned file itself contains a Q_OBJECT.
+  // If this is the case, the moc_foo.cpp should probably be generated from
+  // foo.cpp instead of foo.h, because otherwise it won't build.
+  // But warn, since this is not how it is supposed to be used.
+  if ((dotMocIncluded == false) && (mocUnderscoreIncluded == true))
+    {
+    cmsys::RegularExpression qObjectRegExp("[\n][ \t]*Q_OBJECT[^a-zA-Z0-9_]");
+    if (qObjectRegExp.find(contentsString))
+      {
+      std::cerr << "AUTOMOC: The file \"" << absFilename
+                << "\" contains a Q_OBJECT macro, but does not include "
+                << "\"" << scannedFileBasename << ".moc\", but instead includes "
+                << "\"" << ownMocUnderscoreFile  << "\". Running moc on "
+                << "\"" << absFilename << "\" ! Better include \""
+                << scannedFileBasename << ".moc\" to get a robust build."
+                << std::endl;
+      includedMocs[absFilename] = ownMocUnderscoreFile;
+      includedMocs.erase(ownMocHeaderFile);
+      }
+    }
+
   // search for header files and private header files we may need to moc:
   const std::string basename =
               cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename);

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=72428228970b8b7da54a3c98a36eca6810c46bb5
commit 72428228970b8b7da54a3c98a36eca6810c46bb5
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Thu Nov 10 20:56:46 2011 +0100
Commit:     Alex Neundorf <neundorf at kde.org>
CommitDate: Thu Nov 10 22:12:03 2011 +0100

    automoc: rework the checking for the matching header, to give better warnings
    
    Alex

diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx
index 15a034c..3dc515e 100644
--- a/Source/cmQtAutomoc.cxx
+++ b/Source/cmQtAutomoc.cxx
@@ -545,64 +545,57 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
         // finding the correct header, so we need to remove the moc_ part
         basename = basename.substr(4);
 
-        bool headerFound = false;
+        std::string mocSubDir;
+        if (currentMoc.find_first_of('/') != std::string::npos)
+          {
+          mocSubDir = absPath
+                       + cmsys::SystemTools::GetFilenamePath(currentMoc) + '/';
+          }
+
+        std::string headerToMoc;
         for(std::list<std::string>::const_iterator ext =
                                                       headerExtensions.begin();
             ext != headerExtensions.end();
             ++ext)
           {
-          const std::string &sourceFilePath = absPath + basename + (*ext);
+          std::string sourceFilePath = absPath + basename + (*ext);
           if (cmsys::SystemTools::FileExists(sourceFilePath.c_str()))
             {
-            headerFound = true;
-            includedMocs[sourceFilePath] = currentMoc;
+            headerToMoc = sourceFilePath;
             break;
             }
-          }
-        if (!headerFound)
-          {
-          // the moc file is in a subdir => look for the header in the
-          // same subdir
-          if (currentMoc.find_first_of('/') != std::string::npos)
+          if (!mocSubDir.empty())
             {
-            const std::string &filepath = absPath
-                    + cmsys::SystemTools::GetFilenamePath(currentMoc)
-                    + '/' + basename;
-
-            for(std::list<std::string>::const_iterator ext =
-                                                      headerExtensions.begin();
-                ext != headerExtensions.end();
-                ++ext)
-              {
-              const std::string &sourceFilePath = filepath + (*ext);
-              if (cmsys::SystemTools::FileExists(sourceFilePath.c_str()))
-                {
-                headerFound = true;
-                includedMocs[sourceFilePath] = currentMoc;
-                break;
-                }
-              }
-            if (!headerFound)
+            sourceFilePath = mocSubDir + basename + (*ext);
+            if (cmsys::SystemTools::FileExists(sourceFilePath.c_str()))
               {
-              std::cerr << "AUTOMOC: The file \"" << absFilename
-                        << "\" includes the moc file \"" << currentMoc
-                        << "\", but neither \"" << absPath << basename
-                        << '{' << this->Join(headerExtensions, ',')
-                        << "}\" nor \"" << filepath << '{'
-                        << this->Join(headerExtensions, ',') << '}'
-                        << "\" exist." << std::endl;
-              ::exit(EXIT_FAILURE);
+              headerToMoc = sourceFilePath;
+              break;
               }
             }
+          }
+
+        if (!headerToMoc.empty())
+          {
+          includedMocs[headerToMoc] = currentMoc;
+          }
+        else
+          {
+          std::cerr << "AUTOMOC: The file \"" << absFilename
+                    << "\" includes the moc file \"" << currentMoc
+                    << "\", but could not find header \"" << basename
+                    << '{' << this->Join(headerExtensions, ',') << "}\" ";
+          if (mocSubDir.empty())
+            {
+            std::cerr << "in " << absPath << std::endl;
+            }
           else
             {
-            std::cerr << "AUTOMOC: The file \"" << absFilename
-                      << "\" includes the moc file \"" << currentMoc
-                      << "\", but \"" << absPath << basename << '{'
-                      << this->Join(headerExtensions, ',') << '}'
-                      << "\" does not exist." << std::endl;
-            ::exit(EXIT_FAILURE);
+            std::cerr << "neither in " << absPath
+                      << " nor in " << mocSubDir << std::endl;
             }
+
+          ::exit(EXIT_FAILURE);
           }
         }
       else

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d08bc32bc29078764fc44fd3809eeda527e7017f
commit d08bc32bc29078764fc44fd3809eeda527e7017f
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Thu Nov 10 20:25:28 2011 +0100
Commit:     Alex Neundorf <neundorf at kde.org>
CommitDate: Thu Nov 10 22:11:32 2011 +0100

    automoc: stricter checking for what file is included
    
    foo.cpp must include foo.moc to have itself processed by moc
    
    Alex

diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx
index a839489..15a034c 100644
--- a/Source/cmQtAutomoc.cxx
+++ b/Source/cmQtAutomoc.cxx
@@ -517,6 +517,8 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
     }
   const std::string absPath = cmsys::SystemTools::GetFilenamePath(
                    cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/';
+  const std::string scannedFileBasename = cmsys::SystemTools::
+                                  GetFilenameWithoutLastExtension(absFilename);
 
   std::string::size_type matchOffset = 0;
   if (mocIncludeRegExp.find(contentsString.c_str()))
@@ -605,6 +607,16 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
         }
       else
         {
+        if (basename != scannedFileBasename)
+          {
+          std::cerr << "AUTOMOC: The file \"" << absFilename
+                    << "\" includes the moc file \"" << currentMoc
+                    << "\", which seems to be the moc file from a different "
+                    << "source file. This is not supported. "
+                    << "Include \"" << scannedFileBasename << ".moc\" to run "
+                    << "moc on this source file." << std::endl;
+          ::exit(EXIT_FAILURE);
+          }
         includedMocs[absFilename] = currentMoc;
         }
       matchOffset += mocIncludeRegExp.end();

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

Summary of changes:
 Source/cmQtAutomoc.cxx                |  152 ++++++++++++++++++++++----------
 Tests/QtAutomoc/CMakeLists.txt        |    2 +-
 Tests/QtAutomoc/{foo.h => bar.cpp}    |   22 +++---
 Tests/QtAutomoc/{foo.cpp => blub.cpp} |   21 +++--
 Tests/QtAutomoc/{foo.h => blub.h}     |   12 +--
 Tests/QtAutomoc/main.cpp              |    8 ++
 Tests/QtAutomoc/{foo.h => sub/bar.h}  |   10 +-
 7 files changed, 145 insertions(+), 82 deletions(-)
 copy Tests/QtAutomoc/{foo.h => bar.cpp} (80%)
 copy Tests/QtAutomoc/{foo.cpp => blub.cpp} (67%)
 copy Tests/QtAutomoc/{foo.h => blub.h} (85%)
 copy Tests/QtAutomoc/{foo.h => sub/bar.h} (88%)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list