Skip to content

Commit af83a2a

Browse files
authored
[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.
1 parent d89b771 commit af83a2a

File tree

3 files changed

+4
-13
lines changed

3 files changed

+4
-13
lines changed

lld/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ add_subdirectory(tools/lld)
192192

193193
if (LLVM_INCLUDE_TESTS)
194194
add_custom_target(LLDUnitTests)
195-
llvm_add_unittests(LLD_UNITTESTS_ADDED)
195+
if (TARGET llvm_gtest)
196+
add_subdirectory(unittests)
197+
endif()
196198
add_subdirectory(test)
197199
endif()
198200

lld/test/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,10 @@ configure_lit_site_cfg(
3838
"LLD_SOURCE_DIR"
3939
)
4040

41-
set(LLD_TEST_DEPS lld)
41+
set(LLD_TEST_DEPS lld LLDUnitTests)
4242
if (NOT LLD_BUILT_STANDALONE)
4343
list(APPEND LLD_TEST_DEPS
4444
FileCheck
45-
LLDUnitTests
4645
count
4746
dsymutil
4847
llc

llvm/cmake/modules/AddLLVM.cmake

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2509,13 +2509,3 @@ function(setup_host_tool tool_name setting_name exe_var_name target_var_name)
25092509
add_custom_target(${target_var_name} DEPENDS ${exe_name})
25102510
endif()
25112511
endfunction()
2512-
2513-
# Adds the unittests folder if gtest is available.
2514-
function(llvm_add_unittests tests_added)
2515-
if (EXISTS ${LLVM_THIRD_PARTY_DIR}/unittest/googletest/include/gtest/gtest.h)
2516-
add_subdirectory(unittests)
2517-
set(${tests_added} ON PARENT_SCOPE)
2518-
else()
2519-
message(WARNING "gtest not found, unittests will not be available")
2520-
endif()
2521-
endfunction()

0 commit comments

Comments
 (0)