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
|
|
|
|
|
|
|
# TODO:
|
|
|
|
# * support for jpg and png
|
|
|
|
# * build fortran bindings
|
|
|
|
# * build python bindings
|
2013-03-25 12:04:10 +00:00
|
|
|
|
|
|
|
cmake_minimum_required( VERSION 2.8.4 FATAL_ERROR )
|
|
|
|
|
|
|
|
project( grib_api C )
|
|
|
|
|
|
|
|
set( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH} )
|
|
|
|
|
|
|
|
include( ecbuild_system )
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# local project
|
|
|
|
|
|
|
|
ecbuild_declare_project()
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# some variables/options of this project
|
|
|
|
|
2013-04-03 10:45:13 +00:00
|
|
|
option( GRIB_API_JPG "try to add support for JPG encoding" ON )
|
|
|
|
option( GRIB_API_PNG "try to add support for PNG encoding" ON )
|
|
|
|
option( GRIB_API_NETCDF "try to add support for NetCDF" ON )
|
|
|
|
option( GRIB_API_SZIP "try to add support for SZip encoding" ON )
|
|
|
|
option( GRIB_API_PYTHON "try to build the GRIB_API Python interface" ON )
|
|
|
|
option( GRIB_API_FORTRAN "try to build the GRIB_API Fortran interface" OFF )
|
2013-03-25 12:04:10 +00:00
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# macro processing
|
|
|
|
|
|
|
|
find_package( CMath )
|
|
|
|
|
|
|
|
find_package( SWIG )
|
|
|
|
if( SWIG_FOUND )
|
|
|
|
include( ${SWIG_USE_FILE} )
|
|
|
|
endif()
|
|
|
|
|
2013-04-03 10:45:13 +00:00
|
|
|
### SZIP support
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2013-04-03 10:45:13 +00:00
|
|
|
if( GRIB_API_SZIP )
|
|
|
|
find_package( SZip )
|
|
|
|
set( HAVE_LIBSZIP ${SZIP_FOUND} )
|
|
|
|
endif()
|
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( GRIB_API_JPG_LIBRARIES "" )
|
|
|
|
set( GRIB_API_JPG_INCLUDE_DIRS "" )
|
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-04-03 10:45:13 +00:00
|
|
|
if( GRIB_API_JPG )
|
|
|
|
|
|
|
|
find_package( Jasper )
|
|
|
|
find_package( OpenJPEG )
|
|
|
|
|
|
|
|
if( JASPER_FOUND )
|
|
|
|
list( APPEND GRIB_API_JPG_LIBRARIES ${JASPER_LIBRARIES} )
|
|
|
|
list( APPEND GRIB_API_JPG_INCLUDE_DIRS ${JASPER_INCLUDE_DIR} )
|
|
|
|
set( HAVE_JPEG 1 )
|
|
|
|
set( HAVE_LIBJASPER 1 )
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if( OpenJPEG_FOUND )
|
|
|
|
list( APPEND GRIB_API_JPG_LIBRARIES ${OPENJPEG_LIBRARIES} )
|
|
|
|
list( APPEND GRIB_API_JPG_INCLUDE_DIRS ${OPENJPEG_INCLUDE_DIR} )
|
|
|
|
set( HAVE_JPEG 1 )
|
|
|
|
set( HAVE_LIBOPENJPEG 1 )
|
|
|
|
endif()
|
|
|
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
### PNG support
|
|
|
|
|
|
|
|
set( GRIB_API_PNG_LIBRARIES "" )
|
|
|
|
set( GRIB_API_PNG_INCLUDE_DIRS "" )
|
|
|
|
|
|
|
|
set( HAVE_LIBPNG 0 )
|
|
|
|
|
|
|
|
if( GRIB_API_JPG )
|
|
|
|
|
|
|
|
find_package( PNG )
|
|
|
|
|
|
|
|
if( PNG_FOUND )
|
|
|
|
list( APPEND GRIB_API_PNG_LIBRARIES ${PNG_LIBRARIES} )
|
|
|
|
list( APPEND GRIB_API_PNG_INCLUDE_DIRS ${PNG_INCLUDE_DIR} )
|
|
|
|
list( APPEND GRIB_API_PNG_DEFINITIONS ${PNG_DEFINITIONS} )
|
|
|
|
add_definitions( ${PNG_DEFINITIONS} )
|
|
|
|
set( HAVE_LIBPNG 1 )
|
|
|
|
endif()
|
|
|
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
### NetCDF support
|
|
|
|
|
|
|
|
set( GRIB_API_NETCDF_LIBRARIES "" )
|
|
|
|
set( GRIB_API_NETCDF_INCLUDE_DIRS "" )
|
|
|
|
|
|
|
|
set( HAVE_NETCDF 0 )
|
|
|
|
|
|
|
|
if( GRIB_API_NETCDF )
|
|
|
|
|
|
|
|
find_package( NetCDF )
|
|
|
|
|
|
|
|
if( NETCDF_FOUND )
|
|
|
|
list( APPEND GRIB_API_NETCDF_LIBRARIES ${NETCDF_LIBRARIES} )
|
|
|
|
list( APPEND GRIB_API_NETCDF_INCLUDE_DIRS ${NETCDF_INCLUDE_DIR} )
|
|
|
|
set( HAVE_NETCDF 1 )
|
|
|
|
endif()
|
|
|
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# contents
|
2013-03-25 12:04:10 +00:00
|
|
|
|
|
|
|
if( NOT DEFINED GRIB_API_DEFINITION_PATH )
|
|
|
|
set( GRIB_API_DEFINITION_PATH ${CMAKE_INSTALL_PREFIX}/share/grib_api/definitions )
|
|
|
|
endif()
|
|
|
|
if( NOT DEFINED GRIB_API_SAMPLES_PATH )
|
|
|
|
set( GRIB_API_SAMPLES_PATH ${CMAKE_INSTALL_PREFIX}/share/grib_api/samples )
|
|
|
|
endif()
|
|
|
|
|
2013-04-03 10:45:13 +00:00
|
|
|
### config header
|
|
|
|
|
|
|
|
configure_file( grib_api_config.h.in grib_api_config.h )
|
|
|
|
|
|
|
|
install( FILES ${CMAKE_BINARY_DIR}/grib_api_config.h DESTINATION include/${PROJECT_NAME} )
|
|
|
|
|
|
|
|
### include directories
|
|
|
|
|
|
|
|
include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
|
|
|
|
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src )
|
|
|
|
|
|
|
|
add_definitions( -DHAVE_GRIB_API_CONFIG_H )
|
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 )
|
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" )
|
|
|
|
|
|
|
|
############################################################################################
|
2013-04-03 10:45:13 +00:00
|
|
|
# export to other projects
|
2013-03-25 12:04:10 +00:00
|
|
|
|
2013-04-03 10:45:13 +00:00
|
|
|
if( NOT ${PROJECT_NAME} STREQUAL ${CMAKE_PROJECT_NAME} )
|
|
|
|
set( GRIB_API_DEFINITIONS ${GRIB_API_PNG_DEFINITIONS} PARENT_SCOPE )
|
|
|
|
set( GRIB_API_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src ${NETCDF_INCLUDE_DIR} ${GRIB_API_JPG_INCLUDE_DIRS} ${GRIB_API_PNG_INCLUDE_DIRS} PARENT_SCOPE )
|
|
|
|
set( GRIB_API_LIBRARIES grib_api ${NETCDF_LIBRARIES} ${GRIB_API_JPG_LIBRARIES} ${GRIB_API_PNG_LIBRARIES} ${CMATH_LIBRARIES} PARENT_SCOPE )
|
2013-03-25 12:04:10 +00:00
|
|
|
set( GRIB_API_FOUND TRUE PARENT_SCOPE )
|
|
|
|
endif()
|
|
|
|
|
|
|
|
############################################################################################
|
|
|
|
# finalize
|
|
|
|
|
|
|
|
ecbuild_install_project( NAME grib_api )
|
|
|
|
|
|
|
|
ecbuild_print_summary()
|