File tree Expand file tree Collapse file tree 1 file changed +22
-9
lines changed
Expand file tree Collapse file tree 1 file changed +22
-9
lines changed Original file line number Diff line number Diff line change 33# See LICENSE.TXT
44# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
55
6- include (FetchContent)
7- FetchContent_Declare(
8- googletest
9- GIT_REPOSITORY https://github.com/google/googletest.git
10- GIT_TAG v1.13.0
11- )
6+ set (GTEST_VER 1.13.0)
7+
8+ find_package (GTest ${GTEST_VER} QUIET )
9+
10+ if (GTest_FOUND AND NOT TARGET GTest::gmock)
11+ message (WARNING "Found system install of GTest but not GMock. Building GTest and GMock from source" )
12+ set (GTest_FOUND FALSE )
13+ endif ()
14+
15+ if (NOT GTest_FOUND)
16+ include (FetchContent)
17+ FetchContent_Declare(
18+ googletest
19+ GIT_REPOSITORY https://github.com/google/googletest.git
20+ GIT_TAG v${GTEST_VER}
21+ )
22+ endif ()
1223
1324include (FindLit)
1425
@@ -22,8 +33,10 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND UR_DPCXX AND UR_TEST_FUZZTESTS)
2233 set (UR_FUZZTESTING_ENABLED ON )
2334endif ()
2435
25- set (INSTALL_GTEST OFF )
26- FetchContent_MakeAvailable(googletest)
36+ if (NOT GTest_FOUND)
37+ set (INSTALL_GTEST OFF )
38+ FetchContent_MakeAvailable(googletest)
39+ endif ()
2740enable_testing ()
2841
2942# At the time of writing this comment, this is only used for level_zero adapter testing.
@@ -112,7 +125,7 @@ function(add_gtest_test name)
112125 add_testing_binary(${TEST_TARGET_NAME} ${ARGN} )
113126 target_link_libraries (${TEST_TARGET_NAME}
114127 PRIVATE
115- gmock
128+ GTest:: gmock
116129 GTest::gtest_main)
117130endfunction ()
118131
You can’t perform that action at this time.
0 commit comments