1- # Copyright 2019-2020 CERN and copyright holders of ALICE O2.
1+ # Copyright 2019-2024 CERN and copyright holders of ALICE O2.
22# See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
33# All rights not expressly granted are reserved.
44#
1616# General project definition
1717####################################
1818
19- CMAKE_MINIMUM_REQUIRED (VERSION 3.5.2 FATAL_ERROR )
19+ CMAKE_MINIMUM_REQUIRED (VERSION 3.26 FATAL_ERROR )
2020set (Boost_USE_STATIC_RUNTIME OFF )
2121set (Boost_USE_STATIC_LIBS OFF )
2222set (BUILD_SHARED_LIBS ON )
2323set (Boost_USE_MULTITHREADED ON )
24+ set (O2_MONITORING_KAFKA_ENABLE ON )
25+ set (O2_MONITORING_CONTROL_ENABLE ON )
2426
2527# Set cmake policy by version: https://cmake.org/cmake/help/latest/manual/cmake-policies.7.html
26- if (${CMAKE_VERSION } VERSION_LESS 3.12)
27- cmake_policy (VERSION ${CMAKE_MAJOR_VERSION } .${CMAKE_MINOR_VERSION} )
28- else ()
29- cmake_policy (VERSION 3.12 )
30- endif ()
28+ cmake_policy (VERSION 3.12 )
3129
3230# Define project
3331project (Monitoring
34- VERSION 3.17.5
32+ VERSION 3.19.12
3533 DESCRIPTION "O2 Monitoring library"
3634 LANGUAGES CXX
3735)
@@ -73,13 +71,34 @@ endif()
7371
7472list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR } /cmake" )
7573
76- find_package (Boost 1.70 REQUIRED COMPONENTS unit_test_framework program_options system )
74+ find_package (Boost 1.70 REQUIRED COMPONENTS unit_test_framework program_options )
7775find_package (ApMon MODULE )
7876find_package (CURL MODULE )
79- find_package (RdKafka CONFIG )
8077find_package (InfoLogger CONFIG )
81- find_package (Protobuf )
82- find_package (gRPC CONFIG )
78+ if (O2_MONITORING_KAFKA_ENABLE OR O2_MONITORING_CONTROL_ENABLE)
79+ find_package (Protobuf CONFIG )
80+ endif ()
81+ if (O2_MONITORING_CONTROL_ENABLE)
82+ find_package (gRPC CONFIG )
83+ endif ()
84+
85+ if (RDKAFKA_ROOT)
86+ message ("RDKAFKA_ROOT set, we enable corresponding libs and binaries" )
87+ find_library (RDKAFKA_LIB1 "rdkafka++" REQUIRED PATHS ${RDKAFKA_ROOT} /lib )
88+ find_library (RDKAFKA_LIB2 "rdkafka" REQUIRED PATHS ${RDKAFKA_ROOT} /lib )
89+ set (RDKAFKA_LIBS ${RDKAFKA_LIB1} ${RDKAFKA_LIB2} )
90+ set (RDKAFKA_INCLUDE "${RDKAFKA_ROOT} /include" )
91+ set (RdKafka_FOUND true )
92+ else ()
93+ message ("RDKAFKA_ROOT not set, corresponding libs and binaries won't be built" )
94+ endif ()
95+
96+ if (gRPC_FOUND)
97+ message ("gRPC found, we enable corresponding libs and binaries" )
98+ else ()
99+ message ("gRPC not found, corresponding libs and binaries won't be built" )
100+ endif ()
101+
83102
84103####################################
85104# Set OUTPUT vars
@@ -142,6 +161,7 @@ target_include_directories(Monitoring
142161 PUBLIC
143162 $<INSTALL_INTERFACE :include >
144163 $<BUILD_INTERFACE :${CMAKE_CURRENT_SOURCE_DIR } /include >
164+ $<BUILD_INTERFACE :${RDKAFKA_INCLUDE} >
145165 PRIVATE
146166 ${CMAKE_CURRENT_SOURCE_DIR } /src
147167)
@@ -153,13 +173,12 @@ set_target_properties(Monitoring PROPERTIES OUTPUT_NAME "O2Monitoring")
153173target_link_libraries (Monitoring
154174 PUBLIC
155175 Boost::boost
156- $<$<BOOL :${RdKafka_FOUND} >:RdKafka ::rdkafka ++>
157176 PRIVATE
158- Boost::system
159177 pthread
160178 $<$<BOOL :${ApMon_FOUND} >:ApMon ::ApMon >
161179 $<$<BOOL :${CURL_FOUND} >:CURL ::libcurl >
162180 $<$<BOOL :${InfoLogger_FOUND} >:AliceO2 ::InfoLogger >
181+ $<$<BOOL :${RdKafka_FOUND} >:${RDKAFKA_LIBS} >
163182)
164183
165184# Handle ApMon optional dependency
@@ -247,7 +266,10 @@ foreach (example ${EXAMPLES})
247266 add_executable (${example_name} ${example} )
248267 target_link_libraries (${example_name}
249268 PRIVATE
269+ pthread
250270 Monitoring Boost::program_options
271+ $<$<BOOL :${CURL_FOUND} >:CURL ::libcurl >
272+ $<$<BOOL :${RdKafka_FOUND} >:${RDKAFKA_LIBS} >
251273 )
252274endforeach ()
253275
@@ -258,6 +280,17 @@ if(RdKafka_FOUND)
258280endif ()
259281
260282
283+ # executable: o2-monitoring-send
284+ add_executable (
285+ o2-monitoring-send
286+ src/sendMetric.cxx
287+ )
288+ target_link_libraries (
289+ o2-monitoring-send
290+ Monitoring
291+ )
292+ install (TARGETS o2-monitoring-send)
293+
261294####################################
262295# Generate protobuf
263296####################################
@@ -289,6 +322,7 @@ if(RdKafka_FOUND AND Protobuf_FOUND AND CURL_FOUND)
289322 Boost::program_options
290323 protobuf::libprotobuf
291324 $<$<BOOL :${InfoLogger_FOUND} >:AliceO2 ::InfoLogger >
325+ $<$<BOOL :${RdKafka_FOUND} >:${RDKAFKA_LIBS} >
292326 )
293327 target_compile_definitions (${example_name} PRIVATE $<$<BOOL :${InfoLogger_FOUND} >:O2_MONITORING_WITH_INFOLOGGER >)
294328 target_include_directories (${example_name} PRIVATE ${CMAKE_CURRENT_BINARY_DIR } )
0 commit comments