[llvm-branch-commits] [lld] 5ea33d0 - [PATCH] CMake: Check for gtest headers even if lit.py is not present

Nikita Popov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue May 3 01:16:01 PDT 2022


Author: Tom Stellard
Date: 2022-05-03T10:10:13+02:00
New Revision: 5ea33d0fd269cf90a8d3c69eeb0ac57ab5d8a790

URL: https://github.com/llvm/llvm-project/commit/5ea33d0fd269cf90a8d3c69eeb0ac57ab5d8a790
DIFF: https://github.com/llvm/llvm-project/commit/5ea33d0fd269cf90a8d3c69eeb0ac57ab5d8a790.diff

LOG: [PATCH] CMake: Check for gtest headers even if lit.py is not present

This makes it possible to build the unittests even withotu a full
checkout of the llvm source tree.

Added: 
    

Modified: 
    lld/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt
index f51c864af8375..f98d45b59b199 100644
--- a/lld/CMakeLists.txt
+++ b/lld/CMakeLists.txt
@@ -108,6 +108,15 @@ if(LLD_BUILT_STANDALONE)
       set(LLVM_UTILS_PROVIDED ON)
     endif()
 
+		# Check for gtest
+    set(UNITTEST_DIR ${LLVM_MAIN_SRC_DIR}/utils/unittest)
+    if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h
+        AND NOT EXISTS ${LLVM_LIBRARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX}
+        AND EXISTS ${UNITTEST_DIR}/CMakeLists.txt)
+      add_subdirectory(${UNITTEST_DIR} utils/unittest)
+    endif()
+
+		# Check for lit
     if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
       # Note: path not really used, except for checking if lit was found
       set(LLVM_LIT ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
@@ -117,12 +126,6 @@ if(LLD_BUILT_STANDALONE)
         set(LLVM_UTILS_PROVIDED ON)
         set(LLD_TEST_DEPS FileCheck not)
       endif()
-      set(UNITTEST_DIR ${LLVM_MAIN_SRC_DIR}/utils/unittest)
-      if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h
-          AND NOT EXISTS ${LLVM_LIBRARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX}
-          AND EXISTS ${UNITTEST_DIR}/CMakeLists.txt)
-        add_subdirectory(${UNITTEST_DIR} utils/unittest)
-      endif()
     else()
       # Seek installed Lit.
       find_program(LLVM_LIT


        


More information about the llvm-branch-commits mailing list