diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt --- a/lldb/CMakeLists.txt +++ b/lldb/CMakeLists.txt @@ -124,10 +124,31 @@ finish_swig_lua("lldb-lua" "${lldb_lua_bindings_dir}" "${lldb_lua_target_dir}") 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() + +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() diff --git a/lldb/unittests/CMakeLists.txt b/lldb/unittests/CMakeLists.txt --- a/lldb/unittests/CMakeLists.txt +++ b/lldb/unittests/CMakeLists.txt @@ -17,20 +17,6 @@ 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 ""