Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -419,7 +419,14 @@ add_subdirectory(examples) if( CLANG_INCLUDE_TESTS ) - if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include/gtest/gtest.h) + if(TARGET gtest) + if(NOT EXISTS ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include/gtest/gtest.h) + # add include directories for installed llvm-gtest + foreach(incdir ${LLVM_INCLUDE_DIRS}) + include_directories("${incdir}/llvm-gtest") + endforeach() + endif() + add_subdirectory(unittests) list(APPEND CLANG_TEST_DEPS ClangUnitTests) list(APPEND CLANG_TEST_PARAMS