0
$\begingroup$

Rosanswers logo

I have an interesting circumstance where the public API for my package (diagnostics_aggregator) includes a test node which other packages can use as a test fixture in their tests. This test node builds and links against gtest, which isn't available on all platforms, but I would like to make it part of the binary packages where possible.

What is the recommended way to install a binary that is compiled and linked against gtest?

  • Having an install statement inside of my check for CATKIN_ENABLE_TESTING feels wrong
  • Assuming that gtest is available and can be linked to will likely fail on systems that don't have it

Does catkin expose a separate flag to indicate if gtest has been found or not? Is it set appropriately on the build farm, so that I can guarantee that binary packages are built with all of the expected nodes?


Originally posted by ahendrix on ROS Answers with karma: 47576 on 2014-07-17

Post score: 1


Original comments

Comment by William on 2014-07-18:
I dunno, it might be that you must install the code and build it for each package which uses it. This is essentially how gtest is distributed for Ubuntu (source code goes into /usr/src/gtest or something like that).

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

catkin does find GTest for you and provides the common CMake variables for it:

GTEST_FOUND
GTEST_INCLUDE_DIRS
GTEST_LIBRARIES
GTEST_MAIN_LIBRARIES
GTEST_BOTH_LIBRARIES

But all test related CMake functions (like catkin_add_gtest) will not be available when testing is not enabled.

On the buildfarm when generating debs you can't expect testing to be enabled. Since you want the artifact to be included in the Debian package it must be done outside of the CATKIN_ENABLE_TESTING block.

It is also your responsibility to install the gtest library. Be aware that no downstream package should ever use your packaged version of the gtest library but build it on its own (see gtest docs for more details why). Also you should make sure that your package does not conflict with other packages doing the same - so the library should be named in a way that does not interfere with other code.


Originally posted by Dirk Thomas with karma: 16276 on 2014-07-18

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by ahendrix on 2014-07-19:
Do I still need to build and install the gtest library myself if I'm using the version of gtest that is provided by catkin?

Comment by Dirk Thomas on 2014-07-19:
catkin only does some CMake stuff to find the gtest sources and add their subdirectory with its own CMake code. When ever you use any of these functions gtest will be built. The gtest libraries are never installed by catkin though.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.