From 2d6a5dd67f2fdc346e7ccba55643db30ecfd3a82 Mon Sep 17 00:00:00 2001
From: Julian Büning <julian.buening@rwth-aachen.de>
Date: Mon, 22 Oct 2018 15:42:49 +0200
Subject: CMake: enable reuse of LLVM's googletest src and targets

Fixes an issue that occurs with USE_CMAKE_FIND_PACKAGE_LLVM=ON
and LLVM compiled from sources, which then exports gtest and
gtest_main targets.

In case gtest and gtest_main targets are not imported from LLVM
and GTEST_SRC_DIR is not set, CMake can now reuse the googletest
sources from LLVM_BUILD_MAIN_SRC_DIR (if available) with
USE_CMAKE_FIND_PACKAGE_LLVM=ON. This last limitation is due to
LLVM making modifications to the CMakeLists.txt of googletest
that requires add_llvm_library() from AddLLVM.cmake.
---
 unittests/TestMain.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

(limited to 'unittests/TestMain.cpp')

diff --git a/unittests/TestMain.cpp b/unittests/TestMain.cpp
index 095076b2..9a64a4af 100644
--- a/unittests/TestMain.cpp
+++ b/unittests/TestMain.cpp
@@ -9,6 +9,12 @@
 
 #include "gtest/gtest.h"
 
+// WARNING: If LLVM's gtest_main target is reused
+//          or is built from LLVM's source tree,
+//          this file is ignored. Instead, LLVM's
+//          utils/unittest/UnitTestMain/TestMain.cpp
+//          is used.
+
 int main(int argc, char **argv) {
   testing::InitGoogleTest(&argc, argv);
   return RUN_ALL_TESTS();
-- 
cgit 1.4.1