Skip to content

Commit

Permalink
Move C++ and Fortran and examples to HDF5Examples folder (#4552)
Browse files Browse the repository at this point in the history
  • Loading branch information
byrnHDF authored Jun 8, 2024
1 parent f44fa55 commit dca6370
Show file tree
Hide file tree
Showing 148 changed files with 1,119 additions and 1,029 deletions.
3 changes: 2 additions & 1 deletion HDF5Examples/C/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
cmake_minimum_required (VERSION 3.12)
cmake_minimum_required (VERSION 3.18)
project (HDF5Examples_C C)

#-----------------------------------------------------------------------------
# Build the C Examples
#-----------------------------------------------------------------------------
add_subdirectory (${PROJECT_SOURCE_DIR}/TUTR)
add_subdirectory (${PROJECT_SOURCE_DIR}/H5D)
add_subdirectory (${PROJECT_SOURCE_DIR}/H5G)
add_subdirectory (${PROJECT_SOURCE_DIR}/H5T)
Expand Down
2 changes: 1 addition & 1 deletion HDF5Examples/C/H5D/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 3.12)
cmake_minimum_required (VERSION 3.18)
project (HDF5Examples_C_H5D C)

#-----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion HDF5Examples/C/H5FLT/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 3.12)
cmake_minimum_required (VERSION 3.18)
project (HDF5Examples_C_H5FLT C)

set (dyn_examples)
Expand Down
2 changes: 1 addition & 1 deletion HDF5Examples/C/H5G/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 3.12)
cmake_minimum_required (VERSION 3.18)
project (HDF5Examples_C_H5G C)

#-----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion HDF5Examples/C/H5PAR/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 3.12)
cmake_minimum_required (VERSION 3.18)
project (H5PAR_C C)

#-----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion HDF5Examples/C/H5T/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 3.12)
cmake_minimum_required (VERSION 3.18)
project (HDF5Examples_C_H5T C)

#-----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion HDF5Examples/C/H5VDS/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 3.12)
cmake_minimum_required (VERSION 3.18)
project (HDF5Examples_C_H5VDS C)

#-----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion HDF5Examples/C/Perf/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 3.12)
cmake_minimum_required (VERSION 3.18)
project (HDF5Examples_C_PERFORM C)

#-----------------------------------------------------------------------------
Expand Down
File renamed without changes.
113 changes: 113 additions & 0 deletions HDF5Examples/C/TUTR/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
cmake_minimum_required (VERSION 3.18)
project (HDF5Examples_C_TUTR C)

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

foreach (example_name ${examples})
add_executable (${EXAMPLE_VARNAME}_tutr_${example_name} ${PROJECT_SOURCE_DIR}/${example_name}.c)
target_compile_options(${EXAMPLE_VARNAME}_tutr_${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_116_API}>:-DH5_USE_116_API>"
)
if (H5_HAVE_PARALLEL)
target_include_directories (${EXAMPLE_VARNAME}_tutr_${example_name} PUBLIC ${MPI_C_INCLUDE_DIRS})
endif ()
target_link_libraries (${EXAMPLE_VARNAME}_tutr_${example_name} ${H5EX_HDF5_LINK_LIBS})
endforeach ()


if (H5EX_BUILD_TESTING)
file (MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/red ${PROJECT_BINARY_DIR}/blue ${PROJECT_BINARY_DIR}/u2w)

set (${EXAMPLE_VARNAME}_tutr_CLEANFILES
Attributes.h5
btrees_file.h5
cmprss.h5
default_file.h5
dset.h5
extend.h5
extlink_prefix_source.h5
extlink_source.h5
extlink_target.h5
group.h5
groups.h5
hard_link.h5
mount1.h5
mount2.h5
one_index_file.h5
only_dspaces_and_attrs_file.h5
only_huge_mesgs_file.h5
REF_REG.h5
refere.h5
refer_deprec.h5
refer_extern1.h5
refer_extern2.h5
SDS.h5
SDScompound.h5
SDSextendible.h5
Select.h5
separate_indexes_file.h5
small_lists_file.h5
soft_link.h5
subset.h5
unix2win.h5
blue/prefix_target.h5
red/prefix_target.h5
u2w/u2w_target.h5
)

