[Cmake-commits] CMake branch, next, updated. v2.8.6-2123-g1f5c6e6

Alexander Neundorf neundorf at kde.org
Mon Dec 5 17:15:33 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  1f5c6e61ffa19e9071993e9459c374cccb5fe216 (commit)
       via  62e223e8fab50e87a804efd822dc336577608a9d (commit)
       via  40c516783e1df141f3d4a8f6400e90da822395c1 (commit)
       via  c207f5d3616efacdc4d91217f90609fd3679f116 (commit)
       via  9c0df72dc4b4e9403a3516390bc59f971ad1c3de (commit)
       via  174bf35fbbcb22636e538323c168ecbc33a7cb39 (commit)
       via  8507eaed1659d91709c41d34b351ea6a0585983e (commit)
       via  7ada172002e56d3900f4498a2f1bc2ffbc531816 (commit)
       via  3b93e266c0e6f0a58d813fc8ec7bc5810ace4827 (commit)
       via  47457159c70d031cfdb5704ce461644446de5a26 (commit)
       via  bde4edb6ab6501de42bdc167e027a9f5c5760244 (commit)
       via  74ab0f6aa409a9d3e90c91b1b1c7a6e4b865ed62 (commit)
      from  de3cd51e3546648a7375173301500db44f2b2098 (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=1f5c6e61ffa19e9071993e9459c374cccb5fe216
commit 1f5c6e61ffa19e9071993e9459c374cccb5fe216
Merge: de3cd51 62e223e
Author:     Alexander Neundorf <neundorf at kde.org>
AuthorDate: Mon Dec 5 17:15:29 2011 -0500
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Mon Dec 5 17:15:29 2011 -0500

    Merge topic 'AutomocIncludedDotMocFileHandling' into next
    
    62e223e automoc: add variable CMAKE_AUTOMOC_STRICT_MODE, to enable strict parsing
    40c5167 automoc: accept even more .moc files in non-strict mode
    c207f5d automoc: also accept other files when .moc is included in non-strict mode
    9c0df72 automoc: add a StrictParseCppFile(), which is only qmake-compatible
    174bf35 automoc: move the code for finding headers into separate function
    8507eae automoc: fix handling of included _p.moc files
    7ada172 automoc: some more linebreaks for the warnings for better readability
    3b93e26 automoc: add extra check whether the header contains Q_PRIVATE_SLOT
    4745715 Add a test case for the use of Q_PRIVATE_SLOT.
    bde4edb automoc: add special handling for including basename_p.moc, with test
    74ab0f6 automoc: move some code from the big parsing loop into separate functions

diff --cc Modules/AutomocInfo.cmake.in
index 2c7c724,293ba64..44f2da2
--- a/Modules/AutomocInfo.cmake.in
+++ b/Modules/AutomocInfo.cmake.in
@@@ -11,5 -10,5 +11,6 @@@ set(AM_QT_MOC_EXECUTABLE "@QT_MOC_EXECU
  set(AM_CMAKE_CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@/")
  set(AM_CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@/")
  set(AM_QT_VERSION_MAJOR "@QT_VERSION_MAJOR@" )
 +set(AM_Qt5Core_VERSION_MAJOR "@Qt5Core_VERSION_MAJOR@" )
  set(AM_TARGET_NAME "@_moc_target_name@")
+ set(AM_STRICT_MODE "@_moc_strict_mode@")
diff --cc Source/cmQtAutomoc.cxx
index 65d3da3,77b724c..2aa1cf2
--- a/Source/cmQtAutomoc.cxx
+++ b/Source/cmQtAutomoc.cxx
@@@ -160,11 -200,11 +210,12 @@@ void cmQtAutomoc::SetupAutomocTarget(cm
    makefile->AddDefinition("_moc_incs", _moc_incs.c_str());
    makefile->AddDefinition("_moc_defs", _moc_defs.c_str());
    makefile->AddDefinition("_moc_compile_defs", _moc_compile_defs.c_str());
 +  makefile->AddDefinition("_moc_options", _moc_options.c_str());
    makefile->AddDefinition("_moc_files", _moc_files.c_str());
    makefile->AddDefinition("_moc_headers", _moc_headers.c_str());
+   makefile->AddDefinition("_moc_strict_mode", strictMode ? "TRUE" : "FALSE");
  
 -  const char* cmakeRoot = makefile->GetDefinition("CMAKE_ROOT");
 +  const char* cmakeRoot = makefile->GetSafeDefinition("CMAKE_ROOT");
    std::string inputFile = cmakeRoot;
    inputFile += "/Modules/AutomocInfo.cmake.in";
    std::string outputFile = targetDir;

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=62e223e8fab50e87a804efd822dc336577608a9d
commit 62e223e8fab50e87a804efd822dc336577608a9d
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Fri Dec 2 22:08:06 2011 +0100
Commit:     Alex Neundorf <neundorf at kde.org>
CommitDate: Fri Dec 2 22:08:06 2011 +0100

    automoc: add variable CMAKE_AUTOMOC_STRICT_MODE, to enable strict parsing
    
    Alex

diff --git a/Modules/AutomocInfo.cmake.in b/Modules/AutomocInfo.cmake.in
index 2dc3aa2..293ba64 100644
--- a/Modules/AutomocInfo.cmake.in
+++ b/Modules/AutomocInfo.cmake.in
@@ -11,3 +11,4 @@ set(AM_CMAKE_CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@/")
 set(AM_CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@/")
 set(AM_QT_VERSION_MAJOR "@QT_VERSION_MAJOR@" )
 set(AM_TARGET_NAME "@_moc_target_name@")
+set(AM_STRICT_MODE "@_moc_strict_mode@")
diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx
index aa8c6e2..77b724c 100644
--- a/Source/cmQtAutomoc.cxx
+++ b/Source/cmQtAutomoc.cxx
@@ -115,6 +115,12 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target)
     return;
     }
 
+  bool strictMode = (qtMajorVersion == "5");
+  if (makefile->IsDefinitionSet("CMAKE_AUTOMOC_STRICT_MODE"))
+    {
+    strictMode = makefile->IsOn("CMAKE_AUTOMOC_STRICT_MODE");
+    }
+
   // create a custom target for running automoc at buildtime:
   std::string automocTargetName = targetName;
   automocTargetName += "_automoc";
@@ -196,6 +202,7 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target)
   makefile->AddDefinition("_moc_compile_defs", _moc_compile_defs.c_str());
   makefile->AddDefinition("_moc_files", _moc_files.c_str());
   makefile->AddDefinition("_moc_headers", _moc_headers.c_str());
+  makefile->AddDefinition("_moc_strict_mode", strictMode ? "TRUE" : "FALSE");
 
   const char* cmakeRoot = makefile->GetDefinition("CMAKE_ROOT");
   std::string inputFile = cmakeRoot;
@@ -289,6 +296,8 @@ bool cmQtAutomoc::ReadAutomocInfoFile(cmMakefile* makefile,
   this->ProjectSourceDir = makefile->GetSafeDefinition("AM_CMAKE_SOURCE_DIR");
   this->TargetName = makefile->GetSafeDefinition("AM_TARGET_NAME");
 
+  this->StrictMode = makefile->IsOn("AM_STRICT_MODE");
+
   return true;
 }
 
@@ -481,11 +490,11 @@ bool cmQtAutomoc::RunAutomocQt4()
       {
       std::cout << "AUTOMOC: Checking " << absFilename << std::endl;
       }
-    if (this->QtMajorVersion == "4")
+    if (this->StrictMode == false)
       {
       this->ParseCppFile(absFilename, headerExtensions, includedMocs);
       }
-    else if (this->QtMajorVersion == "5")
+    else
       {
       this->StrictParseCppFile(absFilename, headerExtensions, includedMocs);
       }
diff --git a/Source/cmQtAutomoc.h b/Source/cmQtAutomoc.h
index d91df61..7aa1bea 100644
--- a/Source/cmQtAutomoc.h
+++ b/Source/cmQtAutomoc.h
@@ -83,6 +83,7 @@ private:
   bool ColorOutput;
   bool RunMocFailed;
   bool GenerateAll;
+  bool StrictMode;
 
 };
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=40c516783e1df141f3d4a8f6400e90da822395c1
commit 40c516783e1df141f3d4a8f6400e90da822395c1
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Fri Dec 2 21:54:11 2011 +0100
Commit:     Alex Neundorf <neundorf at kde.org>
CommitDate: Fri Dec 2 21:54:11 2011 +0100

    automoc: accept even more .moc files in non-strict mode
    
    Alex

diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx
index 79ee35b..aa8c6e2 100644
--- a/Source/cmQtAutomoc.cxx
+++ b/Source/cmQtAutomoc.cxx
@@ -37,20 +37,6 @@ static bool containsQ_OBJECT(const std::string& text)
 }
 
 
-static bool containsQ_PRIVATE_SLOT(const std::string& text)
-{
-  // this simple check is much much faster than the regexp
-  if (strstr(text.c_str(), "Q_PRIVATE_SLOT") == NULL)
-    {
-    return false;
-    }
-
-  cmsys::RegularExpression qPrivateSlotRegExp(
-                                      "[\n][ \t]*Q_PRIVATE_SLOT[^a-zA-Z0-9_]");
-  return qPrivateSlotRegExp.find(text);
-}
-
-
 static std::string findMatchingHeader(const std::string& absPath,
                                       const std::string& mocSubDir,
                                       const std::string& basename,
@@ -602,7 +588,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
                    cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/';
   const std::string scannedFileBasename = cmsys::SystemTools::
                                   GetFilenameWithoutLastExtension(absFilename);
-
+  const bool cppContainsQ_OBJECT = containsQ_OBJECT(contentsString);
   bool dotMocIncluded = false;
   bool mocUnderscoreIncluded = false;
   std::string ownMocUnderscoreFile;
@@ -673,7 +659,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
       else
         {
         std::string fileToMoc = absFilename;
-        if (basename != scannedFileBasename)
+        if ((basename != scannedFileBasename) || (cppContainsQ_OBJECT==false))
           {
           std::string mocSubDir = extractSubDir(absPath, currentMoc);
           std::string headerToMoc = findMatchingHeader(
@@ -682,22 +668,34 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
             {
             // this is for KDE4 compatibility:
             fileToMoc = headerToMoc;
-            std::cerr << "AUTOMOC: warning: " << absFilename << ": The file "
-                          "includes the moc file \"" << currentMoc <<
-                          "\" instead of \"moc_" << basename << ".cpp\". "
-                          "Running moc on "
-                      << "\"" << headerToMoc << "\" ! Better include \"moc_"
-                      << basename << ".cpp\" for a robust build.\n"
-                      << std::endl;
+            if ((cppContainsQ_OBJECT==false) && (basename == scannedFileBasename))
+              {
+              std::cerr << "AUTOMOC: warning: " << absFilename << ": The file "
+                            "includes the moc file \"" << currentMoc <<
+                            "\", but does not contain a Q_OBJECT macro. "
+                            "Running moc on "
+                        << "\"" << headerToMoc << "\" ! Better include \"moc_"
+                        << basename << ".cpp\" for a robust build.\n"
+                        << std::endl;
+              }
+            else
+              {
+              std::cerr << "AUTOMOC: warning: " << absFilename << ": The file "
+                            "includes the moc file \"" << currentMoc <<
+                            "\" instead of \"moc_" << basename << ".cpp\". "
+                            "Running moc on "
+                        << "\"" << headerToMoc << "\" ! Better include \"moc_"
+                        << basename << ".cpp\" for a robust build.\n"
+                        << std::endl;
+              }
             }
           else
             {
             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 "
-                        "moc on this source file.\n" << std::endl;
+                        "source file. CMake also could not find a matching "
+                        "header.\n" << std::endl;
             ::exit(EXIT_FAILURE);
             }
           }
@@ -716,7 +714,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
   // 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) && (containsQ_OBJECT(contentsString)))
+  if ((dotMocIncluded == false) && (cppContainsQ_OBJECT == true))
     {
     if (mocUnderscoreIncluded == true)
       {
@@ -743,35 +741,6 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
       }
     }
 
-  // if only the .moc file is included and we are in compatibility mode,
-  // check whether maybe the header must actually be mocced, e.g. because it
-  // might use the Q_PRIVATE_SLOT macro:
-  if ((dotMocIncluded == true) && (mocUnderscoreIncluded == false))
-    {
-    std::string ownHeader=findMatchingHeader(absPath, "", scannedFileBasename,
-                                             headerExtensions);
-
-    if (ownHeader.size() > 0)
-      {
-      const std::string ownHeaderContents = this->ReadAll(ownHeader);
-      if (containsQ_PRIVATE_SLOT(ownHeaderContents))
-        {
-        // this is for KDE4 compatibility:
-        std::cerr << "AUTOMOC: warning: " << absFilename << ": The file "
-                  << "includes \"" << ownDotMocFile << "\", but the "
-                  << "header \"" << ownHeader << "\" contains a "
-                  << "Q_PRIVATE_SLOT macro. "
-                  << "Running moc on " << "\"" << absFilename << "\" ! "
-                  << "Better include \"moc_" << scannedFileBasename << ".cpp\""
-                  << " for a robust build.\n"
-                  << std::endl;
-        includedMocs[ownHeader] = ownDotMocFile;
-        includedMocs.erase(absFilename);
-        }
-
-      }
-    }
-
 }
 
 

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c207f5d3616efacdc4d91217f90609fd3679f116
commit c207f5d3616efacdc4d91217f90609fd3679f116
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Fri Dec 2 21:43:15 2011 +0100
Commit:     Alex Neundorf <neundorf at kde.org>
CommitDate: Fri Dec 2 21:43:15 2011 +0100

    automoc: also accept other files when .moc is included in non-strict mode
    
    Alex

diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx
index 123cf67..79ee35b 100644
--- a/Source/cmQtAutomoc.cxx
+++ b/Source/cmQtAutomoc.cxx
@@ -675,28 +675,22 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
         std::string fileToMoc = absFilename;
         if (basename != scannedFileBasename)
           {
-          bool fail = true;
-          if (basename == scannedFileBasename+"_p")
+          std::string mocSubDir = extractSubDir(absPath, currentMoc);
+          std::string headerToMoc = findMatchingHeader(
+                              absPath, mocSubDir, basename, headerExtensions);
+          if (!headerToMoc.empty())
             {
-            std::string mocSubDir = extractSubDir(absPath, currentMoc);
-            std::string headerToMoc = findMatchingHeader(
-                               absPath, mocSubDir, basename, headerExtensions);
-            if (!headerToMoc.empty())
-              {
-              // this is for KDE4 compatibility:
-              fail = false;
-              fileToMoc = headerToMoc;
-              std::cerr << "AUTOMOC: warning: " << absFilename << ": The file "
-                           "includes the moc file \"" << currentMoc <<
-                           "\" instead of \"moc_" << basename << ".cpp\". "
-                           "Running moc on "
-                        << "\"" << headerToMoc << "\" ! Better include \"moc_"
-                        << basename << ".cpp\" for a robust build.\n"
-                        << std::endl;
-              }
+            // this is for KDE4 compatibility:
+            fileToMoc = headerToMoc;
+            std::cerr << "AUTOMOC: warning: " << absFilename << ": The file "
+                          "includes the moc file \"" << currentMoc <<
+                          "\" instead of \"moc_" << basename << ".cpp\". "
+                          "Running moc on "
+                      << "\"" << headerToMoc << "\" ! Better include \"moc_"
+                      << basename << ".cpp\" for a robust build.\n"
+                      << std::endl;
             }
-
-          if (fail)
+          else
             {
             std::cerr <<"AUTOMOC: error: " << absFilename << ": The file "
                         "includes the moc file \"" << currentMoc <<

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9c0df72dc4b4e9403a3516390bc59f971ad1c3de
commit 9c0df72dc4b4e9403a3516390bc59f971ad1c3de
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Fri Dec 2 20:59:44 2011 +0100
Commit:     Alex Neundorf <neundorf at kde.org>
CommitDate: Fri Dec 2 20:59:44 2011 +0100

    automoc: add a StrictParseCppFile(), which is only qmake-compatible
    
    ParseCppFile() is the one which is automoc4/KDE4-compatible, and which
    becomes a bit crowded. By separating these two it is easier to ensure
    that the strict one doesn't get broken accidentially.
    
    Alex

diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx
index 3ff0477..123cf67 100644
--- a/Source/cmQtAutomoc.cxx
+++ b/Source/cmQtAutomoc.cxx
@@ -495,7 +495,14 @@ bool cmQtAutomoc::RunAutomocQt4()
       {
       std::cout << "AUTOMOC: Checking " << absFilename << std::endl;
       }
-    this->ParseCppFile(absFilename, headerExtensions, includedMocs);
+    if (this->QtMajorVersion == "4")
+      {
+      this->ParseCppFile(absFilename, headerExtensions, includedMocs);
+      }
+    else if (this->QtMajorVersion == "5")
+      {
+      this->StrictParseCppFile(absFilename, headerExtensions, includedMocs);
+      }
     this->SearchHeadersForCppFile(absFilename, headerExtensions, headerFiles);
     }
 
@@ -669,8 +676,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
         if (basename != scannedFileBasename)
           {
           bool fail = true;
-          if ((this->QtMajorVersion == "4")
-                                    && (basename == scannedFileBasename +"_p"))
+          if (basename == scannedFileBasename+"_p")
             {
             std::string mocSubDir = extractSubDir(absPath, currentMoc);
             std::string headerToMoc = findMatchingHeader(
@@ -718,7 +724,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
   // But warn, since this is not how it is supposed to be used.
   if ((dotMocIncluded == false) && (containsQ_OBJECT(contentsString)))
     {
-    if ((this->QtMajorVersion == "4") && (mocUnderscoreIncluded == true))
+    if (mocUnderscoreIncluded == true)
       {
       // this is for KDE4 compatibility:
       std::cerr << "AUTOMOC: warning: " << absFilename << ": The file "
@@ -746,8 +752,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
   // if only the .moc file is included and we are in compatibility mode,
   // check whether maybe the header must actually be mocced, e.g. because it
   // might use the Q_PRIVATE_SLOT macro:
-  if ((dotMocIncluded == true) && (mocUnderscoreIncluded == false)
-                               && (this->QtMajorVersion == "4"))
+  if ((dotMocIncluded == true) && (mocUnderscoreIncluded == false))
     {
     std::string ownHeader=findMatchingHeader(absPath, "", scannedFileBasename,
                                              headerExtensions);
@@ -776,6 +781,117 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
 }
 
 
+void cmQtAutomoc::StrictParseCppFile(const std::string& absFilename,
+                              const std::list<std::string>& headerExtensions,
+                              std::map<std::string, std::string>& includedMocs)
+{
+  cmsys::RegularExpression mocIncludeRegExp(
+              "[\n][ \t]*#[ \t]*include[ \t]+"
+              "[\"<](([^ \">]+/)?moc_[^ \">/]+\\.cpp|[^ \">]+\\.moc)[\">]");
+
+  const std::string contentsString = this->ReadAll(absFilename);
+  if (contentsString.empty())
+    {
+    std::cerr << "AUTOMOC: warning: " << absFilename << ": file is empty\n"
+              << std::endl;
+    return;
+    }
+  const std::string absPath = cmsys::SystemTools::GetFilenamePath(
+                   cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/';
+  const std::string scannedFileBasename = cmsys::SystemTools::
+                                  GetFilenameWithoutLastExtension(absFilename);
+
+  bool dotMocIncluded = false;
+
+  std::string::size_type matchOffset = 0;
+  // 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
+      {
+      const std::string currentMoc = mocIncludeRegExp.match(1);
+
+      std::string basename = cmsys::SystemTools::
+                                   GetFilenameWithoutLastExtension(currentMoc);
+      const bool mocUnderscoreStyle = this->StartsWith(basename, "moc_");
+
+      // If the moc include is of the moc_foo.cpp style we expect
+      // the Q_OBJECT class declaration in a header file.
+      // If the moc include is of the foo.moc style we need to look for
+      // a Q_OBJECT macro in the current source file, if it contains the
+      // macro we generate the moc file from the source file.
+      if (mocUnderscoreStyle)
+        {
+        // basename should be the part of the moc filename used for
+        // finding the correct header, so we need to remove the moc_ part
+        basename = basename.substr(4);
+        std::string mocSubDir = extractSubDir(absPath, currentMoc);
+        std::string headerToMoc = findMatchingHeader(
+                               absPath, mocSubDir, basename, headerExtensions);
+
+        if (!headerToMoc.empty())
+          {
+          includedMocs[headerToMoc] = currentMoc;
+          }
+        else
+          {
+          std::cerr << "AUTOMOC: error: " << absFilename << " The file "
+                    << "includes the moc file \"" << currentMoc << "\", "
+                    << "but could not find header \"" << basename
+                    << '{' << this->Join(headerExtensions, ',') << "}\" ";
+          if (mocSubDir.empty())
+            {
+            std::cerr << "in " << absPath << "\n" << std::endl;
+            }
+          else
+            {
+            std::cerr << "neither in " << absPath
+                      << " nor in " << mocSubDir << "\n" << std::endl;
+            }
+
+          ::exit(EXIT_FAILURE);
+          }
+        }
+      else
+        {
+        if (basename != scannedFileBasename)
+          {
+          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 "
+                      "moc on this source file.\n" << std::endl;
+          ::exit(EXIT_FAILURE);
+          }
+        dotMocIncluded = true;
+        includedMocs[absFilename] = currentMoc;
+        }
+      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) && (containsQ_OBJECT(contentsString)))
+    {
+    // otherwise always error out since it will not compile:
+    std::cerr << "AUTOMOC: error: " << absFilename << ": The file "
+              << "contains a Q_OBJECT macro, but does not include "
+              << "\"" << scannedFileBasename << ".moc\" !\n"
+              << std::endl;
+    ::exit(EXIT_FAILURE);
+    }
+
+}
+
+
 void cmQtAutomoc::SearchHeadersForCppFile(const std::string& absFilename,
                                 const std::list<std::string>& headerExtensions,
                                 std::set<std::string>& absHeaders)
diff --git a/Source/cmQtAutomoc.h b/Source/cmQtAutomoc.h
index d8f65a9..d91df61 100644
--- a/Source/cmQtAutomoc.h
+++ b/Source/cmQtAutomoc.h
@@ -41,6 +41,9 @@ private:
   void ParseCppFile(const std::string& absFilename,
                     const std::list<std::string>& headerExtensions,
                     std::map<std::string, std::string>& includedMocs);
+  void StrictParseCppFile(const std::string& absFilename,
+                          const std::list<std::string>& headerExtensions,
+                          std::map<std::string, std::string>& includedMocs);
   void SearchHeadersForCppFile(const std::string& absFilename,
                                const std::list<std::string>& headerExtensions,
                                std::set<std::string>& absHeaders);

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=174bf35fbbcb22636e538323c168ecbc33a7cb39
commit 174bf35fbbcb22636e538323c168ecbc33a7cb39
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Fri Dec 2 20:38:14 2011 +0100
Commit:     Alex Neundorf <neundorf at kde.org>
CommitDate: Fri Dec 2 20:38:14 2011 +0100

    automoc: move the code for finding headers into separate function
    
    Alex

diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx
index bb81dd3..3ff0477 100644
--- a/Source/cmQtAutomoc.cxx
+++ b/Source/cmQtAutomoc.cxx
@@ -469,6 +469,23 @@ bool cmQtAutomoc::RunAutomocQt4()
   std::vector<std::string> sourceFiles;
   cmSystemTools::ExpandListArgument(this->Sources, sourceFiles);
 
+  std::list<std::string> headerExtensions;
+  headerExtensions.push_back(".h");
+  headerExtensions.push_back(".hpp");
+  headerExtensions.push_back(".hxx");
+#if defined(_WIN32)
+  // not case sensitive, don't add ".H"
+#elif defined(__APPLE__)
+  // detect case-sensitive filesystem
+  long caseSensitive = pathconf(this->Srcdir.c_str(), _PC_CASE_SENSITIVE);
+  if (caseSensitive == 1)
+  {
+    headerExtensions.push_back(".H");
+  }
+#else
+  headerExtensions.push_back(".H");
+#endif
+
   for (std::vector<std::string>::const_iterator it = sourceFiles.begin();
        it != sourceFiles.end();
        ++it)
@@ -478,7 +495,8 @@ bool cmQtAutomoc::RunAutomocQt4()
       {
       std::cout << "AUTOMOC: Checking " << absFilename << std::endl;
       }
-    this->ParseCppFile(absFilename, includedMocs, headerFiles);
+    this->ParseCppFile(absFilename, headerExtensions, includedMocs);
+    this->SearchHeadersForCppFile(absFilename, headerExtensions, headerFiles);
     }
 
   std::vector<std::string> headerFilesVec;
@@ -559,28 +577,12 @@ bool cmQtAutomoc::RunAutomocQt4()
 
 
 void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
-                           std::map<std::string, std::string>& includedMocs,
-                           std::set<std::string>& absHeaders)
+                              const std::list<std::string>& headerExtensions,
+                              std::map<std::string, std::string>& includedMocs)
 {
   cmsys::RegularExpression mocIncludeRegExp(
               "[\n][ \t]*#[ \t]*include[ \t]+"
               "[\"<](([^ \">]+/)?moc_[^ \">/]+\\.cpp|[^ \">]+\\.moc)[\">]");
-  std::list<std::string> headerExtensions;
-  headerExtensions.push_back(".h");
-  headerExtensions.push_back(".hpp");
-  headerExtensions.push_back(".hxx");
-#if defined(_WIN32)
-  // not case sensitive, don't add ".H"
-#elif defined(__APPLE__)
-  // detect case-sensitive filesystem
-  long caseSensitive = pathconf(this->Srcdir.c_str(), _PC_CASE_SENSITIVE);
-  if (caseSensitive == 1)
-  {
-    headerExtensions.push_back(".H");
-  }
-#else
-  headerExtensions.push_back(".H");
-#endif
 
   const std::string contentsString = this->ReadAll(absFilename);
   if (contentsString.empty())
@@ -771,9 +773,19 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
       }
     }
 
+}
+
+
+void cmQtAutomoc::SearchHeadersForCppFile(const std::string& absFilename,
+                                const std::list<std::string>& headerExtensions,
+                                std::set<std::string>& absHeaders)
+{
   // search for header files and private header files we may need to moc:
   const std::string basename =
               cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename);
+  const std::string absPath = cmsys::SystemTools::GetFilenamePath(
+                   cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/';
+
   for(std::list<std::string>::const_iterator ext = headerExtensions.begin();
       ext != headerExtensions.end();
       ++ext)
diff --git a/Source/cmQtAutomoc.h b/Source/cmQtAutomoc.h
index c3550a4..d8f65a9 100644
--- a/Source/cmQtAutomoc.h
+++ b/Source/cmQtAutomoc.h
@@ -39,8 +39,12 @@ private:
   bool GenerateMoc(const std::string& sourceFile,
                    const std::string& mocFileName);
   void ParseCppFile(const std::string& absFilename,
-                    std::map<std::string, std::string>& includedMocs,
-                    std::set<std::string>& absHeaders);
+                    const std::list<std::string>& headerExtensions,
+                    std::map<std::string, std::string>& includedMocs);
+  void SearchHeadersForCppFile(const std::string& absFilename,
+                               const std::list<std::string>& headerExtensions,
+                               std::set<std::string>& absHeaders);
+
   void ParseHeaders(const std::set<std::string>& absHeaders,
                     const std::map<std::string, std::string>& includedMocs,
                     std::map<std::string, std::string>& notIncludedMocs);

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8507eaed1659d91709c41d34b351ea6a0585983e
commit 8507eaed1659d91709c41d34b351ea6a0585983e
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Wed Nov 30 21:43:05 2011 +0100
Commit:     Alex Neundorf <neundorf at kde.org>
CommitDate: Wed Nov 30 21:43:05 2011 +0100

    automoc: fix handling of included _p.moc files
    
    Alex

diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx
index 0103bcc..bb81dd3 100644
--- a/Source/cmQtAutomoc.cxx
+++ b/Source/cmQtAutomoc.cxx
@@ -663,6 +663,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
         }
       else
         {
+        std::string fileToMoc = absFilename;
         if (basename != scannedFileBasename)
           {
           bool fail = true;
@@ -676,7 +677,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
               {
               // this is for KDE4 compatibility:
               fail = false;
-              includedMocs[headerToMoc] = currentMoc;
+              fileToMoc = headerToMoc;
               std::cerr << "AUTOMOC: warning: " << absFilename << ": The file "
                            "includes the moc file \"" << currentMoc <<
                            "\" instead of \"moc_" << basename << ".cpp\". "
@@ -703,7 +704,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
           dotMocIncluded = true;
           ownDotMocFile = currentMoc;
           }
-        includedMocs[absFilename] = currentMoc;
+        includedMocs[fileToMoc] = currentMoc;
         }
       matchOffset += mocIncludeRegExp.end();
       } while(mocIncludeRegExp.find(contentsString.c_str() + matchOffset));

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7ada172002e56d3900f4498a2f1bc2ffbc531816
commit 7ada172002e56d3900f4498a2f1bc2ffbc531816
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Tue Nov 29 21:07:50 2011 +0100
Commit:     Alex Neundorf <neundorf at kde.org>
CommitDate: Tue Nov 29 21:07:50 2011 +0100

    automoc: some more linebreaks for the warnings for better readability
    
    Alex

diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx
index 095e8d0..0103bcc 100644
--- a/Source/cmQtAutomoc.cxx
+++ b/Source/cmQtAutomoc.cxx
@@ -585,7 +585,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
   const std::string contentsString = this->ReadAll(absFilename);
   if (contentsString.empty())
     {
-    std::cerr << "AUTOMOC: warning: " << absFilename << ": file is empty"
+    std::cerr << "AUTOMOC: warning: " << absFilename << ": file is empty\n"
               << std::endl;
     return;
     }
@@ -650,12 +650,12 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
                     << '{' << this->Join(headerExtensions, ',') << "}\" ";
           if (mocSubDir.empty())
             {
-            std::cerr << "in " << absPath << std::endl;
+            std::cerr << "in " << absPath << "\n" << std::endl;
             }
           else
             {
             std::cerr << "neither in " << absPath
-                      << " nor in " << mocSubDir << std::endl;
+                      << " nor in " << mocSubDir << "\n" << std::endl;
             }
 
           ::exit(EXIT_FAILURE);
@@ -682,7 +682,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
                            "\" instead of \"moc_" << basename << ".cpp\". "
                            "Running moc on "
                         << "\"" << headerToMoc << "\" ! Better include \"moc_"
-                        << basename << ".cpp\" for a robust build."
+                        << basename << ".cpp\" for a robust build.\n"
                         << std::endl;
               }
             }
@@ -694,7 +694,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
                         "\", 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;
+                        "moc on this source file.\n" << std::endl;
             ::exit(EXIT_FAILURE);
             }
           }
