diff options
author | Bruce Lai <bruce.lai@sifive.com> | 2023-03-21 22:43:10 -0700 |
---|---|---|
committer | libyuv LUCI CQ <libyuv-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-04-07 07:31:31 +0000 |
commit | 0b3ac31e4d7440a4419c8fa88bb31f9b9dd61a9c (patch) | |
tree | f2db80d23a162dc296a7a1e8ad40983520a1c2f3 /CMakeLists.txt | |
parent | aa47d668d8c531b0e4e775b236d25b3ad08372f0 (diff) | |
download | libyuv-0b3ac31e4d7440a4419c8fa88bb31f9b9dd61a9c.tar.gz |
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>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index bc641685..fe51ae75 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,19 +53,24 @@ if (JPEG_FOUND) endif() if(TEST) - find_library(GTEST_LIBRARY gtest) - if(GTEST_LIBRARY STREQUAL "GTEST_LIBRARY-NOTFOUND") - set(GTEST_SRC_DIR /usr/src/gtest CACHE STRING "Location of gtest sources") - if(EXISTS ${GTEST_SRC_DIR}/src/gtest-all.cc) - message(STATUS "building gtest from sources in ${GTEST_SRC_DIR}") - set(gtest_sources ${GTEST_SRC_DIR}/src/gtest-all.cc) - add_library(gtest STATIC ${gtest_sources}) - include_directories(${GTEST_SRC_DIR}) - include_directories(${GTEST_SRC_DIR}/include) - set(GTEST_LIBRARY gtest) - else() - message(FATAL_ERROR "TEST is set but unable to find gtest library") + if (NOT CMAKE_CROSSCOMPILING) + find_library(GTEST_LIBRARY gtest) + if(GTEST_LIBRARY STREQUAL "GTEST_LIBRARY-NOTFOUND") + set(GTEST_SRC_DIR /usr/src/gtest CACHE STRING "Location of gtest sources") + if(EXISTS ${GTEST_SRC_DIR}/src/gtest-all.cc) + message(STATUS "building gtest from sources in ${GTEST_SRC_DIR}") + set(gtest_sources ${GTEST_SRC_DIR}/src/gtest-all.cc) + add_library(gtest STATIC ${gtest_sources}) + include_directories(${GTEST_SRC_DIR}) + include_directories(${GTEST_SRC_DIR}/include) + set(GTEST_LIBRARY gtest) + else() + message(FATAL_ERROR "TEST is set but unable to find gtest library") + endif() endif() + else() + add_subdirectory(third_party/googletest/src) + set(GTEST_LIBRARY gtest) endif() add_executable(libyuv_unittest ${ly_unittest_sources}) |