Skip to content

Commit

Permalink
Merge branch 'master' into remove_kita
Browse files Browse the repository at this point in the history
  • Loading branch information
jhendersonHDF authored Mar 19, 2024
2 parents edfcf89 + 93cb19f commit 12a300b
Show file tree
Hide file tree
Showing 27 changed files with 4,884 additions and 1,332 deletions.
338 changes: 206 additions & 132 deletions .github/workflows/main.yml

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "src/hdf5"]
path = src/hdf5
url = https://github.com/HDFGroup/hdf5.git
[submodule "test/vol-tests"]
path = test/vol-tests
url = https://github.com/HDFGroup/vol-tests.git
url = https://github.com/HDFGroup/vol-tests
18 changes: 16 additions & 2 deletions CMake/FindYAJL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,25 @@ find_path(YAJL_INCLUDE_DIR yajl/yajl_version.h DOC "YAJL include directory")
find_library(YAJL_SHARED_LIBRARY NAMES yajl libyajl DOC "Shared YAJL library")
find_library(YAJL_STATIC_LIBRARY NAMES yajl_s libyajl_s DOC "Static YAJL library")

# Version
if (YAJL_INCLUDE_DIR)
file(STRINGS "${YAJL_INCLUDE_DIR}/yajl/yajl_version.h" YAJL_H REGEX "^#define YAJL_MAJOR ")
string(REGEX REPLACE "#define YAJL_MAJOR ([0-9]+).*$" "\\1" YAJL_MAJOR "${YAJL_H}")
file(STRINGS "${YAJL_INCLUDE_DIR}/yajl/yajl_version.h" YAJL_H REGEX "^#define YAJL_MINOR ")
string(REGEX REPLACE "#define YAJL_MINOR ([0-9]+).*$" "\\1" YAJL_MINOR "${YAJL_H}")
file(STRINGS "${YAJL_INCLUDE_DIR}/yajl/yajl_version.h" YAJL_H REGEX "^#define YAJL_MICRO ")
string(REGEX REPLACE "#define YAJL_MICRO ([0-9]+).*$" "\\1" YAJL_MICRO "${YAJL_H}")
set(YAJL_VERSION "${YAJL_MAJOR}.${YAJL_MINOR}.${YAJL_MICRO}")
endif ()


include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set LIBYAJL_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(YAJL DEFAULT_MSG
YAJL_SHARED_LIBRARY YAJL_STATIC_LIBRARY YAJL_INCLUDE_DIR)
find_package_handle_standard_args(YAJL
FOUND_VAR YAJL_FOUND
REQUIRED_VARS YAJL_SHARED_LIBRARY YAJL_STATIC_LIBRARY YAJL_INCLUDE_DIR
VERSION_VAR YAJL_VERSION)

