From 02a2e18e60b94b05fe8918aa01f0104ef519bf0f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Micha=C5=82=20G=C3=B3rny?= Date: Wed, 23 Nov 2022 16:07:03 +0100 Subject: [PATCH] [flang] Harmonize standalone gtest support with other projects Use the CMake rules of unittest libraries via `add_subdirectory()` when using standalone builds, similarly to how e.g. Clang does that. Besides making things more consistent, I hope this also unblocks D137035 and effectively we'll be able to simplify things further and have LLVM semi-automatically include gtest support for us in the future. Differential Revision: https://reviews.llvm.org/D138573 --- flang/CMakeLists.txt | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt index ef514be..2115ae9 100644 --- a/flang/CMakeLists.txt +++ b/flang/CMakeLists.txt @@ -153,23 +153,7 @@ if (FLANG_STANDALONE_BUILD) set(UNITTEST_DIR ${LLVM_THIRD_PARTY_DIR}/unittest) if(EXISTS ${UNITTEST_DIR}/googletest/include/gtest/gtest.h) if (NOT TARGET llvm_gtest) - add_library(llvm_gtest - ${UNITTEST_DIR}/googletest/src/gtest-all.cc - ${UNITTEST_DIR}/googlemock/src/gmock-all.cc - ) - target_include_directories(llvm_gtest - PUBLIC - "${UNITTEST_DIR}/googletest/include" - "${UNITTEST_DIR}/googlemock/include" - - PRIVATE - "${UNITTEST_DIR}/googletest" - "${UNITTEST_DIR}/googlemock" - ) - find_package(Threads) - target_link_libraries(llvm_gtest PUBLIC Threads::Threads) - add_library(llvm_gtest_main ${UNITTEST_DIR}/UnitTestMain/TestMain.cpp) - target_link_libraries(llvm_gtest_main PUBLIC llvm_gtest) + add_subdirectory(${UNITTEST_DIR} third-party/unittest) endif() set(FLANG_GTEST_AVAIL 1) else() -- 2.7.4