Skip to content

Install

David Aceituno edited this page Dec 21, 2021 · 2 revisions

See full installation examples under quickstart. Find a summary below.

Option 1: Install with Conan (Recommended)

Make sure to install and configure Conan first. You may need to add the line compiler.cppstd=17 under [settings] in your conan profile ~/.conan/profile/default. Add ConanCenter to your list of conan remotes, e.g.

> conan remote add conancenter https://center.conan.io

Then run the following command to install from ConanCenter:

> conan install h5pp/1.9.0@ --build=missing

The flag --build=missing lets conan install dependencies: HDF5, Eigen and fmt and spdlog.

Note that you can also (as an alternative) use the file conanfile.py bundled with h5pp to create and install directly after cloning this git repo

> git clone https://github.com/DavidAce/h5pp.git
> cd h5pp
> conan create . davidace/stable --build=missing

After installation, use h5pp like any other conan package. For more information refer to the conan docs or have a look at quickstart.

Option 2: Git clone + CMake install

After cloning this repository, build the library just as any CMake project. For example, run the following commands:

    mkdir build
    cd build
    cmake -DCMAKE_INSTALL_PREFIX=<install-dir>  <source-dir>
    make
    make install

Headers will be installed under <install-dir>/include and config files under <install-dir>/share/h5pp/cmake. These config files allow you to usefind_package(h5pp) in your own projects, which in turn defines the target h5pp::h5pp with everything you need to link h5pp correctly (including dependencies if you so choose: see below).

Opt-in automatic dependency installation with CMake

The CMake flag H5PP_PACKAGE_MANAGER controls the automated behavior for finding or installing dependencies. It can take one of these string values:

Value Description
none Skip handling dependencies
find (default) Use CMake's find_package to find dependencies
cmake ¹ Use isolated CMake instances to download and install dependencies during configure. Disregards pre-installed dependencies on your system
fetch ² Use FetchContent to download and install dependencies. Disregards pre-installed dependencies on your system
cpm ³ Use https://github.com/cpm-cmake/CPM.cmaketo download and install dependencies. Disregards pre-installed dependencies on your system
find-or-cmake Start with find and then go to cmake if not found
find-or-fetch Start with find and then go to fetch if not found
find-or-cpm Start with find and then go to cpm if not found
conan Use the Conan package manager to download and install dependencies automatically. Disregards libraries elsewhere on your system

There are several variables you can pass to CMake to guide find_package calls and install location, see CMake options below.

¹ Dependencies are installed into ${H5PP_DEPS_INSTALL_DIR}[/<PackageName>], where H5PP_DEPS_INSTALL_DIR defaults to CMAKE_INSTALL_PREFIX and optionally /<PackageName> is added if H5PP_PREFIX_ADD_PKGNAME=TRUE

² Dependencies are installed into ${CMAKE_INSTALL_PREFIX}[/<PackageName>].

³ Dependencies are installed into ${CMAKE_INSTALL_PREFIX}.

Conan is guided by conanfile.txt found in this project's root directory. This method requires conan to be installed prior (for instance through pip, conda, apt, etc). To let CMake find conan you have three options:

  • Add Conan install (or bin) directory to the environment variable PATH.
  • Export Conan install (or bin) directory in the environment variable CONAN_PREFIX, i.e. from command line: export CONAN_PREFIX=<path-to-conan>
  • Give the variable CONAN_PREFIX directly to CMake, i.e. from command line: cmake -DCONAN_PREFIX:PATH=<path-to-conan> ...

CMake options

The cmake step above takes several options, cmake [-DOPTIONS=var] ../ :

Option Default Description
H5PP_ENABLE_EIGEN3 OFF Enables Eigen linear algebra library support
H5PP_ENABLE_FMT OFF Enables {fmt} string formatting library
H5PP_ENABLE_SPDLOG OFF Enables spdlog support for logging h5pp internal info to stdout (implies fmt)
H5PP_PACKAGE_MANAGER find Download method for dependencies, select, find, cmake,fetch, cpm, find-or-cmake, find-or-fetch or conan
BUILD_SHARED_LIBS OFF Link dependencies with static or shared libraries
CMAKE_INSTALL_PREFIX None Install directory for h5pp and dependencies
H5PP_DEPS_INSTALL_DIR CMAKE_INSTALL_PREFIX Install directory for dependencies only (if a different one is desired)
H5PP_PREFIX_ADD_PKGNAME OFF Appends <PackageName> to install location of dependencies, i.e. ${H5PP_DEPS_INSTALL_DIR}/<PackageName>. This allows simple removal
H5PP_ENABLE_PCH OFF Use precompiled headers to speed up compilation of tests and examples
H5PP_ENABLE_CCACHE OFF Use ccache to speed up compilation of tests and examples
H5PP_ENABLE_TESTS OFF Build tests (recommended!)
H5PP_BUILD_EXAMPLES OFF Build example programs
H5PP_IS_SUBPROJECT OFF Use h5pp with add_subdirectory(). Skips installation of targets if true. Automatic detection if not set
CONAN_PREFIX None conan install directory

In addition, variables such as <PackageName>_ROOT and <PackageName>_DIR can be set to help guide CMake's find_package calls:

Option 3: Copy the headers

Copy the files under h5pp/source/include and add #include<h5pp/h5pp.h>. Make sure to compile with -std=c++17 -lstdc++fs and link the dependencies HDF5, Eigen3, fmt, and spdlog. The actual linking is a non-trivial step, see linking.

Uninstall

The target uninstall is defined by h5pp which removes installed headers and dependencies using their respective install manifests. From the build directory, run the following in the command-line to uninstall:

    cmake --build .  --target uninstall

Clone this wiki locally