From d6026065e76563e38b839591a997bc86b0cc43c1 Mon Sep 17 00:00:00 2001 From: Pedro Maciel Date: Thu, 10 Oct 2024 15:09:24 +0100 Subject: [PATCH] eckit::geo --- CMakeLists.txt | 5 +++++ src/CMakeLists.txt | 9 +++++---- tests/unit/CMakeLists.txt | 20 +++++++++++--------- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 84f1ab2dc..2229bd519 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,8 +110,13 @@ ecbuild_add_option( FEATURE BUILD_TOOLS ecbuild_add_option( FEATURE GEOGRAPHY DESCRIPTION "Support for Geoiterator and nearest neighbour" + REQUIRED_PACKAGES eckit DEFAULT ON ) +if(HAVE_GEOGRAPHY) + find_library(ECKIT_GEO_LIB NAMES eckit_geo REQUIRED) +endif() + ecbuild_add_option( FEATURE JPG DESCRIPTION "Support for JPG decoding/encoding" DEFAULT ON ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 61b63f829..24a051301 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -407,9 +407,10 @@ if( HAVE_MEMFS ) list(APPEND ECCODES_EXTRA_LIBRARIES eccodes_memfs) endif() -list( APPEND eccodes_src_files - eccodes/geo/GribSpec.cc - eccodes/geo/GribSpec.h ) +if(HAVE_GEOGRAPHY) + list(APPEND eccodes_src_files eccodes/geo/GribSpec.cc eccodes/geo/GribSpec.h) + list(APPEND ECCODES_EXTRA_LIBRARIES eckit_geo) +endif() ecbuild_add_library( TARGET eccodes SOURCES ${CMAKE_CURRENT_BINARY_DIR}/grib_api_version.cc @@ -418,7 +419,7 @@ ecbuild_add_library( TARGET eccodes #PRIVATE_LIBS ${ECCODES_EXTRA_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${CMATH_LIBRARIES} PRIVATE_INCLUDES "${AEC_INCLUDE_DIRS}" "${PNG_INCLUDE_DIRS}" PRIVATE_LIBS ${ECCODES_EXTRA_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${AEC_LIBRARIES} ${PNG_LIBRARIES} - PUBLIC_LIBS ${CMATH_LIBRARIES} ${THREADS_LIBRARIES} eckit_geo + PUBLIC_LIBS ${CMATH_LIBRARIES} ${THREADS_LIBRARIES} TEMPLATES ${eccodes_extra_src_files} INSTALL_HEADERS_LIST grib_api.h diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index a970fbbd5..9ca9846ae 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -1,10 +1,12 @@ -foreach( _test - grid_healpix - grid_lambert - grid_polar_stereographic ) - ecbuild_add_test( - TARGET eccodes_tests_unit_${_test} - SOURCES ${_test}.cc - LIBS eccodes ) -endforeach() +if(HAVE_GEOGRAPY) + foreach( _test + grid_healpix + grid_lambert + grid_polar_stereographic ) + ecbuild_add_test( + TARGET eccodes_tests_unit_${_test} + SOURCES ${_test}.cc + LIBS eccodes eckit_geo ) + endforeach() +endif()