Page tree

If using the CTest script and configuration method to build HDF5, you can easily change the build options by either specifying the options on the command line or adding them to the options file, HDF5options.cmake.


Change options from the command line

As described on the Building HDF5 with CMake page, batch files for Windows and a shell script for Unix are provided for building HDF5. These files each contain a command that gets executed on the command line to build HDF5. They can be edited to add or change these options to the build command:

 

OptionPurpose
BUILD_GENERATORWhich CMake generator to use (required)
INSTALLDIR

Root folder where HDF5 is installed

When specifying INSTALLDIR you must run make install from the build/ directory to install HDF5. Please note that if HDF5 is built with SZIP and ZLIB, you must also run make install from the build/ZLIB-prefix/src/ZLIB-build/ and build/SZIP-prefix/src/SZIP-build/ directories in order to install the ZLIB and SZIP libraries with the HDF5 libraries.

CTEST_CONFIGURATION_TYPE  Release, Debug, RelWithDebInfo
CTEST_SOURCE_NAMEName of source folder (eg. hdf5-1.10.N)

These are described at the top of the HDF5config.cmake file.

 


Change options with the options file

The HDF5options.cmake file is provided so that users can change build options without modifying the configuration file. It gets included by the configuration file and it overrides the settings in the configuration file.

Options can be set by using the following format:

set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DXXX:YY=ZZZZ")

The config/cmake/cacheinit.cmake file in the source code has a complete list of the options that can be used to build HDF5. (Section V in the release_docs/INSTALL_CMake.txt file in the source code lists the default CMake options used by HDF5.)

Several options are included in the HDF5options.cmake file, such as the options to turn off ZLIB or SZIP. Additional options can be added to this file, as needed. Common configure options that can be turned off or on in the HDF5options.cmake file are listed below.


 

Common CMake and configure Options

There are numerous CMake options available to users, many of which correspond directly to configure options. Below are a few important options that can be specified in the HDF5options.cmake file. The corresponding configure option is also shown:

OptionConfigureCMake
Build shared libraries--enable-sharedset(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DBUILD_SHARED_LIBS:BOOL=ON")
Build HDF5 C++ library--enable-cxxset(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_CPP_LIB:BOOL=ON")
Build HDF5 Fortran 2003
library
--enable-fortranset(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_FORTRAN:BOOL=ON")
Disable ZLIB filter--with-zlibset(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_Z_LIB_SUPPORT:BOOL=OFF")
Use different ZLIB library--with-zlib

ZLIB_INCLUDE_DIR:PATH=<path to zlib includes directory>

ZLIB_LIBRARY:FILEPATH=<path to zlib/library file>

ZLIB_USE_EXTERNAL=1

Disable SZIP filter--with-szlibset(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_SUPPORT:BOOL=OFF")
set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_ENCODING:BOOL=OFF")
Enable parallel build--enable-parallelset(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_PARALLEL:BOOL=ON")
set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DMPIEXEC_MAX_NUMPROCS:STRING=4")
Enable Threadsafe:--enable-threadsafeset(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_THREADSAFE:BOOL=ON")
Compile in Release Mode--enable-production-C Release (in build script) and set(CTEST_BUILD_CONFIGURATION "Release")
Compile in Debug Mode--enable-debug-C Debug (in build script) and set(CTEST_BUILD_CONFIGURATION "Debug")
Build HDF5 Java library--enable-java

set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_JAVA:BOOL=ON")

Also specify the location of Java in the JAVA_HOME environment variable.

--- Last Modified: October 23, 2018 | 08:18 AM