martinus / nanobench

Simple, fast, accurate single-header microbenchmarking functionality for C++11/14/17/20
https://nanobench.ankerl.com
MIT License
1.43k stars 82 forks source link

Add CMake options to disable building tests and examples #73

Closed tocic closed 1 year ago

tocic commented 2 years ago

When building the library using

cmake -B build/ -S .
cmake --build build/

examples and tests are also built. Is it possible to add CMake options for disabling that (see, e.g., google benchmark)? It's useful for packaging.

martinus commented 1 year ago

I'm bad with cmake, if you are still interested could you do a PR?

tocic commented 1 year ago

Actually, I found out that thanks to #60 you can avoid building tests and examples via building only the nanobench target:

cmake --build "build/" --target "nanobench"

It will not eliminate the configuration step for other targets, but that's not critical. Also, it'd be nice to be able to create dynamic and header-only versions of the library with CMake, but those are separate issues.