Skip to content

Commit

Permalink
Fix sequence and variable usage
Browse files Browse the repository at this point in the history
  • Loading branch information
byrnHDF committed Dec 1, 2023
1 parent 7e50ba6 commit 1f11e0f
Show file tree
Hide file tree
Showing 9 changed files with 142 additions and 98 deletions.
8 changes: 8 additions & 0 deletions C/H5FLT/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ if (H5EX_BUILD_TESTING)
-D "TEST_MASK_ERROR=true"
-D "TEST_OUTPUT=${testname}.out"
-D "TEST_REFERENCE=${testname}.tst"
-D "TEST_ENV_VAR=HDF5_PLUGIN_PATH"
-D "TEST_ENV_VALUE=${H5EX_HDF5_PLUGIN_PATH}"
-D "TEST_SKIP_COMPARE=1"
-D "TEST_ERRREF=1"
-D "GREP_ERRREF=Filter present but encoding disabled"
Expand All @@ -214,6 +216,8 @@ if (H5EX_BUILD_TESTING)
-D "TEST_EXPECT=0"
-D "TEST_OUTPUT=${testname}.out"
-D "TEST_REFERENCE=${testname}.tst"
-D "TEST_ENV_VAR=HDF5_PLUGIN_PATH"
-D "TEST_ENV_VALUE=${H5EX_HDF5_PLUGIN_PATH}"
-D "TEST_LIBRARY_DIRECTORY=${CMAKE_TEST_LIB_DIRECTORY}"
-P "${${EXAMPLE_PACKAGE_NAME}_RESOURCES_DIR}/runTest.cmake"
)
Expand All @@ -233,6 +237,8 @@ if (H5EX_BUILD_TESTING)
-D "TEST_FILTER_REPLACE=PARAMS { \\1 XXXX \\2 }\n"
-D "TEST_EXPECT=0"
-D "TEST_REFERENCE=${testname}.ddl"
-D "TEST_ENV_VAR=HDF5_PLUGIN_PATH"
-D "TEST_ENV_VALUE=${H5EX_HDF5_PLUGIN_PATH}"
-D "TEST_LIBRARY_DIRECTORY=${CMAKE_TEST_LIB_DIRECTORY}"
-P "${${EXAMPLE_PACKAGE_NAME}_RESOURCES_DIR}/runTest.cmake"
)
Expand All @@ -248,6 +254,8 @@ if (H5EX_BUILD_TESTING)
-D "TEST_FILTER_REPLACE:STRING=PARAMS { XXXX }"
-D "TEST_EXPECT=0"
-D "TEST_REFERENCE=${testname}.ddl"
-D "TEST_ENV_VAR=HDF5_PLUGIN_PATH"
-D "TEST_ENV_VALUE=${H5EX_HDF5_PLUGIN_PATH}"
-D "TEST_LIBRARY_DIRECTORY=${CMAKE_TEST_LIB_DIRECTORY}"
-P "${${EXAMPLE_PACKAGE_NAME}_RESOURCES_DIR}/runTest.cmake"
)
Expand Down
72 changes: 51 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
cmake_minimum_required (VERSION 3.12)
project (H5EXAMPLES C CXX)

#-----------------------------------------------------------------------------
# Define some CMake variables for use later in the project
#-----------------------------------------------------------------------------
set (HDF5EX_C_SRC_DIR ${H5EXAMPLES_SOURCE_DIR}/C)
set (HDF5EX_F90_SRC_DIR ${H5EXAMPLES_SOURCE_DIR}/FORTRAN)
set (HDF5EX_JAVA_DIR ${H5EXAMPLES_SOURCE_DIR}/JAVA)
set (HDF5EX_RESOURCES_DIR ${H5EXAMPLES_SOURCE_DIR}/config/cmake)

#-----------------------------------------------------------------------------
# Basic HDF5Examples stuff here
#-----------------------------------------------------------------------------
include (${H5EXAMPLES_SOURCE_DIR}/config/cmake/HDFMacros.cmake)
include (${H5EXAMPLES_SOURCE_DIR}/config/cmake/HDFExampleMacros.cmake)
include (${HDF5EX_RESOURCES_DIR}/HDFMacros.cmake)
include (${HDF5EX_RESOURCES_DIR}/HDFExampleMacros.cmake)
set (CMAKE_JAVA_INCLUDE_PATH "")

