mirror of https://github.com/ecmwf/eccodes.git
ECC-1393: CMake: Add option to build ecCodes with C++
This commit is contained in:
parent
7eae7f474b
commit
76bac8da71
|
@ -65,6 +65,13 @@ ecbuild_info("Operating system=${CMAKE_SYSTEM} (${EC_OS_BITS} bits)")
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# some variables/options of this project
|
# some variables/options of this project
|
||||||
|
|
||||||
|
ecbuild_add_option( FEATURE EXPERIMENTAL_BUILD_WITH_CXX
|
||||||
|
DESCRIPTION "Build ecCodes with a C++ compiler (Experimental)"
|
||||||
|
DEFAULT OFF )
|
||||||
|
if( HAVE_EXPERIMENTAL_BUILD_WITH_CXX )
|
||||||
|
enable_language( CXX )
|
||||||
|
endif()
|
||||||
|
|
||||||
ecbuild_add_option( FEATURE PRODUCT_GRIB
|
ecbuild_add_option( FEATURE PRODUCT_GRIB
|
||||||
DESCRIPTION "Support for the product GRIB"
|
DESCRIPTION "Support for the product GRIB"
|
||||||
DEFAULT ON )
|
DEFAULT ON )
|
||||||
|
@ -515,3 +522,9 @@ ecbuild_info(" | bindings from PyPI with: |")
|
||||||
ecbuild_info(" | $ pip3 install eccodes |")
|
ecbuild_info(" | $ pip3 install eccodes |")
|
||||||
ecbuild_info(" +--------------------------------------+")
|
ecbuild_info(" +--------------------------------------+")
|
||||||
ecbuild_info("")
|
ecbuild_info("")
|
||||||
|
|
||||||
|
if( HAVE_EXPERIMENTAL_BUILD_WITH_CXX )
|
||||||
|
ecbuild_warn("Please note:\n"
|
||||||
|
"The option of building with C++ is currently experimental."
|
||||||
|
"Do not use in operations.")
|
||||||
|
endif()
|
||||||
|
|
|
@ -427,6 +427,14 @@ if( HAVE_MEMFS )
|
||||||
list(APPEND ECCODES_EXTRA_LIBRARIES eccodes_memfs)
|
list(APPEND ECCODES_EXTRA_LIBRARIES eccodes_memfs)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if( HAVE_EXPERIMENTAL_BUILD_WITH_CXX )
|
||||||
|
foreach( _src ${eccodes_src_files} )
|
||||||
|
get_filename_component( _ext ${_src} EXT )
|
||||||
|
if( _ext STREQUAL ".c" )
|
||||||
|
set_source_files_properties( ${_src} PROPERTIES LANGUAGE CXX )
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
ecbuild_add_library( TARGET eccodes
|
ecbuild_add_library( TARGET eccodes
|
||||||
SOURCES ${CMAKE_CURRENT_BINARY_DIR}/grib_api_version.c
|
SOURCES ${CMAKE_CURRENT_BINARY_DIR}/grib_api_version.c
|
||||||
|
|
|
@ -18,6 +18,10 @@ if( EC_OS_NAME MATCHES "windows" )
|
||||||
list( APPEND ecc_tools_sources wingetopt.c )
|
list( APPEND ecc_tools_sources wingetopt.c )
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if( HAVE_EXPERIMENTAL_BUILD_WITH_CXX )
|
||||||
|
set_source_files_properties(${ecc_tools_sources} PROPERTIES LANGUAGE CXX)
|
||||||
|
endif()
|
||||||
|
|
||||||
# tools library
|
# tools library
|
||||||
ecbuild_add_library( TARGET ecc_tools
|
ecbuild_add_library( TARGET ecc_tools
|
||||||
TYPE STATIC
|
TYPE STATIC
|
||||||
|
@ -48,6 +52,9 @@ list( APPEND ecc_tools_binaries_extra
|
||||||
# Install generic tools
|
# Install generic tools
|
||||||
foreach( tool ${ecc_tools_binaries} )
|
foreach( tool ${ecc_tools_binaries} )
|
||||||
# here we use the fact that each tool has only one C file that matches its name
|
# here we use the fact that each tool has only one C file that matches its name
|
||||||
|
if( HAVE_EXPERIMENTAL_BUILD_WITH_CXX )
|
||||||
|
set_source_files_properties(${tool}.c PROPERTIES LANGUAGE CXX)
|
||||||
|
endif()
|
||||||
ecbuild_add_executable( TARGET ${tool}
|
ecbuild_add_executable( TARGET ${tool}
|
||||||
SOURCES ${tool}.c
|
SOURCES ${tool}.c
|
||||||
LIBS ecc_tools )
|
LIBS ecc_tools )
|
||||||
|
|
|
@ -84,7 +84,7 @@ int grib_tool_new_handle_action(grib_runtime_options* options, grib_handle* h)
|
||||||
char* format_values = NULL;
|
char* format_values = NULL;
|
||||||
char format_latlons[32] = {0,};
|
char format_latlons[32] = {0,};
|
||||||
char* default_format_values = "%.10e";
|
char* default_format_values = "%.10e";
|
||||||
char* default_format_latlons = "%9.3f%9.3f";
|
const char* default_format_latlons = "%9.3f%9.3f";
|
||||||
int print_keys = grib_options_on("p:");
|
int print_keys = grib_options_on("p:");
|
||||||
long numberOfPoints = 0;
|
long numberOfPoints = 0;
|
||||||
long bitmapPresent = 0;
|
long bitmapPresent = 0;
|
||||||
|
@ -305,7 +305,7 @@ static grib_values* get_key_values(grib_runtime_options* options, grib_handle* h
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
char value[MAX_STRING_LEN] = {0,};
|
char value[MAX_STRING_LEN] = {0,};
|
||||||
char* notfound = "not found";
|
const char* notfound = "not found";
|
||||||
|
|
||||||
for (i = 0; i < options->print_keys_count; i++) {
|
for (i = 0; i < options->print_keys_count; i++) {
|
||||||
size_t len = MAX_STRING_LEN;
|
size_t len = MAX_STRING_LEN;
|
||||||
|
|
|
@ -45,6 +45,10 @@
|
||||||
#define MODE_TAF 5
|
#define MODE_TAF 5
|
||||||
#define MODE_ANY 6
|
#define MODE_ANY 6
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef union grib_typed_value
|
typedef union grib_typed_value
|
||||||
{
|
{
|
||||||
long* long_value;
|
long* long_value;
|
||||||
|
@ -208,4 +212,8 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil
|
||||||
int grib_no_handle_action(grib_runtime_options* options, int err);
|
int grib_no_handle_action(grib_runtime_options* options, int err);
|
||||||
int exit_if_input_is_directory(const char* toolname, const char* filename);
|
int exit_if_input_is_directory(const char* toolname, const char* filename);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* GRIB_TOOLS_H */
|
#endif /* GRIB_TOOLS_H */
|
||||||
|
|
Loading…
Reference in New Issue