Skip to content

Conversation

@kparzysz-quic
Copy link
Contributor

The gtest framework requires two libraries: gtest and gtest_main. The former is found via find_library, which returns the full path to it. The latter is only added to target_link_libraries as gtest_main. Adding gtest_main to target_link_libraries causes cmake to emit -lgtest_main, but the path to it is not provided (there is no -L flag for it), and the link step can fail.

As a fix, use find_library to get the full path to gtest_main as well.

The gtest framework requires two libraries: gtest and gtest_main. The
former is found via "find_library", which returns the full path to it.
The latter is only added to target_link_libraries as "gtest_main".
Adding "gtest_main" to target_link_libraries causes cmake to emit
-lgtest_main, but the path to it is not provided (there is no -L flag
for it), and the link step can fail.

As a fix, use find_library to get the full path to gtest_main as well.
@tkonolige
Copy link
Contributor

It seems like this problem could be fixed by using find_package(GTest) (https://cmake.org/cmake/help/v3.8/module/FindGTest.html) instead of rolling our own. Is there a reason not to do this?

@kparzysz-quic
Copy link
Contributor Author

It seems like this problem could be fixed by using find_package(GTest) (https://cmake.org/cmake/help/v3.8/module/FindGTest.html) instead of rolling our own. Is there a reason not to do this?

I didn't know about it. I will have the changes ready soon.

@kparzysz-quic
Copy link
Contributor Author

Replaced by #9208

@kparzysz-quic kparzysz-quic deleted the gtest-main-path branch October 6, 2021 14:39
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

Successfully merging this pull request may close these issues.

2 participants