[lld] Fixes for unitests in standalone builds (#83670)
1. Replace the obsolete `llvm_add_unittests()` CMake function with an
explicit check for `TARGET llvm_gtest`. This is more consistent with the
rest of the code, and it makes it possible to avoid checking out
`third-party` tree.
2. Add `LLDUnitTests` test dependency to standalone builds. It is
defined unconditionally, and actually necessary to ensure that unit
tests will be built.
GitOrigin-RevId: af83a2add5687d0c2f70e538612b7e86ccbf47a5
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 595c286..cd8ba62 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -192,7 +192,9 @@
if (LLVM_INCLUDE_TESTS)
add_custom_target(LLDUnitTests)
- llvm_add_unittests(LLD_UNITTESTS_ADDED)
+ if (TARGET llvm_gtest)
+ add_subdirectory(unittests)
+ endif()
add_subdirectory(test)
endif()
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 558da2b..bb6164f 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -38,11 +38,10 @@
"LLD_SOURCE_DIR"
)
-set(LLD_TEST_DEPS lld)
+set(LLD_TEST_DEPS lld LLDUnitTests)
if (NOT LLD_BUILT_STANDALONE)
list(APPEND LLD_TEST_DEPS
FileCheck
- LLDUnitTests
count
dsymutil
llc