-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add support for GTest based unit tests. #485
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
Conversation
As Dominic and I have previously discussed, there is some need/desire to improve the testing situation in Google Benchmark. One step to fixing this problem is to make it easier to write unit tests by adding support for GTest, which is what this patch does. By default it looks for an installed version of GTest. However the user can specify -DBENCHMARK_BUILD_EXTERNAL_GTEST=ON to instead download, build, and use copy of gtest from source. This is quite useful when Benchmark is being built in non-standard configurations, such as against libc++ or in 32 bit mode.
❌ Build benchmark 848 failed (commit 6cd3b8eda5 by @EricWF) |
cmake/HandleGTest.cmake
Outdated
add_library(gtest UNKNOWN IMPORTED) | ||
add_library(gtest_main UNKNOWN IMPORTED) | ||
set_target_properties(gtest PROPERTIES | ||
IMPORTED_LOCATION ${install_dir}/lib/libgtest.a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+ INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR}/googletest/include
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack.
cmake/HandleGTest.cmake
Outdated
IMPORTED_LOCATION ${install_dir}/lib/libgtest.a | ||
) | ||
set_target_properties(gtest_main PROPERTIES | ||
IMPORTED_LOCATION ${install_dir}/lib/libgtest_main.a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As Dominic and I have previously discussed, there is some
need/desire to improve the testing situation in Google Benchmark.
One step to fixing this problem is to make it easier to write
unit tests by adding support for GTest, which is what this patch does.
By default it looks for an installed version of GTest. However the
user can specify -DBENCHMARK_BUILD_EXTERNAL_GTEST=ON to instead
download, build, and use copy of gtest from source. This is
quite useful when Benchmark is being built in non-standard configurations,
such as against libc++ or in 32 bit mode.