Skip to content

Commit 8216910

Browse files
committed
clang/cmake: Use installed gtest libraries for stand-alone builds
(re-commit of cb38df4 with the correct commit message) Reviewed By: phosek, kwk Differential Revision: https://reviews.llvm.org/D138472
1 parent e99ccd8 commit 8216910

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

clang/CMakeLists.txt

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,10 @@ if(CLANG_BUILT_STANDALONE)
118118
set(LLVM_UTILS_PROVIDED ON)
119119
set(CLANG_TEST_DEPS FileCheck count not)
120120
endif()
121-
set(UNITTEST_DIR ${LLVM_THIRD_PARTY_DIR}/unittest)
122-
if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h
123-
AND NOT EXISTS ${LLVM_LIBRARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX}
124-
AND EXISTS ${UNITTEST_DIR}/CMakeLists.txt)
125-
add_subdirectory(${UNITTEST_DIR} third-party/unittest)
126-
endif()
121+
endif()
122+
123+
if (NOT TARGET llvm_gtest)
124+
message(FATAL_ERROR "llvm-gtest not found. Please install llvm-gtest or disable tests with -DLLVM_INCLUDE_TESTS=OFF")
127125
endif()
128126

129127
if(LLVM_LIT)
@@ -506,13 +504,11 @@ endif()
506504

507505

508506
if( CLANG_INCLUDE_TESTS )
509-
if(EXISTS ${LLVM_THIRD_PARTY_DIR}/unittest/googletest/include/gtest/gtest.h)
510-
add_subdirectory(unittests)
511-
list(APPEND CLANG_TEST_DEPS ClangUnitTests)
512-
list(APPEND CLANG_TEST_PARAMS
513-
clang_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/test/Unit/lit.site.cfg
514-
)
515-
endif()
507+
add_subdirectory(unittests)
508+
list(APPEND CLANG_TEST_DEPS ClangUnitTests)
509+
list(APPEND CLANG_TEST_PARAMS
510+
clang_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/test/Unit/lit.site.cfg
511+
)
516512
add_subdirectory(test)
517513
add_subdirectory(bindings/python/tests)
518514

0 commit comments

Comments
 (0)