From 760568cd24acd6ae9083b0dfea2c7c0ea6f0adc2 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Thu, 30 Aug 2018 08:53:56 -0700 Subject: [PATCH 1/2] [PATCH][lld] 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. --- lld/CMakeLists.txt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt index d4e561b..a7406d1c 100644 --- a/lld/CMakeLists.txt +++ b/lld/CMakeLists.txt @@ -68,6 +68,16 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) 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) + set(HAVE_LIBPTHREAD ON) + 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) @@ -77,12 +86,6 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) 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 -- 1.8.3.1