@@ -724,7 +724,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
                    "includes "
                 << "\"" << ownMocUnderscoreFile  << "\". Running moc on "
                 << "\"" << absFilename << "\" ! Better include \""
-                << scannedFileBasename << ".moc\" for a robust build."
+                << scannedFileBasename << ".moc\" for a robust build.\n"
                 << std::endl;
       includedMocs[absFilename] = ownMocUnderscoreFile;
       includedMocs.erase(ownMocHeaderFile);
@@ -734,7 +734,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
       // otherwise always error out since it will not compile:
       std::cerr << "AUTOMOC: error: " << absFilename << ": The file "
                 << "contains a Q_OBJECT macro, but does not include "
-                << "\"" << scannedFileBasename << ".moc\" !"
+                << "\"" << scannedFileBasename << ".moc\" !\n"
                 << std::endl;
       ::exit(EXIT_FAILURE);
       }
@@ -761,7 +761,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
                   << "Q_PRIVATE_SLOT macro. "
                   << "Running moc on " << "\"" << absFilename << "\" ! "
                   << "Better include \"moc_" << scannedFileBasename << ".cpp\""
-                  << " for a robust build."
+                  << " for a robust build.\n"
                   << std::endl;
         includedMocs[ownHeader] = ownDotMocFile;
         includedMocs.erase(absFilename);

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3b93e266c0e6f0a58d813fc8ec7bc5810ace4827
commit 3b93e266c0e6f0a58d813fc8ec7bc5810ace4827
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Tue Nov 29 20:55:36 2011 +0100
Commit:     Alex Neundorf <neundorf at kde.org>
CommitDate: Tue Nov 29 20:55:36 2011 +0100

    automoc: add extra check whether the header contains Q_PRIVATE_SLOT
    
    This is again for KDE4 compatiblity. If foo.moc is included, in general
    moc should run on foo.cpp. Usually this can't cause problems.
    It can only cause problems if moc must run on the header, and the resulting
    file must be included in the cpp file, which is the case with the
    Q_PRIVATE_SLOT macro.
    This makes the test added by Stephen pass.
    
    Alex

diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx
index 9cb8f63..095e8d0 100644
--- a/Source/cmQtAutomoc.cxx
+++ b/Source/cmQtAutomoc.cxx
@@ -37,6 +37,20 @@ static bool containsQ_OBJECT(const std::string& text)
 }
 
 
+static bool containsQ_PRIVATE_SLOT(const std::string& text)
+{
+  // this simple check is much much faster than the regexp
+  if (strstr(text.c_str(), "Q_PRIVATE_SLOT") == NULL)
+    {
+    return false;
+    }
+
+  cmsys::RegularExpression qPrivateSlotRegExp(
+                                      "[\n][ \t]*Q_PRIVATE_SLOT[^a-zA-Z0-9_]");
+  return qPrivateSlotRegExp.find(text);
+}
+
+
 static std::string findMatchingHeader(const std::string& absPath,
                                       const std::string& mocSubDir,
                                       const std::string& basename,
@@ -583,6 +597,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
   bool dotMocIncluded = false;
   bool mocUnderscoreIncluded = false;
   std::string ownMocUnderscoreFile;
+  std::string ownDotMocFile;
   std::string ownMocHeaderFile;
 
   std::string::size_type matchOffset = 0;
@@ -683,8 +698,12 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
             ::exit(EXIT_FAILURE);
             }
           }
