git clone https://github.com/jmuehlig/perf-cpp.git
cd perf-cpp
cmake . -B build
cmake --build build| Option | Default | Description |
|---|---|---|
-DBUILD_EXAMPLES=ON |
OFF |
Build example binaries into build/bin |
-DBUILD_LIB_SHARED=ON |
OFF |
Build as shared library instead of static |
-DBUILD_TESTS=ON |
OFF |
Build unit tests |
-DGEN_PROCESSOR_EVENTS=ON |
OFF |
Embed processor-specific events at compile time (see customizing events) |
Example with multiple options:
cmake . -B build -DBUILD_EXAMPLES=ON -DGEN_PROCESSOR_EVENTS=ON
cmake --build buildNote
-DGEN_PROCESSOR_EVENTS=ON reads events from the event library and generates a source file that can grow large, increasing compilation time significantly.
cmake . -B build -DCMAKE_INSTALL_PREFIX=/path/to/install/dir
cmake --build build
cmake --install buildThe library will then be available via find_package (see below).
include(FetchContent)
FetchContent_Declare(
perf-cpp-external
GIT_REPOSITORY "https://github.com/jmuehlig/perf-cpp"
GIT_TAG "v0.14.1"
)
FetchContent_MakeAvailable(perf-cpp-external)Then link against perf-cpp and add ${perf-cpp-external_SOURCE_DIR}/include/ to your include directories.
include(ExternalProject)
ExternalProject_Add(
perf-cpp-external
GIT_REPOSITORY "https://github.com/jmuehlig/perf-cpp"
GIT_TAG "v0.14.1"
PREFIX "lib/perf-cpp"
INSTALL_COMMAND cmake -E echo ""
)Then add lib/perf-cpp/src/perf-cpp-external/include to your include directories and lib/perf-cpp/src/perf-cpp-external-build to your link directories.
If perf-cpp is installed on your system:
find_package(perf-cpp REQUIRED)
target_link_libraries(your_target perf-cpp::perf-cpp)