[SRU] CMake imported targets GTest::gmock and GTest::gmock_main are not available

Bug #1986665 reported by Eero Aaltonen
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cmake
Fix Released
Unknown
cmake (Ubuntu)
Fix Released
Undecided
Unassigned
Focal
Fix Released
Undecided
Unassigned
Jammy
Fix Released
Undecided
Unassigned
Kinetic
Fix Released
Undecided
Unassigned

Bug Description

[ Test plan ]
cat CMakeLists.txt

project(foo)
cmake_minimum_required(VERSION 3.22)
find_package(GTest)

with the patch, a cmake .. and libgmock-dev installed results in this:
grep mock . -Ri
./CMakeFiles/Makefile.cmake: "/usr/lib/x86_64-linux-gnu/cmake/GTest/GMockTargets-none.cmake"
./CMakeFiles/Makefile.cmake: "/usr/lib/x86_64-linux-gnu/cmake/GTest/GMockTargets.cmake"

[ Where problems could occur ]
* Nowhere, its an upstream patch that don't regress the current status quo, just adding some new variables.

[ Other Info ]
The libgtest-dev and libgmock-dev are both built from the googletest source package. Googletest upstream has provided a CMake **config file package** since version 1.8.1, but for many releases, this config file package has not been included in the -dev packages.

When developers build a CMake project that wants to use a prebuilt GoogleTest for testing, they typically call FindPackage(GTest <REQUIRED_VERSION>) to locate the library. Since the config file package has not been included in libgtest-dev, the FindPackage CMake call falls back to using the FindGTest.cmake module originating from cmake and included in the cmake-data package.

So for several releases up to and including jammy jellyfish, the Imported targets:
* GTest::gtest
* GTest::gtest_main
* GTest::gmock
* GTest::gmock_main

have not been available in the distribution provided packages although defined by Googletest upstream.

Issue in CMake issue tracker https://gitlab.kitware.com/cmake/cmake/-/issues/17365
CMake Merge Request https://gitlab.kitware.com/cmake/cmake/-/merge_requests/6632
Issue in Debian CMake packaging https://salsa.debian.org/cmake-team/cmake/-/merge_requests/11

This issue should already be fixed in kinetic, since the CMake version is 3.24, which includes the update to cmake's FindGTest.cmake module.

I would also like to get this to jammy as a low priority update. Applying only the patch to FindGTest.cmake should make the risk of the update negligible.

Revision history for this message
Gianfranco Costamagna (costamagnagianfranco) wrote :

Hello can you please post a debdiff against the jammy version?

Changed in cmake (Ubuntu):
status: New → Fix Released
Changed in cmake (Ubuntu Jammy):
status: New → Confirmed
Revision history for this message
Gianfranco Costamagna (costamagnagianfranco) wrote :

Uploaded in jammy queue

summary: - CMake imported targets GTest::gmock and GTest::gmock_main are not
+ [SRU] CMake imported targets GTest::gmock and GTest::gmock_main are not
available
description: updated
Changed in cmake (Ubuntu Jammy):
status: Confirmed → In Progress
Revision history for this message
Eero Aaltonen (ejn) wrote :

@costamagnagianfranco: I uploaded the changes to https://launchpad.net/~ejn/+archive/ubuntu/cmake-jammy/

and just tested them. Would the diff from https://launchpad.net/~ejn/+archive/ubuntu/cmake-jammy/+packages suffice?

Revision history for this message
Eero Aaltonen (ejn) wrote (last edit ):

Tested with cmake from ppa and `libgmock-dev` installed.

Simple test project.

CMakeLists.txt
==============
cmake_minimum_required(VERSION 3.16)
project(CMake-gmock-test)

include(CTest)

find_package(GTest 1.10.0)

add_executable(test_gmock_tgt main.cpp)
target_link_libraries(test_gmock_tgt GTest::gtest GTest::gmock GTest::gmock_main)
add_test(NAME test_gmock_tgt COMMAND test_gmock_tgt)
==============

main.cpp
========
#include <gtest/gtest.h>
#include <gmock/gmock.h>
========

would compile (and not complain about missing targets) with commands:
```
cmake -S . -B build
cmake --build build/
ctest --test-dir build
```

Revision history for this message
Eero Aaltonen (ejn) wrote :

Full debdiff to ppa version. Contains some timestamp noise.

Revision history for this message
Gianfranco Costamagna (costamagnagianfranco) wrote :

Hello, your patch contained additional files, and missing addition of a new testcase
and refresh of patches that increase the diff of the changes

e.g. of unwanted files:
0003-backport-gmock-and-gmock-main-definitions.patch.focal
0003-backport-gmock-and-gmock-main-definitions.patch.wip

the changes I uploaded to jammy queue for review are really more compact, and this is what we usually want for a stable release update

http://launchpadlibrarian.net/618681604/cmake_3.22.1-1ubuntu1_3.22.1-1ubuntu1.22.04.1.diff.gz

Revision history for this message
Eero Aaltonen (ejn) wrote :

@costamagnagianfranco I posted the debdiff since you asked. I was just surprised that we were working in parallel.

Note that executing that test code requires libgmock-dev to be installed, but libgmock-dev itself depends on cmake.

Revision history for this message
Chris Halse Rogers (raof) wrote :

The [Where problems could occur] section is rather optimistic - there are *plenty* of ways this could cause problems, such as people testing for the existence of the GTest::gmock target and doing something *slighty* different when it doesn't exist which now breaks 👿.

