2016-04-13 15:12:21 +00:00
#
2020-01-28 14:32:34 +00:00
# (C) Copyright 2005- ECMWF.
2016-04-13 15:12:21 +00:00
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
#
# In applying this licence, ECMWF does not waive the privileges and immunities
# granted to it by virtue of its status as an intergovernmental organisation
# nor does it submit to any jurisdiction.
#
###############################################################################
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
2020-08-21 15:32:53 +00:00
cmake_minimum_required ( VERSION 3.12 FATAL_ERROR )
2020-08-27 16:54:29 +00:00
2020-10-05 10:17:40 +00:00
find_package ( ecbuild 3.4 REQUIRED HINTS ${ CMAKE_CURRENT_SOURCE_DIR } ${ CMAKE_CURRENT_SOURCE_DIR } /../ecbuild )
2013-03-25 12:04:10 +00:00
2020-08-21 15:32:53 +00:00
# Initialise project
2021-12-03 17:42:52 +00:00
project ( eccodes VERSION 2.25.0 LANGUAGES C )
2013-03-25 12:04:10 +00:00
2018-05-11 12:07:03 +00:00
###############################################################################
# system checks needed for eccodes_config.h and some options like MEMFS
2022-02-03 15:25:45 +00:00
check_type_size ( int ECCODES_SIZEOF_INT )
check_type_size ( long ECCODES_SIZEOF_LONG )
check_type_size ( size_t ECCODES_SIZEOF_SIZE_T )
2018-05-19 11:38:24 +00:00
2022-02-03 15:25:45 +00:00
check_include_files ( assert.h ECCODES_HAVE_ASSERT_H )
check_include_files ( string.h ECCODES_HAVE_STRING_H )
check_include_files ( sys/types.h ECCODES_HAVE_SYS_TYPES_H )
check_include_files ( sys/stat.h ECCODES_HAVE_SYS_STAT_H )
check_include_files ( fcntl.h ECCODES_HAVE_FCNTL_H )
check_include_files ( unistd.h ECCODES_HAVE_UNISTD_H )
2018-05-19 11:38:24 +00:00
2022-02-03 15:25:45 +00:00
check_symbol_exists ( fseeko "stdio.h" ECCODES_HAVE_FSEEKO )
check_symbol_exists ( posix_memalign "stdlib.h" ECCODES_HAVE_POSIX_MEMALIGN )
check_symbol_exists ( fmemopen "stdio.h" ECCODES_HAVE_FMEMOPEN )
check_symbol_exists ( funopen "stdio.h" ECCODES_HAVE_FUNOPEN )
check_symbol_exists ( realpath "stdlib.h" ECCODES_HAVE_REALPATH )
check_symbol_exists ( fsync "unistd.h" ECCODES_HAVE_FSYNC )
check_symbol_exists ( fdatasync "unistd.h" ECCODES_HAVE_FDATASYNC )
2018-05-11 12:07:03 +00:00
2018-05-18 15:34:35 +00:00
check_c_source_compiles (
" t y p e d e f i n t f o o _ t ;
s t a t i c i n l i n e f o o _ t static_foo ( ) { r e t u r n 0 ; }
f o o _ t foo ( ) { r e t u r n 0 ; }
i n t main ( int argc, char *argv[] ) { r e t u r n 0 ; }
2020-03-30 13:07:31 +00:00
" E C C O D E S _ H A V E _ C _ I N L I N E
)
2018-05-18 15:34:35 +00:00
2018-05-19 16:42:03 +00:00
include ( eccodes_test_endiness )
2019-01-21 13:18:21 +00:00
if ( EC_OS_NAME MATCHES "windows" )
include ( eccodes_find_linux_utils )
endif ( )
2018-05-18 15:34:35 +00:00
2018-05-19 16:49:38 +00:00
ecbuild_debug ( "ECCODES_BIG_ENDIAN=${ECCODES_BIG_ENDIAN}" )
ecbuild_debug ( "ECCODES_LITTLE_ENDIAN=${ECCODES_LITTLE_ENDIAN}" )
2019-10-08 17:24:59 +00:00
ecbuild_info ( "Operating system=${CMAKE_SYSTEM} (${EC_OS_BITS} bits)" )
2018-05-19 16:49:38 +00:00
2013-03-25 12:04:10 +00:00
###############################################################################
# some variables/options of this project
2020-03-12 17:19:34 +00:00
ecbuild_add_option ( FEATURE PRODUCT_GRIB
D E S C R I P T I O N " S u p p o r t f o r t h e p r o d u c t G R I B "
2020-03-25 17:57:25 +00:00
D E F A U L T O N )
2020-03-12 14:16:45 +00:00
ecbuild_add_option ( FEATURE PRODUCT_BUFR
2020-03-12 17:19:34 +00:00
D E S C R I P T I O N " S u p p o r t f o r t h e p r o d u c t B U F R "
2020-03-25 17:57:25 +00:00
D E F A U L T O N )
2020-10-20 20:30:54 +00:00
if ( NOT HAVE_PRODUCT_GRIB AND NOT HAVE_PRODUCT_BUFR )
ecbuild_critical ( "Cannot disable both GRIB and BUFR! Please specify just one option" )
endif ( )
2020-03-12 14:16:45 +00:00
2015-06-09 13:50:51 +00:00
ecbuild_add_option ( FEATURE EXAMPLES
D E S C R I P T I O N " B u i l d t h e e x a m p l e s "
2020-03-25 17:57:25 +00:00
D E F A U L T O N )
2015-06-09 13:50:51 +00:00
2020-08-07 21:36:59 +00:00
ecbuild_add_option ( FEATURE BUILD_TOOLS
D E S C R I P T I O N " B u i l d t h e c o m m a n d l i n e t o o l s "
D E F A U L T O N )
2014-10-20 16:40:17 +00:00
ecbuild_add_option ( FEATURE JPG
2017-07-21 13:00:54 +00:00
D E S C R I P T I O N " S u p p o r t f o r J P G d e c o d i n g / e n c o d i n g "
2020-03-25 17:57:25 +00:00
D E F A U L T O N )
2019-12-13 15:44:54 +00:00
# Options related to JPG. The Jasper and OpenJPEG libraries
ecbuild_add_option ( FEATURE JPG_LIBJASPER
D E S C R I P T I O N " S u p p o r t f o r J P G d e c o d i n g / e n c o d i n g w i t h t h e J a s p e r l i b r a r y "
C O N D I T I O N E N A B L E _ J P G
2020-03-25 17:57:25 +00:00
D E F A U L T O N )
2019-12-13 15:44:54 +00:00
ecbuild_add_option ( FEATURE JPG_LIBOPENJPEG
D E S C R I P T I O N " S u p p o r t f o r J P G d e c o d i n g / e n c o d i n g w i t h t h e O p e n J P E G l i b r a r y "
C O N D I T I O N E N A B L E _ J P G
2020-03-25 17:57:25 +00:00
D E F A U L T O N )
2014-10-20 16:40:17 +00:00
ecbuild_add_option ( FEATURE PNG
2017-07-21 13:00:54 +00:00
D E S C R I P T I O N " S u p p o r t f o r P N G d e c o d i n g / e n c o d i n g "
2015-01-09 15:18:52 +00:00
D E F A U L T O F F
2020-08-18 10:14:29 +00:00
R E Q U I R E D _ P A C K A G E S P N G )
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
2017-07-21 13:00:54 +00:00
D E S C R I P T I O N " S u p p o r t f o r G R I B t o N e t C D F c o n v e r s i o n "
2015-01-09 15:18:52 +00:00
D E F A U L T O N
2020-08-18 10:14:29 +00:00
R E Q U I R E D _ P A C K A G E S N e t C D F
2020-03-25 17:57:25 +00:00
N O _ T P L )
2014-10-20 16:40:17 +00:00
2020-08-18 10:14:29 +00:00
find_package ( AEC )
2022-02-14 23:09:29 +00:00
if ( NOT DEFINED ENABLE_AEC AND NOT AEC_FOUND )
2022-02-16 15:43:38 +00:00
ecbuild_critical ( "AEC (Adaptive Entropy Coding) support is highly recommended from ecCodes >= 2.25.0\nTo force the build without it, use -DENABLE_AEC=OFF" )
2022-02-14 23:09:29 +00:00
endif ( )
2014-10-20 16:40:17 +00:00
ecbuild_add_option ( FEATURE AEC
2017-07-21 13:00:54 +00:00
D E S C R I P T I O N " S u p p o r t f o r A d a p t i v e E n t r o p y C o d i n g "
2022-02-14 16:34:50 +00:00
D E F A U L T O N
2020-08-17 15:43:18 +00:00
C O N D I T I O N A E C _ F O U N D )
2014-10-20 16:40:17 +00:00
2020-08-17 15:43:18 +00:00
ecbuild_find_python ( VERSION 2.6 NO_LIBS )
find_package ( NumPy )
2020-10-15 16:08:25 +00:00
ecbuild_add_option ( FEATURE PYTHON2
2020-01-10 11:28:41 +00:00
D E S C R I P T I O N " B u i l d t h e e c C o d e s P y t h o n 2 interface ( deprecated ) "
2020-06-24 17:04:50 +00:00
D E F A U L T O F F
2020-08-19 15:08:07 +00:00
#CONDITION Python_FOUND AND NumPy_FOUND
C O N D I T I O N P Y T H O N _ F O U N D A N D N U M P Y _ F O U N D
2020-08-17 15:43:18 +00:00
)
2019-06-11 17:19:20 +00:00
# For Python2 we build our own bindings (using SWIG) in the build directory
2020-03-09 17:02:09 +00:00
# but for Python3 one has to add the eccodes from pip3 AFTER the install
2019-06-11 17:19:20 +00:00
if ( PYTHON_VERSION_MAJOR EQUAL 3 )
set ( HAVE_PYTHON 0 )
endif ( )
2014-10-20 16:40:17 +00:00
2020-03-25 17:57:25 +00:00
## TODO REQUIRED_LANGUAGES Fortran
2014-10-20 16:40:17 +00:00
ecbuild_add_option ( FEATURE FORTRAN
2017-07-21 13:00:54 +00:00
D E S C R I P T I O N " B u i l d t h e e c C o d e s F o r t r a n i n t e r f a c e "
2020-03-25 17:57:25 +00:00
D E F A U L T O N )
2014-10-20 16:40:17 +00:00
2015-06-09 13:50:51 +00:00
# TODO Remove this after REQUIRED_LANGUAGES
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
2018-02-01 16:07:40 +00:00
set ( EC_HAVE_FORTRAN 0 )
2014-10-03 15:49:05 +00:00
ecbuild_enable_fortran ( MODULE_DIRECTORY ${ PROJECT_BINARY_DIR } /fortran/modules )
2015-01-09 15:18:52 +00:00
set ( HAVE_FORTRAN ${ EC_HAVE_FORTRAN } )
2015-06-09 13:50:51 +00:00
else ( )
set ( HAVE_FORTRAN 0 )
2014-03-31 12:57:06 +00:00
endif ( )
2016-07-11 15:29:33 +00:00
# memfs requires only Python executable and not its libraries
2016-06-14 14:27:49 +00:00
ecbuild_add_option ( FEATURE MEMFS
2016-06-20 17:00:09 +00:00
D E S C R I P T I O N " M e m o r y b a s e d a c c e s s t o d e f i n i t i o n s / s a m p l e s "
2016-06-14 14:27:49 +00:00
D E F A U L T O F F
2020-03-25 17:57:25 +00:00
R E Q U I R E D _ P A C K A G E S P y t h o n I n t e r p )
2016-07-04 11:48:40 +00:00
2016-07-11 15:29:33 +00:00
#if( HAVE_MEMFS AND "${CMAKE_C_COMPILER_ID}" STREQUAL "Cray")
# set( HAVE_MEMFS OFF )
# ecbuild_warn("MEMFS not supported with Cray C compiler")
#endif()
2016-07-04 11:48:40 +00:00
2017-09-06 10:16:26 +00:00
if ( HAVE_MEMFS )
set ( _will_install_defs_samples OFF )
else ( )
set ( _will_install_defs_samples ON )
endif ( )
2017-09-06 10:12:48 +00:00
2020-03-12 14:16:45 +00:00
2017-09-06 10:12:48 +00:00
# controls installation of files in definitions/ -- note that it still creates the symlinks in the build dir
# by default, if memfs is available, then we don't need to install definitions
ecbuild_add_option ( FEATURE INSTALL_ECCODES_DEFINITIONS
D E S C R I P T I O N " I n s t a l l t h e e c C o d e s d e f i n i t i o n s "
2020-03-25 17:57:25 +00:00
D E F A U L T $ { _ w i l l _ i n s t a l l _ d e f s _ s a m p l e s } )
2017-09-06 10:12:48 +00:00
# controls installation of files in samples/ and ifs_samples/ -- note that it still creates the symlinks in the build dir
# by default, if memfs is available, then we don't need to install samples
ecbuild_add_option ( FEATURE INSTALL_ECCODES_SAMPLES
D E S C R I P T I O N " I n s t a l l t h e e c C o d e s s a m p l e s , i n c l u d i n g I F S s a m p l e s "
2020-03-25 17:57:25 +00:00
D E F A U L T $ { _ w i l l _ i n s t a l l _ d e f s _ s a m p l e s } )
2017-09-06 10:12:48 +00:00
2014-10-20 16:40:17 +00:00
# advanced options (not visible in cmake-gui )
2017-07-21 13:00:54 +00:00
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 )
2021-01-06 19:19:21 +00:00
ecbuild_add_option ( FEATURE TIMER DESCRIPTION "Enable timer" DEFAULT OFF ADVANCED )
2017-07-21 13:00:54 +00:00
ecbuild_add_option ( FEATURE ECCODES_THREADS DESCRIPTION "Enable POSIX threads" DEFAULT OFF ADVANCED )
2021-11-30 12:12:56 +00:00
ecbuild_add_option ( FEATURE ECCODES_OMP_THREADS DESCRIPTION "Enable OpenMP threads" DEFAULT OFF ADVANCED )
2017-07-21 13:00:54 +00:00
ecbuild_add_option ( FEATURE EXTRA_TESTS DESCRIPTION "Enable extended regression testing" DEFAULT OFF ADVANCED )
2013-03-25 12:04:10 +00:00
###############################################################################
# macro processing
2015-02-18 10:14:22 +00:00
set ( ECCODES_EXTRA_LIBRARIES "" )
set ( ECCODES_EXTRA_INCLUDE_DIRS "" )
set ( ECCODES_EXTRA_DEFINITIONS "" )
2013-03-25 12:04:10 +00:00
2013-04-10 15:46:41 +00:00
find_package ( CMath )
2015-09-18 10:07:02 +00:00
list ( APPEND ECCODES_TPLS 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 )
2019-12-19 17:43:14 +00:00
# Note: The function ecbuild_add_extra_search_paths is deprecated but we need it to find Jasper at ECMWF.
2019-12-13 15:44:54 +00:00
# It modifies CMAKE_PREFIX_PATH
2015-12-17 11:11:42 +00:00
# which can affect future package discovery if not undone by the caller.
# The current CMAKE_PREFIX_PATH is backed up as _CMAKE_PREFIX_PATH
#
2020-08-18 10:14:29 +00:00
#set(CMAKE_WARN_DEPRECATED OFF) # Suppress deprecation message
#ecbuild_add_extra_search_paths( jasper )
2013-04-03 10:45:13 +00:00
find_package ( Jasper )
2020-08-18 10:14:29 +00:00
#set(CMAKE_PREFIX_PATH ${_CMAKE_PREFIX_PATH}) # Restore CMAKE_PREFIX_PATH
#set(CMAKE_WARN_DEPRECATED ON) # Remove suppression
2013-09-18 07:53:52 +00:00
2013-04-03 10:45:13 +00:00
find_package ( OpenJPEG )
2019-12-13 15:44:54 +00:00
if ( JASPER_FOUND AND ENABLE_JPG_LIBJASPER )
2015-09-18 10:07:02 +00:00
list ( APPEND ECCODES_TPLS Jasper )
2013-04-23 08:59:14 +00:00
set ( HAVE_JPEG 1 )
set ( HAVE_LIBJASPER 1 )
2016-12-06 11:51:41 +00:00
# Extract Jasper's major version number to enable conditional code. See ECC-396
string ( REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" JASPER_VERSION_MAJOR "${JASPER_VERSION_STRING}" )
2013-04-03 10:45:13 +00:00
endif ( )
2019-12-13 15:44:54 +00:00
if ( OPENJPEG_FOUND AND ENABLE_JPG_LIBOPENJPEG )
2015-09-18 10:07:02 +00:00
list ( APPEND ECCODES_TPLS OpenJPEG )
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 ( )
2018-11-27 17:56:46 +00:00
ecbuild_info ( " HAVE_JPEG=${HAVE_JPEG}" )
2019-12-13 15:44:54 +00:00
ecbuild_info ( " HAVE_LIBJASPER=${HAVE_LIBJASPER}" )
ecbuild_info ( " HAVE_LIBOPENJPEG=${HAVE_LIBOPENJPEG}" )
2018-11-27 17:56:46 +00:00
2013-04-03 10:45:13 +00:00
endif ( )
2013-05-14 16:38:40 +00:00
###############################################################################
2013-04-10 15:46:41 +00:00
# other options
2021-01-06 19:19:21 +00:00
if ( HAVE_TIMER )
2021-01-06 17:49:43 +00:00
set ( ECCODES_TIMER 1 )
2013-04-10 15:46:41 +00:00
else ( )
2021-01-06 17:49:43 +00:00
set ( ECCODES_TIMER 0 )
2013-04-10 15:46:41 +00:00
endif ( )
2018-05-19 16:49:38 +00:00
set ( IS_BIG_ENDIAN 0 )
2018-05-19 16:42:03 +00:00
if ( ECCODES_BIG_ENDIAN )
2013-04-10 15:46:41 +00:00
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 )
2015-01-29 15:50:51 +00:00
# debug
2016-04-14 10:10:15 +00:00
ecbuild_info ( " CMAKE_THREAD_LIBS_INIT=${CMAKE_THREAD_LIBS_INIT}" )
ecbuild_info ( " CMAKE_USE_PTHREADS_INIT=${CMAKE_USE_PTHREADS_INIT}" )
ecbuild_info ( " HAVE_ECCODES_THREADS=${HAVE_ECCODES_THREADS}" )
2015-01-29 15:50:51 +00:00
2016-04-07 15:51:07 +00:00
2013-04-10 15:46:41 +00:00
set ( GRIB_PTHREADS 0 )
2015-12-30 14:39:02 +00:00
set ( GRIB_OMP_THREADS 0 )
2013-04-10 15:46:41 +00:00
set ( GRIB_LINUX_PTHREADS 0 )
2015-05-14 15:45:03 +00:00
#if( HAVE_ECCODES_THREADS AND CMAKE_THREAD_LIBS_INIT )
if ( HAVE_ECCODES_THREADS )
2016-01-07 11:31:42 +00:00
if ( NOT ${ CMAKE_USE_PTHREADS_INIT } )
2016-04-14 10:10:15 +00:00
ecbuild_critical ( "Pthreads is not supported on your system: thread library found=[${CMAKE_THREAD_LIBS_INIT}]" )
2016-01-07 11:31:42 +00:00
endif ( )
set ( GRIB_PTHREADS 1 )
2021-07-29 14:31:38 +00:00
set ( ECCODES_PTHREADS_LIBRARIES Threads::Threads ) # ECC-1268
2016-01-07 11:31:42 +00:00
if ( ${ CMAKE_SYSTEM_NAME } MATCHES "Linux" )
set ( GRIB_LINUX_PTHREADS 1 )
2013-04-10 15:46:41 +00:00
endif ( )
2015-12-30 14:39:02 +00:00
elseif ( HAVE_ECCODES_OMP_THREADS )
ecbuild_enable_omp ( )
set ( GRIB_OMP_THREADS 1 )
2013-04-10 15:46:41 +00:00
endif ( )
2016-01-07 11:31:42 +00:00
# Cannot have both options
if ( HAVE_ECCODES_THREADS AND HAVE_ECCODES_OMP_THREADS )
2021-11-30 12:12:56 +00:00
ecbuild_critical ( "Cannot enable both POSIX threads and OpenMP! Please specify just one option" )
2016-01-07 11:31:42 +00:00
endif ( )
2021-11-30 12:12:56 +00:00
ecbuild_info ( " POSIX THREADS = ${GRIB_PTHREADS}" )
ecbuild_info ( " OpenMP THREADS= ${GRIB_OMP_THREADS}" )
2013-04-10 15:46:41 +00:00
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 ( )
2022-01-31 17:09:41 +00:00
set ( ECCODES_ON_LINUX_32BIT 0 )
if ( EC_OS_NAME MATCHES "linux" AND EC_OS_BITS EQUAL "32" )
set ( ECCODES_ON_LINUX_32BIT 1 )
endif ( )
2019-12-12 11:08:31 +00:00
set ( ECCODES_ON_WINDOWS 0 )
2019-01-21 13:18:21 +00:00
if ( EC_OS_NAME MATCHES "windows" )
# Symbols need to be explicitly exported on Windows so we can link to dlls.
set ( CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE )
2019-12-12 11:08:31 +00:00
set ( ECCODES_ON_WINDOWS 1 )
2019-01-21 13:18:21 +00:00
# Suppress compliler warnings - see ECC-850
# Suppress warnings about using 'insecure' functions. Fixing this would require changes all over
# the codebase which would damage portability.
ecbuild_add_c_flags ( "/D_CRT_SECURE_NO_WARNINGS" )
# Suppress warnings about using well-known C functions.
ecbuild_add_c_flags ( "/D_CRT_NONSTDC_NO_DEPRECATE" )
# Suppress C4267: warns about possible loss of data when converting 'size_t' to 'int'.
ecbuild_add_c_flags ( "/wd4267" )
endif ( )
2013-04-03 10:45:13 +00:00
###############################################################################
# contents
2020-07-29 13:28:11 +00:00
set ( the_default_data_prefix ${ CMAKE_INSTALL_PREFIX } )
if ( ${ DEVELOPER_MODE } )
ecbuild_info ( "DEVELOPER_MODE is defined" )
2015-08-28 13:00:17 +00:00
set ( the_default_data_prefix ${ CMAKE_BINARY_DIR } )
2014-11-25 13:21:39 +00:00
endif ( )
2015-09-22 10:42:54 +00:00
if ( NOT DEFINED ECCODES_DEFINITION_SUFF )
2017-02-03 12:08:35 +00:00
set ( ECCODES_DEFINITION_SUFF ${ INSTALL_DATA_DIR } /definitions )
2013-03-25 12:04:10 +00:00
endif ( )
2015-09-22 10:42:54 +00:00
if ( NOT DEFINED ECCODES_SAMPLES_SUFF )
2017-02-03 12:08:35 +00:00
set ( ECCODES_SAMPLES_SUFF ${ INSTALL_DATA_DIR } /samples )
2013-03-25 12:04:10 +00:00
endif ( )
2015-09-22 10:42:54 +00:00
if ( NOT DEFINED ECCODES_IFS_SAMPLES_SUFF )
2017-02-03 12:08:35 +00:00
set ( ECCODES_IFS_SAMPLES_SUFF ${ INSTALL_DATA_DIR } /ifs_samples )
2015-01-19 10:23:02 +00:00
endif ( )
2013-03-25 12:04:10 +00:00
2015-09-22 10:42:54 +00:00
set ( ECCODES_DEFINITION_PATH ${ the_default_data_prefix } / ${ ECCODES_DEFINITION_SUFF } )
set ( ECCODES_SAMPLES_PATH ${ the_default_data_prefix } / ${ ECCODES_SAMPLES_SUFF } )
set ( ECCODES_IFS_SAMPLES_PATH ${ the_default_data_prefix } / ${ ECCODES_IFS_SAMPLES_SUFF } )
2018-05-11 10:31:13 +00:00
###############################################################################
2013-04-03 10:45:13 +00:00
### config header
2014-01-03 11:20:14 +00:00
ecbuild_generate_config_headers ( )
2015-02-18 18:11:38 +00:00
configure_file ( eccodes_config.h.in eccodes_config.h )
2013-04-03 10:45:13 +00:00
2015-02-18 18:11:38 +00:00
add_definitions ( -DHAVE_ECCODES_CONFIG_H )
2013-04-10 15:46:41 +00:00
if ( CMAKE_COMPILER_IS_GNUCC )
2015-09-18 09:39:20 +00:00
ecbuild_add_c_flags ( "-pedantic" )
2013-04-10 15:46:41 +00:00
endif ( )
2013-04-03 10:45:13 +00:00
2020-08-04 12:41:40 +00:00
# gfortran 10 has become stricter with argument matching
if ( HAVE_FORTRAN AND CMAKE_Fortran_COMPILER_ID MATCHES "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 10 )
ecbuild_add_fortran_flags ( "-fallow-argument-mismatch" )
endif ( )
2016-04-13 15:12:21 +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
2015-02-18 10:14:22 +00:00
set ( ECCODES_INCLUDE_DIRS ${ CMAKE_CURRENT_BINARY_DIR } ${ CMAKE_CURRENT_SOURCE_DIR } /src ${ CMAKE_CURRENT_BINARY_DIR } /src )
set ( ECCODES_LIBRARIES eccodes )
2013-05-14 16:38:40 +00:00
2015-01-26 22:28:46 +00:00
get_directory_property ( COMPILE_DEFINITIONS ECCODES_DEFINITIONS )
2013-05-14 16:38:40 +00:00
2015-02-18 10:14:22 +00:00
foreach ( _tpl ${ ECCODES_TPLS } )
2014-06-18 16:14:01 +00:00
string ( TOUPPER ${ _tpl } TPL )
if ( ${ TPL } _FOUND )
2019-03-19 16:31:49 +00:00
if ( REPLACE_TPL_ABSOLUTE_PATHS )
# replace TPL absolute paths with their library names
# this helps make ecCodes relocatable
set ( _TMP "" )
foreach ( _lib ${ ${TPL } _LIBRARIES} )
get_filename_component ( _lib_name ${ _lib } NAME_WE )
string ( REGEX REPLACE "^lib" "" _name ${ _lib_name } )
list ( APPEND _TMP "-l${_name}" )
endforeach ( )
set ( ${ TPL } _LIBRARIES ${ _TMP } )
set ( _TMP "" )
endif ( )
2015-02-18 10:14:22 +00:00
list ( APPEND ECCODES_EXTRA_DEFINITIONS ${ ${TPL } _DEFINITIONS} )
list ( APPEND ECCODES_EXTRA_INCLUDE_DIRS ${ ${TPL } _INCLUDE_DIRS} ${ ${TPL } _INCLUDE_DIR} )
list ( APPEND ECCODES_EXTRA_LIBRARIES ${ ${TPL } _LIBRARIES} )
2014-06-18 16:14:01 +00:00
endif ( )
2013-05-14 16:38:40 +00:00
endforeach ( )
2013-04-03 10:45:13 +00:00
### include directories
2015-02-18 10:14:22 +00:00
include_directories ( ${ ECCODES_INCLUDE_DIRS } ${ ECCODES_EXTRA_INCLUDE_DIRS } )
2013-04-03 10:45:13 +00:00
2016-06-14 14:27:49 +00:00
add_subdirectory ( definitions ) # must be before memfs
add_subdirectory ( memfs )
2013-03-25 12:04:10 +00:00
add_subdirectory ( src )
2020-08-07 21:36:59 +00:00
if ( HAVE_BUILD_TOOLS )
add_subdirectory ( tools )
2020-08-08 12:07:16 +00:00
add_subdirectory ( tigge )
2020-08-07 21:36:59 +00:00
endif ( )
2013-03-25 12:04:10 +00:00
add_subdirectory ( fortran )
2019-06-11 16:15:06 +00:00
2020-03-25 17:57:25 +00:00
if ( PYTHON_VERSION_MAJOR GREATER 2 )
2019-06-18 16:05:48 +00:00
# Python3 is no longer built with SWIG but is a separate
2020-03-09 17:02:09 +00:00
# package. User should do: pip3 install eccodes
2019-06-11 16:15:06 +00:00
#add_subdirectory( python3 )
2018-11-23 19:11:47 +00:00
set ( ECCODES_PYTHON_DIR "python3" )
else ( )
add_subdirectory ( python )
2018-11-26 14:19:21 +00:00
set ( ECCODES_PYTHON_DIR "python" )
2018-11-23 19:11:47 +00:00
endif ( )
2013-03-25 12:04:10 +00:00
add_subdirectory ( tests )
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
2020-10-21 10:53:03 +00:00
e x p e r i m e n t a l d o x y g e n c o n f l u e n c e t e s t s / t e s t s . e c m w f
2021-04-06 18:54:28 +00:00
c o n f i g m 4 e x a m p l e s / F 7 7
2020-09-29 16:07:58 +00:00
e x a m p l e s / e x a m p l e s . d e v e x a m p l e s / e x t r a e x a m p l e s / d e p r e c a t e d b a m b o o
f o r t r a n / f o r t r a n C t y p e s t i g g e / t o o l s s h a r e / e c c o d e s . s e t t i n g s )
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 )
2016-04-13 15:12:21 +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
2018-02-01 16:07:40 +00:00
if ( HAVE_FORTRAN )
2015-02-18 10:14:22 +00:00
list ( APPEND ECCODES_INCLUDE_DIRS ${ CMAKE_Fortran_MODULE_DIRECTORY } )
2015-02-27 18:21:10 +00:00
list ( APPEND ECCODES_LIBRARIES eccodes_f90 )
2015-01-19 10:23:02 +00:00
endif ( )
2015-01-29 13:07:39 +00:00
# pkg-config
ecbuild_pkgconfig (
2016-06-06 12:22:29 +00:00
N A M E e c c o d e s
2019-01-28 12:47:22 +00:00
U R L " h t t p s : / / c o n f l u e n c e . e c m w f . i n t / d i s p l a y / E C C / "
2016-06-06 12:22:29 +00:00
D E S C R I P T I O N " T h e e c C o d e s l i b r a r y "
L I B R A R I E S e c c o d e s
2016-09-28 08:58:43 +00:00
I G N O R E _ I N C L U D E _ D I R S $ { P Y T H O N _ I N C L U D E _ D I R S } $ { N U M P Y _ I N C L U D E _ D I R S } $ { N E T C D F _ I N C L U D E _ D I R S }
2017-07-21 13:00:54 +00:00
V A R I A B L E S H A V E _ M E M F S H A V E _ J P E G H A V E _ L I B J A S P E R H A V E _ L I B O P E N J P E G
2016-06-06 12:22:29 +00:00
H A V E _ E C C O D E S _ T H R E A D S H A V E _ E C C O D E S _ O M P _ T H R E A D S
2020-10-15 16:08:25 +00:00
H A V E _ N E T C D F H A V E _ P Y T H O N 2 H A V E _ F O R T R A N H A V E _ P N G H A V E _ A E C
2015-01-29 13:07:39 +00:00
)
2018-02-01 16:07:40 +00:00
if ( HAVE_FORTRAN )
2015-02-05 16:57:47 +00:00
ecbuild_pkgconfig (
N A M E e c c o d e s _ f 9 0
2019-01-28 12:47:22 +00:00
U R L " h t t p s : / / c o n f l u e n c e . e c m w f . i n t / d i s p l a y / E C C / "
2015-02-13 18:04:42 +00:00
L I B R A R I E S e c c o d e s _ f 9 0 e c c o d e s
2015-02-05 16:57:47 +00:00
D E S C R I P T I O N " T h e e c C o d e s l i b r a r y f o r F o r t r a n 9 0 "
I G N O R E _ I N C L U D E _ D I R S $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / f o r t r a n $ { P R O J E C T _ B I N A R Y _ D I R } / f o r t r a n
2016-09-28 08:58:43 +00:00
$ { P Y T H O N _ I N C L U D E _ D I R S } $ { N U M P Y _ I N C L U D E _ D I R S } $ { N E T C D F _ I N C L U D E _ D I R S }
2017-07-21 13:00:54 +00:00
V A R I A B L E S H A V E _ M E M F S H A V E _ J P E G H A V E _ L I B J A S P E R H A V E _ L I B O P E N J P E G
2016-06-06 12:22:29 +00:00
H A V E _ E C C O D E S _ T H R E A D S H A V E _ E C C O D E S _ O M P _ T H R E A D S
2020-10-15 16:08:25 +00:00
H A V E _ N E T C D F H A V E _ P Y T H O N 2 H A V E _ P N G H A V E _ A E C
2015-02-05 16:57:47 +00:00
)
2015-01-29 13:07:39 +00:00
endif ( )
2020-01-13 16:18:07 +00:00
###############################################################################
# Debugging aid. Print all known CMake variables
# get_cmake_property(_variableNames VARIABLES)
# foreach( _variableName ${_variableNames} )
# ecbuild_info(" ${_variableName}=${${_variableName}}")
# endforeach()
2016-04-13 15:12:21 +00:00
###############################################################################
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 ( )
2015-10-02 09:03:28 +00:00
2016-04-14 10:10:15 +00:00
ecbuild_info ( "" )
2017-03-09 15:40:48 +00:00
ecbuild_info ( " +--------------------------+" )
2020-08-18 10:14:29 +00:00
ecbuild_info ( " | ecCodes version ${eccodes_VERSION} |" )
2017-03-09 15:40:48 +00:00
ecbuild_info ( " +--------------------------+" )
2016-04-14 10:10:15 +00:00
ecbuild_info ( "" )
2019-06-11 16:15:06 +00:00
2020-10-15 16:08:25 +00:00
if ( HAVE_PYTHON2 )
2020-01-08 17:53:12 +00:00
ecbuild_deprecate ( "Python2 support is deprecated and will be discontinued" )
endif ( )
2019-06-19 15:39:46 +00:00
ecbuild_info ( " +--------------------------------------+" )
ecbuild_info ( " | Please note: |" )
ecbuild_info ( " | For Python3 support, first install |" )
ecbuild_info ( " | ecCodes and then install the Python |" )
ecbuild_info ( " | bindings from PyPI with: |" )
2020-03-09 17:02:09 +00:00
ecbuild_info ( " | $ pip3 install eccodes |" )
2019-06-19 15:39:46 +00:00
ecbuild_info ( " +--------------------------------------+" )
ecbuild_info ( "" )