2013-03-25 12:04:10 +00:00
|
|
|
############################################################################################
|
|
|
|
# cmake options:
|
|
|
|
#
|
|
|
|
# -DCMAKE_BUILD_TYPE=Debug|RelWithDebInfo|Release|Production
|
|
|
|
# -DCMAKE_INSTALL_PREFIX=/path/to/install
|
|
|
|
#
|
|
|
|
# -DCMAKE_MODULE_PATH=/path/to/ecbuild/cmake
|
2013-04-03 10:45:13 +00:00
|
|
|
|
2013-03-25 12:04:10 +00:00
|
|
|
cmake_minimum_required( VERSION 2.8.4 FATAL_ERROR )
|
|
|
|
|
|
|
|
project( grib_api C )
|
|
|
|
|
2013-12-11 10:12:34 +00:00
|
|
|
set( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../ecbuild/cmake")
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2013-04-10 15:46:41 +00:00
|
|
|
set( GRIB_API_INSTALL_INCLUDE_DIR include CACHE PATH "GRIB_API override installation directory for header files")
|
|
|
|
|
2013-03-25 12:04:10 +00:00
|
|
|
include( ecbuild_system )
|
|
|
|
|
2014-01-03 14:31:16 +00:00
|
|
|
ecbuild_requires_macro_version( 1.3 )
|
2014-01-03 11:20:14 +00:00
|
|
|
|
2013-03-25 12:04:10 +00:00
|
|
|
###############################################################################
|
|
|
|
# local project
|
|
|
|
|
|
|
|
ecbuild_declare_project()
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# some variables/options of this project
|
|
|
|
|
2014-10-20 16:40:17 +00:00
|
|
|
ecbuild_add_option( FEATURE JPG
|
2015-01-09 15:18:52 +00:00
|
|
|
DESCRIPTION "support for JPG decoding/encoding"
|
|
|
|
DEFAULT ON
|
2014-10-20 16:40:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
ecbuild_add_option( FEATURE PNG
|
2015-01-09 15:18:52 +00:00
|
|
|
DESCRIPTION "support for PNG decoding/encoding"
|
|
|
|
DEFAULT OFF
|
|
|
|
REQUIRED_PACKAGES PNG
|
2014-10-20 16:40:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
if( HAVE_PNG )
|
2015-01-09 15:18:52 +00:00
|
|
|
set( HAVE_LIBPNG 1 ) # compatibility with autotools
|
|
|
|
add_definitions( ${PNG_DEFINITIONS} )
|
2014-10-20 16:40:17 +00:00
|
|
|
else()
|
2015-01-09 15:18:52 +00:00
|
|
|
set( HAVE_LIBPNG 0 )
|
2014-10-20 16:40:17 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
ecbuild_add_option( FEATURE NETCDF
|
2015-01-09 15:18:52 +00:00
|
|
|
DESCRIPTION "support for GRIB to NetCDF conversion"
|
|
|
|
DEFAULT ON
|
|
|
|
REQUIRED_PACKAGES NetCDF
|
2014-10-20 16:40:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
ecbuild_add_option( FEATURE AEC
|
2015-01-09 15:18:52 +00:00
|
|
|
DESCRIPTION "support for Adaptive Entropy Coding"
|
|
|
|
DEFAULT OFF
|
|
|
|
REQUIRED_PACKAGES AEC
|
2014-10-20 16:40:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
ecbuild_add_option( FEATURE PYTHON
|
2015-01-09 15:18:52 +00:00
|
|
|
DESCRIPTION "build the GRIB_API Python interface"
|
|
|
|
DEFAULT ON
|
2014-10-20 16:40:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
ecbuild_add_option( FEATURE FORTRAN
|
2015-01-09 15:18:52 +00:00
|
|
|
DESCRIPTION "build the GRIB_API Fortran interface"
|
|
|
|
DEFAULT ON
|
2014-10-20 16:40:17 +00:00
|
|
|
)
|
|
|
|
|
2014-03-31 12:57:06 +00:00
|
|
|
if( ENABLE_FORTRAN )
|
2014-10-03 15:49:05 +00:00
|
|
|
# will set EC_HAVE_FORTRAN with the result
|
|
|
|
ecbuild_enable_fortran( MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/fortran/modules )
|
2015-01-09 15:18:52 +00:00
|
|
|
set( HAVE_FORTRAN ${EC_HAVE_FORTRAN} )
|
2014-03-31 12:57:06 +00:00
|
|
|
endif()
|
|
|
|
|
2014-10-20 16:40:17 +00:00
|
|
|
# advanced options (not visible in cmake-gui )
|
|
|
|
|
|
|
|
ecbuild_add_option( FEATURE MEMORY_MANAGEMENT DESCRIPTION "enable memory management" DEFAULT OFF ADVANCED )
|
|
|
|
ecbuild_add_option( FEATURE ALIGN_MEMORY DESCRIPTION "enable memory alignment" DEFAULT OFF ADVANCED )
|
2013-04-10 15:46:41 +00:00
|
|
|
|
2014-10-20 16:40:17 +00:00
|
|
|
ecbuild_add_option( FEATURE GRIB_TIMER DESCRIPTION "enable timer" DEFAULT OFF ADVANCED )
|
|
|
|
ecbuild_add_option( FEATURE GRIB_THREADS DESCRIPTION "enable threads" DEFAULT OFF ADVANCED )
|
2013-03-25 12:04:10 +00:00
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# macro processing
|
|
|
|
|
2013-04-10 15:46:41 +00:00
|
|
|
set( GRIB_API_EXTRA_LIBRARIES "" )
|
|
|
|
set( GRIB_API_EXTRA_INCLUDE_DIRS "" )
|
|
|
|
set( GRIB_API_EXTRA_DEFINITIONS "" )
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2013-04-10 15:46:41 +00:00
|
|
|
find_package( CMath )
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2013-04-03 10:45:13 +00:00
|
|
|
### JPG support
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2013-04-03 10:45:13 +00:00
|
|
|
set( HAVE_JPEG 0 )
|
|
|
|
set( HAVE_LIBJASPER 0 )
|
|
|
|
set( HAVE_LIBOPENJPEG 0 )
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2013-12-09 14:47:14 +00:00
|
|
|
if( ENABLE_JPG )
|
2013-04-03 10:45:13 +00:00
|
|
|
|
2013-09-18 07:53:52 +00:00
|
|
|
ecbuild_add_extra_search_paths( jasper ) # help standard cmake macro with ecmwf paths
|
2013-04-03 10:45:13 +00:00
|
|
|
find_package( Jasper )
|
2013-09-18 07:53:52 +00:00
|
|
|
|
2013-04-03 10:45:13 +00:00
|
|
|
find_package( OpenJPEG )
|
|
|
|
|
|
|
|
if( JASPER_FOUND )
|
2013-04-23 08:59:14 +00:00
|
|
|
set( HAVE_JPEG 1 )
|
|
|
|
set( HAVE_LIBJASPER 1 )
|
2013-04-03 10:45:13 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if( OpenJPEG_FOUND )
|
2013-04-23 08:59:14 +00:00
|
|
|
set( HAVE_JPEG 1 )
|
2013-04-03 10:45:13 +00:00
|
|
|
set( HAVE_LIBOPENJPEG 1 )
|
|
|
|
endif()
|
|
|
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
2013-05-14 16:38:40 +00:00
|
|
|
###############################################################################
|
2013-04-10 15:46:41 +00:00
|
|
|
# other options
|
|
|
|
|
|
|
|
if( GRIB_TIMER )
|
|
|
|
set( GRIB_TIMER 1 )
|
|
|
|
else()
|
|
|
|
set( GRIB_TIMER 0 )
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set( IS_BIG_ENDIAN 0 )
|
|
|
|
if( EC_BIG_ENDIAN )
|
|
|
|
set( IS_BIG_ENDIAN 1 )
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set( MANAGE_MEM 0 )
|
2013-12-09 14:47:14 +00:00
|
|
|
if( ENABLE_MEMORY_MANAGEMENT )
|
2013-04-10 15:46:41 +00:00
|
|
|
set( MANAGE_MEM 1 )
|
|
|
|
endif()
|
|
|
|
|
2013-12-23 15:50:47 +00:00
|
|
|
set( CMAKE_THREAD_PREFER_PTHREAD 1 ) # find thread library, but prefer pthreads
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
|
2013-04-10 15:46:41 +00:00
|
|
|
set( GRIB_PTHREADS 0 )
|
|
|
|
set( GRIB_LINUX_PTHREADS 0 )
|
|
|
|
if( GRIB_THREADS AND CMAKE_THREAD_LIBS_INIT )
|
|
|
|
if( CMAKE_USE_PTHREADS_INIT )
|
|
|
|
set( GRIB_PTHREADS 1 )
|
|
|
|
if( ${CMAKE_SYSTEM_NAME} MATCHES "Linux" )
|
|
|
|
set( GRIB_LINUX_PTHREADS 1 )
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set( GRIB_MEM_ALIGN 0 )
|
2013-12-09 14:47:14 +00:00
|
|
|
if( ENABLE_ALIGN_MEMORY )
|
2013-04-10 15:46:41 +00:00
|
|
|
set( GRIB_MEM_ALIGN 1 )
|
|
|
|
endif()
|
|
|
|
|
2013-06-19 15:54:11 +00:00
|
|
|
# fix for #if IEEE_LE or IEE_BE instead of #ifdef
|
|
|
|
|
|
|
|
if( IEEE_BE )
|
|
|
|
set( IEEE_LE 0 )
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if( IEEE_LE )
|
|
|
|
set( IEEE_BE 0 )
|
|
|
|
endif()
|
|
|
|
|
2013-04-03 10:45:13 +00:00
|
|
|
###############################################################################
|
|
|
|
# contents
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2014-11-25 13:21:39 +00:00
|
|
|
if( NOT ${DEVELOPER_MODE} )
|
2015-01-09 15:18:52 +00:00
|
|
|
set( grib_api_default_data_prefix ${CMAKE_INSTALL_PREFIX} )
|
2014-11-25 13:21:39 +00:00
|
|
|
else()
|
2015-01-09 15:18:52 +00:00
|
|
|
set( grib_api_default_data_prefix ${CMAKE_BINARY_DIR} )
|
2014-11-25 13:21:39 +00:00
|
|
|
endif()
|
|
|
|
|
2015-01-24 22:19:32 +00:00
|
|
|
if( NOT DEFINED ECCODES_DEFINITION_PATH )
|
|
|
|
set( ECCODES_DEFINITION_PATH ${grib_api_default_data_prefix}/share/grib_api/definitions )
|
2013-03-25 12:04:10 +00:00
|
|
|
endif()
|
2015-01-26 22:28:46 +00:00
|
|
|
if( NOT DEFINED ECCODES_SAMPLES_PATH )
|
|
|
|
set( ECCODES_SAMPLES_PATH ${grib_api_default_data_prefix}/share/grib_api/samples )
|
2013-03-25 12:04:10 +00:00
|
|
|
endif()
|
2015-01-26 22:28:46 +00:00
|
|
|
if( NOT DEFINED ECCODES_IFS_SAMPLES_PATH )
|
|
|
|
set( ECCODES_IFS_SAMPLES_PATH ${grib_api_default_data_prefix}/share/grib_api/ifs_samples )
|
2015-01-19 10:23:02 +00:00
|
|
|
endif()
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2013-04-03 10:45:13 +00:00
|
|
|
### config header
|
|
|
|
|
2014-01-03 11:20:14 +00:00
|
|
|
ecbuild_generate_config_headers()
|
|
|
|
|
2013-04-03 10:45:13 +00:00
|
|
|
configure_file( grib_api_config.h.in grib_api_config.h )
|
|
|
|
|
2013-04-10 15:46:41 +00:00
|
|
|
add_definitions( -DHAVE_GRIB_API_CONFIG_H )
|
|
|
|
|
|
|
|
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/grib_api_config.h DESTINATION ${INSTALL_INCLUDE_DIR} )
|
|
|
|
|
|
|
|
if( CMAKE_COMPILER_IS_GNUCC )
|
|
|
|
cmake_add_c_flags("-pedantic")
|
|
|
|
endif()
|
2013-04-03 10:45:13 +00:00
|
|
|
|
2013-05-14 16:38:40 +00:00
|
|
|
############################################################################################
|
|
|
|
# contents
|
|
|
|
|
2014-03-31 12:57:06 +00:00
|
|
|
### export package to other ecbuild packages
|
2013-05-14 16:38:40 +00:00
|
|
|
|
2014-08-28 09:11:51 +00:00
|
|
|
set( GRIB_API_TPLS AEC PNG NetCDF Jasper OpenJPEG CMath )
|
2013-05-14 16:38:40 +00:00
|
|
|
set( GRIB_API_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src )
|
|
|
|
set( GRIB_API_LIBRARIES grib_api )
|
|
|
|
|
2015-01-26 22:28:46 +00:00
|
|
|
get_directory_property( COMPILE_DEFINITIONS ECCODES_DEFINITIONS )
|
2013-05-14 16:38:40 +00:00
|
|
|
|
|
|
|
foreach( _tpl ${GRIB_API_TPLS} )
|
2014-06-18 16:14:01 +00:00
|
|
|
string( TOUPPER ${_tpl} TPL )
|
|
|
|
if( ${TPL}_FOUND )
|
|
|
|
list( APPEND GRIB_API_EXTRA_DEFINITIONS ${${TPL}_DEFINITIONS} )
|
|
|
|
list( APPEND GRIB_API_EXTRA_INCLUDE_DIRS ${${TPL}_INCLUDE_DIRS} )
|
|
|
|
list( APPEND GRIB_API_EXTRA_LIBRARIES ${${TPL}_LIBRARIES} )
|
|
|
|
endif()
|
2013-05-14 16:38:40 +00:00
|
|
|
endforeach()
|
|
|
|
|
2013-04-03 10:45:13 +00:00
|
|
|
### include directories
|
|
|
|
|
2014-03-31 12:57:06 +00:00
|
|
|
include_directories( ${GRIB_API_INCLUDE_DIRS} ${GRIB_API_EXTRA_INCLUDE_DIRS} )
|
2013-04-03 10:45:13 +00:00
|
|
|
|
2013-03-25 12:04:10 +00:00
|
|
|
add_subdirectory( src )
|
|
|
|
add_subdirectory( tools )
|
|
|
|
add_subdirectory( fortran )
|
|
|
|
add_subdirectory( python )
|
|
|
|
add_subdirectory( definitions )
|
|
|
|
add_subdirectory( tests )
|
|
|
|
add_subdirectory( tigge )
|
|
|
|
add_subdirectory( examples )
|
2014-03-31 12:57:06 +00:00
|
|
|
add_subdirectory( data )
|
2013-04-02 14:17:46 +00:00
|
|
|
|
|
|
|
add_subdirectory( samples )
|
|
|
|
add_subdirectory( ifs_samples ) # must come after samples
|
2013-03-25 12:04:10 +00:00
|
|
|
|
|
|
|
# ecbuild_dont_pack( DIRS samples DONT_PACK_REGEX "*.grib" )
|
2014-07-11 15:31:24 +00:00
|
|
|
ecbuild_dont_pack( DIRS
|
|
|
|
concepts html tests.ecmwf doxygen examples.dev templates sms parameters java
|
|
|
|
perl/GRIB-API/lib perl/GRIB-API/t gaussian_experimental gribex examples/F77
|
2014-11-04 14:49:23 +00:00
|
|
|
examples/extra bamboo use fortran/fortranCtypes tigge/tools share/grib_api grib_api_for_mars
|
2014-07-11 15:31:24 +00:00
|
|
|
)
|
2014-11-04 14:49:23 +00:00
|
|
|
#ecbuild_dont_pack( DIRS data/bufr DONT_PACK_REGEX "*.bufr" )
|
|
|
|
#ecbuild_dont_pack( DIRS data/tigge DONT_PACK_REGEX "*.grib" )
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2014-07-11 15:50:30 +00:00
|
|
|
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
|
|
|
|
|
2013-03-25 12:04:10 +00:00
|
|
|
############################################################################################
|
2013-04-03 10:45:13 +00:00
|
|
|
# export to other projects
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2013-05-14 16:38:40 +00:00
|
|
|
# temporary -- add support for ecbuild 1.0.x sub-project inclusion
|
|
|
|
# to remove once mars server & client use eckit & ecbuild >= 1.1
|
2013-04-23 08:59:14 +00:00
|
|
|
|
2015-01-19 10:23:02 +00:00
|
|
|
if( EC_HAVE_FORTRAN )
|
|
|
|
list( APPEND GRIB_API_INCLUDE_DIRS ${CMAKE_Fortran_MODULE_DIRECTORY} )
|
|
|
|
list( APPEND GRIB_API_LIBRARIES grib_api_f77 grib_api_f90 )
|
|
|
|
endif()
|
|
|
|
|
2015-01-27 10:26:33 +00:00
|
|
|
if( NOT PROJECT_NAME STREQUAL CMAKE_PROJECT_NAME )
|
2015-01-26 22:28:46 +00:00
|
|
|
set( ECCODES_DEFINITIONS ${ECCODES_DEFINITIONS} PARENT_SCOPE )# includes already TPL definitions
|
2015-01-24 22:19:32 +00:00
|
|
|
set( GRIB_API_INCLUDE_DIRS ${GRIB_API_INCLUDE_DIRS} ${GRIB_API_EXTRA_INCLUDE_DIRS} PARENT_SCOPE )
|
|
|
|
set( GRIB_API_LIBRARIES ${GRIB_API_LIBRARIES} ${GRIB_API_EXTRA_LIBRARIES} ${CMATH_LIBRARIES} PARENT_SCOPE )
|
2015-01-26 22:28:46 +00:00
|
|
|
set( ECCODES_FOUND TRUE PARENT_SCOPE )
|
|
|
|
set( ECCODES_SAMPLES_PATH ${ECCODES_SAMPLES_PATH} PARENT_SCOPE )
|
|
|
|
set( ECCODES_IFS_SAMPLES_PATH ${ECCODES_IFS_SAMPLES_PATH} PARENT_SCOPE )
|
2015-01-24 22:19:32 +00:00
|
|
|
set( ECCODES_DEFINITION_PATH ${ECCODES_DEFINITION_PATH} PARENT_SCOPE )
|
2015-01-26 22:28:46 +00:00
|
|
|
set( ECCODES_INSTALL_ECMWF_TOOLS ${ECCODES_INSTALL_ECMWF_TOOLS} PARENT_SCOPE )
|
2013-03-25 12:04:10 +00:00
|
|
|
endif()
|
|
|
|
|
2015-01-29 13:07:39 +00:00
|
|
|
# pkg-config
|
|
|
|
ecbuild_pkgconfig(
|
|
|
|
NAME eccodes
|
|
|
|
URL "https://software.ecmwf.int/wiki/display/ECC"
|
|
|
|
DESCRIPTION "The ecCodes library"
|
2015-01-29 13:27:11 +00:00
|
|
|
IGNORE_LIBRARIES grib_api_f90 grib_api_f77 ${NETCDF_LIBRARIES}
|
2015-01-29 13:07:39 +00:00
|
|
|
IGNORE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/fortran ${CMAKE_CURRENT_BINARY_DIR}/fortran ${NETCDF_INCLUDE_DIRS}
|
2015-01-29 13:27:11 +00:00
|
|
|
VARIABLES HAVE_JPG HAVE_LIBJASPER GRIB_THREADS HAVE_NETCDF HAVE_PYTHON HAVE_FORTRAN HAVE_PNG HAVE_AEC
|
2015-01-29 13:07:39 +00:00
|
|
|
)
|
|
|
|
if( EC_HAVE_FORTRAN )
|
|
|
|
ecbuild_pkgconfig(
|
|
|
|
NAME eccodes_f90
|
|
|
|
URL "https://software.ecmwf.int/wiki/display/ECC"
|
2015-01-29 13:27:11 +00:00
|
|
|
IGNORE_LIBRARIES ${NETCDF_LIBRARIES}
|
2015-01-29 13:07:39 +00:00
|
|
|
IGNORE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/fortran ${CMAKE_CURRENT_BINARY_DIR}/fortran ${NETCDF_INCLUDE_DIRS}
|
|
|
|
DESCRIPTION "The ecCodes library for Fortran 90"
|
2015-01-29 13:27:11 +00:00
|
|
|
VARIABLES HAVE_JPG HAVE_LIBJASPER GRIB_THREADS HAVE_NETCDF HAVE_PYTHON HAVE_PNG HAVE_AEC
|
2015-01-29 13:07:39 +00:00
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2013-03-25 12:04:10 +00:00
|
|
|
############################################################################################
|
|
|
|
# finalize
|
|
|
|
|
2014-03-31 12:57:06 +00:00
|
|
|
ecbuild_install_project( NAME ${CMAKE_PROJECT_NAME} )
|
2013-03-25 12:04:10 +00:00
|
|
|
|
|
|
|
ecbuild_print_summary()
|