From 72f959807d5723c77576e52b1c2b33c28b55f246 Mon Sep 17 00:00:00 2001 From: Andrea Pappacoda Date: Sun, 19 Sep 2021 17:17:02 +0200 Subject: [PATCH] build(cmake): use system GTest when available This speeds up compilation times and makes downstream packaging easier. --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b18c9d..b541bca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,6 +31,10 @@ if(NOT COMMAND add_sanitizers) endif() if(BUILD_TESTS) + find_package(GTest QUIET) + if(TARGET GTest::Main) + add_library(gtest_main ALIAS GTest::Main) + endif() if(NOT TARGET gtest_main) if(NOT EXISTS "${PROJECT_SOURCE_DIR}/googletest/CMakeLists.txt") message(FATAL_ERROR "Could not find googletest: run\n\tgit submodule update --init --recursive\nin base git checkout")