059c998
From e5bdf4580677da063abe8d3880fbab9eaa7a7efe Mon Sep 17 00:00:00 2001
059c998
From: Tom Stellard <tstellar@redhat.com>
059c998
Date: Thu, 30 Aug 2018 08:53:56 -0700
059c998
Subject: [PATCH] CMake: Check for gtest headers even if lit.py is not present
059c998
059c998
This makes it possible to build the unittests even withotu a full
059c998
checkout of the llvm source tree.
059c998
---
059c998
 CMakeLists.txt | 15 +++++++++------
059c998
 1 file changed, 9 insertions(+), 6 deletions(-)
059c998
059c998
diff --git a/CMakeLists.txt b/CMakeLists.txt
059c998
index e2fbdbf..c9b2927 100644
059c998
--- a/CMakeLists.txt
059c998
+++ b/CMakeLists.txt
059c998
@@ -75,6 +75,15 @@ Please install Python or specify the PYTHON_EXECUTABLE CMake variable.")
059c998
       set(LLVM_UTILS_PROVIDED ON)
059c998
     endif()
059c998
 
059c998
+		# Check for gtest
059c998
+    set(UNITTEST_DIR ${LLVM_MAIN_SRC_DIR}/utils/unittest)
059c998
+    if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h
059c998
+        AND NOT EXISTS ${LLVM_LIBRARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX}
059c998
+        AND EXISTS ${UNITTEST_DIR}/CMakeLists.txt)
059c998
+      add_subdirectory(${UNITTEST_DIR} utils/unittest)
059c998
+    endif()
059c998
+
059c998
+		# Check for lit
059c998
     if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
059c998
       # Note: path not really used, except for checking if lit was found
059c998
       set(LLVM_LIT ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
059c998
@@ -84,12 +93,6 @@ Please install Python or specify the PYTHON_EXECUTABLE CMake variable.")
059c998
         set(LLVM_UTILS_PROVIDED ON)
059c998
         set(LLD_TEST_DEPS FileCheck not)
059c998
       endif()
059c998
-      set(UNITTEST_DIR ${LLVM_MAIN_SRC_DIR}/utils/unittest)
059c998
-      if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h
059c998
-          AND NOT EXISTS ${LLVM_LIBRARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX}
059c998
-          AND EXISTS ${UNITTEST_DIR}/CMakeLists.txt)
059c998
-        add_subdirectory(${UNITTEST_DIR} utils/unittest)
059c998
-      endif()
059c998
     else()
059c998
       # Seek installed Lit.
059c998
       find_program(LLVM_LIT
059c998
-- 
059c998
1.8.3.1
059c998