+        else
+          {
+          dotMocIncluded = true;
+          ownDotMocFile = currentMoc;
+          }
         includedMocs[absFilename] = currentMoc;
-        dotMocIncluded = true;
         }
       matchOffset += mocIncludeRegExp.end();
       } while(mocIncludeRegExp.find(contentsString.c_str() + matchOffset));
@@ -721,6 +740,36 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
       }
     }
 
+  // if only the .moc file is included and we are in compatibility mode,
+  // check whether maybe the header must actually be mocced, e.g. because it
+  // might use the Q_PRIVATE_SLOT macro:
+  if ((dotMocIncluded == true) && (mocUnderscoreIncluded == false)
+                               && (this->QtMajorVersion == "4"))
+    {
+    std::string ownHeader=findMatchingHeader(absPath, "", scannedFileBasename,
+                                             headerExtensions);
+
+    if (ownHeader.size() > 0)
+      {
+      const std::string ownHeaderContents = this->ReadAll(ownHeader);
+      if (containsQ_PRIVATE_SLOT(ownHeaderContents))
+        {
+        // this is for KDE4 compatibility:
+        std::cerr << "AUTOMOC: warning: " << absFilename << ": The file "
+                  << "includes \"" << ownDotMocFile << "\", but the "
+                  << "header \"" << ownHeader << "\" contains a "
+                  << "Q_PRIVATE_SLOT macro. "
+                  << "Running moc on " << "\"" << absFilename << "\" ! "
+                  << "Better include \"moc_" << scannedFileBasename << ".cpp\""
+                  << " for a robust build."
+                  << std::endl;
+        includedMocs[ownHeader] = ownDotMocFile;
+        includedMocs.erase(absFilename);
+        }
+
+      }
+    }
+
   // 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=47457159c70d031cfdb5704ce461644446de5a26
