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

Gmock from source on Debian buster #1022

Merged
merged 4 commits into from
Oct 3, 2019

Conversation

sloretz
Copy link
Contributor

@sloretz sloretz commented Aug 3, 2019

This fixes some issues with gmock tests on Debian buster. The gtest rosdep key resolves to libgtest-dev on Debian buster. This package depends on googletest, and also installs gtest headers to /usr/include. The package googletest includes both gtest and gmock, as source files in /usr/src/googletest/. Additionally there is FindGTest.cmake module installed by the package cmake-data. This situation tricks the current logic.

First the search paths here weren't considering that gtest/gmock could be installed in /usr/src. This PR adds those paths.

Second Because GTest in /usr/include is found by the cmake module, the logic sees GTEST_FOUND but not GMOCK_FOUND. The find_package()'d gtest is used gmock is considered unavailable, but gmock would be available if this code tried to find its sources. This PR refactors the logic to the following:

  1. If both gtest and gmock are found using find_package(), use that
  2. If neither gtest or gmock are found, try to find it them from source and use whatever is found
  3. If only 1 of gtest or gmock is found, try to find both from source. If both are found from source, use that. If only one is found from source, use what was found by the find_package() calls.
  4. Finally try to create gtest, gtest_main, gmock and gmock_main targets if they don't exist no matter where we're using gtest/gmock from.

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
@lromor
Copy link

lromor commented Sep 9, 2019

Thank you for this patch!

@GladOSkar
Copy link

Thanks, works like a charm :)

@dirk-thomas
Copy link
Member

Thanks for the patch.

@dirk-thomas dirk-thomas merged commit 77822d3 into ros:kinetic-devel Oct 3, 2019
mikepurvis added a commit to mikepurvis/catkin that referenced this pull request Nov 8, 2019
mikepurvis added a commit to mikepurvis/catkin that referenced this pull request Nov 8, 2019
dirk-thomas pushed a commit that referenced this pull request Nov 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants