Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions HDF5Examples/config/cmake/HDFExampleMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ macro (BASIC_SETTINGS varname)
if (H5EXAMPLE_BUILD_CXX)
ENABLE_LANGUAGE (CXX)

set (CMAKE_CXX_STANDARD 98)
# Match the standard the HDF5 C++ library itself is built with.
# H5public.h includes <cinttypes>, so any C++ translation unit
# with hdf5.h needs C++11
set (CMAKE_CXX_STANDARD 11)
set (CMAKE_CXX_STANDARD_REQUIRED TRUE)
set (CMAKE_CXX_EXTENSIONS OFF)
endif ()
Expand Down Expand Up @@ -246,7 +249,7 @@ macro (HDF5_SUPPORT)
message (STATUS "HDF5 HL libs not found - disable build of HL examples")
else ()
if (H5EXAMPLE_BUILD_HL AND ${HDF5_PROVIDES_HL_LIB})
if (BUILD_SHARED_LIBS AND HDF5_shared_HL_FOUND)
if (H5EXAMPLE_USE_SHARED_LIBS AND HDF5_shared_HL_FOUND)
set (H5EXAMPLE_HDF5_LINK_LIBS ${H5EXAMPLE_HDF5_LINK_LIBS} ${HDF5_HL_SHARED_LIBRARY})
elseif (HDF5_static_HL_FOUND)
set (H5EXAMPLE_HDF5_LINK_LIBS ${H5EXAMPLE_HDF5_LINK_LIBS} ${HDF5_HL_STATIC_LIBRARY})
Expand All @@ -262,7 +265,7 @@ macro (HDF5_SUPPORT)
message (STATUS "HDF5 Fortran libs not found - disable build of Fortran examples")
else ()
if (H5EXAMPLE_BUILD_FORTRAN AND ${HDF5_PROVIDES_FORTRAN})
if (BUILD_SHARED_LIBS AND HDF5_shared_Fortran_FOUND)
if (H5EXAMPLE_USE_SHARED_LIBS AND HDF5_shared_Fortran_FOUND)
set (H5EXAMPLE_HDF5_LINK_LIBS ${H5EXAMPLE_HDF5_LINK_LIBS} ${HDF5_FORTRAN_SHARED_LIBRARY})
if (H5EXAMPLE_BUILD_HL AND ${HDF5_PROVIDES_HL_LIB})
set (H5EXAMPLE_HDF5_LINK_LIBS ${H5EXAMPLE_HDF5_LINK_LIBS} ${HDF5_FORTRAN_HL_SHARED_LIBRARY})
Expand All @@ -284,7 +287,7 @@ macro (HDF5_SUPPORT)
message (STATUS "HDF5 CXX libs not found - disable build of CXX examples")
else ()
if (H5EXAMPLE_BUILD_CXX AND ${HDF5_PROVIDES_CPP_LIB})
if (BUILD_SHARED_LIBS AND HDF5_shared_CXX_FOUND)
if (H5EXAMPLE_USE_SHARED_LIBS AND HDF5_shared_CXX_FOUND)
set (H5EXAMPLE_HDF5_LINK_LIBS ${H5EXAMPLE_HDF5_LINK_LIBS} ${HDF5_CXX_SHARED_LIBRARY})
if (H5EXAMPLE_BUILD_HL AND ${HDF5_PROVIDES_HL_LIB})
set (H5EXAMPLE_HDF5_LINK_LIBS ${H5EXAMPLE_HDF5_LINK_LIBS} ${HDF5_CXX_HL_SHARED_LIBRARY})
Expand Down
28 changes: 28 additions & 0 deletions release_docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,34 @@ We would like to thank the many HDF5 community members who contributed to this r

The installed CMake package version configuration file for the library previously used `SameMinorVersion` for the version compatibility logic, causing a `find_package(HDF5 X.Y.Z)` call to fail unless the version of a located HDF5 installation matched both `X` and `Y` of the version number exactly (i.e., releases with a greater minor version number weren't considered backward compatible). This reflected the version compatibility of HDF5 releases prior to version 2.0.0, but doesn't reflect the version compatibility of HDF5 version 2.0.0+ releases. The version compatibility logic now uses `SameMajorVersion`, so a `find_package(HDF5 X.Y.Z)` call will accept all versions of HDF5 where the major version matches `X` (i.e., only releases with a greater major version number will be rejected as not backward compatible).

### Fixed the C++ examples failing to compile when built standalone

The standalone examples build used C++98, but `H5public.h` includes
`<cinttypes>`, which requires C++11. This affected any C++ translation unit
including `hdf5.h`, and did not match the HDF5 C++ library itself, which is
built as C++11. The C++ examples did not compile, against either static or
shared HDF5. The examples are now built as C++11.

Only the standalone build was affected. Examples built as part of the HDF5
build inherit the library's own C++ standard.

### Fixed the examples skipping the HL, Fortran and C++ programs in some configurations

When built standalone against an installed HDF5, the examples chose between
the shared and static HL, Fortran and C++ libraries using `BUILD_SHARED_LIBS`,
while the C library used `H5EXAMPLE_USE_SHARED_LIBS`. Since
`H5EXAMPLE_USE_SHARED_LIBS` determines which component is requested from
`find_package`, and therefore which `HDF5_<linkage>_<lang>_FOUND` variables
exist, `BUILD_SHARED_LIBS` could not select a linkage on its own. With
`H5EXAMPLE_USE_SHARED_LIBS` on and `BUILD_SHARED_LIBS` unset, those examples
were disabled with a "libs not found" message even though the libraries were
installed and had been found. The selection now uses
`H5EXAMPLE_USE_SHARED_LIBS`, matching the C library.

Builds driven through `CTestScript.cmake` were not affected, since its cache
file forces `BUILD_SHARED_LIBS` on. This affected cases where the examples
were built directly without that cache file.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, is it possible to combine them so that there are no two different things giving the same effect?

## Tools

## Performance
Expand Down
Loading