File tree Expand file tree Collapse file tree 4 files changed +27
-5
lines changed Expand file tree Collapse file tree 4 files changed +27
-5
lines changed Original file line number Diff line number Diff line change @@ -9,4 +9,3 @@ function (build_gtest gtest_name)
99 endif ()
1010 add_subdirectory ("${LLVM_THIRD_PARTY_DIR} /unittest" "${CMAKE_BINARY_DIR} /third-party/${gtest_name} _gtest" )
1111endfunction ()
12-
Original file line number Diff line number Diff line change @@ -76,6 +76,11 @@ endif()
7676set (MLIR_MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR} /../mlir" CACHE PATH "Path to MLIR source tree" )
7777
7878if (FLANG_STANDALONE_BUILD)
79+ if (NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
80+ set (LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR} /../cmake)
81+ endif ()
82+ list (APPEND CMAKE_MODULE_PATH "${LLVM_COMMON_CMAKE_UTILS} /Modules" )
83+
7984 set (FLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} )
8085 set (CMAKE_INCLUDE_CURRENT_DIR ON )
8186 if (NOT MSVC_IDE )
@@ -226,8 +231,9 @@ if (FLANG_STANDALONE_BUILD)
226231 if (FLANG_INCLUDE_TESTS)
227232 set (UNITTEST_DIR ${LLVM_THIRD_PARTY_DIR} /unittest)
228233 if (EXISTS ${UNITTEST_DIR} /googletest/include /gtest/gtest.h)
229- if (NOT TARGET llvm_gtest)
230- add_subdirectory (${UNITTEST_DIR} third-party/unittest)
234+ if (NOT TARGET default_gtest)
235+ include (AddGTest)
236+ build_gtest(flang_gtest LLVM_SUPPORT)
231237 endif ()
232238 set (FLANG_GTEST_AVAIL 1)
233239 else ()
Original file line number Diff line number Diff line change @@ -106,8 +106,9 @@ include_directories(
106106if (LLDB_INCLUDE_TESTS)
107107 # Build the gtest library needed for unittests, if we have LLVM sources
108108 # handy.
109- if (EXISTS ${LLVM_THIRD_PARTY_DIR} /unittest AND NOT TARGET llvm_gtest)
110- add_subdirectory (${LLVM_THIRD_PARTY_DIR} /unittest third-party/unittest)
109+ if (EXISTS ${LLVM_THIRD_PARTY_DIR} /unittest AND NOT TARGET default_gtest)
110+ include (AddGTest)
111+ build_gtest(lldb_gtest LLVM_SUPPORT)
111112 endif ()
112113 # LLVMTestingSupport library is needed for Process/gdb-remote.
113114 if (EXISTS ${LLVM_MAIN_SRC_DIR} /lib/Testing/Support
Original file line number Diff line number Diff line change 77# To run the tests for Google Test itself on Linux, use 'make test' or
88# ctest. You can select which tests to run using 'ctest -R regex'.
99# For more options, run 'ctest --help'.
10+ #
11+ # Do not add_subdirectory(third-party/unittest) this file directly.
12+ # Instead use:
13+ #
14+ # include(AddGTest)
15+ # build_gtest(llvm_gtest [LLVM_SUPPORT])
16+ #
1017########################################################################
1118#
1219# Project-wide settings
1320
1421set (LLVM_SUBPROJECT_TITLE "Third-Party/Google Test" )
1522
23+ if (NOT gtest_name)
24+ message (FATAL_ERROR "Do not add_subdirectory GTest directly. Use the
25+ following helper function instead:
26+
27+ include(AddGTest)
28+ build_gtest(llvm_gtest [LLVM_SUPPORT])
29+ " )
30+ endif ()
31+
1632if (GTEST_USE_LLVM)
1733 set (GTEST_LLVM_COMPONENTS "Support" ) # For llvm::raw_ostream
1834else ()
You can’t perform that action at this time.
0 commit comments