Closed mrboojum closed 1 year ago
this is not the case. there are two libraries built, one with the main and one without: https://github.com/google/benchmark/blob/main/src/CMakeLists.txt#L67 is where the benchmark_main is built.
perhaps you're depending on the wrong library?
your executable should link against the library without main and not include a BENCHMARK_MAIN
statement.
I agree with @dmah42's take.
I'm going to tentatively close this.
Is your feature request related to a problem? Please describe. The usage of the benchmark main function currently can't be explicitly disabled. This makes it impossible to use both benchmark and boost test in a system because the benchmark main is used during the auto linking.
Describe the solution you'd like The benchmark main function to be surrounded by a safeguard for example like below. This would not interfere with any existing usage and adds minimal complexity. `
ifndef NO_BENCHMARK_MAIN
define BENCHMARK_MAIN()
int main(int argc, char argv) { ... return 0; } int main(int, char)
endif
`
Describe alternatives you've considered Creating an issue with vcpkg, will most likely result in referring to benchmakr/boost Creating an issue with boost test, but the boost test main is actually the one i want to use (not my own main). Adding the above compiler safequards on our systems only.
Additional context Problem reproduceable by creating a setup with vcpkg that uses the boost test main in a program that depends on third library that depends on benchmark library. System: Windows, msvc17.5.3, vpckg tag 2023.02.24 with both benchmark, boost installed Create a test executable that depends on the boost main '
define BOOST_TEST_MODULE test MY_TEST
include <boost/test/unit_test.hpp>
add a test '