summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/prop_tgt/AUTOMOC.rst45
-rw-r--r--Help/release/dev/automoc-diagnostics.rst6
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx107
-rw-r--r--Source/cmGlobalXCodeGenerator.h2
-rw-r--r--Source/cmMakefile.cxx21
-rw-r--r--Source/cmQtAutoGeneratorInitializer.cxx130
-rw-r--r--Source/cmQtAutoGenerators.cxx183
-rw-r--r--Source/cmQtAutoGenerators.h10
-rw-r--r--Tests/QtAutogen/CMakeLists.txt4
-rw-r--r--Tests/QtAutogen/same_name/CMakeLists.txt20
-rw-r--r--Tests/QtAutogen/same_name/aaa/bbb/data.qrc6
-rw-r--r--Tests/QtAutogen/same_name/aaa/bbb/item.cpp12
-rw-r--r--Tests/QtAutogen/same_name/aaa/bbb/item.hpp19
-rw-r--r--Tests/QtAutogen/same_name/aaa/data.qrc6
-rw-r--r--Tests/QtAutogen/same_name/aaa/item.cpp10
-rw-r--r--Tests/QtAutogen/same_name/aaa/item.hpp17
-rw-r--r--Tests/QtAutogen/same_name/bbb/aaa/data.qrc6
-rw-r--r--Tests/QtAutogen/same_name/bbb/aaa/item.cpp12
-rw-r--r--Tests/QtAutogen/same_name/bbb/aaa/item.hpp19
-rw-r--r--Tests/QtAutogen/same_name/bbb/data.qrc6
-rw-r--r--Tests/QtAutogen/same_name/bbb/item.cpp10
-rw-r--r--Tests/QtAutogen/same_name/bbb/item.hpp17
-rw-r--r--Tests/QtAutogen/same_name/ccc/data.qrc6
-rw-r--r--Tests/QtAutogen/same_name/ccc/item.cpp26
-rw-r--r--Tests/QtAutogen/same_name/ccc/item.hpp17
-rw-r--r--Tests/QtAutogen/same_name/data.qrc5
-rw-r--r--Tests/QtAutogen/same_name/main.cpp16
28 files changed, 611 insertions, 129 deletions
diff --git a/Help/prop_tgt/AUTOMOC.rst b/Help/prop_tgt/AUTOMOC.rst
index 045ebb2..8143ba9 100644
--- a/Help/prop_tgt/AUTOMOC.rst
+++ b/Help/prop_tgt/AUTOMOC.rst
@@ -6,22 +6,35 @@ Should the target be processed with automoc (for Qt projects).
AUTOMOC is a boolean specifying whether CMake will handle the Qt ``moc``
preprocessor automatically, i.e. without having to use the
:module:`QT4_WRAP_CPP() <FindQt4>` or QT5_WRAP_CPP() macro. Currently Qt4 and Qt5 are
-supported. When this property is set ``ON``, CMake will scan the
-source files at build time and invoke moc accordingly. If an ``#include``
-statement like ``#include "moc_foo.cpp"`` is found, the ``Q_OBJECT`` class
-declaration is expected in the header, and ``moc`` is run on the header
-file. If an ``#include`` statement like ``#include "foo.moc"`` is found, then
-a ``Q_OBJECT`` is expected in the current source file and ``moc`` is run on
-the file itself. Additionally, header files with the same base name (like
-``foo.h``) or ``_p`` appended to the base name (like ``foo_p.h``) are parsed
-for ``Q_OBJECT`` macros, and if found, ``moc`` is also executed on those files.
-``AUTOMOC`` checks multiple header alternative extensions, such as
-``hpp``, ``hxx`` etc when searching for headers.
-The resulting moc files, which are not included as shown above in any
-of the source files are included in a generated
-``<targetname>_automoc.cpp`` file, which is compiled as part of the
-target. This property is initialized by the value of the
-:variable:`CMAKE_AUTOMOC` variable if it is set when a target is created.
+supported.
+
+When this property is set ``ON``, CMake will scan the
+source files at build time and invoke moc accordingly.
+
+* If an ``#include`` statement like ``#include "moc_foo.cpp"`` is found,
+ the ``Q_OBJECT`` class declaration is expected in the header, and
+ ``moc`` is run on the header file. A ``moc_foo.cpp`` file will be
+ generated from the source's header into the
+ :variable:`CMAKE_CURRENT_BINARY_DIR` directory. This allows the
+ compiler to find the included ``moc_foo.cpp`` file regardless of the
+ location the original source. However, if multiple source files
+ in different directories do this then their generated moc files would
+ collide. In this case a diagnostic will be issued.
+
+* If an ``#include`` statement like ``#include "foo.moc"`` is found,
+ then a ``Q_OBJECT`` is expected in the current source file and ``moc``
+ is run on the file itself. Additionally, header files with the same
+ base name (like ``foo.h``) or ``_p`` appended to the base name (like
+ ``foo_p.h``) are parsed for ``Q_OBJECT`` macros, and if found, ``moc``
+ is also executed on those files. ``AUTOMOC`` checks multiple header
+ alternative extensions, such as ``hpp``, ``hxx`` etc when searching
+ for headers. The resulting moc files, which are not included as shown
+ above in any of the source files are included in a generated
+ ``<targetname>_automoc.cpp`` file, which is compiled as part of the
+ target.
+
+This property is initialized by the value of the :variable:`CMAKE_AUTOMOC`
+variable if it is set when a target is created.
Additional command line options for moc can be set via the
:prop_tgt:`AUTOMOC_MOC_OPTIONS` property.
diff --git a/Help/release/dev/automoc-diagnostics.rst b/Help/release/dev/automoc-diagnostics.rst
new file mode 100644
index 0000000..d89f2e1
--- /dev/null
+++ b/Help/release/dev/automoc-diagnostics.rst
@@ -0,0 +1,6 @@
+automoc-diagnostics
+-------------------
+
+* :prop_tgt:`AUTOMOC` now diagnoses name collisions when multiple source
+ files in different directories use ``#include <moc_foo.cpp>`` with the
+ same name (because the generated ``moc_foo.cpp`` files would collide).
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index c23d20d..d066f87 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,5 +1,5 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 5)
-set(CMake_VERSION_PATCH 20160420)
+set(CMake_VERSION_PATCH 20160422)
#set(CMake_VERSION_RC 1)
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 7c85281..755c8a6 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -84,7 +84,7 @@ public:
bool IsEmpty() const { return this->Empty; }
- void Add(const char *newString)
+ void Add(const std::string& newString)
{
this->Empty = false;
@@ -109,7 +109,7 @@ public:
}
else
{
- return this->Generator->CreateString(this->String.c_str());
+ return this->Generator->CreateString(this->String);
}
}
};
@@ -804,7 +804,7 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg,
cmXCodeObject* settings =
this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
- settings->AddAttribute("COMPILER_FLAGS", this->CreateString(flags.c_str()));
+ settings->AddAttribute("COMPILER_FLAGS", this->CreateString(flags));
// Is this a resource file in this target? Add it to the resources group...
//
@@ -1011,8 +1011,8 @@ cmGlobalXCodeGenerator::CreateXCodeFileReferenceFromPath(
std::string name = cmSystemTools::GetFilenameName(path.c_str());
const char* sourceTree = (cmSystemTools::FileIsFullPath(path.c_str())?
"<absolute>" : "SOURCE_ROOT");
- fileRef->AddAttribute("name", this->CreateString(name.c_str()));
- fileRef->AddAttribute("path", this->CreateString(path.c_str()));
+ fileRef->AddAttribute("name", this->CreateString(name));
+ fileRef->AddAttribute("path", this->CreateString(path));
fileRef->AddAttribute("sourceTree", this->CreateString(sourceTree));
if(this->XcodeVersion == 15)
{
@@ -1326,7 +1326,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
ostr << "../" << mit->first.c_str();
}
copyFilesBuildPhase->AddAttribute("dstPath",
- this->CreateString(ostr.str().c_str()));
+ this->CreateString(ostr.str()));
copyFilesBuildPhase->AddAttribute(
"runOnlyForDeploymentPostprocessing", this->CreateString("0"));
buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST);
@@ -1752,7 +1752,7 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase,
(makefile+"$CONFIGURATION").c_str());
makecmd += " all";
buildphase->AddAttribute("shellScript",
- this->CreateString(makecmd.c_str()));
+ this->CreateString(makecmd));
buildphase->AddAttribute("showEnvVarsInLog",
this->CreateString("0"));
}
@@ -2021,7 +2021,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
if(archs.size() == 1)
{
buildSettings->AddAttribute("ARCHS",
- this->CreateString(archs[0].c_str()));
+ this->CreateString(archs[0]));
}
else
{
@@ -2030,7 +2030,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
for(std::vector<std::string>::iterator i = archs.begin();
i != archs.end(); i++)
{
- archObjects->AddObject(this->CreateString((*i).c_str()));
+ archObjects->AddObject(this->CreateString(*i));
}
buildSettings->AddAttribute("ARCHS", archObjects);
}
@@ -2081,13 +2081,13 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
{
std::string pncdir = gtgt->GetDirectory(configName);
buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR",
- this->CreateString(pncdir.c_str()));
+ this->CreateString(pncdir));
}
}
else
{
buildSettings->AddAttribute("OBJROOT",
- this->CreateString(pndir.c_str()));
+ this->CreateString(pndir));
pndir = gtgt->GetDirectory(configName);
}
@@ -2097,9 +2097,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
}
buildSettings->AddAttribute("EXECUTABLE_PREFIX",
- this->CreateString(pnprefix.c_str()));
+ this->CreateString(pnprefix));
buildSettings->AddAttribute("EXECUTABLE_SUFFIX",
- this->CreateString(pnsuffix.c_str()));
+ this->CreateString(pnsuffix));
}
else if(gtgt->GetType() == cmState::OBJECT_LIBRARY)
{
@@ -2112,12 +2112,12 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
std::string pncdir = this->GetObjectsNormalDirectory(
this->CurrentProject, configName, gtgt);
buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR",
- this->CreateString(pncdir.c_str()));
+ this->CreateString(pncdir));
}
else
{
buildSettings->AddAttribute("OBJROOT",
- this->CreateString(pndir.c_str()));
+ this->CreateString(pndir));
pndir = this->GetObjectsNormalDirectory(
this->CurrentProject, configName, gtgt);
}
@@ -2125,9 +2125,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
// Store the product name for all target types.
buildSettings->AddAttribute("PRODUCT_NAME",
- this->CreateString(realName.c_str()));
+ this->CreateString(realName));
buildSettings->AddAttribute("SYMROOT",
- this->CreateString(pndir.c_str()));
+ this->CreateString(pndir));
// Handle settings for each target type.
switch(gtgt->GetType())
@@ -2203,7 +2203,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
{
std::string fw_version = gtgt->GetFrameworkVersion();
buildSettings->AddAttribute("FRAMEWORK_VERSION",
- this->CreateString(fw_version.c_str()));
+ this->CreateString(fw_version));
std::string plist = this->ComputeInfoPListLocation(gtgt);
// Xcode will create the final version of Info.plist at build time,
@@ -2282,17 +2282,17 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
{
std::string frameworkDir = *i;
frameworkDir += "/../";
- frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str());
+ frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir);
if(emitted.insert(frameworkDir).second)
{
- fdirs.Add(this->XCodeEscapePath(frameworkDir.c_str()).c_str());
+ fdirs.Add(this->XCodeEscapePath(frameworkDir));
}
}
else
{
std::string incpath =
- this->XCodeEscapePath(i->c_str());
- dirs.Add(incpath.c_str());
+ this->XCodeEscapePath(*i);
+ dirs.Add(incpath);
}
}
// Add framework search paths needed for linking.
@@ -2304,7 +2304,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
{
if(emitted.insert(*fdi).second)
{
- fdirs.Add(this->XCodeEscapePath(fdi->c_str()).c_str());
+ fdirs.Add(this->XCodeEscapePath(*fdi));
}
}
}
@@ -2390,17 +2390,17 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
if (*li == "CXX")
{
buildSettings->AddAttribute("OTHER_CPLUSPLUSFLAGS",
- this->CreateString(flags.c_str()));
+ this->CreateString(flags));
}
else if (*li == "Fortran")
{
buildSettings->AddAttribute("IFORT_OTHER_FLAGS",
- this->CreateString(flags.c_str()));
+ this->CreateString(flags));
}
else if (*li == "C")
{
buildSettings->AddAttribute("OTHER_CFLAGS",
- this->CreateString(flags.c_str()));
+ this->CreateString(flags));
}
}
@@ -2444,11 +2444,11 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
{
install_name_dir = "";
extraLinkOptions += " -install_name ";
- extraLinkOptions += XCodeEscapePath(install_name.c_str());
+ extraLinkOptions += XCodeEscapePath(install_name);
}
}
buildSettings->AddAttribute("INSTALL_PATH",
- this->CreateString(install_name_dir.c_str()));
+ this->CreateString(install_name_dir));
// Create the LD_RUNPATH_SEARCH_PATHS
cmComputeLinkInformation* pcli = gtgt->GetLinkInformation(configName);
@@ -2473,18 +2473,18 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
{
search_paths += " ";
}
- search_paths += this->XCodeEscapePath(runpath.c_str());
+ search_paths += this->XCodeEscapePath(runpath);
}
}
if(!search_paths.empty())
{
buildSettings->AddAttribute("LD_RUNPATH_SEARCH_PATHS",
- this->CreateString(search_paths.c_str()));
+ this->CreateString(search_paths));
}
}
buildSettings->AddAttribute(this->GetTargetLinkFlagsVar(gtgt),
- this->CreateString(extraLinkOptions.c_str()));
+ this->CreateString(extraLinkOptions));
buildSettings->AddAttribute("OTHER_REZFLAGS",
this->CreateString(""));
buildSettings->AddAttribute("SECTORDER_FLAGS",
@@ -2525,7 +2525,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
v << major << "." << minor << "." << patch;
}
buildSettings->AddAttribute("DYLIB_CURRENT_VERSION",
- this->CreateString(v.str().c_str()));
+ this->CreateString(v.str()));
// SOVERSION -> compatibility_version
gtgt->GetTargetVersion(true, major, minor, patch);
@@ -2537,7 +2537,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
vso << major << "." << minor << "." << patch;
}
buildSettings->AddAttribute("DYLIB_COMPATIBILITY_VERSION",
- this->CreateString(vso.str().c_str()));
+ this->CreateString(vso.str()));
}
// put this last so it can override existing settings
// Convert "XCODE_ATTRIBUTE_*" properties directly.
@@ -2674,14 +2674,14 @@ std::string cmGlobalXCodeGenerator::AddConfigurations(cmXCodeObject* target,
this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
this->CreateBuildSettings(gtgt, buildSettings,
configVector[i].c_str());
- config->AddAttribute("name", this->CreateString(configVector[i].c_str()));
+ config->AddAttribute("name", this->CreateString(configVector[i]));
config->SetComment(configVector[i].c_str());
config->AddAttribute("buildSettings", buildSettings);
}
if(!configVector.empty())
{
configlist->AddAttribute("defaultConfigurationName",
- this->CreateString(configVector[0].c_str()));
+ this->CreateString(configVector[0]));
configlist->AddAttribute("defaultConfigurationIsVisible",
this->CreateString("0"));
return configVector[0];
@@ -2813,7 +2813,7 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmGeneratorTarget* gtgt,
{
fullName = gtgt->GetFullName(defConfig.c_str());
}
- fileRef->AddAttribute("path", this->CreateString(fullName.c_str()));
+ fileRef->AddAttribute("path", this->CreateString(fullName));
if(this->XcodeVersion == 15)
{
fileRef->AddAttribute("refType", this->CreateString("0"));
@@ -3021,7 +3021,7 @@ void cmGlobalXCodeGenerator
{
linkObjs += sep;
sep = " ";
- linkObjs += this->XCodeEscapePath(oi->c_str());
+ linkObjs += this->XCodeEscapePath(*oi);
}
this->AppendBuildSettingAttribute(
target, this->GetTargetLinkFlagsVar(gt),
@@ -3068,10 +3068,10 @@ void cmGlobalXCodeGenerator
// $(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) to it:
linkDirs += " ";
linkDirs += this->XCodeEscapePath(
- (*libDir + "/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)").c_str());
+ *libDir + "/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)");
}
linkDirs += " ";
- linkDirs += this->XCodeEscapePath(libDir->c_str());
+ linkDirs += this->XCodeEscapePath(*libDir);
}
}
this->AppendBuildSettingAttribute(target, "LIBRARY_SEARCH_PATHS",
@@ -3091,7 +3091,7 @@ void cmGlobalXCodeGenerator
sep = " ";
if(li->IsPath)
{
- linkLibs += this->XCodeEscapePath(li->Value.c_str());
+ linkLibs += this->XCodeEscapePath(li->Value);
}
else if (!li->Target
|| li->Target->GetType() != cmState::INTERFACE_LIBRARY)
@@ -3200,7 +3200,7 @@ cmXCodeObject *cmGlobalXCodeGenerator
cmXCodeObject* group = this->CreateObject(cmXCodeObject::PBXGroup);
cmXCodeObject* groupChildren =
this->CreateObject(cmXCodeObject::OBJECT_LIST);
- group->AddAttribute("name", this->CreateString(name.c_str()));
+ group->AddAttribute("name", this->CreateString(name));
group->AddAttribute("children", groupChildren);
if(this->XcodeVersion == 15)
{
@@ -3447,7 +3447,7 @@ bool cmGlobalXCodeGenerator
std::string pdir =
this->RelativeToBinary(root->GetCurrentSourceDirectory());
this->RootObject->AddAttribute("projectDirPath",
- this->CreateString(pdir.c_str()));
+ this->CreateString(pdir));
this->RootObject->AddAttribute("projectRoot", this->CreateString(""));
}
cmXCodeObject* configlist =
@@ -3528,7 +3528,7 @@ bool cmGlobalXCodeGenerator
else
{
// Tell Xcode to use ARCHS (ONLY_ACTIVE_ARCH defaults to NO).
- buildSettings->AddAttribute("ARCHS", this->CreateString(archs.c_str()));
+ buildSettings->AddAttribute("ARCHS", this->CreateString(archs));
}
if(deploymentTarget && *deploymentTarget)
{
@@ -3538,12 +3538,12 @@ bool cmGlobalXCodeGenerator
if(!this->GeneratorToolset.empty())
{
buildSettings->AddAttribute("GCC_VERSION",
- this->CreateString(this->GeneratorToolset.c_str()));
+ this->CreateString(this->GeneratorToolset));
}
std::string symroot = root->GetCurrentBinaryDirectory();
symroot += "/build";
- buildSettings->AddAttribute("SYMROOT", this->CreateString(symroot.c_str()));
+ buildSettings->AddAttribute("SYMROOT", this->CreateString(symroot));
for(Configs::iterator i = configs.begin(); i != configs.end(); ++i)
{
@@ -3932,17 +3932,16 @@ std::string cmGlobalXCodeGenerator::RelativeToBinary(const char* p)
}
//----------------------------------------------------------------------------
-std::string cmGlobalXCodeGenerator::XCodeEscapePath(const char* p)
+std::string cmGlobalXCodeGenerator::XCodeEscapePath(const std::string& p)
{
- std::string ret = p;
- if(ret.find(' ') != ret.npos)
+ if(p.find(' ') != p.npos)
{
- std::string t = ret;
- ret = "\"";
- ret += t;
- ret += "\"";
+ std::string t = "\"";
+ t += p;
+ t += "\"";
+ return t;
}
- return ret;
+ return p;
}
//----------------------------------------------------------------------------
@@ -4025,7 +4024,7 @@ cmGlobalXCodeGenerator::AppendDefines(BuildObjectListOrString& defs,
// Append the flag with needed escapes.
std::string tmp;
this->AppendFlag(tmp, def);
- defs.Add(tmp.c_str());
+ defs.Add(tmp);
}
}
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index 862746f..f7bfb26 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -96,7 +96,7 @@ private:
bool CreateGroups(cmLocalGenerator* root,
std::vector<cmLocalGenerator*>&
generators);
- std::string XCodeEscapePath(const char* p);
+ std::string XCodeEscapePath(const std::string& p);
std::string RelativeToSource(const char* p);
std::string RelativeToBinary(const char* p);
std::string ConvertToRelativeForMake(const char* p);
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 3a56c2a..f01ff74 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1824,10 +1824,11 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value,
cmState::CacheEntryType type,
bool force)
{
- bool haveVal = value ? true : false;
- std::string val = haveVal ? value : "";
const char* existingValue =
this->GetState()->GetInitializedCacheValue(name);
+ // must be outside the following if() to keep it alive long enough
+ std::string nvalue;
+
if(existingValue
&& (this->GetState()->GetCacheEntryType(name)
== cmState::UNINITIALIZED))
@@ -1836,15 +1837,16 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value,
// if it is a force, then use the value being passed in
if(!force)
{
- val = existingValue;
- haveVal = true;
+ value = existingValue;
}
if ( type == cmState::PATH || type == cmState::FILEPATH )
{
std::vector<std::string>::size_type cc;
std::vector<std::string> files;
- std::string nvalue = "";
- cmSystemTools::ExpandListArgument(val, files);
+ nvalue = value ? value : "";
+
+ cmSystemTools::ExpandListArgument(nvalue, files);
+ nvalue = "";
for ( cc = 0; cc < files.size(); cc ++ )
{
if(!cmSystemTools::IsOff(files[cc].c_str()))
@@ -1859,13 +1861,12 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value,
}
this->GetCMakeInstance()->AddCacheEntry(name, nvalue.c_str(), doc, type);
- val = this->GetState()->GetInitializedCacheValue(name);
- haveVal = true;
+ nvalue = this->GetState()->GetInitializedCacheValue(name);
+ value = nvalue.c_str();
}
}
- this->GetCMakeInstance()->AddCacheEntry(name, haveVal ? val.c_str() : 0,
- doc, type);
+ this->GetCMakeInstance()->AddCacheEntry(name, value, doc, type);
// if there was a definition then remove it
this->StateSnapshot.RemoveDefinition(name);
}
diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx
index 4cab81f..ea9ea7c 100644
--- a/Source/cmQtAutoGeneratorInitializer.cxx
+++ b/Source/cmQtAutoGeneratorInitializer.cxx
@@ -25,6 +25,87 @@
# include "cmGlobalVisualStudioGenerator.h"
#endif
+static std::string GetAutogenTargetName(
+ cmGeneratorTarget const* target)
+{
+ std::string autogenTargetName = target->GetName();
+ autogenTargetName += "_automoc";
+ return autogenTargetName;
+}
+
+static std::string GetAutogenTargetDir(
+ cmGeneratorTarget const* target)
+{
+ cmMakefile* makefile = target->Target->GetMakefile();
+ std::string targetDir = makefile->GetCurrentBinaryDirectory();
+ targetDir += makefile->GetCMakeInstance()->GetCMakeFilesDirectory();
+ targetDir += "/";
+ targetDir += GetAutogenTargetName(target);
+ targetDir += ".dir/";
+ return targetDir;
+}
+
+static std::string GetAutogenTargetBuildDir(
+ cmGeneratorTarget const* target)
+{
+ cmMakefile* makefile = target->Target->GetMakefile();
+ std::string targetDir = makefile->GetCurrentBinaryDirectory();
+ targetDir += "/";
+ targetDir += GetAutogenTargetName(target);
+ targetDir += ".dir/";
+ return targetDir;
+}
+
+static std::string GetSourceRelativePath(
+ cmGeneratorTarget const* target,
+ const std::string& fileName)
+{
+ std::string pathRel;
+ // Test if the file is child to any of the known directories
+ {
+ const std::string fileNameReal = cmsys::SystemTools::GetRealPath(fileName);
+ std::string parentDirectory;
+ bool match ( false );
+ {
+ std::string testDirs[4];
+ {
+ cmMakefile* makefile = target->Target->GetMakefile();
+ testDirs[0] = makefile->GetCurrentSourceDirectory();
+ testDirs[1] = makefile->GetCurrentBinaryDirectory();
+ testDirs[2] = makefile->GetHomeDirectory();
+ testDirs[3] = makefile->GetHomeOutputDirectory();
+ }
+ for(int ii=0; ii != sizeof(testDirs)/sizeof(std::string); ++ii )
+ {
+ const ::std::string testDir = cmsys::SystemTools::GetRealPath(
+ testDirs[ii]);
+ if (!testDir.empty()
+ && cmsys::SystemTools::IsSubDirectory(fileNameReal, testDir) )
+ {
+ parentDirectory = testDir;
+ match = true;
+ break;
+ }
+ }
+ }
+ // Use root as fallback parent directory
+ if (!match)
+ {
+ cmsys::SystemTools::SplitPathRootComponent(fileNameReal,
+ &parentDirectory);
+ }
+ pathRel = cmsys::SystemTools::RelativePath(
+ parentDirectory, cmsys::SystemTools::GetParentDirectory(fileNameReal));
+ }
+ // Sanitize relative path
+ if (!pathRel.empty())
+ {
+ pathRel += '/';
+ cmSystemTools::ReplaceString(pathRel, "..", "__");
+ }
+ return pathRel;
+}
+
static void SetupSourceFiles(cmGeneratorTarget const* target,
std::vector<std::string>& skipMoc,
std::vector<std::string>& mocSources,
@@ -61,13 +142,16 @@ static void SetupSourceFiles(cmGeneratorTarget const* target,
if (ext == "qrc"
&& !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC")))
{
+
+ std::string rcc_output_dir = GetAutogenTargetBuildDir(target);
+ rcc_output_dir += GetSourceRelativePath(target,absFile);
+ cmSystemTools::MakeDirectory(rcc_output_dir.c_str());
+
std::string basename = cmsys::SystemTools::
GetFilenameWithoutLastExtension(absFile);
- std::string rcc_output_dir = target->GetSupportDirectory();
- cmSystemTools::MakeDirectory(rcc_output_dir.c_str());
std::string rcc_output_file = rcc_output_dir;
- rcc_output_file += "/qrc_" + basename + ".cpp";
+ rcc_output_file += "qrc_" + basename + ".cpp";
makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES",
rcc_output_file.c_str(), false);
makefile->GetOrCreateSource(rcc_output_file, true);
@@ -433,26 +517,6 @@ static void MergeRccOptions(std::vector<std::string> &opts,
opts.insert(opts.end(), extraOpts.begin(), extraOpts.end());
}
-std::string GetAutogenTargetName(
- cmGeneratorTarget const* target)
-{
- std::string autogenTargetName = target->GetName();
- autogenTargetName += "_automoc";
- return autogenTargetName;
-}
-
-std::string GetAutogenTargetDir(
- cmGeneratorTarget const* target)
-{
- cmMakefile* makefile = target->Target->GetMakefile();
- std::string targetDir = makefile->GetCurrentBinaryDirectory();
- targetDir += makefile->GetCMakeInstance()->GetCMakeFilesDirectory();
- targetDir += "/";
- targetDir += GetAutogenTargetName(target);
- targetDir += ".dir/";
- return targetDir;
-}
-
static void copyTargetProperty(cmTarget* destinationTarget,
cmTarget* sourceTarget,
const std::string& propertyName)
@@ -858,14 +922,18 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
if (ext == "qrc"
&& !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC")))
{
- std::string basename = cmsys::SystemTools::
- GetFilenameWithoutLastExtension(absFile);
-
- std::string rcc_output_dir = target->GetSupportDirectory();
- cmSystemTools::MakeDirectory(rcc_output_dir.c_str());
- std::string rcc_output_file = rcc_output_dir;
- rcc_output_file += "/qrc_" + basename + ".cpp";
- rcc_output.push_back(rcc_output_file);
+
+ {
+ std::string rcc_output_dir = GetAutogenTargetBuildDir(target);
+ rcc_output_dir += GetSourceRelativePath(target,absFile);
+ cmSystemTools::MakeDirectory(rcc_output_dir.c_str());
+
+ std::string basename = cmsys::SystemTools::
+ GetFilenameWithoutLastExtension(absFile);
+ std::string rcc_output_file = rcc_output_dir;
+ rcc_output_file += "qrc_" + basename + ".cpp";
+ rcc_output.push_back(rcc_output_file);
+ }
if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED")))
{
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index c07a0a6..3c6db2d 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -410,11 +410,12 @@ cmQtAutoGenerators::WriteOldMocDefinitionsFile(
void cmQtAutoGenerators::Init()
{
+ this->TargetBuildSubDir = this->TargetName;
+ this->TargetBuildSubDir += ".dir/";
+
this->OutMocCppFilenameRel = this->TargetName;
this->OutMocCppFilenameRel += ".cpp";
-
- this->OutMocCppFilename = this->Builddir;
- this->OutMocCppFilename += this->OutMocCppFilenameRel;
+ this->OutMocCppFilenameAbs = this->Builddir + this->OutMocCppFilenameRel;
std::vector<std::string> cdefList;
cmSystemTools::ExpandListArgument(this->MocCompileDefinitionsStr, cdefList);
@@ -507,7 +508,7 @@ static std::string ReadAll(const std::string& filename)
bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile)
{
- if (!cmsys::SystemTools::FileExists(this->OutMocCppFilename.c_str())
+ if (!cmsys::SystemTools::FileExists(this->OutMocCppFilenameAbs.c_str())
|| (this->OldCompileSettingsStr != this->CurrentCompileSettingsStr))
{
this->GenerateAll = true;
@@ -1047,14 +1048,15 @@ void cmQtAutoGenerators::ParseHeaders(const std::set<std::string>& absHeaders,
std::cout << "AUTOGEN: Checking " << headerName << std::endl;
}
- const std::string basename = cmsys::SystemTools::
- GetFilenameWithoutLastExtension(headerName);
-
- const std::string currentMoc = "moc_" + basename + ".cpp";
std::string macroName;
if (requiresMocing(contents, macroName))
{
//std::cout << "header contains Q_OBJECT macro";
+ const std::string parentDir = this->TargetBuildSubDir
+ + this->SourceRelativePath ( headerName );
+ const std::string basename = cmsys::SystemTools::
+ GetFilenameWithoutLastExtension(headerName);
+ const std::string currentMoc = parentDir + "moc_" + basename + ".cpp";
notIncludedMocs[headerName] = currentMoc;
}
}
@@ -1067,6 +1069,26 @@ bool cmQtAutoGenerators::GenerateMocFiles(
const std::map<std::string, std::string>& includedMocs,
const std::map<std::string, std::string>& notIncludedMocs )
{
+ // look for name collisions
+ {
+ std::multimap<std::string, std::string> collisions;
+ // Test merged map of included and notIncluded
+ std::map<std::string, std::string> mergedMocs ( includedMocs );
+ mergedMocs.insert ( notIncludedMocs.begin(), notIncludedMocs.end() );
+ if( this->NameCollisionTest ( mergedMocs, collisions ) )
+ {
+ std::cerr <<
+ "AUTOGEN: error: "
+ "The same moc file will be generated "
+ "from different sources." << std::endl <<
+ "To avoid this error either" << std::endl <<
+ "- rename the source files or" << std::endl <<
+ "- do not include the (moc_NAME.cpp|NAME.moc) file" << std::endl;
+ this->NameCollisionLog ( collisions );
+ ::exit(EXIT_FAILURE);
+ }
+ }
+
// generate moc files that are included by source files.
for(std::map<std::string, std::string>::const_iterator
it = includedMocs.begin(); it != includedMocs.end(); ++it)
@@ -1125,7 +1147,7 @@ bool cmQtAutoGenerators::GenerateMocFiles(
if (!automocCppChanged)
{
// compare contents of the _automoc.cpp file
- const std::string oldContents = ReadAll(this->OutMocCppFilename);
+ const std::string oldContents = ReadAll(this->OutMocCppFilenameAbs);
if (oldContents == automocSource)
{
// nothing changed: don't touch the _automoc.cpp file
@@ -1148,7 +1170,7 @@ bool cmQtAutoGenerators::GenerateMocFiles(
}
{
cmsys::ofstream outfile;
- outfile.open(this->OutMocCppFilename.c_str(),
+ outfile.open(this->OutMocCppFilenameAbs.c_str(),
std::ios::trunc);
outfile << automocSource;
outfile.close();
@@ -1223,6 +1245,7 @@ bool cmQtAutoGenerators::GenerateUiFiles(
{
// single map with input / output names
std::map<std::string, std::map<std::string, std::string> > uiGenMap;
+ std::map<std::string, std::string> testMap;
for(std::map<std::string, std::vector<std::string> >::const_iterator
it = includedUis.begin(); it != includedUis.end(); ++it)
{
@@ -1240,9 +1263,24 @@ bool cmQtAutoGenerators::GenerateUiFiles(
const std::string uiInputFile = sourcePath + uiFileName + ".ui";
const std::string uiOutputFile = "ui_" + uiFileName + ".h";
sourceMap[uiInputFile] = uiOutputFile;
+ testMap[uiInputFile] = uiOutputFile;
}
}
+ // look for name collisions
+ {
+ std::multimap<std::string, std::string> collisions;
+ if( this->NameCollisionTest ( testMap, collisions ) )
+ {
+ std::cerr << "AUTOGEN: error: The same ui_NAME.h file will be generated "
+ "from different sources." << std::endl
+ << "To avoid this error rename the source files." << std::endl;
+ this->NameCollisionLog ( collisions );
+ ::exit(EXIT_FAILURE);
+ }
+ }
+ testMap.clear();
+
// generate ui files
for(std::map<std::string, std::map<std::string, std::string> >::
const_iterator it = uiGenMap.begin(); it != uiGenMap.end(); ++it)
@@ -1361,12 +1399,29 @@ bool cmQtAutoGenerators::GenerateQrcFiles()
{
std::string basename = cmsys::SystemTools::
GetFilenameWithoutLastExtension(*si);
- std::string qrcOutputFile = "CMakeFiles/" + this->OriginTargetName
- + ".dir/qrc_" + basename + ".cpp";
+ std::string qrcOutputFile = this->TargetBuildSubDir
+ + this->SourceRelativePath ( *si )
+ + "qrc_" + basename + ".cpp";
+ //std::string qrcOutputFile = "CMakeFiles/" + this->OriginTargetName
+ // + ".dir/qrc_" + basename + ".cpp";
qrcGenMap[*si] = qrcOutputFile;
}
}
+ // look for name collisions
+ {
+ std::multimap<std::string, std::string> collisions;
+ if( this->NameCollisionTest ( qrcGenMap, collisions ) )
+ {
+ std::cerr << "AUTOGEN: error: The same qrc_NAME.cpp file"
+ " will be generated from different sources." << std::endl
+ << "To avoid this error rename the source .qrc files."
+ << std::endl;
+ this->NameCollisionLog ( collisions );
+ ::exit(EXIT_FAILURE);
+ }
+ }
+
// generate qrc files
for(std::map<std::string, std::string>::const_iterator
si = qrcGenMap.begin(); si != qrcGenMap.end(); ++si)
@@ -1386,8 +1441,10 @@ bool cmQtAutoGenerators::GenerateQrc (
const std::string& qrcInputFile,
const std::string& qrcOutputFile )
{
- const std::string basename = cmsys::SystemTools::
- GetFilenameWithoutLastExtension(qrcInputFile);
+ std::string relName = this->SourceRelativePath ( qrcInputFile );
+ cmSystemTools::ReplaceString(relName, "/", "_");
+ relName += cmsys::SystemTools::GetFilenameWithoutLastExtension(qrcInputFile);
+
const ::std::string qrcBuildFile = this->Builddir + qrcOutputFile;
int sourceNewerThanQrc = 0;
@@ -1417,7 +1474,7 @@ bool cmQtAutoGenerators::GenerateQrc (
}
command.push_back("-name");
- command.push_back(basename);
+ command.push_back(relName);
command.push_back("-o");
command.push_back(qrcBuildFile);
command.push_back(qrcInputFile);
@@ -1442,6 +1499,102 @@ bool cmQtAutoGenerators::GenerateQrc (
return true;
}
+std::string cmQtAutoGenerators::SourceRelativePath(const std::string& filename)
+{
+ std::string pathRel;
+
+ // Test if the file is child to any of the known directories
+ {
+ std::string fileNameReal = cmsys::SystemTools::GetRealPath( filename );
+ std::string parentDirectory;
+ bool match ( false );
+ {
+ const ::std::string* testDirs[4];
+ testDirs[0] = &(this->Srcdir);
+ testDirs[1] = &(this->Builddir);
+ testDirs[2] = &(this->ProjectSourceDir);
+ testDirs[3] = &(this->ProjectBinaryDir);
+ for(int ii=0; ii != sizeof(testDirs)/sizeof(const ::std::string*); ++ii )
+ {
+ const ::std::string testDir = cmsys::SystemTools::GetRealPath(
+ *(testDirs[ii]));
+ if (cmsys::SystemTools::IsSubDirectory(fileNameReal,
+ testDir) )
+ {
+ parentDirectory = testDir;
+ match = true;
+ break;
+ }
+ }
+ }
+ // Use root as fallback parent directory
+ if ( !match )
+ {
+ cmsys::SystemTools::SplitPathRootComponent(fileNameReal,
+ &parentDirectory);
+ }
+ pathRel = cmsys::SystemTools::RelativePath(
+ parentDirectory, cmsys::SystemTools::GetParentDirectory(fileNameReal));
+ }
+
+ // Sanitize relative path
+ if (!pathRel.empty())
+ {
+ pathRel += '/';
+ cmSystemTools::ReplaceString(pathRel, "..", "__");
+ }
+ return pathRel;
+}
+
+/**
+ * @brief Collects name collisions as output/input pairs
+ * @return True if there were collisions
+ */
+bool cmQtAutoGenerators::NameCollisionTest(
+ const std::map<std::string, std::string >& genFiles,
+ std::multimap<std::string, std::string>& collisions)
+{
+ typedef std::map<std::string, std::string>::const_iterator Iter;
+ typedef std::map<std::string, std::string>::value_type VType;
+ for(Iter ait = genFiles.begin(); ait != genFiles.end(); ++ait )
+ {
+ bool first_match ( true );
+ for (Iter bit = (++Iter(ait)); bit != genFiles.end(); ++bit)
+ {
+ if(ait->second == bit->second)
+ {
+ if (first_match)
+ {
+ if (collisions.find(ait->second) != collisions.end())
+ {
+ // We already know of this collision from before
+ break;
+ }
+ collisions.insert(VType(ait->second, ait->first));
+ first_match = false;
+ }
+ collisions.insert(VType(bit->second, bit->first));
+ }
+ }
+ }
+
+ return !collisions.empty();
+}
+
+void cmQtAutoGenerators::NameCollisionLog(
+ const std::multimap<std::string, std::string>& collisions)
+{
+ typedef std::multimap<std::string, std::string>::const_iterator Iter;
+
+ std::stringstream sbuf;
+ for(Iter it = collisions.begin(); it != collisions.end(); ++it )
+ {
+ sbuf << it->first << " : " << it->second << std::endl;
+ }
+ sbuf.flush();
+ std::cerr << sbuf.str();
+}
+
void cmQtAutoGenerators::LogCommand(const std::vector<std::string>& command)
{
std::stringstream sbuf;
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
index 68ab480..422e1ed 100644
--- a/Source/cmQtAutoGenerators.h
+++ b/Source/cmQtAutoGenerators.h
@@ -78,6 +78,13 @@ private:
void Init();
+ std::string SourceRelativePath(const std::string& filename);
+
+ bool NameCollisionTest(const std::map<std::string, std::string >& genFiles,
+ std::multimap<std::string, std::string>& collisions );
+ void NameCollisionLog(
+ const std::multimap<std::string, std::string>& collisions );
+
void LogCommand(const std::vector<std::string>& command);
std::string JoinExts(const std::vector<std::string>& lst);
@@ -109,8 +116,9 @@ private:
std::string CurrentCompileSettingsStr;
std::string OldCompileSettingsStr;
+ std::string TargetBuildSubDir;
std::string OutMocCppFilenameRel;
- std::string OutMocCppFilename;
+ std::string OutMocCppFilenameAbs;
std::list<std::string> MocIncludes;
std::list<std::string> MocDefinitions;
std::vector<std::string> MocOptions;
diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt
index d5aca55..4875165 100644
--- a/Tests/QtAutogen/CMakeLists.txt
+++ b/Tests/QtAutogen/CMakeLists.txt
@@ -110,6 +110,10 @@ set_target_properties(
AUTOMOC TRUE
)
+# Test AUTOMOC and AUTORCC on source files with the same name
+# but in different subdirectories
+add_subdirectory(same_name)
+
include(GenerateExportHeader)
# The order is relevant here. B depends on A, and B headers depend on A
# headers both subdirectories use CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE and we
diff --git a/Tests/QtAutogen/same_name/CMakeLists.txt b/Tests/QtAutogen/same_name/CMakeLists.txt
new file mode 100644
index 0000000..54bf048
--- /dev/null
+++ b/Tests/QtAutogen/same_name/CMakeLists.txt
@@ -0,0 +1,20 @@
+# Test AUTOMOC and AUTORCC on source files with the same name
+# but in different subdirectories
+
+add_executable(same_name
+ aaa/bbb/item.cpp
+ aaa/bbb/data.qrc
+ aaa/item.cpp
+ aaa/data.qrc
+ bbb/aaa/item.cpp
+ bbb/aaa/data.qrc
+ bbb/item.cpp
+ bbb/data.qrc
+ ccc/item.cpp
+ ccc/data.qrc
+ main.cpp
+ data.qrc
+)
+target_include_directories(same_name PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
+target_link_libraries(same_name ${QT_LIBRARIES})
+set_target_properties( same_name PROPERTIES AUTOMOC TRUE AUTORCC TRUE )
diff --git a/Tests/QtAutogen/same_name/aaa/bbb/data.qrc b/Tests/QtAutogen/same_name/aaa/bbb/data.qrc
new file mode 100644
index 0000000..0ea3537
--- /dev/null
+++ b/Tests/QtAutogen/same_name/aaa/bbb/data.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="aaa/bbb">
+ <file>item.hpp</file>
+ <file>item.cpp</file>
+</qresource>
+</RCC>
diff --git a/Tests/QtAutogen/same_name/aaa/bbb/item.cpp b/Tests/QtAutogen/same_name/aaa/bbb/item.cpp
new file mode 100644
index 0000000..d715116
--- /dev/null
+++ b/Tests/QtAutogen/same_name/aaa/bbb/item.cpp
@@ -0,0 +1,12 @@
+#include "item.hpp"
+
+namespace aaa {
+namespace bbb {
+
+void
+Item::go ( )
+{
+}
+
+}
+}
diff --git a/Tests/QtAutogen/same_name/aaa/bbb/item.hpp b/Tests/QtAutogen/same_name/aaa/bbb/item.hpp
new file mode 100644
index 0000000..c82309d
--- /dev/null
+++ b/Tests/QtAutogen/same_name/aaa/bbb/item.hpp
@@ -0,0 +1,19 @@
+#ifndef SDA_SDB_ITEM_HPP
+#define SDA_SDB_ITEM_HPP
+
+#include <QObject>
+
+namespace aaa {
+namespace bbb {
+
+class Item : public QObject
+{
+ Q_OBJECT
+ Q_SLOT
+ void go ( );
+};
+
+}
+}
+
+#endif
diff --git a/Tests/QtAutogen/same_name/aaa/data.qrc b/Tests/QtAutogen/same_name/aaa/data.qrc
new file mode 100644
index 0000000..379af60
--- /dev/null
+++ b/Tests/QtAutogen/same_name/aaa/data.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="aaa/">
+ <file>item.hpp</file>
+ <file>item.cpp</file>
+</qresource>
+</RCC>
diff --git a/Tests/QtAutogen/same_name/aaa/item.cpp b/Tests/QtAutogen/same_name/aaa/item.cpp
new file mode 100644
index 0000000..7887d76
--- /dev/null
+++ b/Tests/QtAutogen/same_name/aaa/item.cpp
@@ -0,0 +1,10 @@
+#include "item.hpp"
+
+namespace aaa {
+
+void
+Item::go ( )
+{
+}
+
+}
diff --git a/Tests/QtAutogen/same_name/aaa/item.hpp b/Tests/QtAutogen/same_name/aaa/item.hpp
new file mode 100644
index 0000000..3c24275
--- /dev/null
+++ b/Tests/QtAutogen/same_name/aaa/item.hpp
@@ -0,0 +1,17 @@
+#ifndef SDA_ITEM_HPP
+#define SDA_ITEM_HPP
+
+#include <QObject>
+
+namespace aaa {
+
+class Item : public QObject
+{
+ Q_OBJECT
+ Q_SLOT
+ void go ( );
+};
+
+}
+
+#endif
diff --git a/Tests/QtAutogen/same_name/bbb/aaa/data.qrc b/Tests/QtAutogen/same_name/bbb/aaa/data.qrc
new file mode 100644
index 0000000..da98009
--- /dev/null
+++ b/Tests/QtAutogen/same_name/bbb/aaa/data.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="bbb/aaa/">
+ <file>item.hpp</file>
+ <file>item.cpp</file>
+</qresource>
+</RCC>
diff --git a/Tests/QtAutogen/same_name/bbb/aaa/item.cpp b/Tests/QtAutogen/same_name/bbb/aaa/item.cpp
new file mode 100644
index 0000000..36d5b6d
--- /dev/null
+++ b/Tests/QtAutogen/same_name/bbb/aaa/item.cpp
@@ -0,0 +1,12 @@
+#include "item.hpp"
+
+namespace bbb {
+namespace aaa {
+
+void
+Item::go ( )
+{
+}
+
+}
+}
diff --git a/Tests/QtAutogen/same_name/bbb/aaa/item.hpp b/Tests/QtAutogen/same_name/bbb/aaa/item.hpp
new file mode 100644
index 0000000..35a3686
--- /dev/null
+++ b/Tests/QtAutogen/same_name/bbb/aaa/item.hpp
@@ -0,0 +1,19 @@
+#ifndef SDB_SDA_ITEM_HPP
+#define SDB_SDA_ITEM_HPP
+
+#include <QObject>
+
+namespace bbb {
+namespace aaa {
+
+class Item : public QObject
+{
+ Q_OBJECT
+ Q_SLOT
+ void go ( );
+};
+
+}
+}
+
+#endif
diff --git a/Tests/QtAutogen/same_name/bbb/data.qrc b/Tests/QtAutogen/same_name/bbb/data.qrc
new file mode 100644
index 0000000..5b080f5
--- /dev/null
+++ b/Tests/QtAutogen/same_name/bbb/data.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="bbb/">
+ <file>item.hpp</file>
+ <file>item.cpp</file>
+</qresource>
+</RCC>
diff --git a/Tests/QtAutogen/same_name/bbb/item.cpp b/Tests/QtAutogen/same_name/bbb/item.cpp
new file mode 100644
index 0000000..064295b
--- /dev/null
+++ b/Tests/QtAutogen/same_name/bbb/item.cpp
@@ -0,0 +1,10 @@
+#include "item.hpp"
+
+namespace bbb {
+
+void
+Item::go ( )
+{
+}
+
+}
diff --git a/Tests/QtAutogen/same_name/bbb/item.hpp b/Tests/QtAutogen/same_name/bbb/item.hpp
new file mode 100644
index 0000000..eda84a2
--- /dev/null
+++ b/Tests/QtAutogen/same_name/bbb/item.hpp
@@ -0,0 +1,17 @@
+#ifndef SDB_ITEM_HPP
+#define SDB_ITEM_HPP
+
+#include <QObject>
+
+namespace bbb {
+
+class Item : public QObject
+{
+ Q_OBJECT
+ Q_SLOT
+ void go ( );
+};
+
+}
+
+#endif
diff --git a/Tests/QtAutogen/same_name/ccc/data.qrc b/Tests/QtAutogen/same_name/ccc/data.qrc
new file mode 100644
index 0000000..f934c39
--- /dev/null
+++ b/Tests/QtAutogen/same_name/ccc/data.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="ccc/">
+ <file>item.hpp</file>
+ <file>item.cpp</file>
+</qresource>
+</RCC>
diff --git a/Tests/QtAutogen/same_name/ccc/item.cpp b/Tests/QtAutogen/same_name/ccc/item.cpp
new file mode 100644
index 0000000..2584881
--- /dev/null
+++ b/Tests/QtAutogen/same_name/ccc/item.cpp
@@ -0,0 +1,26 @@
+#include "item.hpp"
+
+namespace ccc {
+
+void
+Item::go ( )
+{
+}
+
+class MocTest : public QObject
+{
+ Q_OBJECT;
+ Q_SLOT
+ void go ( );
+};
+
+void
+MocTest::go()
+{
+}
+
+}
+
+// Include own moc files
+#include "moc_item.cpp"
+#include "item.moc"
diff --git a/Tests/QtAutogen/same_name/ccc/item.hpp b/Tests/QtAutogen/same_name/ccc/item.hpp
new file mode 100644
index 0000000..6386dc6
--- /dev/null
+++ b/Tests/QtAutogen/same_name/ccc/item.hpp
@@ -0,0 +1,17 @@
+#ifndef SDC_ITEM_HPP
+#define SDC_ITEM_HPP
+
+#include <QObject>
+
+namespace ccc {
+
+class Item : public QObject
+{
+ Q_OBJECT
+ Q_SLOT
+ void go ( );
+};
+
+}
+
+#endif
diff --git a/Tests/QtAutogen/same_name/data.qrc b/Tests/QtAutogen/same_name/data.qrc
new file mode 100644
index 0000000..4ce0b4e
--- /dev/null
+++ b/Tests/QtAutogen/same_name/data.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>main.cpp</file>
+</qresource>
+</RCC>
diff --git a/Tests/QtAutogen/same_name/main.cpp b/Tests/QtAutogen/same_name/main.cpp
new file mode 100644
index 0000000..166466e
--- /dev/null
+++ b/Tests/QtAutogen/same_name/main.cpp
@@ -0,0 +1,16 @@
+#include "aaa/item.hpp"
+#include "aaa/bbb/item.hpp"
+#include "bbb/item.hpp"
+#include "bbb/aaa/item.hpp"
+#include "ccc/item.hpp"
+
+int main(int argv, char **args)
+{
+ // Object instances
+ ::aaa::Item aaa_item;
+ ::aaa::bbb::Item aaa_bbb_item;
+ ::bbb::Item bbb_item;
+ ::bbb::aaa::Item bbb_aaa_item;
+ ::ccc::Item ccc_item;
+ return 0;
+}