-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use system googletest dependency when available #304
base: main
Are you sure you want to change the base?
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
@Mizux does that look good to you? |
@@ -184,7 +184,8 @@ if(BUILD_TESTING) | |||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | |||
set(CMAKE_CXX_EXTENSIONS OFF) # prefer use of -std14 instead of -gnustd14 | |||
|
|||
if(NOT TARGET gtest OR NOT TARGET gmock_main) | |||
find_package(GTest REQUIRED) | |||
if(NOT TARGET GTest::gtest OR NOT TARGET GTest::gmock_main) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my 2 cents,
-
GTest::gtest seems to be available only since CMake 3.5 (cpu_feature still use 3.0 as minimum requirement...)
ref: https://cmake.org/cmake/help/v3.5/module/FindGTest.html
ref: https://cmake.org/cmake/help/v3.4/module/FindGTest.html -
Googletest didn't provide these aliases until recently
issue: Add CMake aliases googletest#2429
PR: CMake: Add namespaced ALIAS library googletest#3155
commit: google/googletest@6c5c455
available in v1.14.0 … release-1.11.0
to compare with https://repology.org/project/gtest/badges (e.g. ubuntu 20.04 LTS => gtest 1.10.0)
-
If your superbuild is using
add_subdirectory()
ORfetch_content()
(without the new flagFIND_PACKAGE_ARGS NAMES ...
) then youfind_package()
won't work as expected (i.e. ignore the call since your super already provide it)
ref: https://cmake.org/cmake/help/latest/module/FetchContent.html#integrating-with-find-package -
Also in 3.24 we would be able to have FetchContent calling find_package() before sourcing if unavailable...
ref: https://cmake.org/cmake/help/latest/module/FetchContent.html#variable:FETCHCONTENT_TRY_FIND_PACKAGE_MODE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EDIT:
- DONE (we now target cmake 3.13)
- googletest v1.11 (June 2021) should provide alias -> Can we suppose super build use at least googletest 1.11 ?
@@ -184,7 +184,8 @@ if(BUILD_TESTING) | |||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | |||
set(CMAKE_CXX_EXTENSIONS OFF) # prefer use of -std14 instead of -gnustd14 | |||
|
|||
if(NOT TARGET gtest OR NOT TARGET gmock_main) | |||
find_package(GTest REQUIRED) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since you add REQUIRED
-> if not found the cmake configure will fail where instead you would like to fallback to "build googletest if not found in the system"
No description provided.