perf-cpp can be build manually or included into CMake projects.
Note: Throughout the documentation, we use ./build
as the build directory.
However, the build directory can be any directory of your choice (including .
).
git clone https://github.com/jmuehlig/perf-cpp.git
cd perf-cpp
# Optional: switch to latest stable version
git checkout v0.9.0
cmake . -B build
cmake --build build
To install the library, specify the CMAKE_INSTALL_PREFIX
:
# Generate Makefile
cmake . -B build -DCMAKE_INSTALL_PREFIX=/path/to/install/dir
# Build
cmake --build build
# Install
cmake --install build
The library will then be available for discovery via CMake and find_package
(see below).
Enable example compilation with -DBUILD_EXAMPLES=1
and build the examples
target:
# Generate Makefile
cmake . -B build -DBUILD_EXAMPLES=1
# Build Library and Examples
cmake --build build --target examples
The example binaries will be located in build/examples/bin
.
By default, perf-cpp is build as a static library.
You can request to build a shared library with -DBUILD_LIB_SHARED=1
:
cmake . -B build -DBUILD_LIB_SHARED=1
cmake --build build
perf-cpp uses CMake as its build system, facilitating integration into additional CMake projects. Choose from the following methods:
Include ExternalProject
in your CMakeLists.txt
and define the project:
include(ExternalProject)
ExternalProject_Add(
perf-cpp-external
GIT_REPOSITORY "https://github.com/jmuehlig/perf-cpp"
GIT_TAG "v0.9.0"
PREFIX "lib/perf-cpp"
INSTALL_COMMAND cmake -E echo ""
)
- Add
lib/perf-cpp/src/perf-cpp-external/include
to yourinclude_directories()
. - Add
lib/perf-cpp/src/perf-cpp-external-build
to yourlink_directories()
.
Note: The directory lib/
can be any folder of your choice.
Include FetchContent
in your CMakeLists.txt
and define the project:
include(FetchContent)
FetchContent_Declare(
perf-cpp-external
GIT_REPOSITORY "https://github.com/jmuehlig/perf-cpp"
GIT_TAG "v0.9.0"
)
FetchContent_MakeAvailable(perf-cpp-external)
- Add
perf-cpp
to your linked libraries. - Add
${perf-cpp-external_SOURCE_DIR}/include/
to your include directories.
If perf-cpp is already installed on your system (see install instructions above), you can simply use find_package
to link it with your project:
find_package(perf-cpp REQUIRED)
target_link_libraries(perf-cpp::perf-cpp)