From b8990329653459a899bb831529a97d30ad8b9d38 Mon Sep 17 00:00:00 2001 From: Kai Kratz Date: Tue, 23 Sep 2025 13:05:14 +0200 Subject: [PATCH] Now finds libaec from libaec-config.cmake This is in preparation to move libaec to be a source dependency in cxx-dependencies where we will be providing libaec 1.1.4. This is also part of bump of libaec to 1.0.6 across the whole C++ stack. With 1.0.6 libaec introduced cmae config files that replace FindModules. Unfortunately the cmake config file for libaec 1.0.6 to 1.1.3 do not work correctly if libaec is not installed system wide in combination with a system wide installed version of libaec. The bug is that the configuration file just picks up the first libaec.h file and the first libaec.so. Which in this combination will point to the system wide installed version. This can (and is addressed in this PR) by hinting cmake to the correct location of the loaded aec module on ATOS. When using CMAKE_PREFIX_PATH this is not an issue because those paths will be preferred for the resolution. Libaec 1.1.4 fixes this issue. --- .github/ci-hpc-config.yml | 1 + CMakeLists.txt | 15 +------- cmake/FindAEC.cmake | 61 ------------------------------ src/gribjump/CMakeLists.txt | 12 ++---- src/tools/CMakeLists.txt | 2 +- tests/tools/callback_vs_scan.sh.in | 4 +- 6 files changed, 10 insertions(+), 85 deletions(-) delete mode 100644 cmake/FindAEC.cmake diff --git a/.github/ci-hpc-config.yml b/.github/ci-hpc-config.yml index 11a042a3..5c13e816 100644 --- a/.github/ci-hpc-config.yml +++ b/.github/ci-hpc-config.yml @@ -16,3 +16,4 @@ build: env: - ECCODES_SAMPLES_PATH=$ECCODES_DIR/share/eccodes/samples - ECCODES_DEFINITION_PATH=$ECCODES_DIR/share/eccodes/definitions + - libaec_ROOT=$AEC_DIR diff --git a/CMakeLists.txt b/CMakeLists.txt index f251d530..02c6ec0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,6 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") ######################################################################################################################## ### dependencies and options - set( PERSISTENT_NAMESPACE "eckit" CACHE INTERNAL "" ) # needed for generating .b files for persistent support ecbuild_find_package( NAME eckit VERSION 1.28.3 REQUIRED ) ecbuild_find_package( NAME metkit VERSION 1.11.22 REQUIRED ) @@ -27,19 +26,10 @@ if (HAVE_GRIBJUMP_LOCAL_EXTRACT) ecbuild_find_package( NAME eccodes VERSION 2.32.1 REQUIRED ) - ### AEC - # Override eccodes' aec with our own: we need a newer version. + # Can be removed once we rely on next eckit version unset(AEC_INCLUDE_DIRS CACHE) unset(AEC_LIBRARIES CACHE) - ecbuild_find_package( NAME AEC VERSION 1.1.1 REQUIRED ) - - # ecbuild_find_package's version checking does not work if the version is not specified in the package. - if (NOT AEC_VERSION) - message(FATAL_ERROR "AEC version is too old (version unspecified). Minimum supported version is 1.1.1.") - endif() - if (AEC_VERSION VERSION_LESS 1.1.1) - message(FATAL_ERROR "AEC version is too old. Minimum supported version is 1.1.1. Found version: ${AEC_VERSION}") - endif() + ecbuild_find_package( NAME libaec VERSION 1.1.1 REQUIRED ) # Optional dependency: dhskit ecbuild_find_package( NAME dhskit VERSION 0.8.6 ) @@ -62,7 +52,6 @@ include(find_python_module) set( gribjump_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src ) include_directories( - ${AEC_INCLUDE_DIRS} ${gribjump_INCLUDE_DIRS} ${eckit_INCLUDE_DIRS} ) diff --git a/cmake/FindAEC.cmake b/cmake/FindAEC.cmake deleted file mode 100644 index 35c8dee9..00000000 --- a/cmake/FindAEC.cmake +++ /dev/null @@ -1,61 +0,0 @@ -# (C) Copyright 2011- ECMWF. -# -# 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. - -# - Try to find AEC (Adaptive Entropy Coding library) -# See https://www.dkrz.de/redmine/projects/aec/wiki - -# Once done this will define -# AEC_FOUND - System has AEC -# AEC_INCLUDE_DIRS - The AEC include directories -# AEC_LIBRARIES - The libraries needed to use AEC -# -# The following paths will be searched with priority if set in CMake or env -# -# AEC_DIR - prefix path of the AEC installation -# AEC_PATH - prefix path of the AEC installation -# LIBAEC_DIR -# libaec_DIR -# LIBAEC_PATH -# libaec_PATH -# libaec_ROOT - -find_path( AEC_INCLUDE_DIR libaec.h - PATHS ${AEC_DIR} ${AEC_PATH} ${LIBAEC_DIR} ${libaec_DIR} ${LIBAEC_PATH} ${libaec_PATH} ${libaec_ROOT} ENV AEC_DIR ENV AEC_PATH ENV LIBAEC_DIR ENV libaec_DIR ENV LIBAEC_PATH ENV libaec_PATH ENV libaec_ROOT - PATH_SUFFIXES include include/aec NO_DEFAULT_PATH ) -find_path( AEC_INCLUDE_DIR libaec.h PATH_SUFFIXES include include/aec ) - -find_library( AEC_LIBRARY NAMES aec - PATHS ${AEC_DIR} ${AEC_PATH} ${LIBAEC_DIR} ${libaec_DIR} ${LIBAEC_PATH} ${libaec_PATH} ${libaec_ROOT} ENV AEC_DIR ENV AEC_PATH ENV LIBAEC_DIR ENV libaec_DIR ENV LIBAEC_PATH ENV libaec_PATH ENV libaec_ROOT - PATH_SUFFIXES lib lib64 lib/aec lib64/aec NO_DEFAULT_PATH ) -find_library( AEC_LIBRARY NAMES aec PATH_SUFFIXES lib lib64 lib/aec lib64/aec ) - -set( AEC_LIBRARIES ${AEC_LIBRARY} ) -set( AEC_INCLUDE_DIRS ${AEC_INCLUDE_DIR} ) - -include(FindPackageHandleStandardArgs) - -find_package_handle_standard_args(AEC DEFAULT_MSG AEC_LIBRARY AEC_INCLUDE_DIR) - -# Need to look explicitly in the header file for the version. Note that old versions of AEC (too old for gribjump) do not have version information. - -file(STRINGS ${AEC_INCLUDE_DIR}/libaec.h AEC_VERSION_MAJOR REGEX "#define AEC_VERSION_MAJOR") -file(STRINGS ${AEC_INCLUDE_DIR}/libaec.h AEC_VERSION_MINOR REGEX "#define AEC_VERSION_MINOR") -file(STRINGS ${AEC_INCLUDE_DIR}/libaec.h AEC_VERSION_PATCH REGEX "#define AEC_VERSION_PATCH") - -string(REGEX REPLACE "#define AEC_VERSION_MAJOR " "" AEC_VERSION_MAJOR "${AEC_VERSION_MAJOR}") -string(REGEX REPLACE "#define AEC_VERSION_MINOR " "" AEC_VERSION_MINOR "${AEC_VERSION_MINOR}") -string(REGEX REPLACE "#define AEC_VERSION_PATCH " "" AEC_VERSION_PATCH "${AEC_VERSION_PATCH}") - -# check that the version is not empty -if(NOT AEC_VERSION_MAJOR OR NOT AEC_VERSION_MINOR OR NOT AEC_VERSION_PATCH) - set(AEC_VERSION "") -else() - set(AEC_VERSION "${AEC_VERSION_MAJOR}.${AEC_VERSION_MINOR}.${AEC_VERSION_PATCH}") -endif() - -mark_as_advanced(AEC_INCLUDE_DIR AEC_LIBRARY ) diff --git a/src/gribjump/CMakeLists.txt b/src/gribjump/CMakeLists.txt index 64341385..3be5dd6f 100644 --- a/src/gribjump/CMakeLists.txt +++ b/src/gribjump/CMakeLists.txt @@ -130,14 +130,8 @@ if( HAVE_GRIBJUMP_LOCAL_EXTRACT ) FDBPlugin.cc FDBPlugin.h - ) - - set( SERVER_LIBS fdb5 ${AEC_LIBRARIES} ) - -endif() +) -if (GRIBJUMP_HAVE_DHSKIT) -list( APPEND SERVER_LIBS dhskit ) endif() ecbuild_add_library( @@ -160,7 +154,9 @@ ecbuild_add_library( metkit eckit eckit_option - ${SERVER_LIBS} + $<${HAVE_GRIBJUMP_LOCAL_EXTRACT}:libaec::aec> + $<${HAVE_GRIBJUMP_LOCAL_EXTRACT}:fdb5> + $<${GRIBJUMP_HAVE_DHSKIT}:dhskit> ) ############################################################################################ diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt index 852a50c6..7399ea53 100644 --- a/src/tools/CMakeLists.txt +++ b/src/tools/CMakeLists.txt @@ -56,4 +56,4 @@ if ( HAVE_GRIBJUMP_LOCAL_EXTRACT) LIBS gribjump ) -endif() \ No newline at end of file +endif() diff --git a/tests/tools/callback_vs_scan.sh.in b/tests/tools/callback_vs_scan.sh.in index 8b3b13a1..503b9d26 100755 --- a/tests/tools/callback_vs_scan.sh.in +++ b/tests/tools/callback_vs_scan.sh.in @@ -35,7 +35,7 @@ export LD_LIBRARY_PATH="$binary/lib:$binary/lib64:$LD_LIBRARY_PATH" export LOAD_PLUGINS="int.ecmwf.gribjump-plugin" # LD PRELOAD AEC to prevent downstream-CI issues where eckit is linked against an incompatible version (GRIBJUMP-39). -aecpath="@AEC_LIBRARY@" +aecpath="@libaec_LIBRARY@" if [ -e "$aecpath" ]; then export LD_PRELOAD="$aecpath" fi @@ -181,4 +181,4 @@ for i in $(seq 1 $NROOTS); do rm -rf ${bindir}/root${i} done -echo "Test finished" \ No newline at end of file +echo "Test finished"