diff options
author | Brad King <brad.king@kitware.com> | 2019-02-06 11:50:27 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-02-06 11:50:36 (GMT) |
commit | 4400ac07f7bb7da1d85244d1b5ddc2dfd75273f1 (patch) | |
tree | b62367ddfa55d5034fa1dc47c2c72389d5f86bef /Source | |
parent | 3a2387bce79a6c8ea79f64e80079accbbd8696b2 (diff) | |
parent | a28caabf453ab41851b75a40a2e49706439f9478 (diff) | |
download | CMake-4400ac07f7bb7da1d85244d1b5ddc2dfd75273f1.zip CMake-4400ac07f7bb7da1d85244d1b5ddc2dfd75273f1.tar.gz CMake-4400ac07f7bb7da1d85244d1b5ddc2dfd75273f1.tar.bz2 |
Merge topic 'autogen_same_name_different_extension'
a28caabf45 Autogen: AUTOMOC support for files with the same name but different extensions
1f802295f2 Autogen: Extend the SameName test with same name but different extension files
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2920
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmQtAutoGeneratorMocUic.cxx | 46 | ||||
-rw-r--r-- | Source/cmQtAutoGeneratorMocUic.h | 2 |
2 files changed, 35 insertions, 13 deletions
diff --git a/Source/cmQtAutoGeneratorMocUic.cxx b/Source/cmQtAutoGeneratorMocUic.cxx index 0ba5224..ddff4cf 100644 --- a/Source/cmQtAutoGeneratorMocUic.cxx +++ b/Source/cmQtAutoGeneratorMocUic.cxx @@ -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() diff --git a/Source/cmQtAutoGeneratorMocUic.h b/Source/cmQtAutoGeneratorMocUic.h index 32a6006..c22df29 100644 --- a/Source/cmQtAutoGeneratorMocUic.h +++ b/Source/cmQtAutoGeneratorMocUic.h @@ -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: |