You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support find_package for GTest to avoid redundant downloads #1256
In tests/CMakeLists.txt, the current logic uses pkg_search_module(GTestMain gtest_main) to detect a pre-installed GTest. If not found, it falls back to downloading GTest source via Git.
However, pkg_search_module relies on pkg-config (.pc files), which is not commonly available or generated by package managers like vcpkg on Windows. vcpkg provides CMake config files (e.g., GTestConfig.cmake) instead, which are meant to be used with find_package().
As a result, even when GTest is already installed via vcpkg, pkg_search_module fails to find it, and the build unnecessarily downloads and compiles GTest from source.
Suggestion
Add find_package(GTest) as an additional detection method before falling back to the download step. For example:
find_package(GTestQUIET)
if (NOT GTest_FOUND)
pkg_search_module(GTestMaingtest_main)
endif()
if (NOT GTest_FOUND ANDNOT GTestMain_FOUND)
# Fall back to downloading GTest via Git...endif()
This would allow users with GTest installed via vcpkg (or other CMake-config-based package managers) to use their existing installation without redundant downloads.
Activity
carsonRadtke commentedon Jul 30, 2026
Thanks for reporting this issue; I'd be happy to review a PR.
true-brace05 commentedon Jul 30, 2026
Hi, I've submitted a PR for this issue: #1257. Looking forward to your review. Thanks!
fix(cmake): find_package(GTest) before pkg-config / download (microso…