diff options
author | Adrian Imboden <adi@thingdust.com> | 2020-04-07T00·50+0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-07T00·50-0400 |
commit | c01b9916e705dc067d4e3d219ef60b49277353bd (patch) | |
tree | 5c47c808b652a185a57069281897d7760444fbe7 | |
parent | d43b7997c0ca0f3312a51d1057fb73cfe934703b (diff) |
Add option to use an externally provided GoogleTest target (for usage of abseil as add_subdirectory target) (#647)
-rw-r--r-- | CMakeLists.txt | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index e94dcd3f90ec..560f5b4be57f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,6 +81,9 @@ endif() ## pthread find_package(Threads REQUIRED) +option(ABSL_USE_EXTERNAL_GOOGLETEST + "If ON, abseil will assume that the targets for googletest are already provided by the including project folder. This makes sense when abseil is used with add_subproject." OFF) + option(ABSL_USE_GOOGLETEST_HEAD "If ON, abseil will download HEAD from googletest at config time." OFF) @@ -99,14 +102,15 @@ endif() ## check targets if(BUILD_TESTING) - - set(absl_gtest_build_dir ${CMAKE_BINARY_DIR}/googletest-build) - if(${ABSL_USE_GOOGLETEST_HEAD}) - set(absl_gtest_src_dir ${CMAKE_BINARY_DIR}/googletest-src) - else() - set(absl_gtest_src_dir ${ABSL_LOCAL_GOOGLETEST_DIR}) + if (NOT ABSL_USE_EXTERNAL_GOOGLETEST) + set(absl_gtest_build_dir ${CMAKE_BINARY_DIR}/googletest-build) + if(${ABSL_USE_GOOGLETEST_HEAD}) + set(absl_gtest_src_dir ${CMAKE_BINARY_DIR}/googletest-src) + else() + set(absl_gtest_src_dir ${ABSL_LOCAL_GOOGLETEST_DIR}) + endif() + include(CMake/Googletest/DownloadGTest.cmake) endif() - include(CMake/Googletest/DownloadGTest.cmake) check_target(gtest) check_target(gtest_main) |