SET_HDF_BUILD_TYPE()

BASIC_SETTINGS (EXAMPLES)

#-----------------------------------------------------------------------------
# Define some CMake variables for use later in the project
#-----------------------------------------------------------------------------
set (HDF5EX_C_SRC_DIR ${H5EXAMPLES_SOURCE_DIR}/C)
set (HDF5EX_F90_SRC_DIR ${H5EXAMPLES_SOURCE_DIR}/FORTRAN)
set (HDF5EX_JAVA_DIR ${H5EXAMPLES_SOURCE_DIR}/JAVA)

#-----------------------------------------------------------------------------
# HDF5 support
#-----------------------------------------------------------------------------
Expand Down Expand Up @@ -119,11 +120,6 @@ if (H5EX_BUILD_TESTING)
configure_file (${${EXAMPLE_PACKAGE_NAME}_RESOURCES_DIR}/CTestCustom.cmake ${PROJECT_BINARY_DIR}/CTestCustom.ctest @ONLY)
endif ()

#-----------------------------------------------------------------------------
# Build examples
#-----------------------------------------------------------------------------
add_subdirectory (C)

if (${H5_LIBVER_DIR} GREATER 16)
#-----------------------------------------------------------------------------
# Option to build Fortran examples
Expand All @@ -136,19 +132,22 @@ if (${H5_LIBVER_DIR} GREATER 16)
if (EXISTS "${H5EXAMPLES_SOURCE_DIR}/FORTRAN" AND IS_DIRECTORY "${H5EXAMPLES_SOURCE_DIR}/FORTRAN")
option (HDF_BUILD_FORTRAN "Build FORTRAN support" OFF)
if (HDF_BUILD_FORTRAN AND HDF5_BUILD_FORTRAN)
set (LINK_Fortran_LIBS ${H5EX_HDF5_LINK_LIBS})
set (H5EX_LINK_Fortran_LIBS ${H5EX_HDF5_LINK_LIBS})

# Parallel IO usage requires MPI to be Linked and Included
if (H5_HAVE_PARALLEL)
set (LINK_Fortran_LIBS ${LINK_Fortran_LIBS} ${MPI_Fortran_LIBRARIES})
set (H5EX_LINK_Fortran_LIBS ${H5EX_LINK_Fortran_LIBS} ${MPI_Fortran_LIBRARIES})
if (MPI_Fortran_LINK_FLAGS)
set (CMAKE_Fortran_EXE_LINKER_FLAGS "${MPI_Fortran_LINK_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}")
endif ()
endif ()

add_subdirectory (FORTRAN)
configure_file (${HDF5EX_F90_SRC_DIR}/H5D/h5_version.h.in ${PROJECT_BINARY_DIR}/FORTRAN/H5D/h5_version.h @ONLY)
else ()
set (HDF_BUILD_FORTRAN OFF CACHE BOOL "Build examples FORTRAN support" FORCE)
endif ()
else ()
set (HDF_BUILD_FORTRAN OFF CACHE BOOL "Build examples FORTRAN support" FORCE)
endif ()

if (${H5_LIBVER_DIR} GREATER 18)
Expand All @@ -157,16 +156,47 @@ if (${H5_LIBVER_DIR} GREATER 16)
#-----------------------------------------------------------------------------
if (EXISTS "${H5EXAMPLES_SOURCE_DIR}/JAVA" AND IS_DIRECTORY "${H5EXAMPLES_SOURCE_DIR}/JAVA")
option (HDF_BUILD_JAVA "Build JAVA support" OFF)
if (HDF_BUILD_JAVA AND HDF5_BUILD_JAVA)
add_subdirectory (JAVA)
endif ()
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 ()

