Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR]: Export a header-only library GTest::gtest_prod via CMake #4673

Open
sicherha opened this issue Dec 3, 2024 · 0 comments · May be fixed by #4680
Open

[FR]: Export a header-only library GTest::gtest_prod via CMake #4673

sicherha opened this issue Dec 3, 2024 · 0 comments · May be fixed by #4680

Comments

@sicherha
Copy link

sicherha commented Dec 3, 2024

Does the feature exist in the most recent commit?

The Bazel infrastructure already provides a dedicated gtest_prod library, which was introduced by commit 105579a.

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 named gtest_prod of type INTERFACE.
  • Include gtest_prod in the list of targets to be installed.
  • Add a pkgconf template googletest/cmake/gtest_prod.pc.in that 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.

@mp-chet mp-chet linked a pull request Dec 12, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant