blob: 5082090d11fab8062c34f6e3dea5144087ddd2bc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
cmake_minimum_required (VERSION 3.1.0)
PROJECT(HDF5_HL_F90_SRC C CXX Fortran)
#-----------------------------------------------------------------------------
# configure def file for shared libs on windows
if (WIN32)
if (BUILD_SHARED_LIBS)
if (MSVC)
configure_file (${HDF5_HL_F90_SRC_SOURCE_DIR}/hdf5_hl_fortrandll.def.in ${HDF5_HL_F90_SRC_BINARY_DIR}/hdf5_hl_fortrandll.def @ONLY)
endif (MSVC)
endif (BUILD_SHARED_LIBS)
endif (WIN32)
#-----------------------------------------------------------------------------
# Generate the H5LT and H5TB REAL APIs
#-----------------------------------------------------------------------------
add_executable (H5HL_buildiface
${HDF5_HL_F90_SRC_SOURCE_DIR}/H5HL_buildiface.F90
)
if (WIN32 AND MSVC)
if (BUILD_SHARED_LIBS)
set_target_properties (H5HL_buildiface
PROPERTIES
COMPILE_FLAGS "/MT"
)
endif (BUILD_SHARED_LIBS)
set_target_properties (H5HL_buildiface
PROPERTIES
LINK_FLAGS "/SUBSYSTEM:CONSOLE"
)
endif (WIN32 AND MSVC)
set_target_properties (H5HL_buildiface PROPERTIES
LINKER_LANGUAGE Fortran
Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}
)
set (CMD $<TARGET_FILE:H5HL_buildiface>)
add_custom_command (
OUTPUT ${HDF5_HL_F90_SRC_BINARY_DIR}/H5LTff_gen.F90
${HDF5_HL_F90_SRC_BINARY_DIR}/H5TBff_gen.F90
COMMAND ${CMD}
WORKING_DIRECTORY ${HDF5_HL_F90_SRC_BINARY_DIR}
DEPENDS H5HL_buildiface
)
#-----------------------------------------------------------------------------
# Setup include Directories
#-----------------------------------------------------------------------------
INCLUDE_DIRECTORIES (
${HDF5_HL_SRC_DIR}/src
${HDF5_F90_SRC_DIR}/src
${HDF5_F90_BINARY_DIR}
)
#-----------------------------------------------------------------------------
# hl_f90CStub lib
#-----------------------------------------------------------------------------
set (HDF5_HL_F90_C_SRCS
${HDF5_HL_F90_SRC_SOURCE_DIR}/H5DSfc.c
${HDF5_HL_F90_SRC_SOURCE_DIR}/H5LTfc.c
${HDF5_HL_F90_SRC_SOURCE_DIR}/H5IMfc.c
${HDF5_HL_F90_SRC_SOURCE_DIR}/H5IMcc.c
${HDF5_HL_F90_SRC_SOURCE_DIR}/H5TBfc.c
)
set_source_files_properties (${HDF5_HL_F90_C_SRCS} PROPERTIES LANGUAGE C)
set (HDF5_HL_F90_HEADERS ${HDF5_HL_F90_SRC_SOURCE_DIR}/H5LTf90proto.h)
add_library (${HDF5_HL_F90_C_LIB_TARGET} ${LIB_TYPE} ${HDF5_HL_F90_C_SRCS} ${HDF5_HL_F90_HEADERS})
TARGET_C_PROPERTIES (${HDF5_HL_F90_C_LIB_TARGET} ${LIB_TYPE} " " " ")
target_link_libraries (${HDF5_HL_F90_C_LIB_TARGET} ${HDF5_F90_C_LIB_TARGET} ${HDF5_HL_LIB_TARGET})
set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_HL_F90_C_LIB_TARGET}")
H5_SET_LIB_OPTIONS (${HDF5_HL_F90_C_LIB_TARGET} ${HDF5_HL_F90_C_LIB_NAME} ${LIB_TYPE})
set_target_properties (${HDF5_HL_F90_C_LIB_TARGET} PROPERTIES
FOLDER libraries/hl/fortran
LINKER_LANGUAGE C
INTERFACE_INCLUDE_DIRECTORIES "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
)
#-----------------------------------------------------------------------------
# Fortran Modules
#-----------------------------------------------------------------------------
set (HDF5_HL_F90_F_SRCS
${HDF5_HL_F90_SRC_SOURCE_DIR}/H5DSff.F90
${HDF5_HL_F90_SRC_SOURCE_DIR}/H5TBff.F90
${HDF5_HL_F90_SRC_SOURCE_DIR}/H5LTff.F90
${HDF5_HL_F90_SRC_SOURCE_DIR}/H5IMff.F90
)
set (HDF5_HL_F90_F_SRCS
${HDF5_HL_F90_F_SRCS}
# generated files
${HDF5_HL_F90_SRC_BINARY_DIR}/H5LTff_gen.F90
${HDF5_HL_F90_SRC_BINARY_DIR}/H5TBff_gen.F90
)
set_source_files_properties (${HDF5_HL_F90_F_SRCS} PROPERTIES LANGUAGE Fortran)
add_library (${HDF5_HL_F90_LIB_TARGET} ${LIB_TYPE} ${HDF5_HL_F90_F_SRCS})
set (SHARED_LINK_FLAGS " ")
if (BUILD_SHARED_LIBS)
if (WIN32)
set_property (TARGET ${HDF5_HL_F90_LIB_TARGET}
APPEND PROPERTY COMPILE_DEFINITIONS
BUILD_HDF5_HL_DLL
)
if (MSVC)
set (SHARED_LINK_FLAGS "/DLL /DEF:${HDF5_HL_F90_SRC_BINARY_DIR}/hdf5_hl_fortrandll.def")
endif (MSVC)
endif (WIN32)
endif (BUILD_SHARED_LIBS)
if (WIN32)
set_property (TARGET ${HDF5_HL_F90_LIB_TARGET}
APPEND PROPERTY COMPILE_DEFINITIONS
HDF5F90_WINDOWS
)
endif (WIN32)
TARGET_FORTRAN_PROPERTIES (${HDF5_HL_F90_LIB_TARGET} ${LIB_TYPE} " " ${SHARED_LINK_FLAGS})
target_link_libraries (${HDF5_HL_F90_LIB_TARGET} ${HDF5_HL_F90_C_LIB_TARGET} ${HDF5_F90_LIB_TARGET})
set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_HL_F90_LIB_TARGET}")
H5_SET_LIB_OPTIONS (${HDF5_HL_F90_LIB_TARGET} ${HDF5_HL_F90_LIB_NAME} ${LIB_TYPE})
set_target_properties (${HDF5_HL_F90_LIB_TARGET} PROPERTIES
FOLDER libraries/hl/fortran
LINKER_LANGUAGE Fortran
INTERFACE_INCLUDE_DIRECTORIES "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}
)
#-----------------------------------------------------------------------------
# Add file(s) to CMake Install
#-----------------------------------------------------------------------------
if (WIN32)
set (MOD_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY}/\${BUILD_TYPE})
else (WIN32)
set (MOD_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY})
endif (WIN32)
set (mod_files
${MOD_BUILD_DIR}/h5ds.mod
${MOD_BUILD_DIR}/h5tb.mod
${MOD_BUILD_DIR}/h5lt.mod
${MOD_BUILD_DIR}/h5im.mod
)
install (
FILES
${mod_files}
DESTINATION
${HDF5_INSTALL_INCLUDE_DIR}
COMPONENT
fortheaders
)
#-----------------------------------------------------------------------------
# Add Target(s) to CMake Install for import into other projects
#-----------------------------------------------------------------------------
if (HDF5_EXPORTED_TARGETS)
if (BUILD_SHARED_LIBS)
INSTALL_TARGET_PDB (${HDF5_HL_F90_C_LIB_TARGET} ${HDF5_INSTALL_BIN_DIR} hlfortlibraries)
#INSTALL_TARGET_PDB (${HDF5_HL_F90_LIB_TARGET} ${HDF5_INSTALL_BIN_DIR} hlfortlibraries)
endif (BUILD_SHARED_LIBS)
install (
TARGETS
${HDF5_HL_F90_C_LIB_TARGET}
${HDF5_HL_F90_LIB_TARGET}
EXPORT
${HDF5_EXPORTED_TARGETS}
LIBRARY DESTINATION ${HDF5_INSTALL_LIB_DIR} COMPONENT hlfortlibraries
ARCHIVE DESTINATION ${HDF5_INSTALL_LIB_DIR} COMPONENT hlfortlibraries
RUNTIME DESTINATION ${HDF5_INSTALL_BIN_DIR} COMPONENT hlfortlibraries
FRAMEWORK DESTINATION ${HDF5_INSTALL_FWRK_DIR} COMPONENT hlfortlibraries
)
endif (HDF5_EXPORTED_TARGETS)
|