Skip to content
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

Merged
merged 2 commits into from
Jul 21, 2023
Merged

Use CMake config mode for gMock detection #2716

merged 2 commits into from
Jul 21, 2023

Conversation

kmilos
Copy link
Collaborator

@kmilos kmilos commented Jul 21, 2023

No description provided.

@ghost
Copy link

ghost commented Jul 21, 2023

👇 Click on the image for a new way to code review

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

@@ -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)
Copy link
Contributor

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.

Copy link
Collaborator Author

@kmilos kmilos Jul 21, 2023

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...

Copy link
Collaborator Author

@kmilos kmilos Jul 21, 2023

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...

Copy link
Collaborator

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.

Copy link
Contributor

@Ryanf55 Ryanf55 Jul 22, 2023

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.

@codecov
Copy link

codecov bot commented Jul 21, 2023

Codecov Report

Merging #2716 (eddfe7f) into main (3e8e09d) will not change coverage.
The diff coverage is n/a.

@@           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           

@@ -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
Copy link
Collaborator

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?

Copy link
Contributor

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.

Copy link
Collaborator

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.

@neheb neheb merged commit b42586b into main Jul 21, 2023
@neheb neheb deleted the kmilos/cmake_gmock branch July 21, 2023 18:45
@neheb
Copy link
Collaborator

neheb commented Jul 22, 2023

@Mergifyio backport 0.28.x

@mergify
Copy link
Contributor

mergify bot commented Jul 22, 2023

backport 0.28.x

✅ Backports have been created

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.

4 participants