aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2024-04-11 11:04:35 +0300
committerFrank Barchard <fbarchard@chromium.org>2024-04-11 09:09:08 +0000
commit5fb6c8cbe3a68d4c74f0e3166bdc33623cc5f8fe (patch)
tree9f5d187e413b030979e437a4f1ef14f41a31a895
parent38fa3ce2c9e35e7bd2d36aa5de5f58b5307bf470 (diff)
downloadlibyuv-5fb6c8cbe3a68d4c74f0e3166bdc33623cc5f8fe.tar.gz
CMake: Allow the user to set GTEST_SRC_DIR when cross compiling
Previously, we first set GTEST_SRC_DIR as a CACHE variable, which allows the user to set it to a different value if they prefer. Then later, if we're cross compiling, we'd override it to a different value. But when overriding it, we'd lose the value that the user set. Instead set up the default value in a different CMake variable, and set that as default value when setting up the CACHE variable. This way, we have varying defaults, while still respecting the user specified value, if any. Change-Id: I7e571b6251a4d08da02c119a0aad2b1c14585e26 Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/5444428 Reviewed-by: Frank Barchard <fbarchard@chromium.org>
-rw-r--r--CMakeLists.txt5
1 files changed, 3 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7dc0c974..6bf9093c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -146,10 +146,11 @@ endif()
if(UNIT_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")
+ set(GTEST_SRC_DIR_DEFAULT /usr/src/gtest)
if (CMAKE_CROSSCOMPILING)
- set(GTEST_SRC_DIR third_party/googletest/src/googletest)
+ set(GTEST_SRC_DIR_DEFAULT third_party/googletest/src/googletest)
endif()
+ set(GTEST_SRC_DIR ${GTEST_SRC_DIR_DEFAULT} 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)