summaryrefslogtreecommitdiffstats
path: root/Source/cmQtAutomoc.cxx
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-08-07 14:48:09 (GMT)
committerStephen Kelly <steveire@gmail.com>2013-08-28 08:18:11 (GMT)
commitd4937da71b4ca7e3d73b79c3b28c10ec84690ac4 (patch)
tree7918d53d0b5c256dd8d28c61df7517f6a563f0ab /Source/cmQtAutomoc.cxx
parentb15ad0d1de7524be3b32d6691b68d3578ee00ca5 (diff)
downloadCMake-d4937da71b4ca7e3d73b79c3b28c10ec84690ac4.zip
CMake-d4937da71b4ca7e3d73b79c3b28c10ec84690ac4.tar.gz
CMake-d4937da71b4ca7e3d73b79c3b28c10ec84690ac4.tar.bz2
Search for the Q_GADGET macro for running automoc too.
Diffstat (limited to 'Source/cmQtAutomoc.cxx')
-rw-r--r--Source/cmQtAutomoc.cxx46
1 files changed, 32 insertions, 14 deletions
diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx
index 93e39ab..54df12c 100644
--- a/Source/cmQtAutomoc.cxx
+++ b/Source/cmQtAutomoc.cxx
@@ -32,16 +32,28 @@
#include "cmQtAutomoc.h"
-static bool containsQ_OBJECT(const std::string& text)
+static bool requiresMocing(const std::string& text, std::string &macroName)
{
// this simple check is much much faster than the regexp
- if (strstr(text.c_str(), "Q_OBJECT") == NULL)
+ if (strstr(text.c_str(), "Q_OBJECT") == NULL
+ && strstr(text.c_str(), "Q_GADGET") == NULL)
{
return false;
}
cmsys::RegularExpression qObjectRegExp("[\n][ \t]*Q_OBJECT[^a-zA-Z0-9_]");
- return qObjectRegExp.find(text);
+ if (qObjectRegExp.find(text))
+ {
+ macroName = "Q_OBJECT";
+ return true;
+ }
+ cmsys::RegularExpression qGadgetRegExp("[\n][ \t]*Q_GADGET[^a-zA-Z0-9_]");
+ if (qGadgetRegExp.find(text))
+ {
+ macroName = "Q_GADGET";
+ return true;
+ }
+ return false;
}
@@ -837,7 +849,8 @@ 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);
+ std::string macroName;
+ const bool requiresMoc = requiresMocing(contentsString, macroName);
bool dotMocIncluded = false;
bool mocUnderscoreIncluded = false;
std::string ownMocUnderscoreFile;
@@ -908,7 +921,7 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
else
{
std::string fileToMoc = absFilename;
- if ((basename != scannedFileBasename) || (cppContainsQ_OBJECT==false))
+ if ((basename != scannedFileBasename) || (requiresMoc==false))
{
std::string mocSubDir = extractSubDir(absPath, currentMoc);
std::string headerToMoc = findMatchingHeader(
@@ -917,12 +930,12 @@ void cmQtAutomoc::ParseCppFile(const std::string& absFilename,
{
// this is for KDE4 compatibility:
fileToMoc = headerToMoc;
- if ((cppContainsQ_OBJECT==false) &&(basename==scannedFileBasename))
+ if ((requiresMoc==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 "
+ "\", but does not contain a " << macroName
+ << " macro. Running moc on "
<< "\"" << headerToMoc << "\" ! Include \"moc_"
<< basename << ".cpp\" for a compatiblity with "
"strict mode (see CMAKE_AUTOMOC_RELAXED_MODE).\n"
@@ -965,13 +978,14 @@ 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) && (cppContainsQ_OBJECT == true))
+ if ((dotMocIncluded == false) && (requiresMoc == true))
{
if (mocUnderscoreIncluded == true)
{
// this is for KDE4 compatibility:
std::cerr << "AUTOMOC: warning: " << absFilename << ": The file "
- << "contains a Q_OBJECT macro, but does not include "
+ << "contains a " << macroName << " macro, but does not "
+ "include "
<< "\"" << scannedFileBasename << ".moc\", but instead "
"includes "
<< "\"" << ownMocUnderscoreFile << "\". Running moc on "
@@ -986,7 +1000,8 @@ 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 "
+ << "contains a " << macroName << " macro, but does not "
+ "include "
<< "\"" << scannedFileBasename << ".moc\" !\n"
<< std::endl;
::exit(EXIT_FAILURE);
@@ -1094,11 +1109,13 @@ void cmQtAutomoc::StrictParseCppFile(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)))
+ std::string macroName;
+ if ((dotMocIncluded == false) && (requiresMocing(contentsString,
+ macroName)))
{
// 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 "
+ << "contains a " << macroName << " macro, but does not include "
<< "\"" << scannedFileBasename << ".moc\" !\n"
<< std::endl;
::exit(EXIT_FAILURE);
@@ -1165,7 +1182,8 @@ void cmQtAutomoc::ParseHeaders(const std::set<std::string>& absHeaders,
const std::string currentMoc = "moc_" + basename + ".cpp";
const std::string contents = this->ReadAll(headerName);
- if (containsQ_OBJECT(contents))
+ std::string macroName;
+ if (requiresMocing(contents, macroName))
{
//std::cout << "header contains Q_OBJECT macro";
notIncludedMocs[headerName] = currentMoc;