diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt --- a/lldb/CMakeLists.txt +++ b/lldb/CMakeLists.txt @@ -124,10 +124,17 @@ 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() diff --git a/lldb/cmake/modules/LLDBStandalone.cmake b/lldb/cmake/modules/LLDBStandalone.cmake --- a/lldb/cmake/modules/LLDBStandalone.cmake +++ b/lldb/cmake/modules/LLDBStandalone.cmake @@ -97,6 +97,18 @@ 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) 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 ""