# Remove any output file left over from previous test run
add_test (
NAME ${EXAMPLE_VARNAME}_tutr-clear-objects
COMMAND ${CMAKE_COMMAND} -E remove ${${EXAMPLE_VARNAME}_tutr_CLEANFILES}
)
set_tests_properties (${EXAMPLE_VARNAME}_tutr-clear-objects PROPERTIES
FIXTURES_SETUP clear_${EXAMPLE_VARNAME}_tutr
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
)
add_test (
NAME ${EXAMPLE_VARNAME}_tutr-clean-objects
COMMAND ${CMAKE_COMMAND} -E remove ${${EXAMPLE_VARNAME}_tutr_CLEANFILES}
)
set_tests_properties (${EXAMPLE_VARNAME}_tutr-clean-objects PROPERTIES
FIXTURES_CLEANUP clear_${EXAMPLE_VARNAME}_tutr
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
)

macro (ADD_H5_TEST testname)
if (HDF5_USING_ANALYSIS_TOOL)
add_test (NAME ${EXAMPLE_VARNAME}_tutr_${testname} COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:${EXAMPLE_VARNAME}_tutr_${testname}>)
else ()
add_test (
NAME ${EXAMPLE_VARNAME}_tutr_${testname}
COMMAND "${CMAKE_COMMAND}"
-D "TEST_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}"
-D "TEST_PROGRAM=$<TARGET_FILE:${EXAMPLE_VARNAME}_tutr_${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}_tutr_${testname} PROPERTIES FIXTURES_REQUIRED clear_${EXAMPLE_VARNAME}_tutr)
if (last_test)
set_tests_properties (${EXAMPLE_VARNAME}_tutr_${testname} PROPERTIES DEPENDS ${last_test})
endif ()
set (last_test "${EXAMPLE_VARNAME}_tutr_${testname}")
endmacro ()

foreach (example_name ${examples})
ADD_H5_TEST (${example_name})
endforeach ()
endif ()
File renamed without changes.
32 changes: 32 additions & 0 deletions HDF5Examples/C/TUTR/C_sourcefiles.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#-----------------------------------------------------------------------------
# Define Sources, one file per application
#-----------------------------------------------------------------------------
set (examples
h5_crtdat
h5_rdwt
h5_crtatt
h5_crtgrp
h5_crtgrpar
h5_crtgrpd
h5_cmprss
h5_extend
h5_subset
h5_write
h5_read
h5_extend_write
h5_chunk_read
h5_compound
h5_group
h5_select
h5_attribute
h5_mount
h5_ref_extern
h5_ref_compat
h5_reference_deprec
h5_drivers
h5_ref2reg_deprec
h5_extlink
h5_elink_unix2win
h5_shared_mesg
h5_debug_trace
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
22 changes: 18 additions & 4 deletions HDF5Examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
cmake_minimum_required (VERSION 3.12)
cmake_minimum_required (VERSION 3.18)
project (H5EXAMPLES C)

#-----------------------------------------------------------------------------
# Define some CMake variables for use later in the project
#-----------------------------------------------------------------------------
set (H5EX_C_SRC_DIR ${H5EXAMPLES_SOURCE_DIR}/C)
set (H5EX_CXX_SRC_DIR ${H5EXAMPLES_SOURCE_DIR}/CXX)
set (H5EX_F90_SRC_DIR ${H5EXAMPLES_SOURCE_DIR}/FORTRAN)
set (H5EX_JAVA_DIR ${H5EXAMPLES_SOURCE_DIR}/JAVA)
#-----------------------------------------------------------------------------
Expand Down Expand Up @@ -144,7 +145,7 @@ if (${H5_LIBVER_DIR} GREATER 16)
set (H5_FC_FUNC "H5_FC_FUNC(name,NAME) name ## _")
set (H5_FC_FUNC_ "H5_FC_FUNC_(name,NAME) name ## _")
if (EXISTS "${H5EXAMPLES_SOURCE_DIR}/FORTRAN" AND IS_DIRECTORY "${H5EXAMPLES_SOURCE_DIR}/FORTRAN")
option (HDF_BUILD_FORTRAN "Build FORTRAN support" OFF)
option (HDF_BUILD_FORTRAN "Build examples FORTRAN support" OFF)
if (HDF_BUILD_FORTRAN AND HDF5_BUILD_FORTRAN)
set (H5EX_LINK_Fortran_LIBS ${H5EX_HDF5_LINK_LIBS})

Expand All @@ -170,19 +171,28 @@ if (${H5_LIBVER_DIR} GREATER 16)
# Option to build JAVA examples
#-----------------------------------------------------------------------------
if (EXISTS "${H5EXAMPLES_SOURCE_DIR}/JAVA" AND IS_DIRECTORY "${H5EXAMPLES_SOURCE_DIR}/JAVA")
option (HDF_BUILD_JAVA "Build JAVA support" OFF)
option (HDF_BUILD_JAVA "Build examples JAVA support" OFF)
else ()
set (HDF_BUILD_JAVA OFF CACHE BOOL "Build examples JAVA support" FORCE)
endif ()
else ()
set (HDF_BUILD_JAVA OFF CACHE BOOL "Build examples JAVA support" FORCE)
endif ()

#-----------------------------------------------------------------------------
# Build the CPP Examples
#-----------------------------------------------------------------------------
if (EXISTS "${H5EXAMPLES_SOURCE_DIR}/CXX" AND IS_DIRECTORY "${H5EXAMPLES_SOURCE_DIR}/CXX")
option (HDF_BUILD_CPP_LIB "Build examples C++ support" OFF)
else ()
set (HDF_BUILD_CPP_LIB OFF CACHE BOOL "Build examples C++ support" FORCE)
endif ()

#-----------------------------------------------------------------------------
# Option to build filter examples
#-----------------------------------------------------------------------------
if (EXISTS "${H5EXAMPLES_SOURCE_DIR}/C/H5FLT" AND IS_DIRECTORY "${H5EXAMPLES_SOURCE_DIR}/C/H5FLT")
option (HDF_BUILD_FILTERS "Test filter support" OFF)
option (HDF_BUILD_FILTERS "Build examples PLUGIN filter support" OFF)
if (HDF_BUILD_FILTERS AND HDF5_ENABLE_PLUGIN_SUPPORT)
if(DEFINED ENV{HDF5_PLUGIN_PATH})
message (STATUS "ENV PATH=$ENV{HDF5_PLUGIN_PATH}")
Expand All @@ -203,6 +213,7 @@ if (${H5_LIBVER_DIR} GREATER 16)
else ()
set (HDF_BUILD_FORTRAN OFF} CACHE BOOL "Build examples FORTRAN support" FORCE)
set (HDF_BUILD_JAVA OFF CACHE BOOL "Build examples JAVA support" FORCE)
set (HDF_BUILD_CPP_LIB OFF CACHE BOOL "Build examples C++ support" FORCE)
set (HDF_BUILD_FILTERS OFF CACHE BOOL "Build examples PLUGIN filter support" FORCE)
endif ()

Expand All @@ -216,4 +227,7 @@ endif ()
if (HDF_BUILD_JAVA AND HDF5_BUILD_JAVA)
add_subdirectory (JAVA)
endif ()
if (HDF_BUILD_CPP_LIB AND HDF5_BUILD_CPP_LIB)
add_subdirectory (CXX)
endif ()

5 changes: 5 additions & 0 deletions HDF5Examples/CXX/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cmake_minimum_required (VERSION 3.18)
project (HDFCXX_EXAMPLES CXX)

add_subdirectory (H5D)
add_subdirectory (TUTR)
83 changes: 83 additions & 0 deletions HDF5Examples/CXX/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_116_API}>:-DH5_USE_116_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_USING_ANALYSIS_TOOL)
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/CXX/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
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit dca6370

Please sign in to comment.