hdf images hdf images

This web site is no longer maintained (but will remain online).
Please see The HDF Group's new Support Portal for the latest information.

How to Change HDF5 CMake Build Options

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 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:

Option Purpose
BUILD_GENERATOR Which CMake generator to use (required)
INSTALLDIR Root folder where HDF5 is installed
CTEST_CONFIGURATION_TYPE   Release, Debug, RelWithDebInfo
CTEST_SOURCE_NAME Name of source folder (eg. hdf5-1.10.N)
STATIC_ONLY Build/use static libraries (default is YES)
FORTRAN_LIBRARIES Build/use Fortran 2003 libraries (default is NO)
JAVA_LIBRARIES Build/use Java libraries (default is NO)
NO_MAC_FORTRAN Allow shared libraries on the Mac (TRUE by default).

Some examples are shown below:

These are described in detail 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 has a complete list of the options that can be used to build HDF5. (Section V in the INSTALL_CMake.txt file 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 and how to change them in the configuration file. The corresponding configure option is also shown:

Option Configure CMake
Build shared libraries --enable-shared set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DBUILD_SHARED_LIBS:BOOL=ON")
Build HDF5 C++ library --enable-cxx set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_CPP_LIB:BOOL=ON")
Build HDF5 Fortran 2003
library
--enable-fortran set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_FORTRAN:BOOL=ON")
Disable ZLIB filter --with-zlib set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_Z_LIB_SUPPORT:BOOL=OFF")
Disable SZIP filter --with-szlib set(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-parallel set(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-threadsafe set(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")

- - Last modified: 27 April 2017