[flang-commits] [PATCH] D138573: [flang] Harmonize standalone gtest support with other projects

Michał Górny via Phabricator via flang-commits flang-commits at lists.llvm.org
Wed Nov 23 07:10:26 PST 2022


mgorny created this revision.
mgorny added reviewers: awarzynski, stella.stamenova, MaskRay, phosek, thesamesam.
Herald added subscribers: StephenFan, kristof.beyls.
Herald added a project: All.
mgorny requested review of this revision.

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 <https://reviews.llvm.org/D137035>
and effectively we'll be able to simplify things further and have LLVM
semi-automatically include gtest support for us in the future.


https://reviews.llvm.org/D138573

Files:
  flang/CMakeLists.txt


Index: flang/CMakeLists.txt
===================================================================
--- flang/CMakeLists.txt
+++ flang/CMakeLists.txt
@@ -153,23 +153,7 @@
     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()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138573.477497.patch
Type: text/x-patch
Size: 1121 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20221123/c47956f1/attachment.bin>


More information about the flang-commits mailing list