Commit Graph

74 Commits

Author SHA1 Message Date
Yingwei Zheng 3b19d7222d
Fix CPU frequency estimation on riscv (#1549)
* Fix CPU frequency estimation on riscv

* Cleanup code for CPU frequency estimation

* Fix use before definition of the macro

* Move the platform definitions back

* Fix compilation error on windows

* Remove unused sleep.h and sleep.cc
2023-02-21 11:30:28 +00:00
dominic hamon da652a7486
Try removing attempt to set the C++ standard (#1464)
* Try removing attempt to set the C++ standard

Fixes #1460 #1462

* set the standard to 11

* spell it right

* had it right the first time

* require std 11

* plumb through the standard to cxxfeaturecheck

* use policy instead

* can't use policy just yet

* Update CXXFeatureCheck.cmake

* fix CXX_STANDARD_REQUIRED statement

Co-authored-by: Dominic Hamon <dominichamon@users.noreply.github.com>
2022-12-10 19:42:44 -04:00
babbaj 2a78e8cbe9
use CMAKE_INSTALL_FULL in pkg-config file (#1473) 2022-08-23 23:28:02 +03:00
Dominic Hamon 77d1e74d29
add debug option for enabling more output for failed cxxfeaturechecks (#1467)
fixes #1466
2022-08-10 20:42:27 +01:00
Dominic Hamon 974cd5a5c5
Ensure we don't need benchmark installed to pass c++ feature checks (#1456)
* Ensure we don't need benchmark installed to pass c++ feature checks

Requires removal of some dependencies on benchmark.h from internal
low-level headers, which is a good thing.

Also added better logging to the feature check cmake module.
2022-08-04 15:33:35 +01:00
Dominic Hamon 8205547ceb
fix sanitizer builds by using clang 13 (#1426)
* attempt to fix sanitizer builds by moving away from llvm head

* extra verbosity

* try clang 13 and add extra logging

* get latest clang and try again
2022-07-05 10:41:38 +01:00
Dominic Hamon 6cf20f1e02
Suppress GoogleTest warnings on windows (MSVC) too. (#1320)
Fixes #1209
2022-01-13 14:21:43 +00:00
Dominic Hamon 1f99405076
update googletest to latest release tag 1.11.0 (#1301)
* update googletest to latest release tag 1.11.0

* fix cmake builds to the same release
2021-12-08 16:30:03 +00:00
dominc8 680d3fdbb5
Add clang-tidy check (#1290)
* Add clang-tidy.yml and .clang-tidy

* Add mention to authors/contributors

* Temp fix 2 clang-tidy issues

* Enable clang-tidy on pull requests

* Exclude gtest source files from clang-tidy
2021-11-25 15:47:44 +00:00
Donald Aingworth a07f6d1789
Googletest renamed master to main today. (#1285)
Co-authored-by: Donald Aingworth <donald@midpointmarkets.org>
2021-11-17 09:45:03 +00:00
Sergiu Deitsch 1be88c0683 cmake: allow to use package config from build directory 2021-10-19 11:11:11 +02:00
Sergiu Deitsch eb9100bf41 cmake: make package config relocatable 2021-10-19 11:05:29 +02:00
Roman Lebedev 2f30903ca2
GoogleTest.cmake.in: mention BENCHMARK_USE_BUNDLED_GTEST 2021-10-19 11:32:26 +03:00
Roman Lebedev 8c8052aa7b
GoogleTest.cmake.in: immediately error-out after failure message, Closes #1255
Results in a bit nicer output when googletest was not found.
2021-10-19 11:31:32 +03:00
Roman Lebedev e7a8415876
CMake: add forgotten include(FeatureSummary) into FindPFM.cmake to fix build
Sorry!
2021-09-03 01:15:09 +03:00
Roman Lebedev e7fa637cbe
[NFC] PFM: actually report package as found, and advertise description
This slightly prettifies the CMake's `feature_summary()` output,
should the library be built as part of some project that then prints
the CMake summary.
2021-08-23 19:36:34 +03:00
Dominic Hamon 07f833d6b2 so much for googletest not failing any more 2021-08-11 15:10:02 +01:00
Dominic Hamon d0db4e01c1 turn back on strict mode for googletest as it no longer breaks 2021-08-11 15:01:17 +01:00
Dominic Hamon ab74ae5e10
downgrade warnings for googletest (#1203)
fixes #1202. sort of.
2021-07-19 12:11:13 +01:00
Kai Germaschewski a4bcd937b2
fix version recorded in releases (#1047)
* cmake: fix handling the case where `git describe` fails

* cmake: fix version recorded in releases

If downloaded as a tarball release, there will be no info from git
to determine the release, so it ends up v0.0.0. If that's the case,
we'll now use the release specified in the project() command,
which needs to be updated for each new release.

* cmake: add `--tags` to `git describe`

That way, lightweight tags will also be taken into account, which should
never hurt, but it'll help in cases where, for some mysterious reason or
other, annotated tags don't make it into a clone.

* update releasing.md
2021-05-20 17:59:29 +01:00
Mircea Trofin 376ebc2635
Support optional, user-directed collection of performance counters (#1114)
* Support optional, user-directed collection of performance counters

The patch allows an engineer wishing to drill into the root causes
of a regression, for example. Currently, only single threaded runs
are supported. The feature is a build-time opt in, and then a runtime
opt in.

The engineer may run the benchmark executable, passing a list of
performance counter names (using libpfm's naming scheme) at the
command line. The counter values will then be collected and reported
back as UserCounters.

This is different from #240 in that it is a benchmark user opt-in, and
the counter collection is transparent to the benchmark.

Currently, this is only supported on platforms where libpfm is
supported.

libpfm: http://perfmon2.sourceforge.net/

* 'Use' values param in Snapshot when BENCHMARK_OS_WINDOWS

This is to avoid unused parameter warning-as-error

* Added missing include for <vector> in perf_counters.cc

* Moved doc to docs

* Added license blurbs
2021-04-28 09:25:29 +01:00
Kai Germaschewski d882be1ea9
fix cmake issue with referencing a non-existing function argument (#1118)
according to https://cmake.org/cmake/help/latest/command/function.html,
"Referencing to ARGV# arguments beyond ARGC have undefined behavior.",
which I hit with cmake 3.19.7.

This uses ARGC to check whether ARGV1 has been passed before referencing
it.
2021-04-26 09:15:07 +01:00
Vitaly Zaitsev 7efada2dac
Fixed pkg-config on other than Ubuntu GNU/Linux distributions. (#1043)
Signed-off-by: Vitaly Zaitsev <vitaly@easycoding.org>
2020-09-12 18:56:43 +03:00
Jeremy Ong 01c0ab7cbb
Fix Clang builds on Windows (#1021)
Fixes #974. The `cxx_feature_check` now has an additional
optional argument which can be used to supply extra cmake flags
to pass to the `try_compile` command. The `CMAKE_CXX_STANDARD=14`
flag was determined to be the minimum flag necessary to correctly
compile and run the regex feature checks when compiling with Clang
under Windows (n.b. this does *not* refer to clang-cl, the frontend
to the MSVC compiler). The additional flag is not enabled for any
other compiler/platform tuple.
2020-08-27 11:17:19 +01:00
Dominic Hamon 5c25ad3acb
Ctest support (#1025)
* ctest is now working

* Update README

* remove commented out lines

* Tweaked docs

Added note to use parallel and cleaned build config notes

* Response to comments

* revert all but the readme

* make error message clearer

* drop --parallel
2020-08-21 16:25:56 +01:00
Kyle Edwards f4f5dba46b Cache RUN_${FEATURE} variable in CXXFeatureCheck.cmake (#886)
When cross-compiling, this variable was not set on the second run
of CMake, resulting in the next check failing even though it shouldn't
be run in the first place. Fix this by caching the variable.
2019-10-04 09:50:53 +01:00
Attila M. Szilagyi ef7d51c8eb Allow setting GOOGLETEST_PATH cmake argument. Fixes #867 (#868)
In `cmake/GoogleTest.cmake`, GOOGLETEST_PATH is default-initialized, but that init forgot to
account for the fact that the patch is explicitly supposed to be user-configurable.
By passing `CACHE` to `set()` we avoid that error.
2019-09-15 20:25:32 +03:00
Roman Lebedev 727a81aabd
CMake: avoid incorrect extra "" around the GOOGLETEST_PATH.
It was looking in `"<...>/googlebenchmark/build/third_party/googletest"`,
with these extra `"` quotes, and wasn't finding anything..
2019-04-30 19:33:09 +03:00
Roman Lebedev 4b77194032
CMake: codedrop of googletest cmake magic from me (#809)
https://github.com/google/benchmark/pull/801 is stuck with some cryptic cmake failure due to
some linking issue between googletest and threading libraries.

I suspect that is mostly happening because of the, uhm,
intentionally extremely twisted-in-the-brains approach that is being used to
actually build the library as part of the buiild,
except without actually building it as part of the build.

If we do actually build it as part of the build,
then all the transitive dependencies should magically be in order,
and maybe everything will just work.

This new version of cmake magic was written by me in
0e22f085c5/cmake/Modules/GoogleTest.cmake.in
0e22f085c5/cmake/Modules/GoogleTest.cmake, based on the official googletest docs and LOTS of experimentation.
2019-04-30 13:36:29 +03:00
Daniel Kraft 97393e5ef8 Add -lpthread to pkg-config Libs.private. (#755)
Since pthread is required at least for GCC (according to the
documentation), this should be reflected by the pkg-config file.

The same is, for instance, also done by the gflags library:
1005485222/cmake/package.pc.in (L13)
2019-02-01 15:51:44 +03:00
Dominic Hamon bb15a4e3bf Ensure all informational cmake messages have STATUS type 2018-11-13 09:56:22 +00:00
Olzhas Kaiyrakhmet d731697a5d Fix SOURCE_DIR in HandleGTest.cmake (#705)
If benchmark added as cmake subproject, HandleGTest throws an error as  does return absolute source dir.
Change it to , so it will be refering to it's own source dir.

Also see PR #703.
2018-10-13 01:06:41 -07:00
Eric 8356d646bf
Revert "Fix SOURCE_DIR in HandleGTest.cmake (#703)" (#704)
This reverts commit 609752306f.
2018-10-13 00:53:25 -07:00
Olzhas Kaiyrakhmet 609752306f Fix SOURCE_DIR in HandleGTest.cmake (#703)
* Fix SOURCE_DIR in HandleGTest.cmake

If benchmark added as cmake subproject, HandleGTest throws an error as  does return absolute source dir.
Change it to , so it will be refering to it's own source dir.
2018-10-13 00:51:51 -07:00
Gregorio Litenstein 9ffb8df6c5 Fix Clang Detection (#697)
For several versions now, CMake by default refers to macOS’ Clang as AppleClang instead of just Clang, which would fail STREQUAL. Fixed by changing it to MATCHES.
2018-10-05 16:44:02 +01:00
Deniz Evrenci 6d74c0625b split_list is not defined for assembly tests (#595)
* Update AUTHORS and CONTRIBUTORS

* split_list is not defined for assembly tests
2018-05-14 15:02:49 +01:00
Roman Lebedev e8ddd907bb There is no "FATAL" in message(), only "FATAL_ERROR" (#584) 2018-05-08 11:33:37 +01:00
php1ic 16af64500f Run git from the source directory (#589) (#590)
Git was being executed in the current directory, so could not get the
latest tag if cmake was run from a build directory. Force git to be
run from with the source directory.
2018-05-08 11:29:09 +01:00
Yangqing Jia 105ac14b2f Add caching for cxx_feature_check (#573) 2018-04-23 20:57:03 +01:00
Eric Fiselier 2844167ff9 Fix #564 - gmock/gmock.h not found in benchmark tests. 2018-04-05 18:34:13 -06:00
Eric Fiselier 68e228944e Fix #538 - gtest.h not found when building with older CMake versions.
Older CMake versions, in particular 2.8, don't seem to correctly handle
interface include directories. This causes failures when building the
tests. Additionally, older CMake versions use a different library install
directory than expected (i.e. they use lib/<target-triple>). This caused
certain tests to fail to link.

This patch fixes both those issues. The first by manually adding the
correct include directory when building the tests. The second by specifying
the library output directory when configuring the GTest build.
2018-03-21 13:27:04 -06:00
Eric 207b9c7aec
Improve State packing: put important members on first cache line. (#527)
* Improve State packing: put important members on first cache line.

This patch does a few different things to ensure commonly accessed
data is on the first cache line of the `State` object.

First, it moves the `error_occurred_` member to reside after
the `started_` and `finished_` bools, since there was internal
padding there that was unused.

Second, it moves `batch_leftover_` and `max_iterations` further up
in the struct declaration. These variables are used in the calculation
of `iterations()` which users might call within the loop. Therefore
it's more important they exist on the first cache line.

Finally, this patch turns the bool members into bitfields. Although
this shouldn't have much of an effect currently, because padding is
still needed between the last bool and the first size_t, it should
help in future changes that require more "bool like" members.

* Remove bitfield change for now

* Move bools (and their padding) to end of "first cache line" vars.

I think it makes the most sense to move the padding required
following the group of bools to the end of the variables we want
on the first cache line.

This also means that the `total_iterations_` variable, which is the
most accessed, has the same address as the State object.

* Fix static assertion after moving bools
2018-02-14 13:44:41 -07:00
Eric Fiselier 562f9d256d Fix GTest workaround on MSVC 2018-02-12 18:43:32 -07:00
Eric 906749a48e Work around Gtest build failure caused by -Werror=unused-function. (#529)
We're propagating extra warning flags to the gtest build, which
can cause it to fail. This patch prevents passing "-Wextra" to
gtest, since the library itself doesn't test with that flag.
2018-02-12 17:11:01 -08:00
Eric Fiselier 778b85a7a9 Prevent GTest and GMock from being installed with Google Benchmark.
When users satisfy the GTest dependancy by placing a googletest
directory in the project, the targets from GTest and GMock incorrectly
get installed along side this library. We shouldn't be installing
our test dependancies.

This patch forces the options that control installation for googletest
to OFF.
2018-01-05 11:04:22 -07:00
Eric 7db02be244
Add support for GTest based unit tests. (#485)
* Add support for GTest based unit tests.

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.
2017-12-13 16:26:47 -07:00
Roman Lebedev c45f01866b CMake: implement LTO for clang. Fixes #478 (#487)
* CMake: implement LTO for clang. Fixes #478

* LTO: add basic docs about required executables.
2017-11-29 12:48:43 -08:00
Steinar H. Gunderson 0c3ec998c4 Add a pkg-config file, for the benefit of projects not using CMake. (#480) 2017-11-15 11:51:22 -08:00
Roman Lebedev 6e06648133 Attempting to resolve a submoduling issues... (#439) 2017-08-28 16:10:19 -07:00
Victor Costan 902936033d CMake: Fallback from try_run to try_compile when cross-compiling. (#436) 2017-08-15 15:53:30 -07:00