Skip to content

Commit 697da92

Browse files
committed
HDF5 imported target
1 parent 8a60ed7 commit 697da92

File tree

5 files changed

+16
-9
lines changed

5 files changed

+16
-9
lines changed

CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ if(NOT CMAKE_BUILD_TYPE)
44
endif()
55
project(h5fortran
66
LANGUAGES C Fortran
7-
VERSION 3.0.4
7+
VERSION 3.1.0
88
DESCRIPTION "thin, light object-oriented HDF5 Fortran interface"
99
HOMEPAGE_URL https://github.com/geospace-code/h5fortran)
1010
enable_testing()
@@ -33,12 +33,11 @@ endif()
3333

3434
add_library(h5fortran)
3535
target_include_directories(h5fortran
36-
PUBLIC ${HDF5_INCLUDE_DIRS}
3736
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/include # for IBM XL
3837
INTERFACE
3938
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
4039
$<INSTALL_INTERFACE:include>)
41-
target_link_libraries(h5fortran PRIVATE ${HDF5_LIBRARIES})
40+
target_link_libraries(h5fortran PUBLIC HDF5::HDF5)
4241
set_target_properties(h5fortran PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include)
4342
add_library(h5fortran::h5fortran ALIAS h5fortran)
4443

cmake/hdf5.cmake

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,15 @@ list(REMOVE_DUPLICATES HDF5_INCLUDE_DIRS)
3131

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

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

3744
include(CheckSymbolExists)
3845
check_symbol_exists(H5_HAVE_FILTER_SZIP H5pubconf.h use_szip)
@@ -89,6 +96,8 @@ if(MSVC)
8996
endif(MSVC)
9097
endif()
9198

99+
# --- configure time checks
100+
# these checks avoid messy, confusing errors at build time
92101

93102
include(CheckFortranSourceCompiles)
94103
set(_code "program test_minimal

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
project('h5fortran', 'fortran',
22
meson_version : '>=0.52.0',
3-
version : '3.0.4',
3+
version : '3.1.0',
44
default_options : ['default_library=static', 'buildtype=release', 'warning_level=3'])
55

66
subdir('meson')

src/concepts/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11

22
add_executable(proto_file_image file_image.f90)
33
target_include_directories(proto_file_image
4-
PRIVATE ${HDF5_INCLUDE_DIRS}
54
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/include) # for IBM XL
6-
target_link_libraries(proto_file_image PRIVATE ${HDF5_LIBRARIES})
5+
target_link_libraries(proto_file_image PRIVATE HDF5::HDF5)
76
set_target_properties(proto_file_image PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include)
87
add_test(NAME proto:file_image COMMAND $<TARGET_FILE:proto_file_image>)

src/tests/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ endforeach
2424
python = find_program('python')
2525

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

0 commit comments

Comments
 (0)