Enable cross_build gtest in CMake build flow

Signed-off-by: Bruce Lai <bruce.lai@sifive.com>
Change-Id: Ibdc742040940ee6c6402de103759f979f9429419
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/4401739
Reviewed-by: Frank Barchard <fbarchard@chromium.org>
Commit-Queue: Frank Barchard <fbarchard@chromium.org>
This commit is contained in:
Bruce Lai 2023-03-21 22:43:10 -07:00 committed by libyuv LUCI CQ
parent aa47d668d8
commit 0b3ac31e4d

View File

@ -53,6 +53,7 @@ if (JPEG_FOUND)
endif() endif()
if(TEST) if(TEST)
if (NOT CMAKE_CROSSCOMPILING)
find_library(GTEST_LIBRARY gtest) find_library(GTEST_LIBRARY gtest)
if(GTEST_LIBRARY STREQUAL "GTEST_LIBRARY-NOTFOUND") if(GTEST_LIBRARY STREQUAL "GTEST_LIBRARY-NOTFOUND")
set(GTEST_SRC_DIR /usr/src/gtest CACHE STRING "Location of gtest sources") set(GTEST_SRC_DIR /usr/src/gtest CACHE STRING "Location of gtest sources")
@ -67,6 +68,10 @@ if(TEST)
message(FATAL_ERROR "TEST is set but unable to find gtest library") message(FATAL_ERROR "TEST is set but unable to find gtest library")
endif() endif()
endif() endif()
else()
add_subdirectory(third_party/googletest/src)
set(GTEST_LIBRARY gtest)
endif()
add_executable(libyuv_unittest ${ly_unittest_sources}) add_executable(libyuv_unittest ${ly_unittest_sources})
target_link_libraries(libyuv_unittest ${ly_lib_name} ${GTEST_LIBRARY}) target_link_libraries(libyuv_unittest ${ly_lib_name} ${GTEST_LIBRARY})