#-----------------------------------------------------------------------------
# Option to build filter examples
#-----------------------------------------------------------------------------
if (EXISTS "${H5EXAMPLES_SOURCE_DIR}/C/H5F" AND IS_DIRECTORY "${H5EXAMPLES_SOURCE_DIR}/C/H5F")
if (EXISTS "${H5EXAMPLES_SOURCE_DIR}/C/H5FLT" AND IS_DIRECTORY "${H5EXAMPLES_SOURCE_DIR}/C/H5FLT")
option (HDF_BUILD_FILTERS "Test 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}")
set (H5EX_HDF5_PLUGIN_PATH $ENV{HDF5_PLUGIN_PATH})
else ()
message (STATUS "LIBRARY PATH=${HDF5_LIBRARY_PATH}/plugin")
set (H5EX_HDF5_PLUGIN_PATH ${HDF5_LIBRARY_PATH}/plugin)
endif ()
message (STATUS "H5EX_HDF5_PLUGIN_PATH=${H5EX_HDF5_PLUGIN_PATH}")
else ()
set (HDF_BUILD_FILTERS OFF CACHE BOOL "Build examples PLUGIN filter support" FORCE)
endif ()
else ()
set (HDF_BUILD_FILTERS OFF CACHE BOOL "Build examples PLUGIN filter support" FORCE)
endif ()
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_FILTERS OFF CACHE BOOL "Build examples PLUGIN filter support" FORCE)
endif ()

#-----------------------------------------------------------------------------
# Build examples
#-----------------------------------------------------------------------------
add_subdirectory (C)
if (HDF_BUILD_FORTRAN AND HDF5_BUILD_FORTRAN)
add_subdirectory (FORTRAN)
endif ()
if (HDF_BUILD_JAVA AND HDF5_BUILD_JAVA)
add_subdirectory (JAVA)
endif ()

6 changes: 3 additions & 3 deletions FORTRAN/H5D/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ project (HDF5Examples_FORTRAN_H5D C CXX Fortran)
# Setup include Directories
#-----------------------------------------------------------------------------
INCLUDE_DIRECTORIES (
${CMAKE_Fortran_MODULE_DIRECTORY}
${CMAKE_Fortran_MODULE_DIRECTORY}${HDF_MOD_EXT}
${PROJECT_BINARY_DIR}
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
)
Expand All @@ -35,7 +35,7 @@ foreach (example_name ${common_examples})
if (H5_HAVE_PARALLEL)
target_include_directories (${EXAMPLE_VARNAME}_f90_${example_name} PUBLIC ${MPI_Fortran_INCLUDE_DIRS})
endif ()
target_link_libraries (${EXAMPLE_VARNAME}_f90_${example_name} ${LINK_Fortran_LIBS})
target_link_libraries (${EXAMPLE_VARNAME}_f90_${example_name} ${H5EX_LINK_Fortran_LIBS})
set_target_properties (${EXAMPLE_VARNAME}_f90_${example_name} PROPERTIES LINKER_LANGUAGE Fortran)
if (H5EX_BUILD_TESTING)
if (${example_name} STREQUAL "h5ex_d_alloc")
Expand Down Expand Up @@ -80,7 +80,7 @@ if (HDF5_VERSION_MAJOR VERSION_GREATER_EQUAL "1.10")
if (H5_HAVE_PARALLEL)
target_include_directories (${EXAMPLE_VARNAME}_f90_${example_name} PUBLIC ${MPI_C_INCLUDE_DIRS})
endif ()
target_link_libraries (${EXAMPLE_VARNAME}_f90_${example_name} ${H5EX_HDF5_LINK_LIBS})
target_link_libraries (${EXAMPLE_VARNAME}_f90_${example_name} ${H5EX_LINK_Fortran_LIBS})
if (H5EX_BUILD_TESTING)
add_custom_command (
TARGET ${EXAMPLE_VARNAME}_f90_${example_name}
Expand Down
6 changes: 3 additions & 3 deletions FORTRAN/H5G/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ project (HDF5Examples_FORTRAN_H5G C CXX Fortran)
# Setup include Directories
#-----------------------------------------------------------------------------
INCLUDE_DIRECTORIES (
${CMAKE_Fortran_MODULE_DIRECTORY}
${CMAKE_Fortran_MODULE_DIRECTORY}${HDF_MOD_EXT}
${PROJECT_BINARY_DIR}
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
)
Expand All @@ -35,7 +35,7 @@ foreach (example_name ${common_examples})
if (H5_HAVE_PARALLEL)
target_include_directories (${EXAMPLE_VARNAME}_f90_${example_name} PUBLIC ${MPI_Fortran_INCLUDE_DIRS})
endif ()
target_link_libraries (${EXAMPLE_VARNAME}_f90_${example_name} ${LINK_Fortran_LIBS})
target_link_libraries (${EXAMPLE_VARNAME}_f90_${example_name} ${H5EX_LINK_Fortran_LIBS})
set_target_properties (${EXAMPLE_VARNAME}_f90_${example_name} PROPERTIES LINKER_LANGUAGE Fortran)
if (H5EX_BUILD_TESTING)
if (NOT ${example_name} STREQUAL "h5ex_g_create" AND NOT ${example_name} STREQUAL "h5ex_g_compact")
Expand Down Expand Up @@ -64,7 +64,7 @@ endforeach ()
# if (H5_HAVE_PARALLEL)
# target_include_directories (${EXAMPLE_VARNAME}_f90_${example_name} PUBLIC ${MPI_C_INCLUDE_DIRS})
# endif ()
# target_link_libraries (${EXAMPLE_VARNAME}_f90_${example_name} ${H5EX_HDF5_LINK_LIBS})
# target_link_libraries (${EXAMPLE_VARNAME}_f90_${example_name} ${H5EX_LINK_Fortran_LIBS})
# if (H5EX_BUILD_TESTING)
# add_custom_command (
# TARGET ${EXAMPLE_VARNAME}_f90_${example_name}
Expand Down
4 changes: 2 additions & 2 deletions FORTRAN/H5PAR/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ project (HDF5Examples_FORTRAN_H5PAR C CXX Fortran)
# Setup include Directories
#-----------------------------------------------------------------------------
INCLUDE_DIRECTORIES (
${CMAKE_Fortran_MODULE_DIRECTORY}
${CMAKE_Fortran_MODULE_DIRECTORY}${HDF_MOD_EXT}
${PROJECT_BINARY_DIR}
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
)
Expand All @@ -33,7 +33,7 @@ foreach (example_name ${examples})
"$<$<BOOL:${${EXAMPLE_VARNAME}_USE_116_API}>:-DH5_USE_116_API>"
)
target_include_directories (${EXAMPLE_VARNAME}_f90_${example_name} PUBLIC ${MPI_Fortran_INCLUDE_DIRS})
target_link_libraries (${EXAMPLE_VARNAME}_f90_${example_name} ${LINK_Fortran_LIBS})
target_link_libraries (${EXAMPLE_VARNAME}_f90_${example_name} ${H5EX_LINK_Fortran_LIBS})
set_target_properties (${EXAMPLE_VARNAME}_f90_${example_name} PROPERTIES LINKER_LANGUAGE Fortran)
endforeach ()

