From 0de54f00191ca0ec579d50e9e02a41bbce5707db Mon Sep 17 00:00:00 2001 From: David Rohr Date: Fri, 29 Mar 2024 22:40:25 +0100 Subject: [PATCH 1/3] onnxruntime upstream uses onnxruntime::onnxruntime: Adhere to that and remain compatible with our custom onnxruntime build --- CMakeLists.txt | 5 +---- Detectors/ZDC/CMakeLists.txt | 2 +- Detectors/ZDC/fastsimulation/CMakeLists.txt | 2 +- Detectors/ZDC/simulation/CMakeLists.txt | 2 +- dependencies/FindONNXRuntime.cmake | 20 ++++++++++++++++++++ 5 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 dependencies/FindONNXRuntime.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index deacb50958b84..d28f191021fdf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,10 +41,7 @@ o2_build_sanity_checks() set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED TRUE) -find_package(ONNXRuntime::ONNXRuntime CONFIG) -if (ONNXRuntime::ONNXRuntime_FOUND) - add_definitions(-DZDC_FASTSIM_ONNX) -endif() +include(dependencies/FindONNXRuntime.cmake) include(O2CheckCXXFeatures) o2_check_cxx_features() diff --git a/Detectors/ZDC/CMakeLists.txt b/Detectors/ZDC/CMakeLists.txt index c9f51fc56c903..d3c6a661a8131 100644 --- a/Detectors/ZDC/CMakeLists.txt +++ b/Detectors/ZDC/CMakeLists.txt @@ -9,7 +9,7 @@ # granted to it by virtue of its status as an Intergovernmental Organization # or submit itself to any jurisdiction. -if (ONNXRuntime::ONNXRuntime_FOUND) +if (onnxruntime_FOUND) add_subdirectory(fastsimulation) endif() add_subdirectory(base) diff --git a/Detectors/ZDC/fastsimulation/CMakeLists.txt b/Detectors/ZDC/fastsimulation/CMakeLists.txt index c3ce25b9cc28c..ec65489366d22 100644 --- a/Detectors/ZDC/fastsimulation/CMakeLists.txt +++ b/Detectors/ZDC/fastsimulation/CMakeLists.txt @@ -14,7 +14,7 @@ o2_add_library(FASTSimulation SOURCES src/FastSimulations.cxx src/Processors.cxx src/Utils.cxx - PUBLIC_LINK_LIBRARIES ONNXRuntime::ONNXRuntime) + PUBLIC_LINK_LIBRARIES onnxruntime::onnxruntime) o2_data_file(COPY scales DESTINATION Detectors/ZDC/fastsimulation) diff --git a/Detectors/ZDC/simulation/CMakeLists.txt b/Detectors/ZDC/simulation/CMakeLists.txt index 96eef618c79d8..d0dcb2ff577b3 100644 --- a/Detectors/ZDC/simulation/CMakeLists.txt +++ b/Detectors/ZDC/simulation/CMakeLists.txt @@ -17,7 +17,7 @@ list(APPEND LinkLibraries O2::SimulationDataFormat O2::DetectorsRaw O2::Headers) -if (ONNXRuntime::ONNXRuntime_FOUND) +if (onnxruntime_FOUND) list(APPEND LinkLibraries O2::FASTSimulation) endif() diff --git a/dependencies/FindONNXRuntime.cmake b/dependencies/FindONNXRuntime.cmake new file mode 100644 index 0000000000000..4915965cbc05f --- /dev/null +++ b/dependencies/FindONNXRuntime.cmake @@ -0,0 +1,20 @@ +# Copyright 2019-2020 CERN and copyright holders of ALICE O2. +# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +# All rights not expressly granted are reserved. +# +# This software is distributed under the terms of the GNU General Public +# License v3 (GPL Version 3), copied verbatim in the file "COPYING". +# +# In applying this license CERN does not waive the privileges and immunities +# granted to it by virtue of its status as an Intergovernmental Organization +# or submit itself to any jurisdiction. + +find_package(onnxruntime CONFIG) +if (NOT onnxruntime_FOUND) + find_package(ONNXRuntime::ONNXRuntime CONFIG) + if (ONNXRuntime::ONNXRuntime_FOUND) + add_definitions(-DZDC_FASTSIM_ONNX) + set(onnxruntime_FOUND 1) + add_library(onnxruntime::onnxruntime ALIAS ONNXRuntime::ONNXRuntime) + endif() +endif() From 996115749391357a1b55934f6a77acea79d1a88f Mon Sep 17 00:00:00 2001 From: David Rohr Date: Sat, 30 Mar 2024 10:02:48 +0100 Subject: [PATCH 2/3] ZDC Sim: Don't set ZDC_FASTSIM_ONNX as global define but as target compile definition --- Detectors/ZDC/simulation/CMakeLists.txt | 4 ++++ dependencies/FindONNXRuntime.cmake | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Detectors/ZDC/simulation/CMakeLists.txt b/Detectors/ZDC/simulation/CMakeLists.txt index d0dcb2ff577b3..dda2e019c02b9 100644 --- a/Detectors/ZDC/simulation/CMakeLists.txt +++ b/Detectors/ZDC/simulation/CMakeLists.txt @@ -22,11 +22,15 @@ if (onnxruntime_FOUND) endif() o2_add_library(ZDCSimulation + TARGETVARNAME targetName SOURCES src/Detector.cxx src/Digitizer.cxx src/SimCondition.cxx src/ZDCSimParam.cxx src/SpatialPhotonResponse.cxx src/Digits2Raw.cxx src/DigitizerTest.cxx PUBLIC_LINK_LIBRARIES ${LinkLibraries}) +if (onnxruntime_FOUND) + target_compile_definitions(${targetName} PUBLIC ZDC_FASTSIM_ONNX) +endif() o2_target_root_dictionary(ZDCSimulation HEADERS include/ZDCSimulation/Digitizer.h diff --git a/dependencies/FindONNXRuntime.cmake b/dependencies/FindONNXRuntime.cmake index 4915965cbc05f..b34782e99050f 100644 --- a/dependencies/FindONNXRuntime.cmake +++ b/dependencies/FindONNXRuntime.cmake @@ -13,7 +13,6 @@ find_package(onnxruntime CONFIG) if (NOT onnxruntime_FOUND) find_package(ONNXRuntime::ONNXRuntime CONFIG) if (ONNXRuntime::ONNXRuntime_FOUND) - add_definitions(-DZDC_FASTSIM_ONNX) set(onnxruntime_FOUND 1) add_library(onnxruntime::onnxruntime ALIAS ONNXRuntime::ONNXRuntime) endif() From 91257149eb7c6f75d170bc07a552eddfcfefc05f Mon Sep 17 00:00:00 2001 From: David Rohr Date: Sat, 30 Mar 2024 10:05:01 +0100 Subject: [PATCH 3/3] ZDC: Fix copyright statement syntax --- Detectors/ZDC/fastsimulation/CMakeLists.txt | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/Detectors/ZDC/fastsimulation/CMakeLists.txt b/Detectors/ZDC/fastsimulation/CMakeLists.txt index ec65489366d22..527a7ca2553a2 100644 --- a/Detectors/ZDC/fastsimulation/CMakeLists.txt +++ b/Detectors/ZDC/fastsimulation/CMakeLists.txt @@ -1,13 +1,13 @@ -# Copyright 2019-2020 CERN and copyright holders of ALICE O2. -# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. -# All rights not expressly granted are reserved. - -# This software is distributed under the terms of the GNU General Public -# License v3 (GPL Version 3), copied verbatim in the file "COPYING". - -# In applying this license CERN does not waive the privileges and immunities -# granted to it by virtue of its status as an Intergovernmental Organization -# or submit itself to any jurisdiction. +# Copyright 2019-2020 CERN and copyright holders of ALICE O2. +# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +# All rights not expressly granted are reserved. +# +# This software is distributed under the terms of the GNU General Public +# License v3 (GPL Version 3), copied verbatim in the file "COPYING". +# +# In applying this license CERN does not waive the privileges and immunities +# granted to it by virtue of its status as an Intergovernmental Organization +# or submit itself to any jurisdiction. # @author SwirtaB @@ -22,4 +22,3 @@ o2_add_executable(fastsim-example SOURCES tests/run-example.cxx PUBLIC_LINK_LIBRARIES O2::FASTSimulation COMPONENT_NAME zdc) -