Revert "Automoc: Fix support of files with the same name (#12873)"

This reverts commit 9beb2744d7.
Our AUTOMOC documentation states that it should be possible to
`#include "moc_foo.cpp"` in `foo.cpp`, and this will not work if
the file is placed in a different directory.  Another solution
will need to be found to the original problem.

Reported-by: Stephen Kelly <steveire@gmail.com>
This commit is contained in:
Brad King 2016-02-19 08:57:20 -05:00
parent 9beb2744d7
commit 091b649e19
6 changed files with 4 additions and 59 deletions

View File

@ -1104,39 +1104,10 @@ void cmQtAutoGenerators::ParseHeaders(const std::set<std::string>& absHeaders,
std::cout << "AUTOGEN: Checking " << headerName << std::endl; std::cout << "AUTOGEN: Checking " << headerName << std::endl;
} }
std::string headerDirectory; const std::string basename = cmsys::SystemTools::
if (cmsys::SystemTools::IsSubDirectory(headerName, GetFilenameWithoutLastExtension(headerName);
this->ProjectSourceDir))
{
headerDirectory = this->ProjectSourceDir;
}
else if (cmsys::SystemTools::IsSubDirectory(headerName,
this->ProjectBinaryDir))
{
headerDirectory = this->ProjectBinaryDir;
}
else
{
cmsys::SystemTools::SplitPathRootComponent(headerName,
&headerDirectory);
}
std::string baseHeaderName = const std::string currentMoc = "moc_" + basename + ".cpp";
cmsys::SystemTools::GetFilenameWithoutLastExtension(headerName);
headerDirectory = cmsys::SystemTools::RelativePath(
headerDirectory, cmsys::SystemTools::GetParentDirectory(headerName));
if (!headerDirectory.empty())
{
headerDirectory += "/";
}
std::string mocName = headerDirectory + baseHeaderName;
cmSystemTools::ReplaceString(mocName, "/", "_");
const std::string currentMoc = "moc_" + mocName + ".cpp";
std::string macroName; std::string macroName;
if (requiresMocing(contents, macroName)) if (requiresMocing(contents, macroName))
{ {

View File

@ -3,6 +3,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)
add_library(libA SHARED libA.cpp foo.cpp bar/foo.cpp) add_library(libA SHARED libA.cpp)
target_link_libraries(libA LINK_PUBLIC ${QT_QTCORE_TARGET}) target_link_libraries(libA LINK_PUBLIC ${QT_QTCORE_TARGET})
generate_export_header(libA) generate_export_header(libA)

View File

@ -1,4 +0,0 @@
#include "foo.h"
bar::foo::foo() {}
bar::foo::~foo() {}

View File

@ -1,10 +0,0 @@
#include <QObject>
namespace bar {
class foo: public QObject {
Q_OBJECT
public:
foo();
~foo();
};
}

View File

@ -1,4 +0,0 @@
#include "foo.h"
foo::foo() {}
foo::~foo() {}

View File

@ -1,8 +0,0 @@
#include <QObject>
class foo: public QObject {
Q_OBJECT
public:
foo();
~foo();
};