From 1148219311dbf4d8ef35d76467b82c03c6b52d6e Mon Sep 17 00:00:00 2001 From: tmadlener Date: Thu, 11 Jan 2024 10:36:19 +0100 Subject: [PATCH 1/4] Add a small downstream project for testing --- .../CMakeLists.txt | 15 +++++++++++++ .../lcio_test_program.cpp | 22 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 tests/downstream-project-cmake-test/CMakeLists.txt create mode 100644 tests/downstream-project-cmake-test/lcio_test_program.cpp diff --git a/tests/downstream-project-cmake-test/CMakeLists.txt b/tests/downstream-project-cmake-test/CMakeLists.txt new file mode 100644 index 000000000..77f70f5c2 --- /dev/null +++ b/tests/downstream-project-cmake-test/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.14) + +project(DownstreamProjectUsingLCIO) + +find_package(LCIO REQUIRED) + +# Make sure that the LCIO version is set and usableas a version +if (${LCIO_VERSION} VERSION_GREATER "0.0.0") + message(STATUS "Found LCIO version " ${LCIO_VERSION}) +else() + message(FATAL_ERROR "Cannot determine LCIO_VERSION") +endif() + +add_executable(lcio_test_program lcio_test_program.cpp) +target_link_libraries(lcio_test_program PRIVATE LCIO::lcio) diff --git a/tests/downstream-project-cmake-test/lcio_test_program.cpp b/tests/downstream-project-cmake-test/lcio_test_program.cpp new file mode 100644 index 000000000..a53be69fa --- /dev/null +++ b/tests/downstream-project-cmake-test/lcio_test_program.cpp @@ -0,0 +1,22 @@ +#include "EVENT/LCEvent.h" +#include "IMPL/LCCollectionVec.h" +#include "IMPL/LCEventImpl.h" +#include "IMPL/MCParticleImpl.h" +#include "MT/LCWriter.h" + +int main() { + auto mcp = new IMPL::MCParticleImpl(); + mcp->setPDG(11); + + auto coll = new IMPL::LCCollectionVec(EVENT::LCIO::MCPARTICLE); + coll->addElement(mcp); + + auto event = new IMPL::LCEventImpl(); + event->addCollection(coll, "mcps"); + + auto writer = MT::LCWriter(); + writer.open("test.slcio"); + writer.writeEvent(event); + + return 0; +} From c514a653be1d3ec8593702564f2cffe708e977c8 Mon Sep 17 00:00:00 2001 From: tmadlener Date: Thu, 11 Jan 2024 10:39:33 +0100 Subject: [PATCH 2/4] Build downstream project in CI --- .github/workflows/key4hep.yml | 7 +++++++ .github/workflows/linux.yml | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/.github/workflows/key4hep.yml b/.github/workflows/key4hep.yml index 9db920284..1b74f57da 100644 --- a/.github/workflows/key4hep.yml +++ b/.github/workflows/key4hep.yml @@ -28,3 +28,10 @@ jobs: make -k make install ctest --output-on-failure + echo "::group::Test downstream build" + cd - + export CMAKE_PREFIX_PATH=$PWD/install:$CMAKE_PREFIX_PATH + cd tests/downstream-project-cmake-test + mkdir build && cd build + cmake .. -DCMAKE_CXX_STANDARD=17 + make -k diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index f93a904a3..084e222cb 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -30,3 +30,10 @@ jobs: make -k make install ctest --output-on-failure + echo "::group::Test downstream build" + cd - + export CMAKE_PREFIX_PATH=$PWD/install:$CMAKE_PREFIX_PATH + cd tests/downstream-project-cmake-test + mkdir build && cd build + cmake .. -DCMAKE_CXX_STANDARD=17 + make -k From e1c31d1b34c2ed06ed30b62957a8fdbbf481699f Mon Sep 17 00:00:00 2001 From: tmadlener Date: Thu, 11 Jan 2024 10:51:49 +0100 Subject: [PATCH 3/4] Update CMake config template to work with new sio packaging --- cmake/LCIOConfig.cmake.in | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/cmake/LCIOConfig.cmake.in b/cmake/LCIOConfig.cmake.in index e1b545636..ef304a1d6 100644 --- a/cmake/LCIOConfig.cmake.in +++ b/cmake/LCIOConfig.cmake.in @@ -68,12 +68,7 @@ CHECK_PACKAGE_LIBS( LCIO lcio @CHECK_PACKAGE_SIO_LIBRARY@ ) include(CMakeFindDependencyMacro) -if("@CHECK_PACKAGE_SIO_LIBRARY@" STREQUAL "") - find_dependency(SIO REQUIRED) -else() - find_dependency(ZLIB REQUIRED) - include("${CMAKE_CURRENT_LIST_DIR}/SIOTargets.cmake") -endif() +find_dependency(SIO @SIO_VERSION@) # Include the targets file to create the imported targets that a client can link # to or execute From 05d0e0ed5229c9c057400586c9065207b909ba9b Mon Sep 17 00:00:00 2001 From: tmadlener Date: Thu, 11 Jan 2024 11:35:55 +0100 Subject: [PATCH 4/4] Bump minimum required SIO version to v00-01 --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f2a3231e..d44a9424d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -161,8 +161,8 @@ eval $* ENDIF() -# Deal with SIO -FIND_PACKAGE( SIO QUIET ) +# Deal with SIO (we need at least 0.1 since there are no targets before) +FIND_PACKAGE( SIO 0.1 QUIET ) IF( NOT SIO_FOUND ) MESSAGE( STATUS "SIO not found on your system. Using builtin sio" )