Ask Your Question
1

Installing binaries linked against gtest

asked 2014-07-17 16:47:10 -0600

ahendrix gravatar image

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?

edit retag flag offensive close merge delete

Comments

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

William gravatar imageWilliam ( 2014-07-18 20:02:11 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-07-18 20:14:32 -0600

Dirk Thomas gravatar image

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.

edit flag offensive delete link more

Comments

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?

ahendrix gravatar imageahendrix ( 2014-07-19 18:36:20 -0600 )edit

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.

Dirk Thomas gravatar imageDirk Thomas ( 2014-07-19 21:50:43 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-07-17 16:47:10 -0600

Seen: 238 times

Last updated: Jul 18 '14