mirror of
https://github.com/reactos/CMake.git
synced 2024-11-28 22:10:32 +00:00
automoc: add special handling for including basename_p.moc, with test
Alex
This commit is contained in:
parent
74ab0f6aa4
commit
bde4edb6ab
@ -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;
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
32
Tests/QtAutomoc/yaf.cpp
Normal file
32
Tests/QtAutomoc/yaf.cpp
Normal file
@ -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"
|
25
Tests/QtAutomoc/yaf.h
Normal file
25
Tests/QtAutomoc/yaf.h
Normal file
@ -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
|
30
Tests/QtAutomoc/yaf_p.h
Normal file
30
Tests/QtAutomoc/yaf_p.h
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user