Expand Down
13 changes: 11 additions & 2 deletions FORTRAN/H5T/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
cmake_minimum_required (VERSION 3.12)
project (HDF5Examples_FORTRAN_H5T C CXX Fortran)

#-----------------------------------------------------------------------------
# Setup include Directories
#-----------------------------------------------------------------------------
INCLUDE_DIRECTORIES (
${CMAKE_Fortran_MODULE_DIRECTORY}${HDF_MOD_EXT}
${PROJECT_BINARY_DIR}
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
)

#-----------------------------------------------------------------------------
# Define Sources
#-----------------------------------------------------------------------------
Expand All @@ -21,7 +30,7 @@ include (Fortran_sourcefiles.cmake)
if (H5_HAVE_PARALLEL)
target_include_directories (${EXAMPLE_VARNAME}_f90_${example_name} PUBLIC ${MPI_Fortran_INCLUDE_DIRS})
endif ()
target_link_libraries (${EXAMPLE_VARNAME}_f90_${example_name} ${LINK_Fortran_LIBS})
target_link_libraries (${EXAMPLE_VARNAME}_f90_${example_name} ${H5EX_LINK_Fortran_LIBS})
set_target_properties (${EXAMPLE_VARNAME}_f90_${example_name} PROPERTIES LINKER_LANGUAGE Fortran)
if (H5EX_BUILD_TESTING)
add_custom_command (
Expand All @@ -48,7 +57,7 @@ foreach (example_name ${common_examples})
if (H5_HAVE_PARALLEL)
target_include_directories (${EXAMPLE_VARNAME}_f90_${example_name} PUBLIC ${MPI_Fortran_INCLUDE_DIRS})
endif ()
target_link_libraries (${EXAMPLE_VARNAME}_f90_${example_name} ${LINK_Fortran_LIBS})
target_link_libraries (${EXAMPLE_VARNAME}_f90_${example_name} ${H5EX_LINK_Fortran_LIBS})
set_target_properties (${EXAMPLE_VARNAME}_f90_${example_name} PROPERTIES LINKER_LANGUAGE Fortran)
if (H5EX_BUILD_TESTING)
add_custom_command (
Expand Down
6 changes: 3 additions & 3 deletions JAVA/H5D/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ endforeach ()

foreach (example ${HDF_JAVA_EXAMPLES})
get_filename_component (example_name ${example} NAME_WE)
file (WRITE ${PROJECT_BINARY_DIR}/Manifest.txt
file (WRITE ${PROJECT_BINARY_DIR}/${example_name}_Manifest.txt
"Main-Class: ${example_name}
Class-Path: ${HDFJAVA_CLASSJARS}
"
)
add_jar (${EXAMPLE_VARNAME}_${example_name} SOURCES ${example} MANIFEST ${PROJECT_BINARY_DIR}/Manifest.txt)
add_jar (${EXAMPLE_VARNAME}_${example_name} SOURCES ${example} MANIFEST ${PROJECT_BINARY_DIR}/${example_name}_Manifest.txt)
get_target_property (${EXAMPLE_VARNAME}_${example_name}_JAR_FILE ${EXAMPLE_VARNAME}_${example_name} JAR_FILE)
endforeach ()

Expand All @@ -46,7 +46,7 @@ if (H5EX_BUILD_TESTING)
add_test (
NAME ${EXAMPLE_VARNAME}_jnative-h5-${resultfile}
COMMAND "${CMAKE_COMMAND}"
-D "TEST_TESTER=${CMAKE_Java_RUNTIME}"
-D "TEST_TESTER=${CMAKE_Java_RUNTIME};${CMAKE_Java_RUNTIME_FLAGS}"
-D "TEST_PROGRAM=${resultfile}"
-D "TEST_ARGS:STRING=${ARGN}"
-D "TEST_CLASSPATH:STRING=${CMAKE_JAVA_CLASSPATH}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${${EXAMPLE_VARNAME}_${resultfile}_JAR_FILE}"
Expand Down
47 changes: 13 additions & 34 deletions config/cmake/HDFExampleMacros.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
#
# 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 COPYING 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
# [email protected].
#

#-------------------------------------------------------------------------------
macro (BASIC_SETTINGS varname)
string (TOUPPER ${varname} EXAMPLE_PACKAGE_VARNAME)
Expand All @@ -17,35 +29,7 @@ macro (BASIC_SETTINGS varname)
#-----------------------------------------------------------------------------
# Setup output Directories
#-----------------------------------------------------------------------------
if (NOT ${EXAMPLE_PACKAGE_NAME}_EXTERNALLY_CONFIGURED)
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all Executables."
)
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all Libraries"
)
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all static libraries."
)
set (CMAKE_Fortran_MODULE_DIRECTORY
${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all fortran modules."
)
get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(_isMultiConfig)
set (CMAKE_TEST_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE})
set (CMAKE_PDB_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all pdb files."
)
else ()
set (CMAKE_TEST_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif ()
else ()
# if we are externally configured, but the project uses old cmake scripts
# this may not be set
if (NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
endif ()
endif ()
SET_HDF_OUTPUT_DIRS(${EXAMPLE_PACKAGE_NAME})

#-----------------------------------------------------------------------------
# Option to use Shared/Static libs, default is static
Expand Down Expand Up @@ -285,11 +269,6 @@ macro (HDF5_SUPPORT)
else ()
set (H5_LIB_TYPE STATIC)
endif ()

#-----------------------------------------------------------------------------
# Option to build filter examples
#-----------------------------------------------------------------------------
option (HDF_BUILD_FILTERS "Test filter support" OFF)
endmacro ()

#-------------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 1f11e0f

Please sign in to comment.