Skip to content

Support find_package for GTest - #1257

Open
true-brace05 wants to merge 1 commit into
microsoft:mainfrom
true-brace05:fix-find-package-gtest
Open

Support find_package for GTest#1257
true-brace05 wants to merge 1 commit into
microsoft:mainfrom
true-brace05:fix-find-package-gtest

Conversation

@true-brace05

Copy link
Copy Markdown

Summary

This change attempts to locate a pre-installed GoogleTest using find_package(GTest QUIET) before falling back to pkg_search_module and downloading GoogleTest.

This avoids redundant downloads when GoogleTest is already installed through CMake package managers such as vcpkg, while preserving the existing fallback behavior.

Fixes #1256

@true-brace05

Copy link
Copy Markdown
Author

Hi, I've submitted a PR for this issue: #1257. Looking forward to your review. Thanks!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a higher-priority detection path for GoogleTest in tests/CMakeLists.txt so builds can reuse an already-installed GTest (e.g., via vcpkg/CMake package configs) instead of downloading and building it, while retaining the existing download fallback for environments without a preinstalled GTest.

Changes:

  • Attempt to locate GoogleTest via find_package(GTest QUIET) before using pkg_search_module.
  • Keep the existing “download via Git” fallback when no preinstalled GoogleTest is found.
Show a summary per file
File Description
tests/CMakeLists.txt Adds find_package(GTest) as a pre-check before pkg-config detection and the existing download fallback.

Review details

  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread tests/CMakeLists.txt
Comment on lines +25 to +35
find_package(GTest QUIET)

if(GTest_FOUND)
set(GTestMain_LIBRARIES GTest::gtest_main)
endif()

if(NOT GTest_FOUND)
pkg_search_module(GTestMain gtest_main)
endif()

if(NOT GTest_FOUND AND NOT GTestMain_FOUND)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support find_package for GTest to avoid redundant downloads

2 participants