2a948c7
From 760568cd24acd6ae9083b0dfea2c7c0ea6f0adc2 Mon Sep 17 00:00:00 2001
059c998
From: Tom Stellard <tstellar@redhat.com>
059c998
Date: Thu, 30 Aug 2018 08:53:56 -0700
2a948c7
Subject: [PATCH 1/2] [PATCH][lld] CMake: Check for gtest headers even if
2a948c7
 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
---
2a948c7
 lld/CMakeLists.txt | 15 +++++++++------
059c998
 1 file changed, 9 insertions(+), 6 deletions(-)
059c998
2a948c7
diff --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt
2a948c7
index d4e561b..a7406d1c 100644
2a948c7
--- a/lld/CMakeLists.txt
2a948c7
+++ b/lld/CMakeLists.txt
2cb02d9
@@ -68,6 +68,15 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
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)
2cb02d9
@@ -77,12 +86,6 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
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