googletest
googletest copied to clipboard
[FR]: Export a header-only library `GTest::gtest_prod` via CMake
Does the feature exist in the most recent commit?
The Bazel infrastructure already provides a dedicated gtest_prod library, which was introduced by commit 105579a6e43908bc88a289d309492eda8be896be.
Unfortunately, the same does not yet exist for CMake.
Why do we need this feature?
User story
As a C++ application developer using CMake,
I want GoogleTest's CMake config to provide a dedicated header-only library for gtest_prod.h,
so that I can use the FRIEND_TEST() macro in my application code without having to link against the static GTest::gtest library.
Only my unit tests should link against GTest::gtest.
Describe the proposal.
The implementation should look roughly like this:
- In
googletest/CMakeLists.txt, add a library namedgtest_prodof typeINTERFACE. - Include
gtest_prodin the list of targets to be installed. - Add a pkgconf template
googletest/cmake/gtest_prod.pc.inthat adds the correct include-path to the compiler flags.
This will cause a new target, GTest::gtest_prod, to be added to GTestTargets.cmake.
When a user application subsequently links against GTest::gtest_prod in its CMakeLists.txt, the correct include-path will be set. The user application will not pull in the static gtest library.
Is the feature specific to an operating system, compiler, or build system version?
No; this is a platform-agnostic feature. To the best of my knowledge, it does not pose any specific requirements on the CMake version.