2020-02-22 06:16:06 +08:00
|
|
|
cmake_minimum_required (VERSION 3.12)
|
2018-04-20 23:11:55 +08:00
|
|
|
project (HDF5_TOOLS_TEST_H5REPACK C)
|
2016-10-27 23:06:00 +08:00
|
|
|
|
|
|
|
# --------------------------------------------------------------------
|
2019-10-02 05:38:48 +08:00
|
|
|
# Add h5repack test executables
|
2016-10-27 23:06:00 +08:00
|
|
|
# --------------------------------------------------------------------
|
|
|
|
add_executable (testh5repack_detect_szip ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/testh5repack_detect_szip.c)
|
2019-06-18 20:46:25 +08:00
|
|
|
target_include_directories (testh5repack_detect_szip
|
2020-09-26 05:43:57 +08:00
|
|
|
PRIVATE "${HDF5_TOOLS_SRC_H5REPACK_SOURCE_DIR};${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
|
2018-05-10 03:29:44 +08:00
|
|
|
)
|
2019-06-18 20:46:25 +08:00
|
|
|
if (NOT ONLY_SHARED_LIBS)
|
|
|
|
TARGET_C_PROPERTIES (testh5repack_detect_szip STATIC)
|
|
|
|
target_link_libraries (testh5repack_detect_szip PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET} ${HDF5_TEST_LIB_TARGET})
|
|
|
|
else ()
|
|
|
|
TARGET_C_PROPERTIES (testh5repack_detect_szip SHARED)
|
|
|
|
target_link_libraries (testh5repack_detect_szip PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} ${HDF5_TEST_LIBSH_TARGET})
|
|
|
|
endif ()
|
2016-10-27 23:06:00 +08:00
|
|
|
set_target_properties (testh5repack_detect_szip PROPERTIES FOLDER tools)
|
|
|
|
|
2020-09-05 05:36:52 +08:00
|
|
|
# These are the same files used by the h5repack tool
|
2016-10-27 23:06:00 +08:00
|
|
|
set (REPACK_COMMON_SOURCES
|
|
|
|
${HDF5_TOOLS_SRC_H5REPACK_SOURCE_DIR}/h5repack_copy.c
|
|
|
|
${HDF5_TOOLS_SRC_H5REPACK_SOURCE_DIR}/h5repack_filters.c
|
|
|
|
${HDF5_TOOLS_SRC_H5REPACK_SOURCE_DIR}/h5repack_opttable.c
|
|
|
|
${HDF5_TOOLS_SRC_H5REPACK_SOURCE_DIR}/h5repack_parse.c
|
|
|
|
${HDF5_TOOLS_SRC_H5REPACK_SOURCE_DIR}/h5repack_refs.c
|
|
|
|
${HDF5_TOOLS_SRC_H5REPACK_SOURCE_DIR}/h5repack_verify.c
|
|
|
|
${HDF5_TOOLS_SRC_H5REPACK_SOURCE_DIR}/h5repack.c
|
|
|
|
)
|
|
|
|
add_executable (h5repacktest ${REPACK_COMMON_SOURCES} ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/h5repacktst.c)
|
2019-06-18 20:46:25 +08:00
|
|
|
target_include_directories (h5repacktest
|
2020-09-26 05:43:57 +08:00
|
|
|
PRIVATE "${HDF5_TOOLS_SRC_H5REPACK_SOURCE_DIR};${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_TEST_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
|
2018-05-10 03:29:44 +08:00
|
|
|
)
|
2019-06-18 20:46:25 +08:00
|
|
|
if (NOT ONLY_SHARED_LIBS)
|
|
|
|
TARGET_C_PROPERTIES (h5repacktest STATIC)
|
|
|
|
target_link_libraries (h5repacktest PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET})
|
|
|
|
else ()
|
|
|
|
TARGET_C_PROPERTIES (h5repacktest SHARED)
|
|
|
|
target_link_libraries (h5repacktest PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_TEST_LIBSH_TARGET})
|
|
|
|
endif ()
|
2016-10-27 23:06:00 +08:00
|
|
|
set_target_properties (h5repacktest PROPERTIES FOLDER tools)
|
|
|
|
|
2018-04-18 04:57:51 +08:00
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# If plugin library tests can be tested
|
|
|
|
#-----------------------------------------------------------------------------
|
2018-11-07 05:45:58 +08:00
|
|
|
if (BUILD_SHARED_LIBS)
|
2019-06-19 23:35:55 +08:00
|
|
|
set (H5REPACK_TOOL_PLUGIN_LIB_CORENAME "dynlibadd")
|
|
|
|
set (H5REPACK_TOOL_PLUGIN_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${H5REPACK_TOOL_PLUGIN_LIB_CORENAME}")
|
|
|
|
set (H5REPACK_TOOL_PLUGIN_LIB_TARGET ${H5REPACK_TOOL_PLUGIN_LIB_CORENAME})
|
|
|
|
set (H5REPACK_TOOL_PLUGIN_LIB_VCORENAME "dynlibvers")
|
|
|
|
set (H5REPACK_TOOL_PLUGIN_LIB_VNAME "${HDF5_EXTERNAL_LIB_PREFIX}${H5REPACK_TOOL_PLUGIN_LIB_VCORENAME}")
|
|
|
|
set (H5REPACK_TOOL_PLUGIN_LIB_VTARGET ${H5REPACK_TOOL_PLUGIN_LIB_VCORENAME})
|
2016-10-27 23:06:00 +08:00
|
|
|
|
2019-06-19 23:35:55 +08:00
|
|
|
add_library (${H5REPACK_TOOL_PLUGIN_LIB_TARGET} SHARED dynlib_rpk.c)
|
2020-09-26 05:43:57 +08:00
|
|
|
target_include_directories (${H5REPACK_TOOL_PLUGIN_LIB_TARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
|
2019-06-19 23:35:55 +08:00
|
|
|
TARGET_C_PROPERTIES (${H5REPACK_TOOL_PLUGIN_LIB_TARGET} SHARED)
|
2021-06-24 06:08:55 +08:00
|
|
|
target_link_libraries (${H5REPACK_TOOL_PLUGIN_LIB_TARGET} PRIVATE ${HDF5_LIBSH_TARGET})
|
2019-06-19 23:35:55 +08:00
|
|
|
H5_SET_LIB_OPTIONS (${H5REPACK_TOOL_PLUGIN_LIB_TARGET} ${H5REPACK_TOOL_PLUGIN_LIB_NAME} SHARED "LIB")
|
2016-10-27 23:06:00 +08:00
|
|
|
|
2019-06-19 23:35:55 +08:00
|
|
|
add_library (${H5REPACK_TOOL_PLUGIN_LIB_VTARGET} SHARED dynlib_vrpk.c)
|
2020-09-26 05:43:57 +08:00
|
|
|
target_include_directories (${H5REPACK_TOOL_PLUGIN_LIB_VTARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
|
2019-06-19 23:35:55 +08:00
|
|
|
TARGET_C_PROPERTIES (${H5REPACK_TOOL_PLUGIN_LIB_VTARGET} SHARED)
|
2021-06-24 06:08:55 +08:00
|
|
|
target_link_libraries (${H5REPACK_TOOL_PLUGIN_LIB_VTARGET} PRIVATE ${HDF5_LIBSH_TARGET})
|
2019-06-19 23:35:55 +08:00
|
|
|
H5_SET_LIB_OPTIONS (${H5REPACK_TOOL_PLUGIN_LIB_VTARGET} ${H5REPACK_TOOL_PLUGIN_LIB_VNAME} SHARED "LIB")
|
2016-10-27 23:06:00 +08:00
|
|
|
|
2020-09-05 05:36:52 +08:00
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Add Target to clang-format
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
if (HDF5_ENABLE_FORMATTERS)
|
|
|
|
clang_format (HDF5_TOOLS_TEST_H5REPACK_PLUGIN_FORMAT ${H5REPACK_TOOL_PLUGIN_LIB_TARGET})
|
|
|
|
clang_format (HDF5_TOOLS_TEST_H5REPACK_VPLUGIN_FORMAT ${H5REPACK_TOOL_PLUGIN_LIB_VTARGET})
|
|
|
|
endif ()
|
|
|
|
|
2018-11-07 05:45:58 +08:00
|
|
|
# make plugins dir
|
|
|
|
file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/plugins")
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Copy plugin library to a plugins folder
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
add_custom_command (
|
2019-06-19 23:35:55 +08:00
|
|
|
TARGET ${H5REPACK_TOOL_PLUGIN_LIB_TARGET}
|
2018-11-07 05:45:58 +08:00
|
|
|
POST_BUILD
|
|
|
|
COMMAND ${CMAKE_COMMAND}
|
|
|
|
ARGS -E copy_if_different
|
2019-06-19 23:35:55 +08:00
|
|
|
"$<TARGET_FILE:${H5REPACK_TOOL_PLUGIN_LIB_TARGET}>"
|
|
|
|
"${CMAKE_BINARY_DIR}/plugins/$<TARGET_FILE_NAME:${H5REPACK_TOOL_PLUGIN_LIB_TARGET}>"
|
2018-11-07 05:45:58 +08:00
|
|
|
)
|
|
|
|
add_custom_command (
|
2019-06-19 23:35:55 +08:00
|
|
|
TARGET ${H5REPACK_TOOL_PLUGIN_LIB_VTARGET}
|
2018-11-07 05:45:58 +08:00
|
|
|
POST_BUILD
|
|
|
|
COMMAND ${CMAKE_COMMAND}
|
|
|
|
ARGS -E copy_if_different
|
2019-06-19 23:35:55 +08:00
|
|
|
"$<TARGET_FILE:${H5REPACK_TOOL_PLUGIN_LIB_VTARGET}>"
|
|
|
|
"${CMAKE_BINARY_DIR}/plugins/$<TARGET_FILE_NAME:${H5REPACK_TOOL_PLUGIN_LIB_VTARGET}>"
|
2018-11-07 05:45:58 +08:00
|
|
|
)
|
|
|
|
endif ()
|
2016-10-27 23:06:00 +08:00
|
|
|
|
2019-10-02 05:38:48 +08:00
|
|
|
# --------------------------------------------------------------------
|
|
|
|
# Add the h5repack test executable
|
|
|
|
# --------------------------------------------------------------------
|
|
|
|
if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS)
|
|
|
|
add_executable (h5repackgentest ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/h5repackgentest.c)
|
2020-09-26 05:43:57 +08:00
|
|
|
target_include_directories (h5repackgentest PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
|
2019-10-02 05:38:48 +08:00
|
|
|
TARGET_C_PROPERTIES (h5repackgentest STATIC)
|
|
|
|
target_link_libraries (h5repackgentest PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
|
|
|
|
set_target_properties (h5repackgentest PROPERTIES FOLDER generator/tools)
|
|
|
|
|
2020-09-05 05:36:52 +08:00
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Add Target to clang-format
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
if (HDF5_ENABLE_FORMATTERS)
|
|
|
|
clang_format (HDF5_TOOLS_TEST_H5REPACK_FORMAT h5repackgentest)
|
|
|
|
endif ()
|
|
|
|
|
2019-10-02 05:38:48 +08:00
|
|
|
#add_test (NAME h5repackgentest COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5repackgentest>)
|
|
|
|
endif ()
|
|
|
|
|
2020-01-16 02:28:53 +08:00
|
|
|
if (HDF5_TEST_TOOLS AND HDF5_TEST_SERIAL)
|
2020-01-16 01:38:06 +08:00
|
|
|
include (CMakeTests.cmake)
|
|
|
|
endif ()
|