[Lldb-commits] [PATCH] D63544: Use object library if cmake supports it
Tatyana Krasnukha via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed Jun 19 11:33:12 PDT 2019
tatyana-krasnukha updated this revision to Diff 205648.
tatyana-krasnukha retitled this revision from "Add a worlaround for unsupported cmake feature" to "Use object library if cmake supports it".
tatyana-krasnukha added a comment.
As I figured out, cmake allows to use $<TARGET_OBJECTS:...> anywhere since version 3.9 (commit <https://gitlab.kitware.com/cmake/cmake/commit/93c89bc75ceee599ba7c08b8fe1ac5104942054f>).
After the version 3.12 (commit <https://gitlab.kitware.com/cmake/cmake/commit/57538224d06225ce039f9c883465c6743186c2f4>) 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.
Repository:
rLLDB LLDB
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D63544/new/
https://reviews.llvm.org/D63544
Files:
tools/lldb/unittests/tools/lldb-mi/utils/CMakeLists.txt
Index: tools/lldb/unittests/tools/lldb-mi/utils/CMakeLists.txt
===================================================================
--- tools/lldb/unittests/tools/lldb-mi/utils/CMakeLists.txt
+++ tools/lldb/unittests/tools/lldb-mi/utils/CMakeLists.txt
@@ -1,13 +1,30 @@
-add_library(lldb-mi-utils OBJECT
+# Create object library to avoid unnecessary linking. If CMake version
+# doesn't support it, just create an ordinary library.
+if(${CMAKE_VERSION} VERSION_GREATER "3.8.2")
+ set (LIBRARY_TYPE "OBJECT")
+endif()
+
+add_library(lldb-mi-utils ${LIBRARY_TYPE}
${LLDB_SOURCE_DIR}/tools/lldb-mi/MIUtilString.cpp
)
add_lldb_unittest(LLDBMiUtilTests
StringTest.cpp
-
+
LINK_COMPONENTS
Support
)
-target_sources(LLDBMiUtilTests PRIVATE $<TARGET_OBJECTS:lldb-mi-utils>)
+if((${CMAKE_VERSION} VERSION_LESS "3.9.0") OR
+ (${CMAKE_VERSION} VERSION_GREATER "3.11.4"))
+ # Link to either usual (cmake version < 3.9) or
+ # object (3.12 <= cmake version < 3.15) library with lldm-mi sources.
+ target_link_libraries(LLDBMiUtilTests PRIVATE lldb-mi-utils)
+else()
+ # Object libraries still cannot be on the right-hand side of
+ # `target_link_libraries` but $<TARGET_OBJECTS:objlib> expression is
+ # already supported in `target_sources`.
+ target_sources(LLDBMiUtilTests PRIVATE $<TARGET_OBJECTS:lldb-mi-utils>)
+endif()
+
set_target_properties(lldb-mi-utils PROPERTIES FOLDER "lldb libraries")
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63544.205648.patch
Type: text/x-patch
Size: 1426 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190619/7b29187f/attachment.bin>
More information about the lldb-commits
mailing list