2015-06-09 13:50:51 +00:00
|
|
|
if( HAVE_FORTRAN )
|
2014-06-18 16:14:01 +00:00
|
|
|
|
2020-03-22 19:54:43 +00:00
|
|
|
configure_file( eccodes_settings.h.in eccodes_settings.h @ONLY )
|
|
|
|
|
2013-04-10 15:46:41 +00:00
|
|
|
set( srcdir ${CMAKE_CURRENT_SOURCE_DIR} )
|
|
|
|
set( bindir ${CMAKE_CURRENT_BINARY_DIR} )
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2013-05-02 09:28:03 +00:00
|
|
|
include_directories( ${srcdir} ${bindir} )
|
2013-04-10 15:46:41 +00:00
|
|
|
|
|
|
|
ecbuild_add_executable( TARGET grib_types
|
|
|
|
NOINSTALL
|
|
|
|
SOURCES grib_types.f90 grib_fortran_kinds.c )
|
|
|
|
|
|
|
|
add_custom_command( OUTPUT grib_kinds.h
|
|
|
|
COMMAND grib_types > grib_kinds.h
|
|
|
|
DEPENDS grib_types )
|
|
|
|
|
2018-05-19 11:38:24 +00:00
|
|
|
if( ${ECCODES_SIZEOF_INT} EQUAL ${ECCODES_SIZEOF_LONG} )
|
2015-01-28 22:54:42 +00:00
|
|
|
set( _long_int_interface grib_f90_int.f90 )
|
|
|
|
set( _long_int_interface_ec eccodes_f90_int.f90 )
|
2013-04-10 15:46:41 +00:00
|
|
|
else()
|
2015-01-28 22:54:42 +00:00
|
|
|
set( _long_int_interface grib_f90_long_int.f90 )
|
|
|
|
set( _long_int_interface_ec eccodes_f90_long_int.f90 )
|
2013-04-10 15:46:41 +00:00
|
|
|
endif()
|
|
|
|
|
2018-05-19 11:38:24 +00:00
|
|
|
if( ${ECCODES_SIZEOF_INT} EQUAL ${ECCODES_SIZEOF_SIZE_T} )
|
2015-01-28 22:54:42 +00:00
|
|
|
set( _sizet_int_interface grib_f90_int_size_t.f90 )
|
|
|
|
set( _sizet_int_interface_ec eccodes_f90_int_size_t.f90 )
|
2013-07-04 16:52:13 +00:00
|
|
|
else()
|
2015-01-28 22:54:42 +00:00
|
|
|
set( _sizet_int_interface grib_f90_long_size_t.f90 )
|
|
|
|
set( _sizet_int_interface_ec eccodes_f90_long_size_t.f90 )
|
2013-07-04 16:52:13 +00:00
|
|
|
endif()
|
|
|
|
|
2013-04-10 15:46:41 +00:00
|
|
|
add_custom_command( OUTPUT grib_f90.f90
|
2013-07-04 16:52:13 +00:00
|
|
|
COMMAND cat ${srcdir}/grib_f90_head.f90 ${srcdir}/${_long_int_interface} ${srcdir}/${_sizet_int_interface} ${srcdir}/grib_f90_tail.f90 > grib_f90.f90
|
|
|
|
DEPENDS grib_f90_head.f90 grib_f90_tail.f90 grib_kinds.h ${_long_int_interface} ${_sizet_int_interface} )
|
2015-01-28 22:54:42 +00:00
|
|
|
add_custom_command( OUTPUT eccodes_f90.f90
|
|
|
|
COMMAND cat ${srcdir}/eccodes_f90_head.f90 ${srcdir}/${_long_int_interface_ec} ${srcdir}/${_sizet_int_interface_ec} ${srcdir}/eccodes_f90_tail.f90 > eccodes_f90.f90
|
|
|
|
DEPENDS eccodes_f90_head.f90 eccodes_f90_tail.f90 grib_kinds.h ${_long_int_interface_ec} ${_sizet_int_interface_ec} )
|
2013-04-10 15:46:41 +00:00
|
|
|
|
|
|
|
|
2020-09-09 15:47:53 +00:00
|
|
|
# Note: $<BUILD_INTERFACE:...> will be present only while building (for the whole bundle),
|
|
|
|
# whereas $<INSTALL_INTERFACE:...> is only present once you install the package / bundle
|
|
|
|
ecbuild_add_library( TARGET eccodes_f90
|
2024-04-16 16:17:08 +00:00
|
|
|
SOURCES grib_fortran.cc grib_f90.f90 eccodes_f90.f90 grib_kinds.h
|
2020-09-09 15:47:53 +00:00
|
|
|
GENERATED grib_f90.f90 eccodes_f90.f90
|
|
|
|
PUBLIC_INCLUDES $<BUILD_INTERFACE:${CMAKE_Fortran_MODULE_DIRECTORY}>
|
|
|
|
$<INSTALL_INTERFACE:${INSTALL_INCLUDE_DIR}>
|
2021-07-29 14:31:38 +00:00
|
|
|
PRIVATE_LIBS eccodes ${ECCODES_PTHREADS_LIBRARIES} )
|
2020-09-09 15:47:53 +00:00
|
|
|
|
2019-08-02 09:04:53 +00:00
|
|
|
if( DEFINED ecbuild_VERSION AND NOT ${ecbuild_VERSION} VERSION_LESS 3.1 )
|
|
|
|
# Installed module directory is not in the PUBLIC INCLUDES!
|
|
|
|
target_include_directories( eccodes_f90 PUBLIC $<INSTALL_INTERFACE:${INSTALL_INCLUDE_DIR}> )
|
|
|
|
|
|
|
|
# NOTE: When eccodes accepts ecbuild 3.0 as minimum requirement,
|
|
|
|
# this should instead be written inside the ecbuild_add_library macro with:
|
|
|
|
# PUBLIC_INCLUDES $<INSTALL_INTERFACE:${INSTALL_INCLUDE_DIR}>
|
|
|
|
endif()
|
|
|
|
|
2016-07-20 13:39:04 +00:00
|
|
|
add_custom_command( TARGET eccodes_f90 POST_BUILD
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/include
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_Fortran_MODULE_DIRECTORY}/${CMAKE_CFG_INTDIR}/eccodes.mod ${CMAKE_BINARY_DIR}/include
|
2020-03-26 14:21:56 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_Fortran_MODULE_DIRECTORY}/${CMAKE_CFG_INTDIR}/grib_api.mod ${CMAKE_BINARY_DIR}/include )
|
2013-04-10 15:46:41 +00:00
|
|
|
|
2015-01-07 16:12:11 +00:00
|
|
|
# Add the eccodes module file as well
|
2015-01-08 15:34:11 +00:00
|
|
|
#set(_eccodes_mod "${CMAKE_Fortran_MODULE_DIRECTORY}/eccodes.mod" )
|
|
|
|
|
|
|
|
#add_custom_command(
|
|
|
|
# OUTPUT ${_eccodes_mod}
|
|
|
|
# WORKING_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}
|
|
|
|
# #COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_Fortran_MODULE_DIRECTORY}/grib_api.mod" ${_eccodes_mod}
|
|
|
|
# #COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_Fortran_MODULE_DIRECTORY}/grib_api.mod" ${_eccodes_mod}
|
|
|
|
# COMMAND "/usr/bin/sh" "-c" "if test -f GRIB_API.mod; then ln -s GRIB_API.mod ECCODES.mod; fi"
|
|
|
|
# COMMAND "/usr/bin/sh" "-c" "if test -f grib_api.mod; then ln -s grib_api.mod eccodes.mod; fi"
|
2015-02-13 18:04:42 +00:00
|
|
|
# DEPENDS eccodes_f90
|
2015-01-08 15:34:11 +00:00
|
|
|
# VERBATIM
|
|
|
|
#)
|
|
|
|
#add_custom_target(add_eccodes_mod ALL DEPENDS ${_eccodes_mod})
|
2015-01-07 16:12:11 +00:00
|
|
|
|
2013-04-10 15:46:41 +00:00
|
|
|
ecbuild_add_resources( TARGET fortran_resources
|
2017-07-19 17:06:07 +00:00
|
|
|
PACK
|
2023-12-30 12:32:31 +00:00
|
|
|
grib_api_constants.h grib_api_externals.h
|
2013-04-10 15:46:41 +00:00
|
|
|
grib_api_visibility.h grib_types.f90 create_grib_f90.sh
|
2013-07-04 16:52:13 +00:00
|
|
|
grib_f90.f90.head grib_f90.f90.tail grib_f90_int.f90 grib_f90_long_int.f90
|
|
|
|
grib_f90_int_size_t.f90 grib_f90_long_size_t.f90
|
2015-01-28 22:54:42 +00:00
|
|
|
|
|
|
|
eccodes_visibility.h eccodes_constants.h
|
|
|
|
eccodes_f90.f90.head eccodes_f90.f90.tail eccodes_f90_int.f90 eccodes_f90_long_int.f90
|
|
|
|
eccodes_f90_int_size_t.f90 eccodes_f90_long_size_t.f90
|
|
|
|
|
2013-07-04 16:52:13 +00:00
|
|
|
same_int_long.f90 same_int_size_t.f90 grib_fortran_kinds.c )
|
2013-04-10 15:46:41 +00:00
|
|
|
|
2015-01-07 16:12:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
### installation
|
2013-04-10 15:46:41 +00:00
|
|
|
|
2014-12-30 12:53:08 +00:00
|
|
|
# Install the generated .mod file
|
|
|
|
# install( CODE "EXECUTE_PROCESS (COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_Fortran_MODULE_DIRECTORY}/${CMAKE_CFG_INTDIR} ${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR})" )
|
2014-12-30 17:35:40 +00:00
|
|
|
|
|
|
|
# Install the contents of the fortran module directory
|
2017-07-19 17:06:07 +00:00
|
|
|
if(ECBUILD_INSTALL_FORTRAN_MODULES)
|
|
|
|
install( DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/${CMAKE_CFG_INTDIR}/ DESTINATION ${INSTALL_INCLUDE_DIR} )
|
|
|
|
endif()
|
2014-12-30 12:53:08 +00:00
|
|
|
|
2014-12-30 17:35:40 +00:00
|
|
|
# Install the eccodes module file as a copy of the grib api mod file.
|
|
|
|
# Note: the mod filename can be lowercase or uppercase!
|
|
|
|
# First try the lowercase one. Specify OPTIONAL so if it fails it carries on
|
2015-01-08 15:34:11 +00:00
|
|
|
#install( FILES ${CMAKE_Fortran_MODULE_DIRECTORY}/${CMAKE_CFG_INTDIR}/grib_api.mod
|
|
|
|
# RENAME eccodes.mod
|
|
|
|
# OPTIONAL
|
|
|
|
# DESTINATION ${INSTALL_INCLUDE_DIR} )
|
2014-12-30 17:35:40 +00:00
|
|
|
# Now try the uppercase mod file
|
2015-01-08 15:34:11 +00:00
|
|
|
#install( FILES ${CMAKE_Fortran_MODULE_DIRECTORY}/${CMAKE_CFG_INTDIR}/GRIB_API.mod
|
|
|
|
# RENAME ECCODES.mod
|
|
|
|
# OPTIONAL
|
|
|
|
# DESTINATION ${INSTALL_INCLUDE_DIR} )
|
2013-03-25 12:04:10 +00:00
|
|
|
|
|
|
|
endif()
|
2013-04-10 15:46:41 +00:00
|
|
|
|