-
Notifications
You must be signed in to change notification settings - Fork 281
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 CMake config mode for gMock detection #2716
Conversation
unitTests/CMakeLists.txt
Outdated
@@ -1,4 +1,5 @@ | |||
find_package(GTest REQUIRED) | |||
# Prefer using Google suplied CMake config as bult-in module is buggy before 3.23 | |||
find_package(GTest REQUIRED CONFIG) |
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.
If gtest supplies COMPONENTS, then declare a components required.
In the case that gtest is installed but gmock is not installed, the find_package returns found but the gmock namespace target wont exist.
find_package(GTest REQUIRED COMPONENTS gtest gmock gtest_main gmock_main)
There's some churn around the target names depending on how it was found, but that's the idea.
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.
I had a quick look already beforehand, I don't think it (i.e. the package supplied CMake config) does...
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.
But there's a different problem: at least on Fedora, both gmock
(pulled in by gtest-devel
) and gmock-devel
ship the shared objects (the gmock-devel
just the unversioned symlinks though), so this actually doesn't catch the missing gmock-devel
...
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.
FWIW for meson, I use gmock_main as the dependency.
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.
I tried using components on my branch use-gtest-components
like so:
find_package(GTest CONFIG COMPONENTS gtest_main gmock_main)
On Ubuntu 22.04 with libgmock-dev
istalled, the package found returns successfully.
If I add a bogus component foobar
, the gtest find package call reports the component as found. Seems like a bug to me in their find module. I'll file a report against googletest
.
df3b3d3
to
e5e812a
Compare
Codecov Report
@@ Coverage Diff @@
## main #2716 +/- ##
=======================================
Coverage 63.91% 63.91%
=======================================
Files 103 103
Lines 22313 22313
Branches 10804 10804
=======================================
Hits 14261 14261
Misses 5828 5828
Partials 2224 2224 |
42204d2
to
98decef
Compare
98decef
to
eddfe7f
Compare
@@ -24,7 +24,7 @@ debian_build_gtest() { | |||
centos_build_inih() { | |||
[-d inih_build ] || git clone https://github.com/benhoyt/inih.git inih_build | |||
cd inih_build | |||
git checkout r56 |
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.
@eli-schwartz since the wrap is in here, can this section be replaced?
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.
I think this is also used for installing dependencies before running cmake.
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.
I asked Bard about this. It told me about an imaginary function called cmake_subproject that supported meson. And yes, it is. I was thinking mostly of replacing that git clone.
@Mergifyio backport 0.28.x |
✅ Backports have been created
|
No description provided.