Out-of-tree builds

Are there plans to support out-of-tree builds of SW based on O2?

I’ve tried to isolate AliceO2/Examples/Ex1 and build it loading O2 from CVMFS:
user@host$ WORK_DIR=/cvmfs/alice.cern.ch ALIBUILD_ARCH_PREFIX=el7-x86_64/Packages source /cvmfs/alice.cern.ch/el7-x86_64/Packages/O2/nightly-20210618-1/etc/profile.d/init.sh
with the following CMakeLists.txt:

cmake_minimum_required(VERSION 3.17 FATAL_ERROR)

find_package(O2 REQUIRED)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")


include(O2DefineOptions)
o2_define_options()
include(O2DefineOutputPaths)
o2_define_output_paths()

include(O2AddLibrary)


o2_add_library(Ex1
               SOURCES src/A.cxx src/B.cxx
               PUBLIC_LINK_LIBRARIES FairMQ::FairMQ)

and it works, however I had to copy O2DefineOptions.cmake, O2DefineOutputPaths.cmake and O2AddLibrary.cmake from AliceO2 sources, they are not distributed over CVMFS.

Hi Andrey,

There’s one major package which depends on AliceO2 : QualityControl. You might look there to get some inspiration.
But basically, the idea is that, as far as CMake is concerned, AliceO2 should behave like any other C++ package : if you need it, you find_package(AliceO2) (preferably find_package(AliceO2 CONFIG) and then you get access to all the (exported) O2::XXX targets. We do not export our custom CMake functions and macros (o2_yyyy) though, as that’s tailored to create those O2::XXX target, not use them.
At least that’s the idea, and if it’s not working like that, then it means something has to be fixed (but again, it’s working fine as far as I can tell for the QualityControl).

Hope this helps,

Hi,

Taking a quick look, QC do more or less what I did.