Skip to content

ament_cmake_gmock: add final fallback to embedded gmock version - #22

Closed
wjwwood wants to merge 4 commits into
masterfrom
embedded_gmock
Closed

wjwwood wants to merge 4 commits into
masterfrom
embedded_gmock

Conversation

@wjwwood

@wjwwood wjwwood commented Aug 18, 2015

Copy link
Copy Markdown
Contributor

This pull request adds an embedded (vendor) version of gmock (1.7.0) which it will use as a last resort if GMOCK_DIR is not set in the environment and if it is not found in /usr/src/... from the Debian package on Ubuntu.

This makes it easier to use on OS X and Windows. The vendor files number 5 and include two headers, two source files, and a CMakeLists.txt. This seems to be the recommended practice for gtest and gmock:

Obviously the fact that others do it isn't proof in of itself, but I think it's a good indication that this is ok.

Also Homebrew actively discourages distributing gmock and gtest in the package manager and recommends you distribute it with your project:

% brew search gmock
Installing gmock system-wide is not recommended; it should be vendored
in your projects that use it.

% brew search gtest
Installing gtest system-wide is not recommended; it should be vendored
in your projects that use it.

@wjwwood wjwwood added the in progress Actively being worked on (Kanban column) label Aug 18, 2015
@wjwwood wjwwood self-assigned this Aug 18, 2015
@wjwwood wjwwood added in review Waiting for review (Kanban column) and removed in progress Actively being worked on (Kanban column) labels Aug 18, 2015

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the _prefix variable is only used in one branch later it should also only be defined there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8d02524

@dirk-thomas

Copy link
Copy Markdown
Contributor

Please also add a note in ament_cmake_gmock/vendor/googlemock-1.7.0 where exactly the included sources come from.

@wjwwood

wjwwood commented Aug 19, 2015

Copy link
Copy Markdown
Contributor Author

Ok 02cb1ef, I also added the LICENSE file and added the BSD license in the package.xml.

@dirk-thomas

Copy link
Copy Markdown
Contributor

LGTM

@wjwwood

wjwwood commented Aug 19, 2015

Copy link
Copy Markdown
Contributor Author

Ok, the Linux and Windows jobs failed.

On Windows, it seems that older (successful) builds were not finding gtest nor gmock:

http://ci.ros2.org/job/ros2_batch_ci_windows/225/consoleFull (search for 'gtest' not found or 'gmock' not found)

For the new job, it fails to link for gtest in test_rclcpp. I'll have to look into that.

On Linux a similar thing is happening where the new job is finding the gtest provided from gmock and is failing:

http://ci.ros2.org/job/ros2_batch_ci_linux/222/consoleFull (search for Found gtest sources under)

The old jobs found gtest in /usr/src/gtest, as I would expect, but gmock has never been found:

http://ci.ros2.org/job/ros2_batch_ci_linux/221/consoleFull (search for 'gmock' not found)

I guess the logic in ament_cmake_gmock which hands the gmock version of gtest over as if it were gtest only is broken. It looks like it just needs the link directories. I'll try to patch it. The interesting thing is that test_rclcpp is trying to find (and in the case of this branch is finding) gmock even when it doesn't depend on it. There must be some indirect dependency by way of the ament_cmake_gmock_find_gtest_hook.cmake "hook". @dirk-thomas is this what you'd expect to happen?

The side effect of delegating to gmock when finding gtest is that it will never find gtest in /usr/src. This would also be true if we installed gmock into the Linux container. What else should happen here, or is this ok?

@wjwwood

wjwwood commented Aug 19, 2015

Copy link
Copy Markdown
Contributor Author

The reason that the OS X job succeeded was that gtest and gtest_main are install libraries on the library path from the Homebrew formula.

I think before we merge this, I think we need to have a consensus on how this should work in different scenarios and make behave that way. I'm not actually using gmock in rclcpp, so I can avoid merging this for the time being.

@dirk-thomas

Copy link
Copy Markdown
Contributor

Whenever gmock is available the boundled gtest version should be used. Only when gmock is not available (which can't be the case anymore when we bundle it) gtest is searched for elsewhere.

In general the search should first look for user provided input, then in the system location and as a last option use the bundled code.

@dirk-thomas dirk-thomas added in progress Actively being worked on (Kanban column) and removed in review Waiting for review (Kanban column) labels Aug 19, 2015
@dirk-thomas dirk-thomas assigned dirk-thomas and unassigned wjwwood Aug 19, 2015
@dirk-thomas dirk-thomas added in review Waiting for review (Kanban column) in progress Actively being worked on (Kanban column) and removed in progress Actively being worked on (Kanban column) in review Waiting for review (Kanban column) labels Aug 19, 2015
@dirk-thomas

Copy link
Copy Markdown
Contributor

I cherry-picked 5d2f8f8215feadc5337152b5ecfd3946ad99b5b1 to the master. I will look into creating a third-party gmock package (similar to uncrustify) which is then optionally used by ament_cmake_gmock.

@dirk-thomas

Copy link
Copy Markdown
Contributor

I have imported the gmock sources into a standalone package: https://github.com/ament/gmock_vendor

#25 will replace this PR.

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.

2 participants