Skip to content

Commit

Permalink
HDF5 imported target
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Sep 8, 2020
1 parent 8a60ed7 commit 697da92
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if(NOT CMAKE_BUILD_TYPE)
endif()
project(h5fortran
LANGUAGES C Fortran
VERSION 3.0.4
VERSION 3.1.0
DESCRIPTION "thin, light object-oriented HDF5 Fortran interface"
HOMEPAGE_URL https://github.com/geospace-code/h5fortran)
enable_testing()
Expand Down Expand Up @@ -33,12 +33,11 @@ endif()

add_library(h5fortran)
target_include_directories(h5fortran
PUBLIC ${HDF5_INCLUDE_DIRS}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/include # for IBM XL
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_link_libraries(h5fortran PRIVATE ${HDF5_LIBRARIES})
target_link_libraries(h5fortran PUBLIC HDF5::HDF5)
set_target_properties(h5fortran PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include)
add_library(h5fortran::h5fortran ALIAS h5fortran)

Expand Down
13 changes: 11 additions & 2 deletions cmake/hdf5.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,15 @@ list(REMOVE_DUPLICATES HDF5_INCLUDE_DIRS)

set(HDF5_LIBRARIES ${HDF5_Fortran_HL_LIBRARIES} ${HDF5_Fortran_LIBRARIES} ${HDF5_LIBRARIES})

set(CMAKE_REQUIRED_INCLUDES ${HDF5_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${HDF5_LIBRARIES})
# --- make imported target
# NOTE: this is coming to CMake 3.19 FindHDF5, but the alpha didn't work for Intel Windows.
add_library(HDF5::HDF5 INTERFACE IMPORTED)
target_include_directories(HDF5::HDF5 INTERFACE "${HDF5_INCLUDE_DIRS}")
target_link_libraries(HDF5::HDF5 INTERFACE "${HDF5_LIBRARIES}")
target_compile_definitions(HDF5::HDF5 INTERFACE "${HDF5_DEFINITIONS}")

set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_LIBRARIES HDF5::HDF5)

include(CheckSymbolExists)
check_symbol_exists(H5_HAVE_FILTER_SZIP H5pubconf.h use_szip)
Expand Down Expand Up @@ -89,6 +96,8 @@ if(MSVC)
endif(MSVC)
endif()

# --- configure time checks
# these checks avoid messy, confusing errors at build time

include(CheckFortranSourceCompiles)
set(_code "program test_minimal
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
project('h5fortran', 'fortran',
meson_version : '>=0.52.0',
version : '3.0.4',
version : '3.1.0',
default_options : ['default_library=static', 'buildtype=release', 'warning_level=3'])

subdir('meson')
Expand Down
3 changes: 1 addition & 2 deletions src/concepts/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

add_executable(proto_file_image file_image.f90)
target_include_directories(proto_file_image
PRIVATE ${HDF5_INCLUDE_DIRS}
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/include) # for IBM XL
target_link_libraries(proto_file_image PRIVATE ${HDF5_LIBRARIES})
target_link_libraries(proto_file_image PRIVATE HDF5::HDF5)
set_target_properties(proto_file_image PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include)
add_test(NAME proto:file_image COMMAND $<TARGET_FILE:proto_file_image>)
2 changes: 1 addition & 1 deletion src/tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ endforeach
python = find_program('python')

test('check_shape', python,
args: [files('test_shape.py')],
args: [files('test_shape.py'), meson.build_root() / 'test_shape.h5'],
is_parallel: false,
suite: 'h5shaky', priority: -100, timeout: 90)

0 comments on commit 697da92

Please sign in to comment.