summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmQtAutomoc.cxx39
-rw-r--r--Tests/QtAutomoc/CMakeLists.txt2
-rw-r--r--Tests/QtAutomoc/main.cpp4
-rw-r--r--Tests/QtAutomoc/yaf.cpp32
-rw-r--r--Tests/QtAutomoc/yaf.h25
-rw-r--r--Tests/QtAutomoc/yaf_p.h30
6 files changed, 124 insertions, 8 deletions
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@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@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@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