Use pkg-config to find nOS-V

This commit is contained in:
Rodrigo Arias 2023-11-02 18:21:26 +01:00
parent 4b4f1bd218
commit eda93acc49
4 changed files with 29 additions and 12 deletions

View File

@ -15,6 +15,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Don't modify nOS-V subsystem state on task pause. The "Task: Running"
state is now renamed to "Task: In body" to reflect the change.
- Use pkg-config to locate the nOS-V library and get the version. Use
`PKG_CONFIG_LIBDIR=/path/to/nosv/install/lib/pkgconfig` to use a custom
installation path.
## [1.3.0] - 2023-09-07

19
cmake/FindNosv.cmake Normal file
View File

@ -0,0 +1,19 @@
# Copyright (c) 2023 Barcelona Supercomputing Center (BSC)
# SPDX-License-Identifier: GPL-3.0-or-later
find_package(PkgConfig)
if(NOT PKG_CONFIG_FOUND)
message(STATUS "pkg-config not found, required to locate nOSV-V")
return()
endif()
# Use PKG_CONFIG_LIBDIR=/path/to/nosv/install/lib/pkgconfig to use a custom
# installation.
pkg_search_module(NOSV IMPORTED_TARGET nos-v)
if(NOT NOSV_FOUND)
message(STATUS "nOS-V not found")
else()
message(STATUS "Found nOS-V ${NOSV_VERSION} at ${NOSV_LINK_LIBRARIES}")
endif()

View File

@ -67,7 +67,7 @@
# We need to be able to exit the chroot to run Nanos6 tests, as they
# require access to /sys for hwloc
__noChroot = true;
buildInputs = old.buildInputs ++ (with pkgs; [ nosv nanos6 nodes ]);
buildInputs = old.buildInputs ++ (with pkgs; [ pkg-config nosv nanos6 nodes ]);
cmakeFlags = old.cmakeFlags ++ [ "-DENABLE_ALL_TESTS=ON" ];
preConfigure = old.preConfigure or "" + ''
export NODES_HOME="${pkgs.nodes}"

View File

@ -1,16 +1,13 @@
# Copyright (c) 2021-2022 Barcelona Supercomputing Center (BSC)
# Copyright (c) 2021-2023 Barcelona Supercomputing Center (BSC)
# SPDX-License-Identifier: GPL-3.0-or-later
find_library(nosv libnosv)
find_path(NOSV_INCLUDE_DIR nosv.h)
find_package(Nosv)
check_library_exists(nosv nosv_init "nosv.h" HAVE_NOSV)
if(NOT HAVE_NOSV)
if(NOT NOSV_FOUND)
if(ENABLE_ALL_TESTS)
message(FATAL_ERROR "nOS-V library not found, cannot enable nOS-V RT tests")
message(FATAL_ERROR "nOS-V not found, cannot enable nOS-V RT tests")
else()
message(STATUS "nOS-V library not found, disabling nOS-V RT tests")
message(STATUS "nOS-V not found, disabling nOS-V RT tests")
endif()
return()
else()
@ -19,9 +16,7 @@ endif()
function(nosv_test)
ovni_test(${ARGN})
target_link_libraries("${OVNI_TEST_NAME}" PRIVATE nosv)
target_include_directories("${OVNI_TEST_NAME}"
PUBLIC ${NOSV_INCLUDE_DIR})
target_link_libraries("${OVNI_TEST_NAME}" PRIVATE PkgConfig::NOSV)
set_property(TEST "${OVNI_TEST_NAME}" APPEND
PROPERTY
ENVIRONMENT "NOSV_CONFIG=${OVNI_TEST_SOURCE_DIR}/rt/nosv/nosv.toml")