diff --git a/CMakeLists.txt b/CMakeLists.txt index 26b95389e..c5848ba79 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -337,8 +337,6 @@ configure_file( eccodes_config.h.in eccodes_config.h ) add_definitions( -DHAVE_ECCODES_CONFIG_H ) -install( FILES ${CMAKE_CURRENT_BINARY_DIR}/eccodes_config.h DESTINATION ${INSTALL_INCLUDE_DIR} ) - if( CMAKE_COMPILER_IS_GNUCC ) ecbuild_add_c_flags("-pedantic") endif() diff --git a/fortran/CMakeLists.txt b/fortran/CMakeLists.txt index 119f09c2c..c0099c342 100644 --- a/fortran/CMakeLists.txt +++ b/fortran/CMakeLists.txt @@ -44,6 +44,15 @@ if( HAVE_FORTRAN ) SOURCES grib_fortran.c grib_f90.f90 eccodes_f90.f90 grib_kinds.h GENERATED grib_f90.f90 eccodes_f90.f90 LIBS eccodes ) + 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 $ ) + + # NOTE: When eccodes accepts ecbuild 3.0 as minimum requirement, + # this should instead be written inside the ecbuild_add_library macro with: + # PUBLIC_INCLUDES $ + endif() + 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 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5c85c9c48..7d43d4995 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -434,14 +434,13 @@ endif() ecbuild_add_library(TARGET eccodes SOURCES grib_api_version.c # griby.c gribl.c - ${grib_api_srcs} + ${grib_api_srcs} GENERATED grib_api_version.c LIBS ${ECCODES_EXTRA_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${CMATH_LIBRARIES} - TEMPLATES ${grib_api_extra_srcs}) - - -install( FILES grib_api.h eccodes.h eccodes_windef.h DESTINATION ${INSTALL_INCLUDE_DIR} ) -install( FILES ${CMAKE_CURRENT_BINARY_DIR}/eccodes_version.h DESTINATION ${INSTALL_INCLUDE_DIR} ) - - - + TEMPLATES ${grib_api_extra_srcs} + INSTALL_HEADERS_LIST + grib_api.h + eccodes.h + eccodes_windef.h + ${CMAKE_CURRENT_BINARY_DIR}/eccodes_version.h + ${PROJECT_BINARY_DIR}/eccodes_config.h )