-
Notifications
You must be signed in to change notification settings - Fork 433
Description
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.
google-cloud-cpp/cmake/FindGMockWithTargets.cmake
Lines 98 to 100 in 48644a7
| 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
-
This decision may be worth revisiting, although I already released a version of
google-cloud-cppthat installs mocks without heeding some extra flag 🤷 ↩