@cryptotaxi247 / netdata-1 / commits / 6f3ee178a

Fix cmake build (#11862)

Vladimir Kobal committed Jan 11, 2022 at 10:35 UTC 6f3ee178ac3393bc6303b5df58d11b20e3e0b4f4
2 files changed +74 -5
CMakeLists.txt
+73 -4
@@ -346,6 +346,18 @@ IF(LINUX AND EXISTS "${CMAKE_SOURCE_DIR}/externaldeps/libbpf/libbpf.a")
346 ENDIF(ELF_LIBRARIES)
347 ENDIF()
348
349 +# -----------------------------------------------------------------------------
350 +# Detect ml dependencies
351 +file(STRINGS "${CMAKE_SOURCE_DIR}/config.h" DEFINE_ENABLE_ML REGEX "^#define ENABLE_ML 1$")
352 +IF(DEFINE_ENABLE_ML MATCHES ".+" AND
353 + EXISTS "${CMAKE_SOURCE_DIR}/ml/kmeans/dlib/dlib/all/source.cpp" AND
354 + EXISTS "${CMAKE_SOURCE_DIR}/ml/json/single_include/nlohmann/json.hpp")
355 + set(ENABLE_ML True)
356 + list(APPEND NETDATA_COMMON_CFLAGS "-DDLIB_NO_GUI_SUPPORT")
357 + list(APPEND NETDATA_COMMON_INCLUDE_DIRS "ml/kmeans/dlib")
358 +ELSE()
359 + set(ENABLE_ML False)
360 +ENDIF()
361
362 # -----------------------------------------------------------------------------
363 # netdata files
@@ -922,10 +934,36 @@ set(DAEMON_FILES
934 )
935
936 set(ML_FILES
925 - ml/ml.h
926 - ml/ml-dummy.c
937 + ml/ml.h
938 + ml/ml-dummy.c
939 )
940
941 +IF(ENABLE_ML)
942 + list(APPEND ML_FILES
943 + ml/BitBufferCounter.h
944 + ml/BitBufferCounter.cc
945 + ml/BitRateWindow.h
946 + ml/BitRateWindow.cc
947 + ml/Config.h
948 + ml/Config.cc
949 + ml/Database.h
950 + ml/Database.cc
951 + ml/Dimension.cc
952 + ml/Dimension.h
953 + ml/Host.h
954 + ml/Host.cc
955 + ml/Query.h
956 + ml/kmeans/KMeans.h
957 + ml/kmeans/KMeans.cc
958 + ml/kmeans/SamplesBuffer.h
959 + ml/kmeans/SamplesBuffer.cc
960 + ml/kmeans/dlib/dlib/all/source.cpp
961 + ml/json/single_include/nlohmann/json.hpp
962 + ml/ml.cc
963 + ml/ml-private.h
964 + )
965 +ENDIF()
966 +
967 set(NETDATA_FILES
968 collectors/all.h
969 ${DAEMON_FILES}
@@ -1021,7 +1059,38 @@ IF(ENABLE_BACKEND_PROMETHEUS_REMOTE_WRITE)
1059 message(STATUS "prometheus remote write backend: enabled")
1060
1061 find_package(Protobuf REQUIRED)
1024 - protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS exporting/prometheus/remote_write/remote_write.proto)
1062 +
1063 + function(PROTOBUF_REMOTE_WRITE_GENERATE_CPP SRCS HDRS)
1064 + if(NOT ARGN)
1065 + message(SEND_ERROR "Error: PROTOBUF_REMOTE_WRITE_GENERATE_CPP() called without any proto files")
1066 + return()
1067 + endif()
1068 +
1069 + set(${SRCS})
1070 + set(${HDRS})
1071 + foreach(FIL ${ARGN})
1072 + get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
1073 + get_filename_component(DIR ${ABS_FIL} DIRECTORY)
1074 + get_filename_component(FIL_WE ${FIL} NAME_WE)
1075 + set(GENERATED_PB_CC "${DIR}/${FIL_WE}.pb.cc")
1076 + set(GENERATED_PB_H "${DIR}/${FIL_WE}.pb.h")
1077 + list(APPEND ${SRCS} ${GENERATED_PB_CC})
1078 + list(APPEND ${HDRS} ${GENERATED_PB_H})
1079 + add_custom_command(
1080 + OUTPUT ${GENERATED_PB_CC}
1081 + ${GENERATED_PB_H}
1082 + COMMAND ${PROTOBUF_PROTOC_EXECUTABLE}
1083 + ARGS -I=${CMAKE_SOURCE_DIR}/exporting/prometheus/remote_write --cpp_out=${CMAKE_SOURCE_DIR}/exporting/prometheus/remote_write ${ABS_FIL}
1084 + DEPENDS ${ABS_FIL} ${PROTOBUF_PROTOC_EXECUTABLE}
1085 + COMMENT "Running C++ protocol buffer compiler on ${FIL}"
1086 + VERBATIM )
1087 + endforeach()
1088 + set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES GENERATED TRUE)
1089 + set(${SRCS} ${${SRCS}} PARENT_SCOPE)
1090 + set(${HDRS} ${${HDRS}} PARENT_SCOPE)
1091 + endfunction()
1092 +
1093 + protobuf_remote_write_generate_cpp(PROTO_SRCS PROTO_HDRS exporting/prometheus/remote_write/remote_write.proto)
1094
1095 list(APPEND NETDATA_FILES ${PROMETHEUS_REMOTE_WRITE_BACKEND_FILES} ${PROMETHEUS_REMOTE_WRITE_EXPORTING_FILES} ${PROTO_SRCS} ${PROTO_HDRS})
1096 list(APPEND NETDATA_COMMON_LIBRARIES ${PROTOBUF_LIBRARIES} ${SNAPPY_LIBRARIES})
@@ -1115,6 +1184,7 @@ include_directories(BEFORE ${CMAKE_SOURCE_DIR}/mqtt_websockets/c-rbuf/include)
1184 # netdata
1185
1186 IF(LINUX)
1187 + list(APPEND NETDATA_COMMON_LIBRARIES rt)
1188 add_executable(netdata config.h ${NETDATA_FILES}
1189 ${CGROUPS_PLUGIN_FILES}
1190 ${DISKSPACE_PLUGIN_FILES}
@@ -1299,7 +1369,6 @@ ELSE()
1369 message(STATUS "cgroup-network: disabled (requires Linux)")
1370 ENDIF()
1371
1302 -
1372 # -----------------------------------------------------------------------------
1373 # Unit tests
1374
backends/prometheus/remote_write/remote_write.cc
+1 -1
@@ -1,7 +1,7 @@
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 #include <snappy.h>
4 -#include "remote_write.pb.h"
4 +#include "exporting/prometheus/remote_write/remote_write.pb.h"
5 #include "remote_write.h"
6
7 using namespace prometheus;