commit 47457159c70d031cfdb5704ce461644446de5a26
Author:     Stephen Kelly <steveire at gmail.com>
AuthorDate: Tue Nov 22 22:26:42 2011 +0100
Commit:     Stephen Kelly <steveire at gmail.com>
CommitDate: Tue Nov 22 22:26:42 2011 +0100

    Add a test case for the use of Q_PRIVATE_SLOT.

diff --git a/Tests/QtAutomoc/CMakeLists.txt b/Tests/QtAutomoc/CMakeLists.txt
index f47d5fd..ebfb4f5 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 blub.cpp bar.cpp abc.cpp xyz.cpp yaf.cpp)
+add_executable(foo main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp abc.cpp xyz.cpp yaf.cpp private_slot.cpp)
 
 set_target_properties(foo codeeditorLib PROPERTIES AUTOMOC TRUE)
 
diff --git a/Tests/QtAutomoc/private_slot.cpp b/Tests/QtAutomoc/private_slot.cpp
new file mode 100644
index 0000000..1387a70
--- /dev/null
+++ b/Tests/QtAutomoc/private_slot.cpp
@@ -0,0 +1,21 @@
+
+#include "private_slot.h"
+
+class PrivateSlotPrivate
+{
+public:
+
+  void privateSlot()
+  {
+
+  }
+};
+
+PrivateSlot::PrivateSlot(QObject *parent)
+  : QObject(parent),
+  d(new PrivateSlotPrivate)
+{
+
+}
+
+#include "private_slot.moc"
diff --git a/Tests/QtAutomoc/private_slot.h b/Tests/QtAutomoc/private_slot.h
new file mode 100644
index 0000000..28e5448
--- /dev/null
+++ b/Tests/QtAutomoc/private_slot.h
@@ -0,0 +1,20 @@
+
+#ifndef PRIVATE_SLOT_H
+#define PRIVATE_SLOT_H
+
+#include <QObject>
+
+class PrivateSlotPrivate;
+
+class PrivateSlot : public QObject
+{
+  Q_OBJECT
+public:
+  PrivateSlot(QObject *parent = 0);
+
+private:
+  PrivateSlotPrivate * const d;
+  Q_PRIVATE_SLOT(d, void privateSlot())
+};
+
+#endif

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bde4edb6ab6501de42bdc167e027a9f5c5760244
commit bde4edb6ab6501de42bdc167e027a9f5c5760244
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Tue Nov 22 22:01:13 2011 +0100
Commit:     Alex Neundorf <neundorf at kde.org>
CommitDate: Tue Nov 22 22:01:13 2011 +0100

    automoc: add special handling for including basename_p.moc, with test
    
    Alex

diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx
index 931cc5d..9cb8f63 100644
--- a/Source/cmQtAutomoc.cxx
+++ b/Source/cmQtAutomoc.cxx
@@ -650,13 +650,38 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
         {
         if (basename != scannedFileBasename)
           {
-          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 "
-                    << "moc on this source file." << std::endl;
-          ::exit(EXIT_FAILURE);
+          bool fail = true;
+          if ((this->QtMajorVersion == "4")
+                                    && (basename == scannedFileBasename +"_p"))
+            {
+            std::string mocSubDir = extractSubDir(absPath, currentMoc);
+            std::string headerToMoc = findMatchingHeader(
+                               absPath, mocSubDir, basename, headerExtensions);
+            if (!headerToMoc.empty())
+              {
+              // this is for KDE4 compatibility:
+              fail = false;
+              includedMocs[headerToMoc] = currentMoc;
+              std::cerr << "AUTOMOC: warning: " << absFilename << ": The file "
+                           "includes the moc file \"" << currentMoc <<
+                           "\" instead of \"moc_" << basename << ".cpp\". "
+                           "Running moc on "
+                        << "\"" << headerToMoc << "\" ! Better include \"moc_"
+                        << basename << ".cpp\" for a robust build."
+                        << std::endl;
+              }
+            }
+
+          if (fail)
+            {
+            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 "
+                        "moc on this source file." << std::endl;
+            ::exit(EXIT_FAILURE);
+            }
           }
         includedMocs[absFilename] = currentMoc;
         dotMocIncluded = true;
diff --git a/Tests/QtAutomoc/CMakeLists.txt b/Tests/QtAutomoc/CMakeLists.txt
index 9f02618..f47d5fd 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 blub.cpp bar.cpp abc.cpp xyz.cpp)
+add_executable(foo main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp abc.cpp xyz.cpp yaf.cpp)
 
 set_target_properties(foo codeeditorLib PROPERTIES AUTOMOC TRUE)
 
