Using $<TARGET_OBJECTS:...> in anything other than add_library and add_executable was not supported until cmake 3.9.
The issue was added with https://reviews.llvm.org/D55653.
Details
- Reviewers
hintonda beanz - Commits
- rGd76c7b1c2a79: [unittests] Simplify CMakeLists with object library
rLLDB364035: [unittests] Simplify CMakeLists with object library
rL364035: [unittests] Simplify CMakeLists with object library
rG36358cd3ed0f: [unittests] Use object library if cmake supports it
rL363933: [unittests] Use object library if cmake supports it
rLLDB363933: [unittests] Use object library if cmake supports it
Diff Detail
- Repository
- rL LLVM
Event Timeline
why not just change lldb-mi-utils into a conventional (STATIC) library, at which point it can just be linked in using regular target_link_libraries, which has worked since forever?
It will cause some time overhead for linking a library. Linking is already formidable for the project and I'd avoid it when possible.
tools/lldb/unittests/tools/lldb-mi/utils/CMakeLists.txt | ||
---|---|---|
16 ↗ | (On Diff #205556) | I'm assuming from your comment, that this is a performance issue. If so, could you add a comment and also update the commit message so people can appreciate the need for the added complexity? Btw, just tested with 3.4.3, and your change made cmake happy. Thanks! |
I just reviewed all the release notes, and while 3.9 relaxed the usage of TARGET_OBJECTS, cmake doesn't explicitly mention allowing them in target_link_libraries until release 3.15.
I don't have any of those versions, but it looks like 3.15 is probably the version you need to use instead of 3.9. Please see: https://cmake.org/cmake/help/latest/release/3.15.html
As I figured out, cmake allows to use $<TARGET_OBJECTS:...> anywhere since version 3.9 (commit).
After the version 3.12 (commit) object libraries may be used as a right-hand side of target_link_libraries.
Version 3.15 allows to use $<TARGET_OBJECTS:...> expression for other types of libraries, but this change doesn't affect the patch.
Finally updated versions - target_sources supports using $<TARGET_OBJECTS:...> since CMake 3.5.0.
I really don't think this is the right solution.
$<TARGET_OBJECTS:lldb-mi-utils> can be passed in as source files in the unit test target, which should work just fine on CMake 3.4.x.