Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to use HighFive C++ #5095

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from
Draft
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
26 changes: 14 additions & 12 deletions CMakeInstallation.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -609,18 +609,20 @@ The HDF5 data model, file format, API, library, and tools are open and distribut
INSTALL_TYPES Full Developer User
)
if (HDF5_BUILD_CPP_LIB)
cpack_add_component (hlcpplibraries
DISPLAY_NAME "HDF5 HL C++ Libraries"
DEPENDS hllibraries
GROUP Runtime
INSTALL_TYPES Full Developer User
)
cpack_add_component (hlcppheaders
DISPLAY_NAME "HDF5 HL C++ Headers"
DEPENDS hlcpplibraries
GROUP Development
INSTALL_TYPES Full Developer
)
if (NOT HDF5_USE_HIGH_FIVE)
cpack_add_component (hlcpplibraries
DISPLAY_NAME "HDF5 HL C++ Libraries"
DEPENDS hllibraries
GROUP Runtime
INSTALL_TYPES Full Developer User
)
cpack_add_component (hlcppheaders
DISPLAY_NAME "HDF5 HL C++ Headers"
DEPENDS hlcpplibraries
GROUP Development
INSTALL_TYPES Full Developer
)
endif ()
endif ()
if (HDF5_BUILD_FORTRAN)
cpack_add_component (hlfortlibraries
Expand Down
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,7 @@ if (EXISTS "${HDF5_SOURCE_DIR}/c++" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/c++")
option (HDF5_BUILD_CPP_LIB "Build HDF5 C++ Library" OFF)
if (HDF5_BUILD_CPP_LIB)
# check for unsupported options
if (HDF5_ENABLE_PARALLEL)
if (HDF5_ENABLE_PARALLEL AND NOT HDF5_USE_HIGH_FIVE)
if (NOT HDF5_ALLOW_UNSUPPORTED)
message (FATAL_ERROR " **** Parallel and C++ options are mutually exclusive, override with HDF5_ALLOW_UNSUPPORTED option **** ")
else ()
Expand All @@ -1192,7 +1192,9 @@ if (EXISTS "${HDF5_SOURCE_DIR}/c++" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/c++")
if (HDF5_BUILD_HL_LIB)
if (EXISTS "${HDF5_SOURCE_DIR}/hl/c++" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/hl/c++")
#-- Build the High Level Fortran source codes
add_subdirectory (hl/c++)
if (NOT HDF5_USE_HIGH_FIVE)
add_subdirectory (hl/c++)
endif ()
endif ()
endif ()
endif ()
Expand Down
40 changes: 33 additions & 7 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,24 @@
"PLUGIN_USE_LOCALCONTENT": "OFF"
}
},
{
"name": "ci-HighFiveVars",
"hidden": true,
"cacheVariables": {
"HIGHFIVE_TGZ_NAME": {"type": "STRING", "value": "v2.10.0.tar.gz"},
"HIGHFIVE_TGZ_ORIGPATH": {"type": "STRING", "value": "https://github.com/BlueBrain/HighFive/archive/refs/tags"},
"HIGHFIVE_GIT_URL": {"type": "STRING", "value": "https://github.com/BlueBrain/HighFive.git"},
"HIGHFIVE_GIT_BRANCH": {"type": "STRING", "value": "master"}
}
},
{
"name": "ci-HighFive",
"hidden": true,
"inherits": ["ci-HighFiveVars", "ci-base-tgz"],
"cacheVariables": {
"HIGHFIVE_USE_LOCALCONTENT": "OFF"
}
},
{
"name": "ci-StdExamples",
"hidden": true,
Expand Down Expand Up @@ -123,12 +141,20 @@
"HDF_TEST_EXPRESS": "2"
}
},
{
"name": "ci-HighFiveCPP",
"hidden": true,
"inherits": ["ci-CPP", "ci-HighFive"],
"cacheVariables": {
"HDF5_USE_HIGH_FIVE": "ON"
}
},
{
"name": "ci-StdShar-MSVC",
"description": "MSVC Standard Config for x64 (Release)",
"inherits": [
"ci-x64-Release-MSVC",
"ci-CPP",
"ci-HighFiveCPP",
"ci-Java",
"ci-StdShar"
]
Expand All @@ -138,7 +164,7 @@
"description": "MSVC Standard Config for x64 (Release)",
"inherits": [
"ci-x64-Release-MSVC",
"ci-CPP",
"ci-HighFiveCPP",
"ci-Fortran",
"ci-Java",
"ci-StdShar"
Expand All @@ -149,7 +175,7 @@
"description": "Clang Standard Config for x64 (Release)",
"inherits": [
"ci-x64-Release-Clang",
"ci-CPP",
"ci-HighFiveCPP",
"ci-Fortran",
"ci-Java",
"ci-StdShar"
Expand All @@ -160,7 +186,7 @@
"description": "Clang Standard Config for macos (Release)",
"inherits": [
"ci-macos-Release-Clang",
"ci-CPP",
"ci-HighFiveCPP",
"ci-Java",
"ci-StdShar"
]
Expand All @@ -170,7 +196,7 @@
"description": "GNUC Standard Config for macos (Release)",
"inherits": [
"ci-macos-Release-GNUC",
"ci-CPP",
"ci-HighFiveCPP",
"ci-Java",
"ci-StdShar"
]
Expand All @@ -180,7 +206,7 @@
"description": "GNUC Standard Config for x64 (Release)",
"inherits": [
"ci-x64-Release-GNUC",
"ci-CPP",
"ci-HighFiveCPP",
"ci-Fortran",
"ci-Java",
"ci-StdShar"
Expand All @@ -199,7 +225,7 @@
"description": "Intel Standard Config for x64 (Release)",
"inherits": [
"ci-x64-Release-Intel",
"ci-CPP",
"ci-HighFiveCPP",
"ci-Fortran",
"ci-Java",
"ci-StdShar"
Expand Down
6 changes: 5 additions & 1 deletion HDF5Examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,11 @@ if (H5EX_BUILD_JAVA AND HDF5_BUILD_JAVA)
add_subdirectory (JAVA)
endif ()
if (H5EX_BUILD_CXX AND HDF5_BUILD_CPP_LIB)
add_subdirectory (CXX)
if (NOT H5EX_USE_HIGH_FIVE AND NOT HDF5_USE_HIGH_FIVE)
add_subdirectory (CXX)
else ()
add_subdirectory (HFCXX)
endif ()
endif ()
if (H5EX_BUILD_PYTHON)
add_subdirectory (PYTHON)
Expand Down
10 changes: 10 additions & 0 deletions HDF5Examples/HFCXX/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required (VERSION 3.18)
project (HDFCXX_EXAMPLES CXX)

add_subdirectory (H5D)
#add_subdirectory (TUTR)

#-- Add High Level Examples
#if (H5EX_BUILD_HL AND HDF5_BUILD_HL_LIB)
# add_subdirectory (HL)
#endif ()
83 changes: 83 additions & 0 deletions HDF5Examples/HFCXX/H5D/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
cmake_minimum_required (VERSION 3.18)
project (HDF5Examples_CXX_H5D CXX)

#-----------------------------------------------------------------------------
# Define Sources
#-----------------------------------------------------------------------------
include (C_sourcefiles.cmake)

if (HDF5_VERSION_MAJOR VERSION_GREATER_EQUAL "1.8")
foreach (example_name ${examples})
add_executable (${EXAMPLE_VARNAME}_cpp_ex_${example_name} ${PROJECT_SOURCE_DIR}/${example_name}.cpp)
target_compile_options(${EXAMPLE_VARNAME}_cpp_ex_${example_name}
PRIVATE
"$<$<BOOL:${${EXAMPLE_VARNAME}_USE_16_API}>:-DH5_USE_16_API>"
"$<$<BOOL:${${EXAMPLE_VARNAME}_USE_18_API}>:-DH5_USE_18_API>"
"$<$<BOOL:${${EXAMPLE_VARNAME}_USE_110_API}>:-DH5_USE_110_API>"
"$<$<BOOL:${${EXAMPLE_VARNAME}_USE_112_API}>:-DH5_USE_112_API>"
"$<$<BOOL:${${EXAMPLE_VARNAME}_USE_114_API}>:-DH5_USE_114_API>"
"$<$<BOOL:${${EXAMPLE_VARNAME}_USE_200_API}>:-DH5_USE_200_API>"
)
if (H5_HAVE_PARALLEL)
target_include_directories (${EXAMPLE_VARNAME}_cpp_ex_${example_name} PUBLIC ${MPI_C_INCLUDE_DIRS})
endif ()
target_link_libraries (${EXAMPLE_VARNAME}_cpp_ex_${example_name} ${H5EX_HDF5_LINK_LIBS})
endforeach ()
endif ()

if (H5EX_BUILD_TESTING)
set (${EXAMPLE_VARNAME}_cpp_ex_CLEANFILES
Group.h5
SDS.h5
SDScompound.h5
SDSextendible.h5
Select.h5
)
add_test (
NAME ${EXAMPLE_VARNAME}_cpp_ex-clear-objects
COMMAND ${CMAKE_COMMAND}
-E remove ${${EXAMPLE_VARNAME}_cpp_ex_CLEANFILES}
)
set_tests_properties (${EXAMPLE_VARNAME}_cpp_ex-clear-objects PROPERTIES
FIXTURES_SETUP clear_${EXAMPLE_VARNAME}_cpp_ex
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
)
add_test (
NAME ${EXAMPLE_VARNAME}_cpp_ex-clean-objects
COMMAND ${CMAKE_COMMAND}
-E remove ${${EXAMPLE_VARNAME}_cpp_ex_CLEANFILES}
)
set_tests_properties (${EXAMPLE_VARNAME}_cpp_ex-clean-objects PROPERTIES
FIXTURES_CLEANUP clear_${EXAMPLE_VARNAME}_cpp_ex
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
)

macro (ADD_H5_TEST testname)
if (HDF5_ENABLE_USING_MEMCHECKER)
add_test (NAME ${EXAMPLE_VARNAME}_cpp_ex_${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:${EXAMPLE_VARNAME}_cpp_ex_${testname}>)
else ()
add_test (
NAME ${EXAMPLE_VARNAME}_cpp_ex_${testname}
COMMAND "${CMAKE_COMMAND}"
-D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
-D "TEST_PROGRAM=$<TARGET_FILE:${EXAMPLE_VARNAME}_cpp_ex_${testname}>"
-D "TEST_ARGS:STRING="
-D "TEST_FOLDER=${PROJECT_BINARY_DIR}"
-D "TEST_EXPECT=0"
-D "TEST_SKIP_COMPARE=TRUE"
-D "TEST_OUTPUT=${testname}.out"
-D "TEST_LIBRARY_DIRECTORY=${CMAKE_TEST_LIB_DIRECTORY}"
-P "${H5EX_RESOURCES_DIR}/runTest.cmake"
)
endif ()
set_tests_properties (${EXAMPLE_VARNAME}_cpp_ex_${testname} PROPERTIES FIXTURES_REQUIRED clear_${EXAMPLE_VARNAME}_cpp_ex)
if (last_test)
set_tests_properties (${EXAMPLE_VARNAME}_cpp_ex_${testname} PROPERTIES DEPENDS ${last_test})
endif ()
set (last_test "${EXAMPLE_VARNAME}_cpp_ex_${testname}")
endmacro ()

foreach (example_name ${examples})
ADD_H5_TEST (${example_name})
endforeach ()
endif ()
12 changes: 12 additions & 0 deletions HDF5Examples/HFCXX/H5D/C_sourcefiles.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#-----------------------------------------------------------------------------
# Define Sources, one file per application
#-----------------------------------------------------------------------------
set (examples
create
# readdata
# writedata
# compound
# extend_ds
# chunks
# h5group
)
81 changes: 81 additions & 0 deletions HDF5Examples/HFCXX/H5D/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#
# Copyright by The HDF Group.
# All rights reserved.
#
# This file is part of HDF5. The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
# the LICENSE file, which can be found at the root of the source code
# distribution tree, or in https://www.hdfgroup.org/licenses.
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
##
## Makefile.am
## Run automake to generate a Makefile.in from this file.
##
#
# HDF5 Library Examples Makefile(.in)
#

include $(top_srcdir)/config/commence.am

INSTALL_SCRIPT_FILES = run-c++-ex.sh

# These are the programs that 'make all' or 'make prog' will build and
# which 'make check' will run. List them in the order they should be run.
EXAMPLE_PROG=create readdata writedata compound extend_ds chunks h5group \
h5tutr_cmprss h5tutr_crtatt h5tutr_crtdat h5tutr_crtgrpar \
h5tutr_crtgrp h5tutr_crtgrpd h5tutr_extend h5tutr_rdwt \
h5tutr_subset
TEST_SCRIPT=testh5c++.sh
TEST_EXAMPLES_SCRIPT=$(INSTALL_SCRIPT_FILES)

# These are the example files to be installed
INSTALL_FILES=create.cpp readdata.cpp writedata.cpp compound.cpp \
extend_ds.cpp chunks.cpp h5group.cpp \
h5tutr_cmprss.cpp h5tutr_crtatt.cpp h5tutr_crtdat.cpp \
h5tutr_crtgrpar.cpp h5tutr_crtgrp.cpp h5tutr_crtgrpd.cpp \
h5tutr_extend.cpp h5tutr_rdwt.cpp h5tutr_subset.cpp

# Some of the examples depend on files created by running other examples
readdata.chkexe_: create.chkexe_
chunks.chkexe_: extend_ds.chkexe_
h5tutr_rdwt.chkexe_: h5tutr_crtdat.chkexe
h5tutrcrtatt.chkexe_: h5tutr_crtdat.chkexe
h5tutr_crtgrpd.chkexe_: h5tutr_crtgrpar.chkexe

# Tell conclude.am that these are C++ tests.
CXX_API=yes

# Where to install examples
# Note: no '/' after DESTDIR. Explanation in commence.am
EXAMPLEDIR=${DESTDIR}$(examplesdir)/c++
EXAMPLETOPDIR=${DESTDIR}$(examplesdir)

# How to build programs using h5c++
$(EXTRA_PROG): $(H5CPP)
$(H5CPP) $(H5CCFLAGS) $(CPPFLAGS) -o $@ $(srcdir)/$@.cpp

# List dependencies for each program. Normally, automake would take
# care of this for us, but if we tell automake about the programs it
# will try to build them with the normal C++ compiler, not h5c++. This is
# an inelegant way of solving the problem, unfortunately.
create: $(srcdir)/create.cpp
readdata: $(srcdir)/readdata.cpp
writedata: $(srcdir)/writedata.cpp
compound: $(srcdir)/compound.cpp
extend_ds: $(srcdir)/extend_ds.cpp
chunks: $(srcdir)/chunks.cpp
h5group: $(srcdir)/h5group.cpp

h5tutr_cmprss: $(srcdir)/h5tutr_cmprss.cpp
h5tutr_crtatt: $(srcdir)/h5tutr_crtatt.cpp
h5tutr_crtdat: $(srcdir)/h5tutr_crtdat.cpp
h5tutr_crtgrpar: $(srcdir)/h5tutr_crtgrpar.cpp
h5tutr_crtgrp: $(srcdir)/h5tutr_crtgrp.cpp
h5tutr_crtgrpd: $(srcdir)/h5tutr_crtgrpd.cpp
h5tutr_extend: $(srcdir)/h5tutr_extend.cpp
h5tutr_rdwt: $(srcdir)/h5tutr_rdwt.cpp
h5tutr_subset: $(srcdir)/h5tutr_subset.cpp

include $(top_srcdir)/config/examples.am
include $(top_srcdir)/config/conclude.am
Loading
Loading