diff --git a/Tests/QtAutomoc/main.cpp b/Tests/QtAutomoc/main.cpp
index 7eb29a3..738f677 100644
--- a/Tests/QtAutomoc/main.cpp
+++ b/Tests/QtAutomoc/main.cpp
@@ -47,6 +47,7 @@
 #include "sub/bar.h"
 #include "abc.h"
 #include "xyz.h"
+#include "yaf.h"
 
 int main(int argv, char **args)
 {
@@ -74,5 +75,8 @@ int main(int argv, char **args)
   Xyz xyz;
   xyz.doXyz();
 
+  Yaf yaf;
+  yaf.doYaf();
+
   return app.exec();
 }
diff --git a/Tests/QtAutomoc/yaf.cpp b/Tests/QtAutomoc/yaf.cpp
new file mode 100644
index 0000000..d278ab4
--- /dev/null
+++ b/Tests/QtAutomoc/yaf.cpp
@@ -0,0 +1,32 @@
+/*============================================================================
+  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 "yaf.h"
+#include "yaf_p.h"
+
+#include <stdio.h>
+
+Yaf::Yaf()
+{
+}
+
+
+void Yaf::doYaf()
+{
+  YafP yafP;
+  yafP.doYafP();
+}
+
+// check that including a moc file from a private header the wrong way works:
+#include "yaf_p.moc"
diff --git a/Tests/QtAutomoc/yaf.h b/Tests/QtAutomoc/yaf.h
new file mode 100644
index 0000000..8689f83
--- /dev/null
+++ b/Tests/QtAutomoc/yaf.h
@@ -0,0 +1,25 @@
+/*============================================================================
+  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 YAF_H
+#define YAF_H
+
+class Yaf
+{
+  public:
+    Yaf();
+  public:
+    void doYaf();
+};
+
+#endif
diff --git a/Tests/QtAutomoc/yaf_p.h b/Tests/QtAutomoc/yaf_p.h
new file mode 100644
index 0000000..f0368ad
--- /dev/null
+++ b/Tests/QtAutomoc/yaf_p.h
@@ -0,0 +1,30 @@
+/*============================================================================
+  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 YAF_P_H
+#define YAF_P_H
+
+#include <QObject>
+
+#include <stdio.h>
+
+class YafP : public QObject
+{
+  Q_OBJECT
+  public:
+    YafP() {}
+  public slots:
+    void doYafP() { printf("I am yet another file !\n"); }
+};
+
+#endif

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=74ab0f6aa409a9d3e90c91b1b1c7a6e4b865ed62
commit 74ab0f6aa409a9d3e90c91b1b1c7a6e4b865ed62
Author:     Alex Neundorf <neundorf at kde.org>
AuthorDate: Tue Nov 22 21:35:08 2011 +0100
Commit:     Alex Neundorf <neundorf at kde.org>
CommitDate: Tue Nov 22 21:35:08 2011 +0100

    automoc: move some code from the big parsing loop into separate functions
    
    Alex

diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx
index ad11668..931cc5d 100644
--- a/Source/cmQtAutomoc.cxx
+++ b/Source/cmQtAutomoc.cxx
@@ -37,6 +37,50 @@ static bool containsQ_OBJECT(const std::string& text)
 }
 
 
+static std::string findMatchingHeader(const std::string& absPath,
+                                      const std::string& mocSubDir,
+                                      const std::string& basename,
+                                const std::list<std::string>& headerExtensions)
+{
+  std::string header;
+  for(std::list<std::string>::const_iterator ext = headerExtensions.begin();
+      ext != headerExtensions.end();
+      ++ext)
+    {
+    std::string sourceFilePath = absPath + basename + (*ext);
+    if (cmsys::SystemTools::FileExists(sourceFilePath.c_str()))
+      {
+      header = sourceFilePath;
+      break;
+      }
+    if (!mocSubDir.empty())
+      {
+      sourceFilePath = mocSubDir + basename + (*ext);
+      if (cmsys::SystemTools::FileExists(sourceFilePath.c_str()))
+        {
+        header = sourceFilePath;
+        break;
+        }
+      }
+    }
+
+  return header;
+}
+
+
+static std::string extractSubDir(const std::string& absPath,
+                                 const std::string& currentMoc)
+{
+  std::string subDir;
+  if (currentMoc.find_first_of('/') != std::string::npos)
+    {
+    subDir = absPath
+                  + cmsys::SystemTools::GetFilenamePath(currentMoc) + '/';
+    }
+  return subDir;
+}
+
+
 cmQtAutomoc::cmQtAutomoc()
 :Verbose(cmsys::SystemTools::GetEnv("VERBOSE") != 0)
 ,ColorOutput(true)
@@ -569,36 +613,9 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
         // basename should be the part of the moc filename used for
         // finding the correct header, so we need to remove the moc_ part
         basename = basename.substr(4);
-
-        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)
-          {
-          std::string sourceFilePath = absPath + basename + (*ext);
-          if (cmsys::SystemTools::FileExists(sourceFilePath.c_str()))
-            {
-            headerToMoc = sourceFilePath;
-            break;
-            }
-          if (!mocSubDir.empty())
-            {
-            sourceFilePath = mocSubDir + basename + (*ext);
-            if (cmsys::SystemTools::FileExists(sourceFilePath.c_str()))
-              {
-              headerToMoc = sourceFilePath;
-              break;
-              }
-            }
-          }
+        std::string mocSubDir = extractSubDir(absPath, currentMoc);
+        std::string headerToMoc = findMatchingHeader(
+                               absPath, mocSubDir, basename, headerExtensions);
 
         if (!headerToMoc.empty())
           {

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

Summary of changes:
 Modules/AutomocInfo.cmake.in         |    1 +
 Source/cmQtAutomoc.cxx               |  326 +++++++++++++++++++++++++++-------
 Source/cmQtAutomoc.h                 |   12 +-
 Tests/QtAutomoc/CMakeLists.txt       |    2 +-
 Tests/QtAutomoc/main.cpp             |    4 +
 Tests/QtAutomoc/private_slot.cpp     |   21 +++
 Tests/QtAutomoc/private_slot.h       |   20 ++
 Tests/QtAutomoc/{xyz.cpp => yaf.cpp} |   14 +-
 Tests/QtAutomoc/{blub.h => yaf.h}    |   13 +-
 Tests/QtAutomoc/{abc_p.h => yaf_p.h} |   10 +-
 10 files changed, 336 insertions(+), 87 deletions(-)
 create mode 100644 Tests/QtAutomoc/private_slot.cpp
 create mode 100644 Tests/QtAutomoc/private_slot.h
 copy Tests/QtAutomoc/{xyz.cpp => yaf.cpp} (76%)
 copy Tests/QtAutomoc/{blub.h => yaf.h} (86%)
 copy Tests/QtAutomoc/{abc_p.h => yaf_p.h} (83%)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list