mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2026-11-25 21:21:37 +00:00
ci: check the installed package with a downstream project
- Install to a prefix, relocate it and build a minimal consumer that uses find_package(FairMQ) and FairMQ::FairMQ - Fail if documented package variables are missing or if installed files still refer to the original prefix Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
33
test/consumer/CMakeLists.txt
Normal file
33
test/consumer/CMakeLists.txt
Normal file
@@ -0,0 +1,33 @@
|
||||
################################################################################
|
||||
# Copyright (C) 2026 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||
# #
|
||||
# This software is distributed under the terms of the #
|
||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||
# copied verbatim in the file "LICENSE" #
|
||||
################################################################################
|
||||
|
||||
# Minimal downstream project. It checks that an installed FairMQ can be found
|
||||
# and used the way the README describes. Run it via check-install.sh.
|
||||
|
||||
cmake_minimum_required(VERSION 3.15...3.30 FATAL_ERROR)
|
||||
project(FairMQConsumer LANGUAGES CXX)
|
||||
|
||||
find_package(FairCMakeModules REQUIRED)
|
||||
include(FairFindPackage2)
|
||||
find_package2(PUBLIC FairMQ REQUIRED)
|
||||
find_package2_implicit_dependencies()
|
||||
|
||||
# Variables documented in the README
|
||||
foreach(var IN ITEMS FairMQ_VERSION FairMQ_PREFIX FairMQ_PACKAGE_DEPENDENCIES
|
||||
FairMQ_PACKAGE_COMPONENTS)
|
||||
if("${${var}}" STREQUAL "")
|
||||
message(FATAL_ERROR "${var} is not set by find_package(FairMQ)")
|
||||
endif()
|
||||
endforeach()
|
||||
if(NOT FairMQ_fairmq_FOUND STREQUAL "TRUE")
|
||||
message(FATAL_ERROR "FairMQ_fairmq_FOUND is not set")
|
||||
endif()
|
||||
message(STATUS "FairMQ_PACKAGE_COMPONENTS: ${FairMQ_PACKAGE_COMPONENTS}")
|
||||
|
||||
add_executable(consumer main.cxx)
|
||||
target_link_libraries(consumer PRIVATE FairMQ::FairMQ)
|
||||
56
test/consumer/check-install.sh
Executable file
56
test/consumer/check-install.sh
Executable file
@@ -0,0 +1,56 @@
|
||||
#!/bin/bash
|
||||
|
||||
################################################################################
|
||||
# Copyright (C) 2026 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||
# #
|
||||
# This software is distributed under the terms of the #
|
||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||
# copied verbatim in the file "LICENSE" #
|
||||
################################################################################
|
||||
|
||||
# Checks an installed FairMQ:
|
||||
# 1. install to a temporary prefix that differs from CMAKE_INSTALL_PREFIX
|
||||
# 2. check that no installed file refers to the configure-time prefix
|
||||
# (scripts must be configured for the prefix given at install time)
|
||||
# 3. move the installation to a second prefix and build and run a small
|
||||
# downstream project against it (the CMake package must be relocatable)
|
||||
#
|
||||
# Usage: check-install.sh <fairmq-build-dir> [extra cmake configure args...]
|
||||
#
|
||||
# Dependencies of FairMQ (FairLogger, FairCMakeModules, ...) must be found via
|
||||
# CMAKE_PREFIX_PATH (environment or extra cmake args).
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "Usage: $0 <fairmq-build-dir> [extra cmake configure args...]" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
here=$(cd "$(dirname "$0")" && pwd)
|
||||
build=$(cd "$1" && pwd)
|
||||
shift
|
||||
|
||||
work=$(mktemp -d)
|
||||
trap 'rm -rf "$work"' EXIT
|
||||
first="$work/prefix-one"
|
||||
second="$work/prefix-two"
|
||||
|
||||
echo "--- install to $first"
|
||||
cmake --install "$build" --prefix "$first" > "$work/install.log"
|
||||
|
||||
echo "--- check for references to the configure-time prefix"
|
||||
configured=$(sed -n 's/^CMAKE_INSTALL_PREFIX:PATH=//p' "$build/CMakeCache.txt")
|
||||
if [ -n "$configured" ] && [ "$configured" != "$first" ] && grep -rIl -F "$configured/" "$first"; then
|
||||
echo "ERROR: installed files above refer to the configure-time prefix $configured" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "--- relocate to $second"
|
||||
mv "$first" "$second"
|
||||
|
||||
echo "--- build downstream project"
|
||||
cmake -S "$here" -B "$work/consumer" -DCMAKE_PREFIX_PATH="$second${CMAKE_PREFIX_PATH:+;$CMAKE_PREFIX_PATH}" "$@"
|
||||
cmake --build "$work/consumer"
|
||||
LD_LIBRARY_PATH="$second/lib:$second/lib64${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" "$work/consumer/consumer"
|
||||
echo "OK"
|
||||
19
test/consumer/main.cxx
Normal file
19
test/consumer/main.cxx
Normal file
@@ -0,0 +1,19 @@
|
||||
/********************************************************************************
|
||||
* Copyright (C) 2026 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||
* *
|
||||
* This software is distributed under the terms of the *
|
||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
#include <fairmq/Device.h>
|
||||
#include <fairmq/Version.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
fair::mq::Device device;
|
||||
std::cout << "FairMQ " << FAIRMQ_VERSION << " consumer ok\n";
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user