[PATCH] D137669: clang/cmake: Require pre-built test dependencies for stand-alone builds

Tom Stellard via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 8 13:22:29 PST 2022


tstellar created this revision.
tstellar added reviewers: phosek, mgorny, Ericson2314.
Herald added a project: All.
tstellar requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

If the FileCheck, count, and not tools are not found in
LLVM_TOOLS_BINARY_DIR, then tests will be disabled.  CMake will
no longer try to build these tool from the llvm sources.

In theory, since stand-alone builds are meant to be done without
access to the llvm sources, this should be a no-op, but this
change will affect anyone trying to do stand-alone builds with
the full monorepo sources.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137669

Files:
  clang/CMakeLists.txt


Index: clang/CMakeLists.txt
===================================================================
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -86,34 +86,26 @@
       set(LLVM_UTILS_PROVIDED ON)
     endif()
 
-    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)
-      if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/llvm-lit)
-        add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/llvm-lit utils/llvm-lit)
+    # Seek installed Lit.
+    find_program(LLVM_LIT
+                 NAMES llvm-lit lit.py lit
+                 PATHS "${LLVM_MAIN_SRC_DIR}/utils/lit"
+                 DOC "Path to lit.py")
+
+    if (LLVM_LIT AND LLVM_UTILS_PROVIDED)
+      if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
+        # Note: path not really used, except for checking if lit was found
+        if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/llvm-lit)
+          add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/llvm-lit utils/llvm-lit)
+        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()
       endif()
-      if(NOT LLVM_UTILS_PROVIDED)
-        add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/FileCheck utils/FileCheck)
-        add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/count utils/count)
-        add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/not utils/not)
-        set(LLVM_UTILS_PROVIDED ON)
-        set(CLANG_TEST_DEPS FileCheck count 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
-                   NAMES llvm-lit lit.py lit
-                   PATHS "${LLVM_MAIN_SRC_DIR}/utils/lit"
-                   DOC "Path to lit.py")
-    endif()
 
-    if(LLVM_LIT)
       # Define the default arguments to use with 'lit', and an option for the user
       # to override.
       set(LIT_ARGS_DEFAULT "-sv")


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137669.474078.patch
Type: text/x-patch
Size: 2567 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221108/fce7f611/attachment-0001.bin>


More information about the cfe-commits mailing list