if (YAJL_FOUND)
add_library(yajl-shared SHARED IMPORTED)
Expand Down
2 changes: 1 addition & 1 deletion CMakeInstallation.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ if (NOT HDF5_VOL_REST_NO_PACKAGES)
set (CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES")
set (CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
endif ()
# set the install/unistall icon used for the installer itself
# set the install/uninstall icon used for the installer itself
# There is a bug in NSI that does not handle full unix paths properly.
set (CPACK_NSIS_MUI_ICON "${HDF5_VOL_REST_RESOURCES_EXT_DIR}\\\\hdf.ico")
set (CPACK_NSIS_MUI_UNIICON "${HDF5_VOL_REST_RESOURCES_EXT_DIR}\\\\hdf.ico")
Expand Down
114 changes: 44 additions & 70 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ mark_as_advanced (HDF5_VOL_REST_NO_PACKAGES)
set (HDF5_VOL_REST_LIB_CORENAME "hdf5_vol_rest")
set (HDF5_VOL_REST_TEST_LIB_CORENAME "hdf5_vol_rest_test")


#-----------------------------------------------------------------------------
# Set the target names of all the libraries
#-----------------------------------------------------------------------------
Expand All @@ -100,42 +99,37 @@ set (HDF5_VOL_REST_UTIL_DIR ${HDF5_VOL_REST_SOURCE_DIR}/src/util)
set (HDF5_VOL_REST_TEST_SRC_DIR ${HDF5_VOL_REST_SOURCE_DIR}/test)
set (HDF5_VOL_REST_EXAMPLES_DIR ${HDF5_VOL_REST_SOURCE_DIR}/examples)
set (HDF5_DIR_NAME "hdf5")
set (HDF5_DIR ${HDF5_VOL_REST_SRC_DIR}/${HDF5_DIR_NAME})
set (HDF5_BINARY_DIR ${HDF5_VOL_REST_BINARY_DIR}/${HDF5_DIR_NAME})


#-----------------------------------------------------------------------------
# Define a CMake variable which the user can override to use
# a pre-built HDF5 distribution for building the REST VOL connector
#-----------------------------------------------------------------------------
set (PREBUILT_HDF5_DIR CACHE STRING "Directory of pre-built HDF5 distribution")
set (HDF5_HL_DIR_NAME "hl")

#-----------------------------------------------------------------------------
# Find HDF5, cURL and YAJL before building
#-----------------------------------------------------------------------------
set (HDF5_FOUND FALSE)
if (NOT PREBUILT_HDF5_DIR)
find_package(HDF5 MODULE COMPONENTS C HL)
if (HDF5_ENABLE_THREADSAFE AND NOT Threads_FOUND)
find_package(Threads)
endif ()
if (NOT HDF5_FOUND)
set (HDF5_DIR ${HDF5_VOL_REST_SRC_DIR}/${HDF5_DIR_NAME})
endif ()
if (HDF5_FOUND STREQUAL "")
set (HDF5_FOUND FALSE)
endif()

find_package(HDF5 MODULE COMPONENTS C HL)

if (NOT HDF5_FOUND)
message(SEND_ERROR "HDF5 not found!")
endif()

if (HDF5_ENABLE_THREADSAFE AND NOT Threads_FOUND)
find_package(Threads)
endif ()

find_package (CURL REQUIRED)
find_package (CURL 7.61 REQUIRED)
if (CURL_FOUND)
include_directories(${CURL_INCLUDE_DIRS})
set (LINK_LIBS ${LINK_LIBS} ${CURL_LIBRARIES})
set (LINK_LIBS ${LINK_LIBS} CURL::libcurl)
else ()
message (FATAL_ERROR "cURL not found; please check CURL_INCLUDE_DIR")
endif ()

# Include custom module for finding YAJL
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${HDF5_VOL_REST_RESOURCES_MOD_DIR}")

find_package (YAJL REQUIRED)
find_package (YAJL 2.0.4 REQUIRED)
if (YAJL_FOUND)
include_directories(${YAJL_INCLUDE_DIRS})
set (LINK_LIBS ${LINK_LIBS} yajl)
Expand Down Expand Up @@ -288,7 +282,7 @@ macro (HDF5_VOL_REST_SET_LIB_OPTIONS libtarget libname libtype)
endmacro (HDF5_VOL_REST_SET_LIB_OPTIONS)

#-------------------------------------------------------------------------------
macro (TARGET_C_PROPERTIES wintarget libtype addcompileflags addlinkflags)
macro (RV_TARGET_C_PROPERTIES wintarget libtype addcompileflags addlinkflags)
if (MSVC)
TARGET_MSVC_PROPERTIES (${wintarget} ${libtype} "${addcompileflags} ${WIN_COMPILE_FLAGS}" "${addlinkflags} ${WIN_LINK_FLAGS}")
else ()
Expand Down Expand Up @@ -459,38 +453,23 @@ configure_file (${HDF5_VOL_REST_RESOURCES_DIR}/rv_cmake_config.h.in ${HDF5_VOL_R
#-----------------------------------------------------------------------------
# Include the main src directory and HDF5 distribution directory
#-----------------------------------------------------------------------------
if (PREBUILT_HDF5_DIR)
set (HDF5_VOL_REST_INCLUDE_DIRECTORIES
${HDF5_VOL_REST_SRC_DIR}
${HDF5_VOL_REST_BINARY_DIR}
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
${PREBUILT_HDF5_DIR}/include
CACHE
INTERNAL
"Include directories for HDF5 REST VOL connector"
)
elseif (HDF5_FOUND)
set (HDF5_VOL_REST_INCLUDE_DIRECTORIES
${HDF5_VOL_REST_SRC_DIR}
${HDF5_VOL_REST_BINARY_DIR}
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
${HDF5_INCLUDE_DIRS}
CACHE
INTERNAL
"Include directories for HDF5 REST VOL connector"
)
else ()
set (HDF5_VOL_REST_INCLUDE_DIRECTORIES

set (HDF5_VOL_REST_INCLUDE_DIRECTORIES
${HDF5_VOL_REST_SRC_DIR}
${HDF5_VOL_REST_BINARY_DIR}
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
${HDF5_DIR}
${HDF5_BINARY_DIR}
CACHE
INTERNAL
)

list(APPEND HDF5_VOL_REST_INCLUDE_DIRECTORIES
${HDF5_INCLUDE_DIRS}
)

set(HDF5_VOL_REST_INCLUDE_DIRECTORIES
${HDF5_VOL_REST_INCLUDE_DIRECTORIES}
CACHE
INTERNAL
"Include directories for HDF5 REST VOL connector"
)
endif ()
)

INCLUDE_DIRECTORIES (${HDF5_VOL_REST_INCLUDE_DIRECTORIES})

Expand Down Expand Up @@ -587,27 +566,22 @@ include (${HDF5_VOL_REST_RESOURCES_DIR}/HDFCompilerFlags.cmake)
#endif ()

#-----------------------------------------------------------------------------
# Build HDF5, unless the user has specified to use
# a pre-built HDF5 distribution
# Include HDF5 Directories
#-----------------------------------------------------------------------------
if (NOT PREBUILT_HDF5_DIR AND NOT HDF5_FOUND)
include_directories(${HDF5_VOL_REST_SRC_DIR}/${HDF5_DIR_NAME}/src)
include_directories(${HDF5_VOL_REST_SRC_DIR}/${HDF5_DIR_NAME}/src/H5FDsubfiling)
add_subdirectory(${HDF5_DIR} ${PROJECT_BINARY_DIR}/${HDF5_DIR_NAME})
elseif (NOT PREBUILT_HDF5_DIR AND HDF5_FOUND)
set (HDF5_LIBRARIES_TO_EXPORT
${HDF5_C_HL_LIBRARIES}
include_directories(${HDF5_INCLUDE_DIRS})

if (BUILD_SHARED_LIBS)
list (APPEND LINK_SHARED_LIBS
${HDF5_C_LIBRARIES}
)
else ()
link_directories(${PREBUILT_HDF5_DIR}/lib)
set (HDF5_LIBRARIES_TO_EXPORT
libhdf5.so
libhdf5_hl.so
libhdf5.a
libhdf5_hl.a
)
endif ()
${HDF5_C_HL_LIBRARIES})
endif()

if (BUILD_STATIC_LIBS)
list (APPEND LINK_LIBS
${HDF5_C_LIBRARIES}
${HDF5_C_HL_LIBRARIES})
endif()


#-----------------------------------------------------------------------------
# Build the REST VOL
Expand Down
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
- [II.B.iii.b Autotools options](#iibiiib-autotools-options)
- [II.B.iii.c Manual Build with CMake](#iibiiic-manual-build-with-cmake)
- [II.B.iii.d CMake options](#iibiiid-cmake-options)
- [II.B.iv. Build Results](#iibiv-build-results)
- [II.B.iv. Building at HDF5 Build Time](#iibiv-building-at-hdf5-build-time)
- [II.B.v. Build Results](#iibv-build-results)
- [III. Using/Testing the REST VOL connector](#iii-usingtesting-the-rest-vol-connector)
- [IV. More Information](#iv-more-information)

Expand Down Expand Up @@ -63,7 +64,7 @@ To build the REST VOL connector, the following libraries are required:
Additionally, the HDF5 library must have its high-level interface enabled at build time
unless the REST VOL examples are disabled.

+ libcurl - networking support
+ libcurl (ver. 7.61.0 or greater) - networking support
+ https://curl.haxx.se/

+ libyajl (ver. 2.0.4 or greater) - JSON parsing and construction
Expand Down Expand Up @@ -122,7 +123,7 @@ include the flag `-H <dir>` where `dir` is the path to the HDF5 install prefix.

NOTE: For those who are capable of using both build systems, the autotools build currently
does not support out-of-tree builds. If the REST VOL source directory is used for an autotools
build, it is important not to re-use the source directory for a later build using CMake.
build, it is important not to reuse the source directory for a later build using CMake.
This can cause build conflicts and result in strange and unexpected behavior.


Expand Down Expand Up @@ -294,8 +295,11 @@ components mentioned previously cannot be found within the system path.
Note, when setting BUILD_SHARED_LIBS=ON and YAJL_USE_STATIC_LIBRARIES=ON, the static YAJL libraries have be build with the position independent code (PIC) option enabled. In the static YAJL build,
this PIC option has been turned off by default.

### II.B.iv. Building at HDF5 Build Time

### II.B.iv. Build Results
It is also possible to build the REST VOL as part of the build process for the HDF5 library, using CMake's FetchContent module. This can be done using a local copy of the REST VOL's source code, or by providing the information for the repository to be automatically cloned from a branch of a Github repository. For full instructions on this process, see [Building and testing HDF5 VOL connectors with CMake FetchContent](https://github.com/HDFGroup/hdf5/blob/develop/doc/cmake-vols-fetchcontent.md).

### II.B.v. Build Results

If the build is successful, the following files will be written into the installation directory:

Expand Down
32 changes: 10 additions & 22 deletions build_vol_cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ INSTALL_DIR="${SCRIPT_DIR}/rest_vol_build"
# Set the default build directory
BUILD_DIR="${SCRIPT_DIR}/rest_vol_cmake_build_files"

# Default name of the directory for the included HDF5 source distribution,
# as well as the default directory where it gets installed
HDF5_DIR="src/hdf5"

# By default, tell CMake to generate Unix Makefiles
CMAKE_GENERATOR="Unix Makefiles"

Expand All @@ -40,8 +36,7 @@ CONNECTOR_DEBUG_OPT=
CURL_DEBUG_OPT=
MEM_TRACK_OPT=
THREAD_SAFE_OPT=
PREBUILT_HDF5_OPT=
PREBUILT_HDF5_DIR=
HDF5_INSTALL_DIR=
CURL_OPT=
YAJL_OPT=
YAJL_LIB_OPT=
Expand Down Expand Up @@ -78,7 +73,7 @@ usage()
echo " is 'source directory/rest_vol_build'."
echo
echo " -H DIR To specify a directory where HDF5 has already"
echo " been built."
echo " been installed."
echo
echo " -B DIR Specifies the directory that CMake should use as"
echo " the build tree location. Default is"
Expand All @@ -96,7 +91,7 @@ usage()
echo
}

optspec=":hctdmstG:H:C:Y:B:P:-"
optspec=":hctdmstlG:H:C:Y:B:P:-"
while getopts "$optspec" optchar; do
case "${optchar}" in
h)
Expand Down Expand Up @@ -143,8 +138,7 @@ while getopts "$optspec" optchar; do
echo
;;
H)
PREBUILT_HDF5_OPT="-DPREBUILT_HDF5_DIR=$OPTARG"
PREBUILT_HDF5_DIR="$OPTARG"
HDF5_INSTALL_DIR="$OPTARG"
echo "Set HDF5 install directory to: $OPTARG"
echo
;;
Expand Down Expand Up @@ -181,13 +175,13 @@ if [ "$NPROCS" -eq "0" ]; then
fi
fi

# Ensure that the HDF5 submodule gets checked out
if [ -z "$(ls -A ${SCRIPT_DIR}/${HDF5_DIR})" ]; then
# Ensure that the vol-tests submodule gets checked out
if [ -z "$(ls -A ${SCRIPT_DIR}/test/vol-tests)" ]; then
git submodule init
git submodule update
fi

# Once HDF5 has been built, build the REST VOL connector against HDF5.
# Build the REST VOL connector against HDF5.
echo "*******************************************"
echo "* Building REST VOL connector and test suite *"
echo "*******************************************"
Expand All @@ -201,7 +195,7 @@ rm -f "${BUILD_DIR}/CMakeCache.txt"

cd "${BUILD_DIR}"

CFLAGS="-D_POSIX_C_SOURCE=200809L" cmake -G "${CMAKE_GENERATOR}" -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" "${PREBUILT_HDF5_OPT}" "${CURL_OPT}" "${YAJL_OPT}" "${YAJL_LIB_OPT}" "${CONNECTOR_DEBUG_OPT}" "${CURL_DEBUG_OPT}" "${MEM_TRACK_OPT}" "${THREAD_SAFE_OPT}" "${SCRIPT_DIR}"
CFLAGS="-D_POSIX_C_SOURCE=200809L" cmake -G "${CMAKE_GENERATOR}" "-DHDF5_ROOT=${HDF5_INSTALL_DIR}" -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" "${CURL_OPT}" "${YAJL_OPT}" "${YAJL_LIB_OPT}" "${CONNECTOR_DEBUG_OPT}" "${CURL_DEBUG_OPT}" "${MEM_TRACK_OPT}" "${THREAD_SAFE_OPT}" "${SCRIPT_DIR}"

echo "Build files have been generated for CMake generator '${CMAKE_GENERATOR}'"

Expand All @@ -210,7 +204,7 @@ if [ "${CMAKE_GENERATOR}" = "Unix Makefiles" ]; then
make -j${NPROCS} && make install || exit 1
fi

echo "REST VOL (and HDF5) built"
echo "REST VOL built"

# Clean out the old CMake cache
rm -f "${BUILD_DIR}/CMakeCache.txt"
Expand All @@ -220,13 +214,7 @@ rm -f "${BUILD_DIR}/CMakeCache.txt"
mkdir -p "${BUILD_DIR}/tests/vol-tests"
cd "${BUILD_DIR}/tests/vol-tests"

if [ -z "$PREBUILT_HDF5_DIR" ]; then
HDF5_INSTALL_DIR=$HDF5_DIR
else
HDF5_INSTALL_DIR=$PREBUILT_HDF5_DIR
fi

CFLAGS="-D_POSIX_C_SOURCE=200809L" cmake -G "${CMAKE_GENERATOR}" -DHDF5_DIR=${HDF5_INSTALL_DIR} -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" "${CONNECTOR_DEBUG_OPT}" "${CURL_DEBUG_OPT}" "${MEM_TRACK_OPT}" "${THREAD_SAFE_OPT}" "${SCRIPT_DIR}/test/vol-tests"
CFLAGS="-D_POSIX_C_SOURCE=200809L" cmake -G "${CMAKE_GENERATOR}" "-DHDF5_DIR=${HDF5_INSTALL_DIR}" -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" "${CONNECTOR_DEBUG_OPT}" "${CURL_DEBUG_OPT}" "${MEM_TRACK_OPT}" "${THREAD_SAFE_OPT}" "${SCRIPT_DIR}/test/vol-tests"

echo "Build files generated for vol-tests"

Expand Down
3 changes: 2 additions & 1 deletion config/cmake/rv-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ else ()
endif ()

set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} @PACKAGE_SHARE_INSTALL_DIR@/..)
find_package (YAJL REQUIRED)
find_package (CURL 7.61 QUIET REQUIRED)
find_package (YAJL 2.0.4 QUIET REQUIRED)
8 changes: 4 additions & 4 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ set (examples
foreach (example ${examples})
if (BUILD_STATIC_LIBS)
add_executable (${example} ${HDF5_VOL_REST_EXAMPLES_SOURCE_DIR}/${example}.c)
TARGET_C_PROPERTIES (${example} STATIC " " " ")
target_link_libraries (${example} PUBLIC ${HDF5_VOL_REST_LIB_TARGET} ${HDF5_LIBRARIES_TO_EXPORT})
RV_TARGET_C_PROPERTIES (${example} STATIC " " " ")
target_link_libraries (${example} PUBLIC ${HDF5_VOL_REST_LIB_TARGET} ${LINK_LIBS})
set_target_properties (${example} PROPERTIES FOLDER examples)
endif ()

if (BUILD_SHARED_LIBS)
add_executable (${example}-shared ${HDF5_VOL_REST_EXAMPLES_SOURCE_DIR}/${example}.c)
TARGET_C_PROPERTIES (${example}-shared SHARED " " " ")
target_link_libraries (${example}-shared PUBLIC ${HDF5_VOL_REST_LIBSH_TARGET} ${HDF5_LIBRARIES_TO_EXPORT})
RV_TARGET_C_PROPERTIES (${example}-shared SHARED " " " ")
target_link_libraries (${example}-shared PUBLIC ${HDF5_VOL_REST_LIBSH_TARGET} ${LINK_SHARED_LIBS})
set_target_properties (${example}-shared PROPERTIES FOLDER examples)
endif ()

Expand Down
Loading

0 comments on commit 12a300b

Please sign in to comment.