You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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).
The
make/Makefile
build and theCMake
build generategtest_main.a
very differently: themake
build includes all ofgtest.a
ingtest_main.a
so you only need to link togtest_main.a
, while in theCMake
build thegtest_main.a
is very small and only includes themain()
function itself, so you need to link to bothgtest.a
andgtest_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 theCMakeLists.txt
file we haveSome more details in this SO answer which also shows some of the confusion this has sowed.
The text was updated successfully, but these errors were encountered: