[PATCH] D23959: cmake: Support building unittests against installed LLVM gtest

Michał Górny via cfe-commits cfe-commits at lists.llvm.org
Sat Aug 27 07:26:00 PDT 2016


mgorny created this revision.
mgorny added reviewers: chapuni, delcypher, vsk, Bigcheese.
mgorny added a subscriber: cfe-commits.

Support using gtest library & headers installed by LLVM to make it possible to build unittests without LLVM sources.

Depends on LLVM patch https://reviews.llvm.org/D23958

https://reviews.llvm.org/D23959

Files:
  CMakeLists.txt

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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23959.69488.patch
Type: text/x-patch
Size: 705 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160827/81484c76/attachment.bin>


More information about the cfe-commits mailing list