Instead of relying on magic to generate unique names, allow user to specify unique prefix for target names.
llvm_target_prefix() sets the prefix for targets created with llvm_singlesource()/llvm_multisource().
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
While the patch looks good to me, what about the alternative approach of just error out on a name clash? AFAIK the only clash we have is between SingleSource/Benchmarks/Shootout and SingleSource/Benchmarks/Shootout-C++ and I'd rather go for a low-tech solution like allowing to specify a prefix in the shootout CMakeFiles and throw an error on non-unique targets instead of going through all the trouble to automatically create unique names.
How about adding llvm_test_name_prefix() which would add given prefix to all targets generated within scope?
Default will remain empty, but for testsuites that have name clashes it would provide an easy way to make their names unique.
Or we can even require having prefix set before we call llvm_multisource(). With that in place we can remove unique name magic and error out on name clashes.
Yep that's what I had in mind. Though I think using a variable like TARGET_PREFIX instead of a function would be more in-line with the current way the singlesource()/multisource() are configured.
cmake/modules/SingleMultiSource.cmake | ||
---|---|---|
17–24 ↗ | (On Diff #54716) | Is there a benefit in having a function here instead of just letting users set TARGET_PREFIX immediately? |
26–47 ↗ | (On Diff #54716) | I just tried it and cmake errors out by itself if you create two (logical) targets with the same name if you set: |
cmake/modules/SingleMultiSource.cmake | ||
---|---|---|
17–24 ↗ | (On Diff #54716) | None, other than separating end-user from the details of implementation. |
26–47 ↗ | (On Diff #54716) | It does error out, but having explicit "please set prefix" message may make experience of adding new tests somewhat less painful. |