From 091b649e198bade6fba7518b6c970bfa23b7365f Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 19 Feb 2016 08:57:20 -0500 Subject: [PATCH] Revert "Automoc: Fix support of files with the same name (#12873)" This reverts commit 9beb2744d7685fca9cd5717308d4457dffdefcdc. 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 --- Source/cmQtAutoGenerators.cxx | 35 +++-------------------------- Tests/QtAutogen/Adir/CMakeLists.txt | 2 +- Tests/QtAutogen/Adir/bar/foo.cpp | 4 ---- Tests/QtAutogen/Adir/bar/foo.h | 10 --------- Tests/QtAutogen/Adir/foo.cpp | 4 ---- Tests/QtAutogen/Adir/foo.h | 8 ------- 6 files changed, 4 insertions(+), 59 deletions(-) delete mode 100644 Tests/QtAutogen/Adir/bar/foo.cpp delete mode 100644 Tests/QtAutogen/Adir/bar/foo.h delete mode 100644 Tests/QtAutogen/Adir/foo.cpp delete mode 100644 Tests/QtAutogen/Adir/foo.h diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 226ab430e..b16eccda3 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -1104,39 +1104,10 @@ void cmQtAutoGenerators::ParseHeaders(const std::set& absHeaders, std::cout << "AUTOGEN: Checking " << headerName << std::endl; } - std::string headerDirectory; - if (cmsys::SystemTools::IsSubDirectory(headerName, - this->ProjectSourceDir)) - { - headerDirectory = this->ProjectSourceDir; - } - else if (cmsys::SystemTools::IsSubDirectory(headerName, - this->ProjectBinaryDir)) - { - headerDirectory = this->ProjectBinaryDir; - } - else - { - cmsys::SystemTools::SplitPathRootComponent(headerName, - &headerDirectory); - } + const std::string basename = cmsys::SystemTools:: + GetFilenameWithoutLastExtension(headerName); - std::string baseHeaderName = - 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"; + const std::string currentMoc = "moc_" + basename + ".cpp"; std::string macroName; if (requiresMocing(contents, macroName)) { diff --git a/Tests/QtAutogen/Adir/CMakeLists.txt b/Tests/QtAutogen/Adir/CMakeLists.txt index 0c7848dbb..a1c36ffce 100644 --- a/Tests/QtAutogen/Adir/CMakeLists.txt +++ b/Tests/QtAutogen/Adir/CMakeLists.txt @@ -3,6 +3,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC 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}) generate_export_header(libA) diff --git a/Tests/QtAutogen/Adir/bar/foo.cpp b/Tests/QtAutogen/Adir/bar/foo.cpp deleted file mode 100644 index 3f5e0a989..000000000 --- a/Tests/QtAutogen/Adir/bar/foo.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include "foo.h" - -bar::foo::foo() {} -bar::foo::~foo() {} diff --git a/Tests/QtAutogen/Adir/bar/foo.h b/Tests/QtAutogen/Adir/bar/foo.h deleted file mode 100644 index daf23679a..000000000 --- a/Tests/QtAutogen/Adir/bar/foo.h +++ /dev/null @@ -1,10 +0,0 @@ -#include - -namespace bar { - class foo: public QObject { - Q_OBJECT - public: - foo(); - ~foo(); - }; -} diff --git a/Tests/QtAutogen/Adir/foo.cpp b/Tests/QtAutogen/Adir/foo.cpp deleted file mode 100644 index 86e4d8eec..000000000 --- a/Tests/QtAutogen/Adir/foo.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include "foo.h" - -foo::foo() {} -foo::~foo() {} diff --git a/Tests/QtAutogen/Adir/foo.h b/Tests/QtAutogen/Adir/foo.h deleted file mode 100644 index a51960c28..000000000 --- a/Tests/QtAutogen/Adir/foo.h +++ /dev/null @@ -1,8 +0,0 @@ -#include - -class foo: public QObject { - Q_OBJECT -public: - foo(); - ~foo(); -};