BPHash
General object hashing library for C++
Building and Testing

Table of Contents

Overview

The BPHash project is configured and built using CMake (https://cmake.org).

Dependencies

The only dependencies are a C++ compiler (and standard libraries) capable of compiling C++11 (in particular, variadic templates) and CMake (v3.1.3 or above).

Building

The basic building steps are the traditional CMake steps:

1 mkdir build
2 cd build
3 cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/path/to/install ../
4 make
5 make test
6 make install

There are a few more helpful options:

BUILD_SHARED_LIBS can be set to True to build a shared library, rather than the default static library.

1 cmake -DCMAKE_BUILD_TYPE=Release \
2  -DCMAKE_INSTALL_PREFIX=/path/to/install \
3  -DBUILD_SHARED_LIBS=True \
4  ../

CMAKE_CXX_FLAGS can be set to compiler-specific optimization flags. For example, to let g++ autodetect the best optimization for the current system, you can use

1 cmake -DCMAKE_BUILD_TYPE=Release \
2  -DCMAKE_INSTALL_PREFIX=/path/to/install \
3  -DCMAKE_CXX_FLAGS="-march=native" \
4  ../

For the Intel compiler, the equivalent would be

1 cmake -DCMAKE_BUILD_TYPE=Release \
2  -DCMAKE_INSTALL_PREFIX=/path/to/install \
3  -DCMAKE_CXX_FLAGS="-xHOST" \
4  ../

Testing & Benchmarking

Testing is done with make test. A quick benchmark can be run with the test_benchmark program. To do so, run the following command from the top-level build directory:

1 test/test_benchmark 1048576

The only argument is the size of the data set to benchmark with (in bytes).

Installation & Including in Other Projects

make install will install the headers and library. It will also install a CMake configuration file that can be used to include BPHash in other projects. This creates a CMake interface target that can be used with target_link_libraries. The top-level install path (what was passed to CMAKE_INSTALL_PREFIX) must be in your CMAKE_PREFIX_PATH (or be one of the system defaults).

1 # Make sure that the top-level install path is in the CMAKE_PREFIX_PATH
2 find_package(bphash)
3 
4 # Later, link to it. This will also pull in header paths
5 target_link_libraries(myproject bphash).

Note that your project must be built with (at least) C++11 support.