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

gtest.a vs gtest_main.a inconsistency #1015

Closed
travisdowns opened this issue Feb 14, 2017 · 1 comment
Closed

gtest.a vs gtest_main.a inconsistency #1015

travisdowns opened this issue Feb 14, 2017 · 1 comment

Comments

@travisdowns
Copy link

travisdowns commented Feb 14, 2017

The make/Makefile build and the CMake build generate gtest_main.a very differently: the make build includes all of gtest.a in gtest_main.a so you only need to link to gtest_main.a, while in the CMake build the gtest_main.a is very small and only includes the main() function itself, so you need to link to both gtest.a and gtest_main.a.

Since CMake is the primary build system (from what I understand), one could assume the latter approach is the correct one, but the documentation seems to contradict this - directly in the CMakeLists.txt file we have

# Defines the gtest & gtest_main libraries.  User tests should link
# with one of them.

Some more details in this SO answer which also shows some of the confusion this has sowed.

@absassi
Copy link

absassi commented May 24, 2017

For the sake of completeness, I'd like to add that the gmock_main library does include gmock and gtest when built by CMake or by make/Makefile. When using Autotools, the gtest_main built by Makefile.am includes gtest (like make/Makefile) and the gmock_main includes gmock but not gtest (unlike any other).

To summarize, the contents of each library are:

Build method gtest gtest_main gmock gmock_main
CMake gtest gtest_main gtest, gmock gtest, gmock, gmock_main
Makefile gtest gtest, gtest_main gtest, gmock gtest, gmock, gmock_main
Autotools gtest gtest, gtest_main gmock gmock, gmock_main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants