@@ -425,15 +425,21 @@ inline bool compile(options opt = {}) {
425425 headers.clear ();
426426 inlineMoc.clear ();
427427 }
428- std::map<std::string, fs::path> mocNames;
428+ // EVERY GENERATED NAME HAS ONE SOURCE. Each generator names its output
429+ // after the input's stem, in one directory, so two inputs with one stem in
430+ // different directories would be two actions writing one file; refused
431+ // naming both, for moc, uic, rcc and lrelease alike.
432+ std::map<std::string, fs::path> claimed;
433+ auto claim = [&](const std::string& outName, const fs::path& in) -> bool {
434+ auto [it, fresh] = claimed.try_emplace (outName, in);
435+ if (fresh) return true ;
436+ std::cerr << std::format (" {}: two files produce `{}`: {} and {}. Generated files are "
437+ " named after the input's stem; rename one.\n " ,
438+ who, outName, generic (it->second ), generic (in));
439+ return false ;
440+ };
429441 auto mocOne = [&](const fs::path& in, const std::string& outName) -> bool {
430- auto [it, fresh] = mocNames.try_emplace (outName, in);
431- if (!fresh) {
432- std::cerr << std::format (" {}: two files produce `{}`: {} and {}. moc outputs are named "
433- " after the file's stem; rename one.\n " ,
434- who, outName, generic (it->second ), generic (in));
435- return false ;
436- }
442+ if (!claim (outName, in)) return false ;
437443 const std::string out = generic (gen / outName);
438444 const std::string dep = out + " .d" ;
439445 const std::string src = generic (in);
@@ -464,6 +470,7 @@ inline bool compile(options opt = {}) {
464470 forms.clear ();
465471 }
466472 for (auto const & f : forms) {
473+ if (!claim (" ui_" + fs::path (f).stem ().string () + " .h" , detail::absolute_from_root (f))) return false ;
467474 const std::string in = generic (detail::absolute_from_root (f));
468475 const std::string out = generic (gen / (" ui_" + fs::path (f).stem ().string () + " .h" ));
469476 const std::string id = " qt:uic:" + fs::path (f).stem ().string ();
@@ -490,6 +497,7 @@ inline bool compile(options opt = {}) {
490497 for (auto const & r : resources) {
491498 const fs::path qrc = detail::absolute_from_root (r);
492499 const std::string stem = qrc.stem ().string ();
500+ if (!claim (" qrc_" + stem + " .cpp" , qrc)) return false ;
493501 const std::string in = generic (qrc);
494502 const std::string out = generic (gen / (" qrc_" + stem + " .cpp" ));
495503 const std::string id = " qt:rcc:" + stem;
@@ -532,6 +540,7 @@ inline bool compile(options opt = {}) {
532540 for (auto const & t : ts) {
533541 const fs::path file = detail::absolute_from_root (t);
534542 const std::string stem = file.stem ().string ();
543+ if (!claim (stem + " .qm" , file)) return false ;
535544 const std::string in = generic (file);
536545 const fs::path qmDir = opt.i18n .out_dir .empty () ? gen / " translations"
537546 : detail::absolute_from_root (opt.i18n .out_dir );
0 commit comments