diff --git a/CMakeLists.txt b/CMakeLists.txt index 26c9f1b10..443ad539d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,14 +110,12 @@ endif() ecbuild_add_option( FEATURE OPENFAM DEFAULT OFF - REQUIRED_PACKAGES "LibUUID REQUIRED" "protobuf REQUIRED" "gRPC REQUIRED" "OpenFAM REQUIRED" + REQUIRED_PACKAGES "LibUUID REQUIRED" "OpenFAM REQUIRED" DESCRIPTION "Enables OpenFAM support" ) if( eckit_HAVE_OPENFAM ) find_package( LibUUID REQUIRED ) - find_package( protobuf CONFIG REQUIRED ) - find_package( gRPC CONFIG REQUIRED ) - find_package( OpenFAM 3.0.1 CONFIG REQUIRED ) + find_package( OpenFAM REQUIRED ) endif() ### RADOS diff --git a/cmake/FindOpenFAM.cmake b/cmake/FindOpenFAM.cmake new file mode 100644 index 000000000..81bab8ac4 --- /dev/null +++ b/cmake/FindOpenFAM.cmake @@ -0,0 +1,109 @@ +# Copyright 2024- European Centre for Medium-Range Weather Forecasts (ECMWF) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# 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. +# +# Requires: +# FindPackageHandleStandardArgs (CMake standard module) +# + +#[=======================================================================[.rst: +FindLibOpenFAM +-------- + +This module finds the openfam library. + +Imported Targets +^^^^^^^^^^^^^^^^ + +This module provides the following imported targets, if found: + +``LibOpenFAM`` + The openfam library + +Result variables +^^^^^^^^^^^^^^^^ + +This module will set the following variables in your project: + +``OpenFAM_FOUND`` + True if the openfam library is found. +``OpenFAM_INCLUDE_DIRS`` + Include directories needed to use openfam. +``OpenFAM_LIBRARIES`` + Libraries needed to link to openfam. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set to help find openfam library: + +``OpenFAM_INCLUDE_DIR`` + where to find the openfam headers. +``OpenFAM_LIBRARY`` + where to find the openfam library. + +Hints +^^^^^ + +The environment variables ``OpenFAM_ROOT``, ``OpenFAM_DIR``, and ``OpenFAM_PATH`` +may also be set to help find openfam library. + +#]=======================================================================] + +find_path(OpenFAM_INCLUDE_DIR fam/fam.h + HINTS + ${OpenFAM_ROOT} + ${OpenFAM_DIR} + ${OpenFAM_PATH} + ENV OpenFAM_ROOT + ENV OpenFAM_DIR + ENV OpenFAM_PATH +) + +find_library(OpenFAM_LIBRARY + NAMES openfam + HINTS + ${OpenFAM_ROOT} + ${OpenFAM_DIR} + ${OpenFAM_PATH} + ENV OpenFAM_ROOT + ENV OpenFAM_DIR + ENV OpenFAM_PATH + PATH_SUFFIXES lib lib64 +) + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(OpenFAM + FOUND_VAR OpenFAM_FOUND + REQUIRED_VARS + OpenFAM_LIBRARY + OpenFAM_INCLUDE_DIR) + +if (OpenFAM_FOUND) + set(OpenFAM_INCLUDE_DIRS ${OpenFAM_INCLUDE_DIR}/fam) + set(OpenFAM_LIBRARIES ${OpenFAM_LIBRARY}) + if(NOT TARGET OpenFAM) + add_library(OpenFAM INTERFACE IMPORTED) + set_target_properties(OpenFAM PROPERTIES + IMPORTED_LOCATION "${OpenFAM_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${OpenFAM_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "${OpenFAM_LIBRARY}") + endif() +endif() + +mark_as_advanced(OpenFAM_INCLUDE_DIR OpenFAM_LIBRARY) diff --git a/src/eckit/CMakeLists.txt b/src/eckit/CMakeLists.txt index d8e87d414..476ef01c5 100644 --- a/src/eckit/CMakeLists.txt +++ b/src/eckit/CMakeLists.txt @@ -977,7 +977,7 @@ ecbuild_add_library( "${CURL_LIBRARIES}" "${AIO_LIBRARIES}" "${RADOS_LIBRARIES}" - $<${HAVE_OPENFAM}:OpenFAM::openfam> + $<${HAVE_OPENFAM}:OpenFAM> PUBLIC_LIBS ${CMATH_LIBRARIES} diff --git a/tests/io/fam_common.h b/tests/io/fam_common.h index d7af6f68d..4c63fe509 100644 --- a/tests/io/fam_common.h +++ b/tests/io/fam_common.h @@ -46,7 +46,7 @@ inline auto randomNumber() -> std::string { return std::to_string(::random()); } -const auto testEndpoint = "127.0.0.1:8880"s; +const auto testEndpoint = "10.115.3.2:8080"s; class TestFam { public: diff --git a/tests/io/test_fam.cc b/tests/io/test_fam.cc index 6ecf902fc..9fb24b6dc 100644 --- a/tests/io/test_fam.cc +++ b/tests/io/test_fam.cc @@ -165,15 +165,17 @@ CASE("FamObject: lookup, create, and destroy") { EXPECT_NO_THROW(FamRegionName(fam::testEndpoint, path).create(regionSize, regionPerm)); - FamObject::UPtr object; + { + FamObject::UPtr object; - // object inherits permissions from region - EXPECT_NO_THROW(object = FamObjectName(fam::testEndpoint, path).allocate(objectSize).clone()); + // object inherits permissions from region + EXPECT_NO_THROW(object = FamObjectName(fam::testEndpoint, path).allocate(objectSize).clone()); - const FamProperty prop {objectSize, regionPerm, objectName}; - EXPECT_EQUAL(prop, object->property()); + const FamProperty objectProp {objectSize, regionPerm, objectName, 10005, 10005}; + EXPECT_EQUAL(objectProp, object->property()); - EXPECT_NO_THROW(object->deallocate()); + EXPECT_NO_THROW(object->deallocate()); + } { auto name = FamRegionName(fam::testEndpoint, ""); @@ -185,7 +187,7 @@ CASE("FamObject: lookup, create, and destroy") { { const auto size = 12; EXPECT_NO_THROW(region.allocateObject(size, objectPerm, objectName)); - EXPECT(region.lookupObject(objectName).size() == size); + EXPECT_EQUAL(region.lookupObject(objectName).size(), size); } // overwrite: allocate with different size @@ -193,8 +195,8 @@ CASE("FamObject: lookup, create, and destroy") { auto object = region.lookupObject(objectName); - const FamProperty prop {objectSize, objectPerm, objectName}; - EXPECT(object.property() == prop); + const FamProperty objectProp {objectSize, objectPerm, objectName, 10005, 10005}; + EXPECT_EQUAL(objectProp, object.property()); EXPECT_NO_THROW(object.deallocate());