Improve the installation and usage docs for CMake (#5636)

* Workflow presets introduced in version CMake 3.25
This commit is contained in:
Allen Byrne
2025-07-28 09:14:35 -05:00
committed by GitHub
parent 4a12cfec19
commit f8aa8aa1ba
12 changed files with 496 additions and 187 deletions
+8 -8
View File
@@ -979,29 +979,29 @@ if (HDF5_ENABLE_CONCURRENCY)
endif ()
endif ()
if (HDF_ENABLE_PARALLEL)
if (NOT ALLOW_UNSUPPORTED)
message (FATAL_ERROR " **** Parallel and multi-threaded concurrency options are not supported, override with ALLOW_UNSUPPORTED option **** ")
if (NOT HDF5_ALLOW_UNSUPPORTED)
message (FATAL_ERROR " **** Parallel and multi-threaded concurrency options are not supported, override with HDF5_ALLOW_UNSUPPORTED option **** ")
else ()
message (VERBOSE " **** Allowing unsupported parallel and multi-threaded concurrency options **** ")
endif ()
endif ()
if (HDF5_BUILD_FORTRAN)
if (NOT ALLOW_UNSUPPORTED)
message (FATAL_ERROR " **** Fortran and multi-threaded concurrency options are not supported, override with ALLOW_UNSUPPORTED option **** ")
if (NOT HDF5_ALLOW_UNSUPPORTED)
message (FATAL_ERROR " **** Fortran and multi-threaded concurrency options are not supported, override with HDF5_ALLOW_UNSUPPORTED option **** ")
else ()
message (VERBOSE " **** Allowing unsupported Fortran and multi-threaded concurrency options **** ")
endif ()
endif ()
if (HDF5_BUILD_CPP_LIB)
if (NOT ALLOW_UNSUPPORTED)
message (FATAL_ERROR " **** C++ and multi-threaded concurrency options are not supported, override with ALLOW_UNSUPPORTED option **** ")
if (NOT HDF5_ALLOW_UNSUPPORTED)
message (FATAL_ERROR " **** C++ and multi-threaded concurrency options are not supported, override with HDF5_ALLOW_UNSUPPORTED option **** ")
else ()
message (VERBOSE " **** Allowing unsupported C++ and multi-threaded concurrency options **** ")
endif ()
endif ()
if (HDF5_BUILD_HL_LIB)
if (NOT ALLOW_UNSUPPORTED)
message (FATAL_ERROR " **** HL and multi-threaded concurrency options are not supported, override with ALLOW_UNSUPPORTED option **** ")
if (NOT HDF5_ALLOW_UNSUPPORTED)
message (FATAL_ERROR " **** HL and multi-threaded concurrency options are not supported, override with HDF5_ALLOW_UNSUPPORTED option **** ")
else ()
message (VERBOSE " **** Allowing unsupported HL and multi-threaded concurrency options **** ")
endif ()
+9
View File
@@ -114,6 +114,15 @@
"HDF5_ENABLE_HDFS": "OFF"
}
},
{
"name": "ci-S3-proxy",
"hidden": true,
"cacheVariables": {
"HDF5_ENABLE_DOCKER_PROXY": "ON",
"HDF5_ENABLE_ROS3_VFD": "ON",
"HDF5_ENABLE_HDFS": "OFF"
}
},
{
"name": "ci-StdShar",
"hidden": true,
+175 -92
View File
@@ -2,99 +2,187 @@
* Build and Test HDF5 Examples with CMake *
************************************************************************
Notes: This short instruction is written for users who want to quickly build
HDF5 Examples using the HDF5 binary package using the CMake tools.
Notes: This short instruction is written for users who want to quickly
exercise the installation of HDF5 by using the CMake tools to build
and test the HDF5 Examples. The following instructions will show
the default usage and then present common changes for non-default
installations.
More information about using CMake can be found at the Kitware
site, www.cmake.org.
CMake uses the command line; however, the visual CMake tool is
available for the configuration step. The steps are similar for
all of the operating systems supported by CMake.
Table of Contents
NOTES:
1. Using CMake for building and using HDF5 is under active
development. While we have attempted to provide error-free
files, please understand that development with CMake has not
been extensively tested outside of HDF. The CMake specific
files may change before the next release.
2. CMake for HDF5 development should be usable on any system
where CMake is supported. Please send us any comments on how
CMake support can be improved on any system.
Section I: Preconditions
Section II: Building HDF5 Examples with CMake
1. Using presets
2. Using CTestScript.cmake
3. Using Command Line CMake
Section III: Defaults in the CMakePresets.json file
Section IV: Defaults in the HDF5_Examples_options.cmake file
========================================================================
I. Preconditions
========================================================================
1. We suggest you obtain the latest CMake for windows from the Kitware
1. We suggest you obtain the latest CMake from the Kitware
web site. The HDF5 product requires a minimum CMake version
of 3.18.
of 3.18. If you are using VS2022, the minimum CMake version is 3.21.
CMakePresets.json, requires CMake 3.25 or higher.
2. You have installed the HDF5 library built with CMake, by executing
the HDF Install Utility (the *.msi file in the binary package for
Windows or the *.sh on Linux). If you are using a Windows platform,
you can obtain a pre-built Windows binary from The HDF Group's website
at www.hdfgroup.org.
Windows or the *.sh on Linux). You can obtain pre-built binaries
from The HDF Group's website at www.hdfgroup.org.
3. Set the environment variable HDF5_DIR to the installed location of
the config files for HDF5. On Windows:
HDF5_ROOT=C:/Program Files/HDF_Group/HDF5/z.y.x
3. Set the HDF5_ROOT CMake variable, -DHDF5_ROOT=<install_path>
or environment variable, set(ENV{HDF5_ROOT} "<install_path>")
to the installed location of HDF5.
On Windows:
HDF5_ROOT=C:/Program Files/HDF_Group/HDF5/z.y.x/
On unix:
HDF5_ROOT=<install root folder>/HDF_Group/HDF5/z.y.x/
If you are using shared libraries, you may need to add to the path
environment variable. Set the path environment variable to the
installed location of the library files for HDF5.
On Windows (*.dll):
PATH=%PATH%;C:/Program Files/HDF_Group/HDF5/z.y.x/bin
On unix (*.so):
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<install root folder>/HDF_Group/HDF5/z.y.x/lib
(Note there are no quote characters used on Windows and all platforms
use forward slashes)
4. Create separate source and build directories.
4. Use separate source and build directories.
(CMake commands are executed in the build directory)
========================================================================
II. Building HDF5 Examples with CMake
========================================================================
Go through these steps to build HDF5 applications with CMake.
1. Using presets
NOTE:
The CMakePresets.json files created by HDF Group are intended to be used with the Ninja build system,
which may need to be installed separately on some platforms.
1. Run CMake
2. Configure the cache settings
3. Build HDF5 Examples
4. Test HDF5 Examples.
Files in the HDF5 install/HDF5Examples directory:
CMakePresets.json
These steps are described in more detail below.
Default build process:
Create a directory to run the examples, i.e. \test_hdf5.
Copy the HDF5Examples folder to this directory.
Change into the HDF5Examples directory where CMakePresets.json exists.
Other options can be changed by creating a
CMakeUsersPresets.json file. (Advanced usage)
Available configurations presets can be displayed by executing:
cmake -S <path-to-source> --list-presets
1. Run CMake
Using individual command presets (where <compiler-type> is GNUC or MSVC or Clang):
cmake --preset ci-StdShar-<compiler-type>
cmake --build --preset ci-StdShar-<compiler-type>
ctest --preset ci-StdShar-<compiler-type>
cpack --preset ci-StdShar-<compiler-type>
Using the workflow preset to configure, build, and test the standard configuration:
execute "cmake --workflow --preset ci-StdShar-<compiler-type> --fresh"
where <compiler-type> is GNUC or MSVC or Clang
2. Using CTestScript.cmake
Files in the HDF5 install directory:
HDF5Examples folder
CTestScript.cmake
HDF5_Examples.cmake
HDF5_Examples_options.cmake
Default build process:
Create a directory to run the examples, i.e. \test_hdf5.
Copy HDF5Examples folder to this directory.
Copy CTestScript.cmake to this directory.
Copy HDF5_Examples.cmake to this directory.
Copy HDF5_Examples_options.cmake to this directory.
The default source folder is defined as "HDF5Examples". It can be changed
with the CTEST_SOURCE_NAME script option.
The default installation folder is defined for the platform.
It can be changed with the INSTALLDIR script option.
(Note: Windows has issues with spaces and paths -The path will need to
be set correctly.)
The default ctest configuration is defined as "Release". It can be changed
with the CTEST_CONFIGURATION_TYPE script option. Note that this must
be the same as the value used with the -C command line option.
On Windows, you can set the CTEST_VSVERS script option to either
64_VS2022 or 64_VS2019. Alternately, you can set the script
CTEST_CMAKE_GENERATOR option to "Visual Studio 16 2019" or "Visual Studio 17 2022",
and the CMAKE_GENERATOR_ARCHITECTURE script option to "x64".
The default build configuration is defined to build and use static libraries.
Shared libraries and other options can be changed by editing the
HDF5_Examples_options.cmake file.
If the defaults are okay, execute from this directory:
ctest -S HDF5_Examples.cmake -C Release -VV -O test.log
If the defaults need change, execute from this directory:
ctest -S HDF5_Examples.cmake,CTEST_SOURCE_NAME=MyExamples,INSTALLDIR=MyLocation -C Release -VV -O test.log
When executed, the ctest script will save the results to the log file, test.log, as
indicated by the ctest command. If you wish to see more build and test information,
add "-VV" to the ctest command. The output should show;
100% tests passed, 0 tests failed out of 206.
3. Using Command Line CMake
A. Visual Configuration
The visual CMake executable is named "cmake-gui.exe" on Windows and should be
available in your Start menu. For Linux, UNIX, and Mac users the
executable is named "cmake-gui" and can be found where CMake was
installed.
executable is named "cmake-gui" or the ncurses-based "ccmake" and can be found
where CMake was installed.
Specify the source and build directories. Make the build and source
directories different. For example on Windows, if the source is at
c:\MyHDFstuff\hdf5ex, then use c:\MyHDFstuff\hdf5ex\build or
c:\MyHDFstuff\build\hdf5ex for the build directory.
C:\MyHDFstuff\hdf5ex, then use C:\MyHDFstuff\hdf5ex\build or
C:\MyHDFstuff\build\hdf5ex for the build directory.
PREFERRED:
Users can perform the configuration step without using the visual
cmake-gui program. The following is an example command line
configuration step executed within the build directory:
Click the Configure button. If this is the first time you are
running cmake-gui in this directory, you will be prompted for the
generator you wish to use (for example on Windows, Visual Studio 15).
CMake will read in the CMakeLists.txt files from the source directory and
display options for the HDF5 Examples project. After the first configure you
can adjust the cache settings and/or specify locations of other programs.
Any conflicts or new values will be highlighted by the configure
process in red. Once you are happy with all the settings and there are no
more values in red, click the Generate button to produce the appropriate
build files.
On Windows, if you are using a Visual Studio generator, the solution and
project files will be created in the build folder.
On linux, if you are using the Unix Makefiles generator, the Makefiles will
be created in the build folder.
B. Alternative Command Line Configuration
Users can perform the configuration step without using the visual
cmake-gui program. The following is an example command line
configuration step executed within the build directory:
cmake -G "<generator>" [-D<options>] <sourcepath>
Where <generator> is
* Borland Makefiles
Where <generator> is (examples):
* MSYS Makefiles
* MinGW Makefiles
* NMake Makefiles
* Unix Makefiles
* Visual Studio 15
* Visual Studio 15 Win64
* Visual Studio 17
* Visual Studio 17 Win64
* Visual Studio 19
* Visual Studio 15 2017
* Visual Studio 15 2017 Win64
* Visual Studio 16 2019
* ... in addition VS2019 will need to set the "-A" option,
* ... [Win32, x64, ARM, ARM64]
* Visual Studio 17 2022
* ... in addition VS2022 will need to set the "-A" option,
* ... [Win32, x64, ARM, ARM64]
<options> is:
* H5EX_BUILD_TESTING:BOOL=ON
@@ -105,31 +193,11 @@ These steps are described in more detail below.
if the hdf5 library was built with a namespace (i.e. "hdf5::") add:
-D HDF5_NAMESPACE:STRING=hdf5::
2. Configure the cache settings
Example command line on Windows in c:\MyHDFstuff\hdf5ex\build directory:
2.1 Visual CMake users, click the Configure button. If this is the first time you are
running cmake-gui in this directory, you will be prompted for the
generator you wish to use (for example on Windows, Visual Studio 15).
CMake will read in the CMakeLists.txt files from the source directory and
display options for the HDF5 Examples project. After the first configure you
can adjust the cache settings and/or specify locations of other programs.
cmake -G "Visual Studio 17 2022" -DH5EX_BUILD_TESTING:BOOL=ON -DBUILD_SHARED_LIBS:BOOL=ON ..
Any conflicts or new values will be highlighted by the configure
process in red. Once you are happy with all the settings and there are no
more values in red, click the Generate button to produce the appropriate
build files.
On Windows, if you are using a Visual Studio generator, the solution and
project files will be created in the build folder.
On linux, if you are using the Unix Makefiles generator, the Makefiles will
be created in the build folder.
2.2 Alternative command line example on Windows in c:\MyHDFstuff\hdf5ex\build directory:
cmake -G "Visual Studio 19" -DH5EX_BUILD_TESTING:BOOL=ON -DBUILD_SHARED_LIBS:BOOL=ON ..
3. Build HDF5 examples
C. Build HDF5 examples
On Windows, you can build HDF5 examples using either the Visual Studio Environment
or the command line. The command line is normally used on linux, Unix, and Mac.
@@ -143,11 +211,11 @@ These steps are described in more detail below.
recommend choosing either Debug or Release on Windows. If you are
using the pre-built binaries from HDF, use Release.
3.1 If you wish to use the Visual Studio environment, open the solution
file in your build directory. Be sure to select either Debug or
Release and build the solution.
If you wish to use the Visual Studio environment, open the solution
file in your build directory. Be sure to select either Debug or
Release and build the solution.
4. Test HDF5 Examples.
D. Test HDF5 Examples.
To test the build, navigate to your build directory and execute:
@@ -157,6 +225,11 @@ These steps are described in more detail below.
recommend choosing either Debug or Release to match the build
step on Windows.
4. The files that support building with CMake are all of the files in the
config/cmake folder, the CMakeLists.txt files in each source folder.
CTestConfig.cmake is specific to the internal testing
4.1 Alternative command line example using the pkg-config shell scripts:
export HDF5_HOME=<root_path>/HDF_Group/HDF5/2.0.0
@@ -172,29 +245,39 @@ These steps are described in more detail below.
installation and needs.
========================================================================
III. Using HDF5 Libraries with Visual Studio 2008 (no longer supported)
III. Defaults in the CMakePresets.json file
========================================================================
1. Set up path for external libraries and headers
#### DEFAULT:
#### "generator": "Ninja"
#### "binaryDir": "${sourceParentDir}/build/${presetName}"
#### "name": "ci-StdShar"
#### "BUILD_SHARED_LIBS": "ON",
#### "USE_SHARED_LIBS": "ON"
#### "CMAKE_BUILD_TYPE": "RelWithDebInfo"
#### "H5EX_BUILD_FORTRAN": "ON"
#### "H5EX_BUILD_CXX": "ON"
#### "H5EX_BUILD_JAVA": "ON"
#### "HDF5_NAMESPACE": {"type": "STRING", "value": "hdf5::"},
#### "HDF5_PACKAGE_NAME": {"type": "STRING", "value": "hdf5"},
#### "H5EX_BUILD_TESTING": "ON"
Invoke Microsoft Visual Studio and go to "Tools" and select "Options",
find "Projects", and then "VC++ Directories".
1.1 If you are building on 64-bit Windows, find the "Platform" dropdown
and select "x64".
========================================================================
IV. Defaults in the HDF5_Examples_options.cmake file
========================================================================
1.2 Find the box "Show directories for", choose "Include files", add the
header path (i.e. c:\Program Files\HDF Group\HDF5\hdf5-1.8.x\include)
to the included directories.
1.3 Find the box "Show directories for", choose "Library files", add the
library path (i.e. c:\Program Files\HDF Group\HDF5\hdf5-1.8.x\lib)
to the library directories.
1.4 If using Fortran libraries, you will also need to setup the path
for the Intel Fortran compiler.
#### DEFAULT:
#### BUILD_SHARED_LIBS:BOOL=OFF
#### H5EX_BUILD_C:BOOL=ON
#### H5EX_BUILD_HL:BOOL=OFF
#### H5EX_BUILD_CXX:BOOL=OFF
#### H5EX_BUILD_FORTRAN:BOOL=OFF
#### H5EX_BUILD_JAVA:BOOL=OFF
#### H5EX_BUILD_FILTERS:BOOL=OFF
#### H5EX_BUILD_TESTING:BOOL=OFF
#### H5EX_ENABLE_PARALLEL:BOOL=OFF
************************************************************************
+10 -7
View File
@@ -2,13 +2,13 @@
> HDF5 version 2.0.0 currently under development
> [!WARNING]
> **Heads Up: HDF5 Drops Autotools March 10th**
> **Heads Up: HDF5 Dropped Autotools March 10th**
>
> The day has arrived: the day we've all been dreading—or eagerly anticipating, depending on your perspective. Yes, we're switching to CMake-only builds in HDF5. Prepare yourselves.
> The day has passed: the day we've all been dreading—or eagerly anticipating, depending on your perspective. Yes, we have switched to CMake-only builds in HDF5.
>
> The [PR stripping all autotools](https://github.com/HDFGroup/hdf5/pull/5308) will go into the "develop" branch on **March 10, 2025**. HDF5 2.0, scheduled for release in Fall 2025, will *only* support the CMake build system.
> The [PR stripping all autotools](https://github.com/HDFGroup/hdf5/pull/5308) has been merged into the "develop" branch on **March 10, 2025**. HDF5 2.0, scheduled for release in Fall 2025, will *only* support the CMake build system.
>
>If you’d like to learn more about this decision, check out this blog post from November 2022: [Can we remove the autotools?](https://www.hdfgroup.org/2022/11/14/can-we-remove-the-autotools/) And the [HDF5 2.0 planning wiki](https://github.com/HDFGroup/hdf5/wiki/HDF5-2.0-Release-Planning). If you use autotools for your builds, now is a great time to update your workflows to CMake.
>If you’d like to learn more about this decision, check out this blog post from November 2022: [Can we remove the autotools?](https://www.hdfgroup.org/2022/11/14/can-we-remove-the-autotools/) and the [HDF5 2.0 planning wiki](https://github.com/HDFGroup/hdf5/wiki/HDF5-2.0-Release-Planning). If you use autotools for your builds, you will need to update your workflows to CMake.
![HDF5 Logo][u3]
@@ -26,7 +26,7 @@
[HPC configure/build/test results](https://my.cdash.org/index.php?project=HDF5)
*Please refer to the release_docs/INSTALL file for installation instructions.*
*Please refer to the release_docs/INSTALL file for installation/usage instructions.*
This repository contains a high-performance library's source code and a file format
specification that implements the HDF5® data model. The model has been adopted across
@@ -53,11 +53,14 @@ to the features and updates included in this release of the library.
Several more files are located within the [release_docs/][u4] directory with specific
details for several common platforms and configurations.
INSTALL - Start Here. General instructions for compiling and installing the library
INSTALL_CMAKE - instructions for building with CMake (Kitware.com)
INSTALL - Start Here. General instructions for compiling and installing the library or using an installed library
INSTALL_CMAKE - instructions for building with CMake (Kitware.com)
INSTALL_parallel - instructions for building and configuring Parallel HDF5
INSTALL_Windows and INSTALL_Cygwin - MS Windows installations.
USING_HDF5_CMake - Build and Install HDF5 Applications with CMake
USING_CMake_Examples - Build and Test HDF5 Examples with CMake
HELP AND SUPPORT
+1 -1
View File
@@ -54,7 +54,7 @@ macro (EXTERNAL_HDF5_LIBRARY compress_type)
set (BUILD_TESTING OFF CACHE BOOL "Build JHDF5 Unit Testing" FORCE)
set (HDF5_BUILD_EXAMPLES OFF CACHE BOOL "Build JHDF5 Library Examples" FORCE)
set (HDF5_BUILD_HL_LIB OFF CACHE BOOL "Build JHDF5 HIGH Level HDF5 Library" FORCE)
set (HDF5_ENABLE_Z_LIB_SUPPORT OFF CACHE BOOL "Enable Zlib Filters" FORCE)
set (HDF5_ENABLE_ZLIB_SUPPORT OFF CACHE BOOL "Enable Zlib Filters" FORCE)
set (HDF5_ENABLE_SZIP_SUPPORT OFF CACHE BOOL "Use SZip Filter" FORCE)
add_subdirectory(${hdf5lib_SOURCE_DIR} ${hdf5lib_BINARY_DIR})
+8 -2
View File
@@ -980,10 +980,16 @@ in the share folder or you can go to the <a href="https://\SRCURL/HDF5Examples">
Go into the share directory and follow the instructions in <a href="https://\SRCURL/release_docs/USING_CMake_Examples.txt">Using CMake to Build Examples</a> to build the examples.
In general, users must first set the HDF5_ROOT environment variable to the installed location of the CMake
configuration files for HDF5. For example, on Windows the following path might be set:
configuration files for HDF5.
For example, on Windows the following path might be set:
\code
HDF5_ROOT=C:/Program Files/HDF_Group/HDF5/1.N.N
HDF5_ROOT=C:/Program Files/HDF_Group/HDF5/z.y.x
\endcode
For example, on Linux the following path might be set:
\code
HDF5_ROOT=<install root folder>/HDF_Group/HDF5/z.y.x/
\endcode
\subsection subsecLBCompilingCMakeTroubless Troubleshooting CMake
+7 -4
View File
@@ -11,7 +11,7 @@ You want to build HDF5 with CMake, but there are so many options to consider.
\par Solution
CMake introduced presets in version 3.19. HDF Group provides a
<a href="https://\SRCURL/CMakePresets.json"><tt>CMakePresets.json</tt></a>,
requiring CMake 3.24 or higher,
requiring CMake 3.25 or higher,
that will build HDF5 with the options for building a typical shared library with
the common languages for a platform. The features include building the tools, examples,
plugins, and the shared and static libraries.
@@ -29,6 +29,9 @@ how to build HDF5 with the
The above example will create a "build" folder in the source parent directory, which
will contain the results of the build, including installation package files.
The CMakePresets.json files created by HDF Group are intended to be used with the Ninja build system,
which may need to be installed separately on some platforms.
\par See Also
See CMake documentation for details on presets:
\li https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html
@@ -48,7 +51,7 @@ Create a CMakeUserPresets.json file with the following content:
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 24,
"minor": 25,
"patch": 0
},
"configurePresets": [
@@ -259,7 +262,7 @@ Create a CMakeUserPresets.json file with the following content:
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 24,
"minor": 25,
"patch": 0
},
"configurePresets": [
@@ -393,7 +396,7 @@ Create a CMakeUserPresets.json file with the following content:
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 24,
"minor": 25,
"patch": 0
},
"configurePresets": [
+33 -19
View File
@@ -18,10 +18,11 @@ CONTENTS
2. Third-party Software Requirements
2.1 zlib
2.2 Szip (optional)
2.3 MPI and MPI-IO
2.3 compression plugins
2.4 MPI and MPI-IO
3. HDF5 Source Code and Precompiled Binaries
4. Build and Install HDF5 Libraries and Tools with CMake
5. Quick Start Presets
3.1. Build and Install HDF5 Libraries and Tools with CMake
4. Quick Start Presets
*****************************************************************************
@@ -44,7 +45,12 @@ CONTENTS
uses the extended-Rice lossless compression algorithm for chunked
datasets.
2.3. MPI and MPI-IO
2.3. compression plugins
The HDF5 plugins project, https://github.com/HDFGroup/hdf5_plugins, provides
compression libraries that can be used at runtime with the hdf5 shared
library.
2.4. MPI and MPI-IO
The parallel version of the library is built upon the foundation
provided by MPI and MPI-IO. If these libraries are not available
when HDF5 is configured, only a serial version of HDF5 can be built.
@@ -55,35 +61,43 @@ CONTENTS
https://github.com/HDFGroup/hdf5/releases
4. Build and Install HDF5 Libraries and Tools with CMake
3.1. Build and Install HDF5 Libraries and Tools with CMake
see the release_docs/INSTALL_CMake.txt file.
5. Quick Start Presets
You want to build HDF5 with CMake, but there are so many options to consider.
4. Quick Start Presets
You want to build HDF5 with CMake or use an installed HDF5 binary with CMake,
but there are so many options to consider.
5.1. Solution
4.1. Solution
CMake introduced presets in version 3.19. HDF Group provides a file in the source,
CMakePresets.json, requiring CMake 3.24 or higher, that will build HDF5 with the
options for building a typical shared library with the common languages for a
platform. The features include building the tools, examples, plugins, and the
shared and static libraries.
CMakePresets.json, requiring CMake 3.25 or higher. This file is in the HDF5 library
source as well as the HDF5Examples source of the installed binary.
The library source file will build HDF5 with the options for building a typical
shared library with the common languages for a platform. The features include building
the tools, examples, plugins, and the shared and static libraries.
The HDF5Examples source file will build the examples with the components that were
enabled by the options selected when the install HDF5 library was built. The typical
library built by HDF5 and available from the HDF5 Releases page includes C, Java, and Fortran
compilers along with the tools, examples, plugins, and the shared and static libraries.
5.2. Discussion
The CMakePresets.json file is located in the root directory of the HDF5 source.
4.2. Discussion
The CMakePresets.json file is located in the root directory of the HDF5 source and
the HDF5Examples source of the installed binary.
It is from here you will execute the cmake command to build HDF5. The following
example shows how to build HDF5 with the CMakePresets.json file:
- change directory to the hdf5 source folder
example shows how to build HDF5 or examples with the CMakePresets.json file:
- change directory to the source folder
- execute "cmake --workflow --preset ci-StdShar-<compiler-type> --fresh"
where "<compiler-type>" is GNUC, MSVC, Clang
The above example will create a "build" folder in the source parent directory, which
will contain the results of the build, including installation package files.
will contain the results of the build, including installation package files when the
library is built.
5.3. Customization
4.3. Customization
See the HDF5 documentation for more on presets, especially the presets section in:
- release_docs/INSTALL_CMake.txt file
5.4. See Also
4.4. See Also
See CMake documentation for details on presets:
- https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html
+35 -20
View File
@@ -46,7 +46,7 @@ CMake version
1. We suggest you obtain the latest CMake from the Kitware web site.
The HDF5 2."X"."Y" product requires a minimum CMake version 3.18,
where "X"."Y" is the current HDF5 release version. If you are using
VS2022, the minimum version is 3.21.
VS2022, the minimum version is 3.21. CMakePresets requires CMake 3.25.
Note:
To change the install prefix from the platform defaults initialize
@@ -65,12 +65,14 @@ This short set of instructions is written for users who want to quickly
build the HDF5 C, C++ and Fortran shared libraries and tools
from the HDF5 source code package using the CMake tools. This procedure
will use the default settings in the config/cmake/cacheinit.cmake file.
The HDF Group recommends using the ctest script mode to build HDF5.
The HDF Group recommends using the presets process to build HDF5.
NOTE: if you are using CMake 3.24 or later, you can use the presets process.
NOTE: if you are using CMake 3.25 or later, you can use the presets process.
The CMakePresets.json file in the source directory will configure, build, test,
and package HDF5 with the same options that are set in the cacheinit.cmake file.
see Section X: Using CMakePresets.json for compiling
In addition, it will get the optional files listed below that are needed, from
the appropriate repositories.
See Section X: Using CMakePresets.json for compiling
-------------------------------------------------------------------------
-------------------------------------------------------------------------
@@ -298,9 +300,10 @@ Notes: This short set of instructions is written for users who want to
IV. Further Considerations
========================================================================
1. We suggest you obtain the latest CMake for windows from the Kitware
1. We suggest you obtain the latest CMake from the Kitware
web site. The HDF5 2."X"."Y" product requires a minimum CMake version 3.18.
If you are using VS2022, the CMake minimum version is 3.21.
If you are using VS2022, the CMake minimum version is 3.21. CMakePresets
requires CMake 3.25.
2. If you plan to use Zlib or Szip (aka libaec):
A. Download the binary packages and install them in a central location.
@@ -440,16 +443,12 @@ IV. Further Considerations
Notes: CMake and HDF5
1. Using CMake for building and using HDF5 is under active development.
We have attempted to provide error-free files. The CMake specific
files may change before the next release.
2. CMake support for HDF5 development should be usable on any
1. CMake support for HDF5 development should be usable on any
system where CMake is supported. Please send us any comments on
how CMake support can be improved on any system. Visit the
Kitware site for more information about CMake.
3. Build and test results can be submitted to our HDF5 CDash server:
2. Build and test results can be submitted to our HDF5 CDash server:
The CDash server for community submissions of hdf5 is at
https://my.cdash.org.
@@ -461,7 +460,7 @@ Notes: CMake and HDF5
configuration every time. "EXPERIMENTAL" submissions can be expected to
be different for each submission.
4. See the appendix at the bottom of this file for examples of using
3. See the appendix at the bottom of this file for examples of using
a ctest script for building and testing. Using a ctest script is
preferred because of its flexibility.
@@ -529,7 +528,7 @@ These five steps are described in detail below.
cmake -C <sourcepath>/config/cmake/cacheinit.cmake -G "<generator>" [-D<options>] <sourcepath>
Where <generator> is
Where <generator> is (examples):
* MinGW Makefiles
* NMake Makefiles
* Unix Makefiles
@@ -553,6 +552,7 @@ These five steps are described in detail below.
* ZLIB_LIBRARY:FILEPATH=<path to zlib/library file>
or
* ZLIB_ROOT:PATH=<path to zlib root directory>
* <HDF5OPTION>:BOOL=[ON | OFF]
<cacheinit.cmake> highlights are:
@@ -992,7 +992,7 @@ NOTE:
The multi-threaded concurrency, C++, and Java interfaces are not compatible
with the HDF5_ENABLE_PARALLEL option.
Unless ALLOW_UNSUPPORTED has been specified,
Unless HDF5_ALLOW_UNSUPPORTED has been specified,
the following options must be disabled:
HDF5_ENABLE_CONCURRENCY, HDF5_BUILD_CPP_LIB, HDF5_BUILD_JAVA
@@ -1117,7 +1117,7 @@ Quick Start Presets
Solution
-------------------------------
CMake introduced presets in version 3.19. HDF Group provides a file in the source,
CMakePresets.json, requiring CMake 3.24 or higher, that will build HDF5 with the
CMakePresets.json, requiring CMake 3.25 or higher, that will build HDF5 with the
options for building a typical shared library with the common languages for a
platform. The features include building the tools, examples, plugins, and the
shared and static libraries.
@@ -1145,6 +1145,9 @@ Discussion
present if --preset is specified). CMakePresets.json is meant to specify project-wide build
details, while CMakeUserPresets.json is meant for developers to specify their own local build details.
The CMakePresets.json files created by HDF Group are intended to be used with the Ninja build system,
which may need to be installed separately on some platforms.
See CMake documentation for details: https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html
HDF-provided CMakePresets.json
@@ -1229,12 +1232,24 @@ XI. Using the Library
shared HDF5 libraries. However CMake provides a programmable method to
determine the features of the library. The CMake installation will
provide a CMake package configuration file, located in the installation folder,
cmake/HDF5config.cmake, and can be used to determine the features of the library.
cmake/hdf5-config.cmake, and can be used to determine the features of the library.
The file is accessed by using the find_package command in your CMakeLists.txt file.
1. Set the environment variable HDF5_DIR to the installed location of
the config files for HDF5. On Windows:
HDF5_ROOT=C:/Program Files/HDF_Group/HDF5/z.y.x
1. Set the HDF5_ROOT CMake variable, -DHDF5_ROOT=<install_path>
or environment variable, set(ENV{HDF5_ROOT} "<install_path>")
to the installed location of HDF5.
On Windows:
HDF5_ROOT=C:/Program Files/HDF_Group/HDF5/z.y.x/
On unix:
HDF5_ROOT=<install root folder>/HDF_Group/HDF5/z.y.x/
If you are using shared libraries, you may need to add to the path
environment variable. Set the path environment variable to the
installed location of the library files for HDF5.
On Windows (*.dll):
PATH=%PATH%;C:/Program Files/HDF_Group/HDF5/z.y.x/bin
On unix (*.so):
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<install root folder>/HDF_Group/HDF5/z.y.x/lib
(Note there are no quote characters used on Windows and all platforms
use forward slashes)
+1 -1
View File
@@ -3,7 +3,7 @@
************************************************************************
This document is an instruction on how to build, test and install HDF5 library
on Cygwin. See detailed information in hdf5/INSTALL.
on Cygwin.
NOTE: hdf5 can be built with CMake, see the INSTALL_CMake.txt file for more
guidance.
+197 -16
View File
@@ -12,8 +12,15 @@ Notes: This short instruction is written for users who want to quickly
More information about using CMake can be found at the Kitware
site, www.cmake.org.
CMake uses the command line and these instructions use the script
method of the ctest command.
Table of Contents
Section I: Preconditions
Section II: Building HDF5 Examples with CMake
1. Using presets
2. Using CTestScript.cmake
3. Using Command Line CMake
Section III: Defaults in the CMakePresets.json file
Section IV: Defaults in the HDF5_Examples_options.cmake file
========================================================================
@@ -21,27 +28,78 @@ I. Preconditions
========================================================================
1. We suggest you obtain the latest CMake for your platform from the Kitware
web site. The HDF5 2.0.x product requires a minimum CMake version
web site. The HDF5 z.y.x product requires a minimum CMake version
of 3.18. If you are using VS2022, the minimum CMake version is 3.21.
CMakePresets.json, requires CMake 3.25 or higher.
2. You have installed the HDF5 library built with CMake, by executing
the HDF Install Utility (the *.msi file in the binary package for
Windows or the *.sh on Linux). You can obtain pre-built binaries
from The HDF Group's website at www.hdfgroup.org.
3. Set the HDF5_ROOT CMake variable, -DHDF5_ROOT=<install_path>
or environment variable, set(ENV{HDF5_ROOT} "<install_path>")
to the installed location of HDF5.
On Windows:
HDF5_ROOT=C:/Program Files/HDF_Group/HDF5/z.y.x/
On unix:
HDF5_ROOT=<install root folder>/HDF_Group/HDF5/z.y.x/
If you are using shared libraries, you may need to add to the path
environment variable. Set the path environment variable to the
installed location of the library files for HDF5.
On Windows (*.dll):
PATH=%PATH%;C:/Program Files/HDF_Group/HDF5/z.y.x/bin
On unix (*.so):
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<install root folder>/HDF_Group/HDF5/z.y.x/lib
(Note there are no quote characters used on Windows and all platforms
use forward slashes)
4. Use separate source and build directories.
(CMake commands are executed in the build directory)
========================================================================
II. Building HDF5 Examples with CMake
========================================================================
Files in the HDF5 install directory:
1. Using presets
NOTE:
The CMakePresets.json files created by HDF Group are intended to be used with the Ninja build system,
which may need to be installed separately on some platforms.
Files in the HDF5 install/HDF5Examples directory:
CMakePresets.json
Default build process:
Create a directory to run the examples, i.e. \test_hdf5.
Copy the HDF5Examples folder to this directory.
Change into the HDF5Examples directory where CMakePresets.json exists.
Other options can be changed by creating a
CMakeUsersPresets.json file. (Advanced usage)
Available configurations presets can be displayed by executing:
cmake -S <path-to-source> --list-presets
Using individual command presets (where <compiler-type> is GNUC or MSVC or Clang):
cmake --preset ci-StdShar-<compiler-type>
cmake --build --preset ci-StdShar-<compiler-type>
ctest --preset ci-StdShar-<compiler-type>
cpack --preset ci-StdShar-<compiler-type>
Using the workflow preset to configure, build, and testthe standard configuration:
execute "cmake --workflow --preset ci-StdShar-<compiler-type> --fresh"
where <compiler-type> is GNUC or MSVC or Clang
2. Using CTestScript.cmake
Files in the HDF5 install directory:
HDF5Examples folder
CTestScript.cmake
HDF5_Examples.cmake
HDF5_Examples_options.cmake
Default installation process:
Default build process:
Create a directory to run the examples, i.e. \test_hdf5.
Copy HDF5Examples folder to this directory.
Copy CTestScript.cmake to this directory.
@@ -76,19 +134,142 @@ Default installation process:
add "-VV" to the ctest command. The output should show;
100% tests passed, 0 tests failed out of 206.
3. Using Command Line CMake
A. Visual Configuration
The visual CMake executable is named "cmake-gui.exe" on Windows and should be
available in your Start menu. For Linux, UNIX, and Mac users the
executable is named "cmake-gui" or the ncurses-based "ccmake" and can be found
where CMake was installed.
Specify the source and build directories. Make the build and source
directories different. For example on Windows, if the source is at
C:\MyHDFstuff\hdf5ex, then use C:\MyHDFstuff\hdf5ex\build or
C:\MyHDFstuff\build\hdf5ex for the build directory.
Click the Configure button. If this is the first time you are
running cmake-gui in this directory, you will be prompted for the
generator you wish to use (for example on Windows, Visual Studio 15).
CMake will read in the CMakeLists.txt files from the source directory and
display options for the HDF5 Examples project. After the first configure you
can adjust the cache settings and/or specify locations of other programs.
Any conflicts or new values will be highlighted by the configure
process in red. Once you are happy with all the settings and there are no
more values in red, click the Generate button to produce the appropriate
build files.
On Windows, if you are using a Visual Studio generator, the solution and
project files will be created in the build folder.
On linux, if you are using the Unix Makefiles generator, the Makefiles will
be created in the build folder.
B. Alternative Command Line Configuration
Users can perform the configuration step without using the visual
cmake-gui program. The following is an example command line
configuration step executed within the build directory:
cmake -G "<generator>" [-D<options>] <sourcepath>
Where <generator> is (examples):
* MSYS Makefiles
* MinGW Makefiles
* NMake Makefiles
* Unix Makefiles
* Visual Studio 15 2017
* Visual Studio 15 2017 Win64
* Visual Studio 16 2019
* ... in addition VS2019 will need to set the "-A" option,
* ... [Win32, x64, ARM, ARM64]
* Visual Studio 17 2022
* ... in addition VS2022 will need to set the "-A" option,
* ... [Win32, x64, ARM, ARM64]
<options> is:
* H5EX_BUILD_TESTING:BOOL=ON
* BUILD_SHARED_LIBS:BOOL=[ON | OFF]
* H5EX_BUILD_FORTRAN:BOOL=[ON | OFF]
* H5EX_BUILD_JAVA:BOOL=[ON | OFF]
if the hdf5 library was built with a namespace (i.e. "hdf5::") add:
-D HDF5_NAMESPACE:STRING=hdf5::
Example command line on Windows in c:\MyHDFstuff\hdf5ex\build directory:
cmake -G "Visual Studio 16 2019" -DH5EX_BUILD_TESTING:BOOL=ON -DBUILD_SHARED_LIBS:BOOL=ON ..
C. Build HDF5 examples
On Windows, you can build HDF5 examples using either the Visual Studio Environment
or the command line. The command line is normally used on linux, Unix, and Mac.
To build from the command line, navigate to your build directory and
execute the following:
cmake --build . --config {Debug | Release}
NOTE: "--config {Debug | Release}" may be optional on your platform. We
recommend choosing either Debug or Release on Windows. If you are
using the pre-built binaries from HDF, use Release.
If you wish to use the Visual Studio environment, open the solution
file in your build directory. Be sure to select either Debug or
Release and build the solution.
D. Test HDF5 Examples.
To test the build, navigate to your build directory and execute:
ctest . -C {Debug | Release}
NOTE: "-C {Debug | Release}" may be optional on your platform. We
recommend choosing either Debug or Release to match the build
step on Windows.
4. The files that support building with CMake are all of the files in the
config/cmake folder, the CMakeLists.txt files in each source folder.
CTestConfig.cmake is specific to the internal testing
performed by The HDF Group. It should be altered for the user's
installation and needs. The cacheinit.cmake file settings are used by
The HDF Group for daily testing. It should be altered/ignored for the user's
installation and needs.
========================================================================
III. Defaults in the HDF5_Examples_options.cmake file
III. Defaults in the CMakePresets.json file
========================================================================
#### DEFAULT: ###
#### BUILD_SHARED_LIBS:BOOL=OFF ###
#### H5EX_BUILD_C:BOOL=ON ###
#### H5EX_BUILD_HL:BOOL=OFF ###
#### H5EX_BUILD_CXX:BOOL=OFF ###
#### H5EX_BUILD_FORTRAN:BOOL=OFF ###
#### H5EX_BUILD_JAVA:BOOL=OFF ###
#### H5EX_BUILD_FILTERS:BOOL=OFF ###
#### H5EX_BUILD_TESTING:BOOL=OFF ###
#### H5EX_ENABLE_PARALLEL:BOOL=OFF ###
#### DEFAULT:
#### "generator": "Ninja"
#### "binaryDir": "${sourceParentDir}/build/${presetName}"
#### "name": "ci-StdShar"
#### "BUILD_SHARED_LIBS": "ON",
#### "USE_SHARED_LIBS": "ON"
#### "CMAKE_BUILD_TYPE": "RelWithDebInfo"
#### "H5EX_BUILD_FORTRAN": "ON"
#### "H5EX_BUILD_CXX": "ON"
#### "H5EX_BUILD_JAVA": "ON"
#### "HDF5_NAMESPACE": {"type": "STRING", "value": "hdf5::"},
#### "HDF5_PACKAGE_NAME": {"type": "STRING", "value": "hdf5"},
#### "H5EX_BUILD_TESTING": "ON"
========================================================================
IV. Defaults in the HDF5_Examples_options.cmake file
========================================================================
#### DEFAULT:
#### BUILD_SHARED_LIBS:BOOL=OFF
#### H5EX_BUILD_C:BOOL=ON
#### H5EX_BUILD_HL:BOOL=OFF
#### H5EX_BUILD_CXX:BOOL=OFF
#### H5EX_BUILD_FORTRAN:BOOL=OFF
#### H5EX_BUILD_JAVA:BOOL=OFF
#### H5EX_BUILD_FILTERS:BOOL=OFF
#### H5EX_BUILD_TESTING:BOOL=OFF
#### H5EX_ENABLE_PARALLEL:BOOL=OFF
+12 -17
View File
@@ -15,21 +15,15 @@ Notes: This short instruction is written for users who want to quickly
all of the operating systems supported by CMake.
NOTES:
1. Using CMake for building and using HDF5 is under active
development. While we have attempted to provide error-free
files, please understand that development with CMake has not
been extensively tested outside of HDF. The CMake specific
files may change before the next release.
2. CMake for HDF5 development should be usable on any system
1. CMake for HDF5 development should be usable on any system
where CMake is supported. Please send us any comments on how
CMake support can be improved on any system.
3. See the appendix at the bottom of this file for an example
2. See the appendix at the bottom of this file for an example
of using a ctest script for building and testing. See
INSTALL_CMake.txt for more information.
4. See https://cmake.org/cmake/help/latest/command/find_package.html
3. See https://cmake.org/cmake/help/latest/command/find_package.html
for more information on the CMake "Config Mode Search Procedure".
@@ -38,8 +32,9 @@ I. Preconditions
========================================================================
1. We suggest you obtain the latest CMake for your platform from the Kitware
web site. The HDF5 2.0.x product requires a minimum CMake version
web site. The HDF5 z.y.x product requires a minimum CMake version
of 3.18. If you are using VS2022, the minimum CMake version is 3.21.
CMakePresets.json, requires CMake 3.25 or higher.
2. You have installed the HDF5 library built with CMake, by executing
the HDF Install Utility (the *.msi file in the binary package for
@@ -50,24 +45,24 @@ I. Preconditions
or environment variable, set(ENV{HDF5_ROOT} "<install_path>")
to the installed location of HDF5.
On Windows:
HDF5_ROOT=C:/Program Files/HDF_Group/HDF5/2.0.x/
HDF5_ROOT=C:/Program Files/HDF_Group/HDF5/z.y.x/
On unix:
HDF5_ROOT=<install root folder>/HDF_Group/HDF5/2.0.x/
HDF5_ROOT=<install root folder>/HDF_Group/HDF5/z.y.x/
If you are using shared libraries, you may need to add to the path
environment variable. Set the path environment variable to the
installed location of the library files for HDF5.
On Windows (*.dll):
PATH=%PATH%;C:/Program Files/HDF_Group/HDF5/2.0.x/bin
PATH=%PATH%;C:/Program Files/HDF_Group/HDF5/z.y.x/bin
On unix (*.so):
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<install root folder>/HDF_Group/HDF5/2.0.x/lib
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<install root folder>/HDF_Group/HDF5/z.y.x/lib
If you are using filter plugin libraries, you will need to set the
HDF5_PLUGIN_PATH environment variable.
On Windows:
HDF5_PLUGIN_PATH=C:/Program Files/HDF_Group/HDF5/2.0.x/lib/plugin
HDF5_PLUGIN_PATH=C:/Program Files/HDF_Group/HDF5/z.y.x/lib/plugin
On unix:
HDF5_PLUGIN_PATH=<install root folder>/HDF_Group/HDF5/2.0.x/lib/plugin
HDF5_PLUGIN_PATH=<install root folder>/HDF_Group/HDF5/z.y.x/lib/plugin
(Note there are no quote characters used on Windows and all platforms
use forward slashes)
@@ -112,7 +107,7 @@ These steps are described in more detail below.
cmake -G "<generator>" [-D<options>] <sourcepath>
Where <generator> is
Where <generator> is (examples):
* MinGW Makefiles
* NMake Makefiles
* Unix Makefiles