That said, this would be a build-time only problem as we're talking about a testing framework, and the changes necessary to fix it would be pretty obvious.

Changed in cmake (Ubuntu Jammy):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-jammy
Revision history for this message
Chris Halse Rogers (raof) wrote : Please test proposed package

Hello Eero, or anyone else affected,

Accepted cmake into jammy-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/cmake/3.22.1-1ubuntu1.22.04.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-jammy to verification-done-jammy. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-jammy. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Revision history for this message
Ubuntu SRU Bot (ubuntu-sru-bot) wrote : Autopkgtest regression report (cmake/3.22.1-1ubuntu1.22.04.1)

All autopkgtests for the newly accepted cmake (3.22.1-1ubuntu1.22.04.1) for jammy have finished running.
The following regressions have been reported in tests triggered by the package:

sagemath/9.5-4 (amd64)
boost1.74/1.74.0-14ubuntu3 (armhf)

Please visit the excuses page listed below and investigate the failures, proceeding afterwards as per the StableReleaseUpdates policy regarding autopkgtest regressions [1].

https://people.canonical.com/~ubuntu-archive/proposed-migration/jammy/update_excuses.html#cmake

[1] https://wiki.ubuntu.com/StableReleaseUpdates#Autopkgtest_Regressions

Thank you!

Revision history for this message
Gianfranco Costamagna (costamagnagianfranco) wrote :

grep GMock . -R
./CMakeFiles/Makefile.cmake: "/usr/lib/x86_64-linux-gnu/cmake/GTest/GMockTargets-none.cmake"
./CMakeFiles/Makefile.cmake: "/usr/lib/x86_64-linux-gnu/cmake/GTest/GMockTargets.cmake"

confirmed the fix working as expected for me.

tags: added: verification-done verification-done-jammy
removed: verification-needed verification-needed-jammy
Revision history for this message
Gianfranco Costamagna (costamagnagianfranco) wrote :

@ejn I would appreciate a double testing from your side, since you are the original reported of the issue :)

Revision history for this message
Eero Aaltonen (ejn) wrote :

@costamagnagianfranco I can confirm that the test project in comment #4 compiles fine with
3.22.1-1ubuntu1.22.04.1 from jammy-proposed.

Changed in cmake:
status: Unknown → Fix Released
Revision history for this message
Gianfranco Costamagna (costamagnagianfranco) wrote :

thanks!

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package cmake - 3.22.1-1ubuntu1.22.04.1

---------------
cmake (3.22.1-1ubuntu1.22.04.1) jammy; urgency=medium

  * Cherry pick upstream change to fix FindGTest for Gmock (LP: #1986665)

 -- Gianfranco Costamagna <email address hidden> Wed, 17 Aug 2022 12:44:06 +0200

Changed in cmake (Ubuntu Jammy):
status: Fix Committed → Fix Released
Revision history for this message
Łukasz Zemczak (sil2100) wrote : Update Released

The verification of the Stable Release Update for cmake has completed successfully and the package is now being released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Revision history for this message
Eero Aaltonen (ejn) wrote :

Our maintenance effort would benefit if this was also backported to focal. I'm attaching a proposed debdiff patch. With the addition of defining the previous (undocumented) module variables in the config-file package case, it should be fully backwards compatible.

Revision history for this message
Eero Aaltonen (ejn) wrote :

@costamagnagianfranco could you please also add "Also affect CMake (Ubuntu) → Focal" and take a look at my proposed patch when you have time?

Revision history for this message
Gianfranco Costamagna (costamagnagianfranco) wrote :

uploaded in focal queue after changing the changelog entry :)

Changed in cmake (Ubuntu Focal):
status: New → In Progress
Revision history for this message
Timo Aaltonen (tjaalton) wrote : Please test proposed package

Hello Eero, or anyone else affected,

Accepted cmake into focal-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/cmake/3.16.3-1ubuntu1.20.04.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-focal to verification-done-focal. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-focal. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in cmake (Ubuntu Focal):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-focal
removed: verification-done
Revision history for this message
Eero Aaltonen (ejn) wrote (last edit ):

Installed the proposed packages with
    sudo apt-get install cmake=3.16.3-1ubuntu1.20.04.1 cmake-data=3.16.3-1ubuntu1.20.04.1 cmake-qt-gui=3.16.3-1ubuntu1.20.04.1 cmake-doc=3.16.3-1ubuntu1.20.04.1

And compiled two test projects that use the GTest::gmock and GTest::gmock_main targets.

Works like a charm :)

Eero Aaltonen (ejn)
tags: added: verification-done verification-done-focal
removed: verification-needed verification-needed-focal
Revision history for this message
Eero Aaltonen (ejn) wrote :

The test project from comment#4 now builds with cmake 3.16.3-1ubuntu1.20.04 as well as the other projects I tested.

@tjaalton: is there anything else you need from me?

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package cmake - 3.16.3-1ubuntu1.20.04.1

---------------
cmake (3.16.3-1ubuntu1.20.04.1) focal; urgency=medium

  * Backport CMake imported targets GTest::gmock and GTest::gmock_main.
    (LP: #1986665)

 -- Eero Aaltonen <email address hidden> Tue, 27 Sep 2022 12:09:35 +0300

Changed in cmake (Ubuntu Focal):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.