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
This commit is contained in:
Tom Stellard 2022-08-10 16:56:05 -07:00
parent 1d5e7a498f
commit 9c6c4d675b
3 changed files with 20 additions and 15 deletions

View File

@ -124,10 +124,17 @@ if (LLDB_ENABLE_LUA)
finish_swig_lua("lldb-lua" "${lldb_lua_bindings_dir}" "${lldb_lua_target_dir}")
endif()
set(LLDB_INCLUDE_UNITTESTS ON)
if (NOT TARGET llvm_gtest)
set(LLDB_INCLUDE_UNITTESTS OFF)
endif()
option(LLDB_INCLUDE_TESTS "Generate build targets for the LLDB unit tests." ${LLVM_INCLUDE_TESTS})
if(LLDB_INCLUDE_TESTS)
add_subdirectory(test)
add_subdirectory(unittests)
if (LLDB_INCLUDE_UNITTESTS)
add_subdirectory(unittests)
endif()
add_subdirectory(utils)
endif()

View File

@ -97,6 +97,18 @@ include(LLVMDistributionSupport)
set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
set(LLVM_INCLUDE_TESTS ON CACHE INTERNAL "")
# Build the gtest library needed for unittests, if we have LLVM sources
# handy.
if (EXISTS ${LLVM_MAIN_SRC_DIR}/utils/unittest AND NOT TARGET llvm_gtest)
add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/unittest utils/unittest)
endif()
# LLVMTestingSupport library is needed for Process/gdb-remote.
if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
AND NOT TARGET LLVMTestingSupport)
add_subdirectory(${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
lib/Testing/Support)
endif()
option(LLVM_USE_FOLDERS "Enable solution folders in Visual Studio. Disable for Express versions." ON)
if(LLVM_USE_FOLDERS)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

View File

@ -17,20 +17,6 @@ else ()
list(APPEND LLVM_COMPILE_FLAGS -include ${LLDB_GTEST_COMMON_INCLUDE})
endif ()
if (LLDB_BUILT_STANDALONE)
# Build the gtest library needed for unittests, if we have LLVM sources
# handy.
if (EXISTS ${LLVM_MAIN_SRC_DIR}/utils/unittest AND NOT TARGET llvm_gtest)
add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/unittest utils/unittest)
endif()
# LLVMTestingSupport library is needed for Process/gdb-remote.
if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
AND NOT TARGET LLVMTestingSupport)
add_subdirectory(${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
lib/Testing/Support)
endif()
endif()
function(add_lldb_unittest test_name)
cmake_parse_arguments(ARG
""