|
| 1 | +# Copyright 2019-2026 CERN and copyright holders of ALICE O2. |
| 2 | +# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. |
| 3 | +# All rights not expressly granted are reserved. |
| 4 | +# |
| 5 | +# This software is distributed under the terms of the GNU General Public |
| 6 | +# License v3 (GPL Version 3), copied verbatim in the file "COPYING". |
| 7 | +# |
| 8 | +# In applying this license CERN does not waive the privileges and immunities |
| 9 | +# granted to it by virtue of its status as an Intergovernmental Organization |
| 10 | +# or submit itself to any jurisdiction. |
| 11 | + |
| 12 | +# ROOT-free reader for AO2D files. Nothing in this directory may depend on |
| 13 | +# ROOT, at build or run time: see the check at the end of this file. |
| 14 | +o2_add_library(AODNative |
| 15 | + SOURCES src/ByteSource.cxx |
| 16 | + src/LocalByteSource.cxx |
| 17 | + src/Container.cxx |
| 18 | + src/Objects.cxx |
| 19 | + src/Codecs.cxx |
| 20 | + src/Decoder.cxx |
| 21 | + src/ArrowTable.cxx |
| 22 | + src/ReadPlan.cxx |
| 23 | + TARGETVARNAME targetName |
| 24 | + PRIVATE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_LIST_DIR}/src |
| 25 | + PUBLIC_LINK_LIBRARIES Arrow::arrow_shared |
| 26 | + PRIVATE_LINK_LIBRARIES PkgConfig::zstd PkgConfig::lz4 PkgConfig::lzma ZLIB::ZLIB) |
| 27 | + |
| 28 | +# Reading over root:// needs the XRootD client, which does not depend on ROOT. |
| 29 | +if(XROOTD_FOUND AND XROOTD_CLIENT_FOUND) |
| 30 | + target_sources(${targetName} PRIVATE src/XRootDByteSource.cxx) |
| 31 | + target_include_directories(${targetName} SYSTEM PRIVATE ${XROOTD_INCLUDE_DIRS}) |
| 32 | + target_link_libraries(${targetName} PRIVATE ${XROOTD_CLIENT_LIBRARIES}) |
| 33 | + target_compile_definitions(${targetName} PRIVATE AODNATIVE_WITH_XROOTD) |
| 34 | +endif() |
| 35 | + |
| 36 | +# Public HTTP(S) with libcurl. |
| 37 | +if(TARGET CURL::libcurl) |
| 38 | + target_sources(${targetName} PRIVATE src/HttpByteSource.cxx) |
| 39 | + target_link_libraries(${targetName} PRIVATE CURL::libcurl) |
| 40 | + target_compile_definitions(${targetName} PRIVATE AODNATIVE_WITH_CURL) |
| 41 | +endif() |
| 42 | + |
| 43 | +o2_add_executable(inspect |
| 44 | + COMPONENT_NAME aod-native |
| 45 | + SOURCES tools/inspect.cxx |
| 46 | + PUBLIC_LINK_LIBRARIES O2::AODNative) |
| 47 | + |
| 48 | +o2_add_executable(dump |
| 49 | + COMPONENT_NAME aod-native |
| 50 | + SOURCES tools/dump.cxx |
| 51 | + PUBLIC_LINK_LIBRARIES O2::AODNative) |
| 52 | + |
| 53 | +add_executable(o2-test-framework-aod-native |
| 54 | + test/test_Codecs.cxx |
| 55 | + test/test_Objects.cxx |
| 56 | + test/test_Decoder.cxx |
| 57 | + test/test_ReadPlan.cxx) |
| 58 | +target_include_directories(o2-test-framework-aod-native PRIVATE ${CMAKE_CURRENT_LIST_DIR}/src) |
| 59 | +target_link_libraries(o2-test-framework-aod-native PRIVATE O2::AODNative O2::Catch2 PkgConfig::zstd PkgConfig::lz4 PkgConfig::lzma ZLIB::ZLIB) |
| 60 | + |
| 61 | +get_filename_component(outdir ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/../tests ABSOLUTE) |
| 62 | +set_property(TARGET o2-test-framework-aod-native PROPERTY RUNTIME_OUTPUT_DIRECTORY ${outdir}) |
| 63 | + |
| 64 | +add_test(NAME framework:aod-native COMMAND o2-test-framework-aod-native) |
| 65 | + |
| 66 | +# Measures private memory while decoding the files given on the command line. |
| 67 | +# It interposes glibc's malloc, so it is Linux only and cannot be built with sanitizers. |
| 68 | +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") |
| 69 | + add_executable(o2-test-framework-aod-native-memory test/test_Memory.cxx) |
| 70 | + target_link_libraries(o2-test-framework-aod-native-memory PRIVATE O2::AODNative) |
| 71 | + set_property(TARGET o2-test-framework-aod-native-memory PROPERTY RUNTIME_OUTPUT_DIRECTORY ${outdir}) |
| 72 | +endif() |
| 73 | + |
| 74 | +# libFuzzer target for the container, object and decoder layers. Needs clang, |
| 75 | +# and the whole library built with -fsanitize=address,undefined to be useful. |
| 76 | +option(AODNATIVE_FUZZ "Build the AODNative libFuzzer target" OFF) |
| 77 | +if(AODNATIVE_FUZZ) |
| 78 | + add_executable(o2-fuzz-aod-native test/fuzz/fuzz_RootFile.cxx) |
| 79 | + target_include_directories(o2-fuzz-aod-native PRIVATE ${CMAKE_CURRENT_LIST_DIR}/src) |
| 80 | + target_compile_options(o2-fuzz-aod-native PRIVATE -fsanitize=fuzzer) |
| 81 | + target_link_options(o2-fuzz-aod-native PRIVATE -fsanitize=fuzzer) |
| 82 | + target_link_libraries(o2-fuzz-aod-native PRIVATE O2::AODNative PkgConfig::zstd PkgConfig::lz4 PkgConfig::lzma ZLIB::ZLIB) |
| 83 | +endif() |
| 84 | + |
| 85 | +# The reader core must not link ROOT, directly or through its dependencies. |
| 86 | +foreach(property LINK_LIBRARIES INTERFACE_LINK_LIBRARIES) |
| 87 | + get_target_property(libs ${targetName} ${property}) |
| 88 | + foreach(lib IN LISTS libs) |
| 89 | + if(lib MATCHES "ROOT::" OR lib MATCHES "O2::Framework") |
| 90 | + message(FATAL_ERROR "O2::AODNative must not depend on ROOT, but links ${lib}") |
| 91 | + endif() |
| 92 | + endforeach() |
| 93 | +endforeach() |
0 commit comments