Skip to content

Commit fd025c0

Browse files
committed
[CMake] Move test dependency tracking into test/CMakeLists.txt
As the name suggests, the LLDB test dependencies only matter to the different test suites. Therefore they belong in test/CMakeLists.txt rather than the top-level CMakeLists.txt.
1 parent 220cce1 commit fd025c0

File tree

3 files changed

+88
-91
lines changed

3 files changed

+88
-91
lines changed

lldb/CMakeLists.txt

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -83,80 +83,6 @@ option(LLDB_INCLUDE_TESTS "Generate build targets for the LLDB unit tests." ${LL
8383
if(LLDB_INCLUDE_TESTS)
8484
set(LLDB_TEST_BUILD_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lldb-test-build.noindex" CACHE PATH "The build root for building tests.")
8585

86-
add_custom_target(lldb-test-deps)
87-
set_target_properties(lldb-test-deps PROPERTIES FOLDER "lldb misc")
88-
add_lldb_test_dependency(lldb)
89-
90-
# lldb-test is an hard dependency for the testsuite.
91-
add_lldb_test_dependency(lldb-test)
92-
93-
# darwin-debug is an hard dependency for the testsuite.
94-
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
95-
add_lldb_test_dependency(darwin-debug)
96-
endif()
97-
98-
if(TARGET lldb-server)
99-
add_lldb_test_dependency(lldb-server)
100-
endif()
101-
102-
if(TARGET lldb-vscode)
103-
add_lldb_test_dependency(lldb-vscode)
104-
endif()
105-
106-
if(TARGET lldb-instr)
107-
add_lldb_test_dependency(lldb-instr)
108-
endif()
109-
110-
if(NOT LLDB_BUILT_STANDALONE)
111-
add_lldb_test_dependency(yaml2obj)
112-
add_lldb_test_dependency(dsymutil)
113-
endif()
114-
115-
if(TARGET liblldb)
116-
add_lldb_test_dependency(liblldb)
117-
endif()
118-
119-
if(TARGET lldb-framework)
120-
add_lldb_test_dependency(lldb-framework)
121-
endif()
122-
123-
# Add dependencies if we test with the in-tree clang.
124-
# This works with standalone builds as they import the clang target.
125-
if(TARGET clang)
126-
add_lldb_test_dependency(clang)
127-
if(APPLE)
128-
# If we build clang, we should build libcxx.
129-
# FIXME: Standalone builds should import the cxx target as well.
130-
if(LLDB_BUILT_STANDALONE)
131-
# For now check that the include directory exists.
132-
set(cxx_dir "${LLVM_BINARY_DIR}/include/c++")
133-
if(NOT EXISTS ${cxx_dir})
134-
message(WARNING "LLDB test suite requires libc++ in llvm/projects/libcxx or an existing build symlinked to ${cxx_dir}")
135-
endif()
136-
else()
137-
# We require libcxx for the test suite, so if we aren't building it,
138-
# try to provide a helpful error about how to resolve the situation.
139-
if(NOT TARGET cxx)
140-
if(LLVM_ENABLE_PROJECTS STREQUAL "")
141-
# If `LLVM_ENABLE_PROJECTS` is not being used (implying that we are
142-
# using the old layout), suggest checking it out.
143-
message(FATAL_ERROR
144-
"LLDB test suite requires libc++, but it is currently disabled. "
145-
"Please checkout `libcxx` in `llvm/projects` or disable tests "
146-
"via `LLDB_INCLUDE_TESTS=OFF`.")
147-
else()
148-
# If `LLVM_ENABLE_PROJECTS` is being used, suggest adding it.
149-
message(FATAL_ERROR
150-
"LLDB test suite requires libc++, but it is currently disabled. "
151-
"Please add `libcxx` to `LLVM_ENABLE_PROJECTS` or disable tests "
152-
"via `LLDB_INCLUDE_TESTS=OFF`.")
153-
endif()
154-
endif()
155-
add_lldb_test_dependency(cxx)
156-
endif()
157-
endif()
158-
endif()
159-
16086
add_subdirectory(test)
16187
add_subdirectory(unittests)
16288
add_subdirectory(utils/lit-cpuid)

lldb/cmake/modules/AddLLDB.cmake

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ function(lldb_tablegen)
2727
endif()
2828
endfunction(lldb_tablegen)
2929

30-
function(add_lldb_test_dependency)
31-
foreach(dependency ${ARGN})
32-
add_dependencies(lldb-test-deps ${dependency})
33-
endforeach()
34-
endfunction(add_lldb_test_dependency)
35-
3630
function(add_lldb_library name)
3731
include_directories(BEFORE
3832
${CMAKE_CURRENT_BINARY_DIR}

lldb/test/CMakeLists.txt

Lines changed: 88 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,94 @@ endif ()
1717
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_LIBS_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
1818
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TOOLS_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
1919

20+
# Create a custom target to track test dependencies.
21+
add_custom_target(lldb-test-deps)
22+
set_target_properties(lldb-test-deps PROPERTIES FOLDER "lldb misc")
23+
24+
function(add_lldb_test_dependency)
25+
foreach(dependency ${ARGN})
26+
add_dependencies(lldb-test-deps ${dependency})
27+
endforeach()
28+
endfunction(add_lldb_test_dependency)
29+
30+
# lldb itself and lldb-test is an hard dependency for the testsuites.
31+
add_lldb_test_dependency(lldb)
32+
add_lldb_test_dependency(lldb-test)
33+
34+
# On Darwin, darwin-debug is an hard dependency for the testsuites.
35+
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
36+
add_lldb_test_dependency(darwin-debug)
37+
endif()
38+
39+
if(TARGET lldb-server)
40+
add_lldb_test_dependency(lldb-server)
41+
endif()
42+
43+
if(TARGET lldb-vscode)
44+
add_lldb_test_dependency(lldb-vscode)
45+
endif()
46+
47+
if(TARGET lldb-instr)
48+
add_lldb_test_dependency(lldb-instr)
49+
endif()
50+
51+
if(TARGET liblldb)
52+
add_lldb_test_dependency(liblldb)
53+
endif()
54+
55+
if(TARGET lldb-framework)
56+
add_lldb_test_dependency(lldb-framework)
57+
endif()
58+
59+
# Add dependencies that are not exported targets when building standalone.
60+
if(NOT LLDB_BUILT_STANDALONE)
61+
add_lldb_test_dependency(
62+
FileCheck
63+
count
64+
dsymutil
65+
llvm-strip
66+
not
67+
yaml2obj
68+
)
69+
endif()
70+
71+
# Add dependencies if we test with the in-tree clang.
72+
# This works with standalone builds as they import the clang target.
73+
if(TARGET clang)
74+
add_lldb_test_dependency(clang)
75+
if(APPLE)
76+
# If we build clang, we should build libcxx.
77+
# FIXME: Standalone builds should import the cxx target as well.
78+
if(LLDB_BUILT_STANDALONE)
79+
# For now check that the include directory exists.
80+
set(cxx_dir "${LLVM_BINARY_DIR}/include/c++")
81+
if(NOT EXISTS ${cxx_dir})
82+
message(WARNING "LLDB test suite requires libc++ in llvm/projects/libcxx or an existing build symlinked to ${cxx_dir}")
83+
endif()
84+
else()
85+
# We require libcxx for the test suite, so if we aren't building it,
86+
# try to provide a helpful error about how to resolve the situation.
87+
if(NOT TARGET cxx)
88+
if(LLVM_ENABLE_PROJECTS STREQUAL "")
89+
# If `LLVM_ENABLE_PROJECTS` is not being used (implying that we are
90+
# using the old layout), suggest checking it out.
91+
message(FATAL_ERROR
92+
"LLDB test suite requires libc++, but it is currently disabled. "
93+
"Please checkout `libcxx` in `llvm/projects` or disable tests "
94+
"via `LLDB_INCLUDE_TESTS=OFF`.")
95+
else()
96+
# If `LLVM_ENABLE_PROJECTS` is being used, suggest adding it.
97+
message(FATAL_ERROR
98+
"LLDB test suite requires libc++, but it is currently disabled. "
99+
"Please add `libcxx` to `LLVM_ENABLE_PROJECTS` or disable tests "
100+
"via `LLDB_INCLUDE_TESTS=OFF`.")
101+
endif()
102+
endif()
103+
add_lldb_test_dependency(cxx)
104+
endif()
105+
endif()
106+
endif()
107+
20108
add_lldb_test_dependency(
21109
lit-cpuid
22110
llc
@@ -29,17 +117,6 @@ add_lldb_test_dependency(
29117
llvm-readobj
30118
)
31119

32-
if(NOT LLDB_BUILT_STANDALONE)
33-
# Since llvm-strip is a symlink created by add_custom_target, it doesn't
34-
# expose an export target when building standalone.
35-
add_lldb_test_dependency(
36-
llvm-strip
37-
FileCheck
38-
count
39-
not
40-
)
41-
endif()
42-
43120
if(TARGET lld)
44121
add_lldb_test_dependency(lld)
45122
else()

0 commit comments

Comments
 (0)