Skip to content

Commit 9c6c4d6

Browse files
committed
lldb: Disable unittests if llvm_gtest target does not exist
This fixes the stand-alone build configuration where LLVM_MAIN_SRC_DIR does not exist. Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D124314
1 parent 1d5e7a4 commit 9c6c4d6

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

lldb/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,17 @@ if (LLDB_ENABLE_LUA)
124124
finish_swig_lua("lldb-lua" "${lldb_lua_bindings_dir}" "${lldb_lua_target_dir}")
125125
endif()
126126

127+
set(LLDB_INCLUDE_UNITTESTS ON)
128+
if (NOT TARGET llvm_gtest)
129+
set(LLDB_INCLUDE_UNITTESTS OFF)
130+
endif()
131+
127132
option(LLDB_INCLUDE_TESTS "Generate build targets for the LLDB unit tests." ${LLVM_INCLUDE_TESTS})
128133
if(LLDB_INCLUDE_TESTS)
129134
add_subdirectory(test)
130-
add_subdirectory(unittests)
135+
if (LLDB_INCLUDE_UNITTESTS)
136+
add_subdirectory(unittests)
137+
endif()
131138
add_subdirectory(utils)
132139
endif()
133140

lldb/cmake/modules/LLDBStandalone.cmake

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,18 @@ include(LLVMDistributionSupport)
9797
set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
9898
set(LLVM_INCLUDE_TESTS ON CACHE INTERNAL "")
9999

100+
# Build the gtest library needed for unittests, if we have LLVM sources
101+
# handy.
102+
if (EXISTS ${LLVM_MAIN_SRC_DIR}/utils/unittest AND NOT TARGET llvm_gtest)
103+
add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/unittest utils/unittest)
104+
endif()
105+
# LLVMTestingSupport library is needed for Process/gdb-remote.
106+
if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
107+
AND NOT TARGET LLVMTestingSupport)
108+
add_subdirectory(${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
109+
lib/Testing/Support)
110+
endif()
111+
100112
option(LLVM_USE_FOLDERS "Enable solution folders in Visual Studio. Disable for Express versions." ON)
101113
if(LLVM_USE_FOLDERS)
102114
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

lldb/unittests/CMakeLists.txt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,6 @@ else ()
1717
list(APPEND LLVM_COMPILE_FLAGS -include ${LLDB_GTEST_COMMON_INCLUDE})
1818
endif ()
1919

20-
if (LLDB_BUILT_STANDALONE)
21-
# Build the gtest library needed for unittests, if we have LLVM sources
22-
# handy.
23-
if (EXISTS ${LLVM_MAIN_SRC_DIR}/utils/unittest AND NOT TARGET llvm_gtest)
24-
add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/unittest utils/unittest)
25-
endif()
26-
# LLVMTestingSupport library is needed for Process/gdb-remote.
27-
if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
28-
AND NOT TARGET LLVMTestingSupport)
29-
add_subdirectory(${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
30-
lib/Testing/Support)
31-
endif()
32-
endif()
33-
3420
function(add_lldb_unittest test_name)
3521
cmake_parse_arguments(ARG
3622
""

0 commit comments

Comments
 (0)