Commit 4400ac07 authored by Brad King's avatar Brad King Committed by Kitware Robot
Browse files

Merge topic 'autogen_same_name_different_extension'

a28caabf Autogen: AUTOMOC support for files with the same name but different extensions
1f802295

 Autogen: Extend the SameName test with same name but different extension files
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !2920
parents 3a2387bc a28caabf
......@@ -678,19 +678,21 @@ void cmQtAutoGeneratorMocUic::JobMocT::Process(WorkerT& wrk)
BuildFile += '/';
BuildFile += IncludeString;
} else {
std::string rel = wrk.FileSys().GetFilePathChecksum(SourceFile);
rel += "/moc_";
rel += wrk.FileSys().GetFilenameWithoutLastExtension(SourceFile);
rel += ".cpp";
// Register relative file path
wrk.Gen().ParallelMocAutoRegister(rel);
// Relative build path
std::string relPath = wrk.FileSys().GetFilePathChecksum(SourceFile);
relPath += "/moc_";
relPath += wrk.FileSys().GetFilenameWithoutLastExtension(SourceFile);
// Register relative file path with duplication check
relPath = wrk.Gen().ParallelMocAutoRegister(relPath);
// Absolute build path
if (wrk.Base().MultiConfig) {
BuildFile = wrk.Base().AutogenIncludeDir;
BuildFile += '/';
BuildFile += rel;
BuildFile += relPath;
} else {
BuildFile = wrk.Base().AbsoluteBuildPath(rel);
BuildFile = wrk.Base().AbsoluteBuildPath(relPath);
}
}
......@@ -1953,11 +1955,31 @@ bool cmQtAutoGeneratorMocUic::ParallelMocIncluded(
return (MocIncludedFiles_.find(sourceFile) != MocIncludedFiles_.end());
}
void cmQtAutoGeneratorMocUic::ParallelMocAutoRegister(
std::string const& mocFile)
std::string cmQtAutoGeneratorMocUic::ParallelMocAutoRegister(
std::string const& baseName)
{
std::lock_guard<std::mutex> mocLock(JobsMutex_);
MocAutoFiles_.emplace(mocFile);
std::string res;
{
std::lock_guard<std::mutex> mocLock(JobsMutex_);
res = baseName;
res += ".cpp";
if (MocAutoFiles_.find(res) == MocAutoFiles_.end()) {
MocAutoFiles_.emplace(res);
} else {
// Append number suffix to the file name
for (unsigned int ii = 2; ii != 1024; ++ii) {
res = baseName;
res += '_';
res += std::to_string(ii);
res += ".cpp";
if (MocAutoFiles_.find(res) == MocAutoFiles_.end()) {
MocAutoFiles_.emplace(res);
break;
}
}
}
}
return res;
}
void cmQtAutoGeneratorMocUic::ParallelMocAutoUpdated()
......
......@@ -389,7 +389,7 @@ public:
bool ParallelJobPushMoc(JobHandleT& jobHandle);
bool ParallelJobPushUic(JobHandleT& jobHandle);
bool ParallelMocIncluded(std::string const& sourceFile);
void ParallelMocAutoRegister(std::string const& mocFile);
std::string ParallelMocAutoRegister(std::string const& baseName);
void ParallelMocAutoUpdated();
private:
......
......@@ -17,6 +17,10 @@ add_executable(sameName
ccc/item.cpp
ccc/data.qrc
item.cpp
object.h
object.h++
object.hpp
object.hxx
data.qrc
main.cpp
)
......
......@@ -3,14 +3,25 @@
#include "bbb/aaa/item.hpp"
#include "bbb/item.hpp"
#include "ccc/item.hpp"
#include "item.hpp"
#include "object.h"
#include "object.h++"
#include "object.hpp"
#include "object.hxx"
int main(int argv, char** args)
{
// Object instances
// Item instances
::Item item;
::aaa::Item aaa_item;
::aaa::bbb::Item aaa_bbb_item;
::bbb::Item bbb_item;
::bbb::aaa::Item bbb_aaa_item;
::ccc::Item ccc_item;
// Object instances
::Object_h obj_h;
::Object_hplpl obj_hplpl;
::Object_hpp obj_hpp;
::Object_hxx obj_hxx;
return 0;
}
#ifndef OBJECT_H
#define OBJECT_H
#include <QObject>
class Object_h : public QObject
{
Q_OBJECT
Q_SLOT
void go(){};
};
#endif
#ifndef OBJECT_HPLPL
#define OBJECT_HPLPL
#include <QObject>
class Object_hplpl : public QObject
{
Q_OBJECT
Q_SLOT
void go(){};
};
#endif
#ifndef OBJECT_HPP
#define OBJECT_HPP
#include <QObject>
class Object_hpp : public QObject
{
Q_OBJECT
Q_SLOT
void go(){};
};
#endif
#ifndef OBJECT_HXX
#define OBJECT_HXX
#include <QObject>
class Object_hxx : public QObject
{
Q_OBJECT
Q_SLOT
void go(){};
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment