Skip to content

Support installing test libraries that are not header only #13550

@dbolduc

Description

@dbolduc

In #13546 we made bigtable_mocks header only. We did this to work around a problem.

CMake complained when we tried to export google_cloud_cpp_bigtable_mocks because it cannot find the linked library: GTest::gmock_main. This problem does not come up with interface (header only) libraries.

Finding GTest/GMock can be complicated. We have a helper that defines missing targets, but note that it only does anything if (BUILD_TESTING). Also, we don't really want to Find(GTest) when building our libraries normally.

elseif (NOT BUILD_TESTING)
# Tests are turned off via -DBUILD_TESTING, do not load the googletest or
# googlemock dependency.

Also, we decided1 that we always want to install the mocks (vs. adding another parameter to the CMake configuration). Regardless, we know BUILD_TESTING should not determine whether the mocks are installed. BUILD_TESTING is more for building our unit tests, integration tests, etc.

Part of the problem is that in our cmake-install build, we build with -DBUILD_TESTING=OFF. Of course, this is what most customers will be doing.

Footnotes

  1. This decision may be worth revisiting, although I already released a version of google-cloud-cpp that installs mocks without heeding some extra flag 🤷

Metadata

Metadata

Assignees

Labels

type: cleanupAn internal cleanup or hygiene concern.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions