summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt336
1 files changed, 232 insertions, 104 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9752f371..c12e9c81 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,31 +9,25 @@ project(netdata C CXX)
find_package(Threads REQUIRED)
find_package(PkgConfig REQUIRED)
+include(CheckFunctionExists)
+include(CheckLibraryExists)
+
# default is "Debug"
#set(CMAKE_BUILD_TYPE "Release")
# set this to see the compilation commands
-# set(CMAKE_VERBOSE_MAKEFILE 1)
-
+#set(CMAKE_VERBOSE_MAKEFILE 1)
# -----------------------------------------------------------------------------
# Set compilation options according to build type
+set(CMAKE_C_STANDARD 11)
+
IF("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
+ set(CXX_DEFAULT_CFLAGS "-O0 -g -DNETDATA_INTERNAL_CHECKS=1 -DNETDATA_DEV_MODE=1 -fstack-protector-all -fno-omit-frame-pointer")
message(STATUS "building for: debugging")
-
- ## unfortunately these produce errors
- #include(CheckCXXCompilerFlag)
- #CHECK_CXX_COMPILER_FLAG("-Wformat-signedness" CXX_FORMAT_SIGNEDNESS)
- #CHECK_CXX_COMPILER_FLAG("-Werror=format-security" CXX_FORMAT_SECURITY)
- #CHECK_CXX_COMPILER_FLAG("-fstack-protector-all" CXX_STACK_PROTECTOR)
- set(CXX_FORMAT_SIGNEDNESS "-Wformat-signedness")
- set(CXX_FORMAT_SECURITY "-Werror=format-security")
- set(CXX_STACK_PROTECTOR "-fstack-protector-all")
- set(CXX_FLAGS_DEBUG "-O0")
- set(CMAKE_C_STANDARD 99)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O1 -ggdb -Wall -Wextra -DNETDATA_INTERNAL_CHECKS=1 -DNETDATA_VERIFY_LOCKS=1 ${CXX_FORMAT_SIGNEDNESS} ${CXX_FORMAT_SECURITY} ${CXX_STACK_PROTECTOR} ${CXX_FLAGS_DEBUG}")
ELSE()
+ set(CXX_DEFAULT_CFLAGS "-O2")
message(STATUS "building for: release")
cmake_policy(SET CMP0069 "NEW")
include(CheckIPOSupported)
@@ -46,6 +40,7 @@ ELSE()
ENDIF()
ENDIF()
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O1 -ggdb -Wall -Wextra -Wformat-signedness -Werror=format-security -Wunused-result ${CXX_DEFAULT_CFLAGS}")
# -----------------------------------------------------------------------------
# O/S Detection
@@ -67,6 +62,15 @@ ENDIF()
# show the operating system on the console
message(STATUS "system name: ${CMAKE_SYSTEM_NAME}")
+set(GENERATED_CONFIG_H_DIR ${CMAKE_BINARY_DIR})
+set(GENERATED_CONFIG_H ${GENERATED_CONFIG_H_DIR}/config.h)
+
+# -----------------------------------------------------------------------------
+# Math
+
+set(NETDATA_COMMON_LIBRARIES ${NETDATA_COMMON_LIBRARIES} m)
+set(NETDATA_REQUIRED_DEFINES "-DSTORAGE_WITH_MATH=1 ${NETDATA_REQUIRED_DEFINES}")
+
# -----------------------------------------------------------------------------
# Detect libuuid
@@ -82,6 +86,7 @@ pkg_check_modules(ZLIB REQUIRED zlib)
set(NETDATA_COMMON_CFLAGS ${NETDATA_COMMON_CFLAGS} ${ZLIB_CFLAGS_OTHER})
set(NETDATA_COMMON_LIBRARIES ${NETDATA_COMMON_LIBRARIES} ${ZLIB_LIBRARIES})
set(NETDATA_COMMON_INCLUDE_DIRS ${NETDATA_COMMON_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS})
+# set(NETDATA_REQUIRED_DEFINES "${NETDATA_REQUIRED_DEFINES} -DNETDATA_WITH_ZLIB=1")
# -----------------------------------------------------------------------------
# libuv multi-platform support library with a focus on asynchronous I/O
@@ -98,6 +103,7 @@ pkg_check_modules(LIBLZ4 REQUIRED liblz4)
set(NETDATA_COMMON_CFLAGS ${NETDATA_COMMON_CFLAGS} ${LIBLZ4_CFLAGS_OTHER})
set(NETDATA_COMMON_LIBRARIES ${NETDATA_COMMON_LIBRARIES} ${LIBLZ4_LIBRARIES})
set(NETDATA_COMMON_INCLUDE_DIRS ${NETDATA_COMMON_INCLUDE_DIRS} ${LIBLZ4_INCLUDE_DIRS})
+# set(NETDATA_REQUIRED_DEFINES "${NETDATA_REQUIRED_DEFINES} -DENABLE_COMPRESSION=1")
# -----------------------------------------------------------------------------
# Judy General purpose dynamic array
@@ -111,6 +117,7 @@ pkg_check_modules(OPENSSL REQUIRED openssl)
set(NETDATA_COMMON_CFLAGS ${NETDATA_COMMON_CFLAGS} ${OPENSSL_CFLAGS_OTHER})
set(NETDATA_COMMON_LIBRARIES ${NETDATA_COMMON_LIBRARIES} ${OPENSSL_LIBRARIES})
set(NETDATA_COMMON_INCLUDE_DIRS ${NETDATA_COMMON_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIRS})
+# set(NETDATA_REQUIRED_DEFINES "${NETDATA_REQUIRED_DEFINES} -DENABLE_HTTPS=1")
# -----------------------------------------------------------------------------
# JSON-C used to health
@@ -220,7 +227,11 @@ pkg_check_modules(CURL libcurl)
# -----------------------------------------------------------------------------
# Detect libcups
-pkg_check_modules(CURL libcups)
+pkg_check_modules(CUPS libcups)
+IF(NOT CUPS_LIBRARIES)
+ pkg_check_modules(CUPS cups)
+ENDIF()
+
# later we use:
# ${CUPS_LIBRARIES}
# ${CUPS_CFLAGS_OTHER}
@@ -328,8 +339,9 @@ IF(LINUX AND EXISTS "${CMAKE_SOURCE_DIR}/externaldeps/libbpf/libbpf.a")
${CMAKE_SOURCE_DIR}/externaldeps/libbpf/libbpf.a
${ELF_LIBRARIES})
list(APPEND NETDATA_COMMON_INCLUDE_DIRS ${ELF_INCLUDE_DIRS})
- include_directories(BEFORE ${CMAKE_SOURCE_DIR}/externaldeps/libbpf/include)
+ include_directories(BEFORE ${CMAKE_SOURCE_DIR}/externaldeps/libbpf/include ${CMAKE_SOURCE_DIR}/externaldeps/libbpf/include/uapi)
set(ENABLE_PLUGIN_EBPF True)
+ set(HAVE_LIBBPF True)
ELSE(ELF_LIBRARIES)
set(ENABLE_PLUGIN_EBPF False)
message(STATUS "ebpf plugin: disabled (requires libelf)")
@@ -340,11 +352,11 @@ ENDIF()
# Detect ml dependencies
file(STRINGS "${CMAKE_SOURCE_DIR}/config.h" DEFINE_ENABLE_ML REGEX "^#define ENABLE_ML 1$")
IF(DEFINE_ENABLE_ML MATCHES ".+" AND
- EXISTS "${CMAKE_SOURCE_DIR}/ml/kmeans/dlib/dlib/all/source.cpp" AND
+ EXISTS "${CMAKE_SOURCE_DIR}/ml/dlib/dlib/all/source.cpp" AND
EXISTS "${CMAKE_SOURCE_DIR}/ml/json/single_include/nlohmann/json.hpp")
set(ENABLE_ML True)
list(APPEND NETDATA_COMMON_CFLAGS "-DDLIB_NO_GUI_SUPPORT")
- list(APPEND NETDATA_COMMON_INCLUDE_DIRS "ml/kmeans/dlib")
+ list(APPEND NETDATA_COMMON_INCLUDE_DIRS "ml/dlib")
ELSE()
set(ENABLE_ML False)
ENDIF()
@@ -409,6 +421,8 @@ target_include_directories(judy PUBLIC
libnetdata/libjudy/src
libnetdata/libjudy/src/JudyCommon)
+target_include_directories(judy BEFORE PUBLIC ${GENERATED_CONFIG_H_DIR})
+
target_compile_definitions(judy PUBLIC
JU_64BIT
JUDYL)
@@ -445,6 +459,8 @@ set(LIBNETDATA_FILES
libnetdata/avl/avl.h
libnetdata/buffer/buffer.c
libnetdata/buffer/buffer.h
+ libnetdata/circular_buffer/circular_buffer.c
+ libnetdata/circular_buffer/circular_buffer.h
libnetdata/clocks/clocks.c
libnetdata/clocks/clocks.h
libnetdata/completion/completion.c
@@ -453,10 +469,15 @@ set(LIBNETDATA_FILES
libnetdata/dictionary/dictionary.h
libnetdata/eval/eval.c
libnetdata/eval/eval.h
+ libnetdata/health/health.c
+ libnetdata/health/health.h
libnetdata/inlined.h
+ libnetdata/json/json.c
+ libnetdata/json/json.h
+ libnetdata/json/jsmn.c
+ libnetdata/json/jsmn.h
libnetdata/libnetdata.c
libnetdata/libnetdata.h
- libnetdata/required_dummies.h
libnetdata/locks/locks.c
libnetdata/locks/locks.h
libnetdata/log/log.c
@@ -469,6 +490,9 @@ set(LIBNETDATA_FILES
libnetdata/popen/popen.h
libnetdata/procfile/procfile.c
libnetdata/procfile/procfile.h
+ libnetdata/required_dummies.h
+ libnetdata/socket/security.c
+ libnetdata/socket/security.h
libnetdata/simple_pattern/simple_pattern.c
libnetdata/simple_pattern/simple_pattern.h
libnetdata/socket/socket.c
@@ -477,23 +501,16 @@ set(LIBNETDATA_FILES
libnetdata/statistical/statistical.h
libnetdata/storage_number/storage_number.c
libnetdata/storage_number/storage_number.h
+ libnetdata/string/string.c
+ libnetdata/string/string.h
libnetdata/threads/threads.c
libnetdata/threads/threads.h
libnetdata/url/url.c
libnetdata/url/url.h
- libnetdata/json/json.c
- libnetdata/json/json.h
- libnetdata/json/jsmn.c
- libnetdata/json/jsmn.h
- libnetdata/health/health.c
- libnetdata/health/health.h
libnetdata/string/utf8.h
- libnetdata/socket/security.c
- libnetdata/socket/security.h
libnetdata/worker_utilization/worker_utilization.c
libnetdata/worker_utilization/worker_utilization.h
- libnetdata/circular_buffer/circular_buffer.c
- libnetdata/circular_buffer/circular_buffer.h)
+ )
IF(ENABLE_PLUGIN_EBPF)
list(APPEND LIBNETDATA_FILES
@@ -503,13 +520,11 @@ ENDIF()
add_library(libnetdata OBJECT ${LIBNETDATA_FILES})
+target_include_directories(libnetdata BEFORE PUBLIC ${GENERATED_CONFIG_H_DIR})
+
set(APPS_PLUGIN_FILES
collectors/apps.plugin/apps_plugin.c)
-set(CHECKS_PLUGIN_FILES
- collectors/checks.plugin/plugin_checks.c
- )
-
set(FREEBSD_PLUGIN_FILES
collectors/freebsd.plugin/plugin_freebsd.c
collectors/freebsd.plugin/plugin_freebsd.h
@@ -633,8 +648,6 @@ set(PROC_PLUGIN_FILES
collectors/proc.plugin/proc_net_netstat.c
collectors/proc.plugin/proc_net_rpc_nfs.c
collectors/proc.plugin/proc_net_rpc_nfsd.c
- collectors/proc.plugin/proc_net_snmp.c
- collectors/proc.plugin/proc_net_snmp6.c
collectors/proc.plugin/proc_net_sctp_snmp.c
collectors/proc.plugin/proc_net_sockstat.c
collectors/proc.plugin/proc_net_sockstat6.c
@@ -716,6 +729,8 @@ set(RRD_PLUGIN_FILES
database/rrddimvar.c
database/rrddimvar.h
database/rrdfamily.c
+ database/rrdfunctions.c
+ database/rrdfunctions.h
database/rrdhost.c
database/rrdlabels.c
database/rrd.c
@@ -729,6 +744,8 @@ set(RRD_PLUGIN_FILES
database/storage_engine.h
database/ram/rrddim_mem.c
database/ram/rrddim_mem.h
+ database/sqlite/sqlite_metadata.c
+ database/sqlite/sqlite_metadata.h
database/sqlite/sqlite_functions.c
database/sqlite/sqlite_functions.h
database/sqlite/sqlite_context.c
@@ -741,8 +758,6 @@ set(RRD_PLUGIN_FILES
database/sqlite/sqlite_health.h
database/sqlite/sqlite_aclk_node.c
database/sqlite/sqlite_aclk_node.h
- database/sqlite/sqlite_aclk_chart.c
- database/sqlite/sqlite_aclk_chart.h
database/sqlite/sqlite_aclk_alert.c
database/sqlite/sqlite_aclk_alert.h
database/sqlite/sqlite3.c
@@ -762,16 +777,6 @@ set(RRD_PLUGIN_FILES
database/engine/pagecache.h
database/engine/rrdenglocking.c
database/engine/rrdenglocking.h
- database/engine/metadata_log/metadatalog.h
- database/engine/metadata_log/metadatalogapi.c
- database/engine/metadata_log/metadatalogapi.h
- database/engine/metadata_log/logfile.h
- database/engine/metadata_log/logfile.c
- database/engine/metadata_log/metadatalogprotocol.h
- database/engine/metadata_log/metalogpluginsd.c
- database/engine/metadata_log/metalogpluginsd.h
- database/engine/metadata_log/compaction.c
- database/engine/metadata_log/compaction.h
database/KolmogorovSmirnovDist.c
database/KolmogorovSmirnovDist.h
)
@@ -851,6 +856,8 @@ set(STREAMING_PLUGIN_FILES
streaming/compression.c
streaming/receiver.c
streaming/sender.c
+ streaming/replication.c
+ streaming/replication.h
)
set(CLAIM_PLUGIN_FILES
@@ -860,15 +867,13 @@ set(CLAIM_PLUGIN_FILES
set(ACLK_ALWAYS_BUILD
aclk/aclk_rrdhost_state.h
- aclk/aclk_api.c
- aclk/aclk_api.h
aclk/aclk_proxy.c
aclk/aclk_proxy.h
+ aclk/aclk.c
+ aclk/aclk.h
)
set(ACLK_FILES
- aclk/aclk.c
- aclk/aclk.h
aclk/aclk_util.c
aclk/aclk_util.h
aclk/aclk_stats.c
@@ -885,38 +890,18 @@ set(ACLK_FILES
aclk/aclk_rx_msgs.h
aclk/https_client.c
aclk/https_client.h
- aclk/aclk_charts_api.c
- aclk/aclk_charts_api.h
aclk/aclk_alarm_api.c
aclk/aclk_alarm_api.h
aclk/aclk_contexts_api.c
aclk/aclk_contexts_api.h
- mqtt_websockets/src/mqtt_wss_client.c
- mqtt_websockets/src/include/mqtt_wss_client.h
- mqtt_websockets/src/mqtt_wss_log.c
- mqtt_websockets/src/include/mqtt_wss_log.h
- mqtt_websockets/src/ws_client.c
- mqtt_websockets/src/include/ws_client.h
- mqtt_websockets/src/mqtt_ng.c
- mqtt_websockets/src/include/mqtt_ng.h
- mqtt_websockets/src/common_public.c
- mqtt_websockets/src/include/common_public.h
- mqtt_websockets/src/include/common_internal.h
- mqtt_websockets/c-rbuf/src/ringbuffer.c
- mqtt_websockets/c-rbuf/include/ringbuffer.h
- mqtt_websockets/c-rbuf/src/ringbuffer_internal.h
- mqtt_websockets/MQTT-C/src/mqtt.c
- mqtt_websockets/MQTT-C/include/mqtt.h
+ aclk/aclk_capas.c
+ aclk/aclk_capas.h
aclk/schema-wrappers/connection.cc
aclk/schema-wrappers/connection.h
aclk/schema-wrappers/node_connection.cc
aclk/schema-wrappers/node_connection.h
aclk/schema-wrappers/node_creation.cc
aclk/schema-wrappers/node_creation.h
- aclk/schema-wrappers/chart_stream.cc
- aclk/schema-wrappers/chart_stream.h
- aclk/schema-wrappers/chart_config.cc
- aclk/schema-wrappers/chart_config.h
aclk/schema-wrappers/alarm_stream.cc
aclk/schema-wrappers/alarm_stream.h
aclk/schema-wrappers/alarm_config.cc
@@ -934,6 +919,27 @@ set(ACLK_FILES
aclk/schema-wrappers/schema_wrappers.h
aclk/schema-wrappers/schema_wrapper_utils.cc
aclk/schema-wrappers/schema_wrapper_utils.h
+ aclk/helpers/mqtt_wss_pal.h
+ aclk/helpers/ringbuffer_pal.h
+ )
+
+set(MQTT_WEBSOCKETS_FILES
+ mqtt_websockets/src/mqtt_wss_client.c
+ mqtt_websockets/src/include/mqtt_wss_client.h
+ mqtt_websockets/src/mqtt_wss_log.c
+ mqtt_websockets/src/include/mqtt_wss_log.h
+ mqtt_websockets/src/ws_client.c
+ mqtt_websockets/src/include/ws_client.h
+ mqtt_websockets/src/mqtt_ng.c
+ mqtt_websockets/src/include/mqtt_ng.h
+ mqtt_websockets/src/common_public.c
+ mqtt_websockets/src/include/common_public.h
+ mqtt_websockets/src/include/common_internal.h
+ mqtt_websockets/c-rbuf/src/ringbuffer.c
+ mqtt_websockets/c-rbuf/include/ringbuffer.h
+ mqtt_websockets/c-rbuf/src/ringbuffer_internal.h
+ mqtt_websockets/MQTT-C/src/mqtt.c
+ mqtt_websockets/MQTT-C/include/mqtt.h
)
set(SPAWN_PLUGIN_FILES
@@ -1018,30 +1024,30 @@ set(ML_FILES
ml/ml-dummy.c
)
+# -----------------------------------------------------------------------------
+# ML
+
IF(ENABLE_ML)
+ message(STATUS "ML: enabled")
list(APPEND ML_FILES
- ml/BitBufferCounter.h
- ml/BitBufferCounter.cc
- ml/BitRateWindow.h
- ml/BitRateWindow.cc
ml/Config.h
ml/Config.cc
- ml/Database.h
- ml/Database.cc
ml/Dimension.cc
ml/Dimension.h
ml/Host.h
ml/Host.cc
ml/Query.h
- ml/kmeans/KMeans.h
- ml/kmeans/KMeans.cc
- ml/kmeans/SamplesBuffer.h
- ml/kmeans/SamplesBuffer.cc
- ml/kmeans/dlib/dlib/all/source.cpp
+ ml/KMeans.h
+ ml/KMeans.cc
+ ml/SamplesBuffer.h
+ ml/SamplesBuffer.cc
+ ml/dlib/dlib/all/source.cpp
ml/json/single_include/nlohmann/json.hpp
ml/ml.cc
ml/ml-private.h
)
+ELSE()
+ message(STATUS "ML: disabled")
ENDIF()
set(NETDATA_FILES
@@ -1049,7 +1055,6 @@ set(NETDATA_FILES
${DAEMON_FILES}
${API_PLUGIN_FILES}
${EXPORTING_ENGINE_FILES}
- ${CHECKS_PLUGIN_FILES}
${HEALTH_PLUGIN_FILES}
${IDLEJITTER_PLUGIN_FILES}
${ML_FILES}
@@ -1194,6 +1199,10 @@ ENDIF()
set(NETDATA_COMMON_LIBRARIES ${NETDATA_COMMON_LIBRARIES} m ${CMAKE_THREAD_LIBS_INIT})
+option(ENABLE_ACLK "Enables functionality required to connect to cloud (must be activated by user at run time)" ON)
+
+if(ENABLE_ACLK)
+
find_package(Protobuf REQUIRED)
function(PROTOBUF_ACLK_GENERATE_CPP SRCS HDRS)
@@ -1238,10 +1247,6 @@ set(ACLK_PROTO_DEFS
aclk/aclk-schemas/proto/agent/v1/connection.proto
aclk/aclk-schemas/proto/alarm/v1/config.proto
aclk/aclk-schemas/proto/alarm/v1/stream.proto
- aclk/aclk-schemas/proto/chart/v1/config.proto
- aclk/aclk-schemas/proto/chart/v1/dimension.proto
- aclk/aclk-schemas/proto/chart/v1/instance.proto
- aclk/aclk-schemas/proto/chart/v1/stream.proto
aclk/aclk-schemas/proto/nodeinstance/connection/v1/connection.proto
aclk/aclk-schemas/proto/nodeinstance/create/v1/creation.proto
aclk/aclk-schemas/proto/nodeinstance/info/v1/info.proto
@@ -1253,14 +1258,29 @@ PROTOBUF_ACLK_GENERATE_CPP(ACLK_PROTO_BUILT_SRCS ACLK_PROTO_BUILT_HDRS ${ACLK_PR
list(APPEND NETDATA_COMMON_LIBRARIES ${PROTOBUF_LIBRARIES})
list(APPEND NETDATA_COMMON_INCLUDE_DIRS ${PROTOBUF_INCLUDE_DIRS})
list(APPEND NETDATA_COMMON_CFLAGS ${PROTOBUF_CFLAGS_OTHER})
-list(APPEND NETDATA_FILES ${ACLK_ALWAYS_BUILD})
-list(APPEND NETDATA_FILES ${TIMEX_PLUGIN_FILES})
list(APPEND NETDATA_FILES ${ACLK_FILES} ${ACLK_PROTO_BUILT_SRCS} ${ACLK_PROTO_BUILT_HDRS})
include_directories(BEFORE ${CMAKE_SOURCE_DIR}/aclk/aclk-schemas)
include_directories(BEFORE ${CMAKE_SOURCE_DIR}/mqtt_websockets/MQTT-C/include)
include_directories(BEFORE ${CMAKE_SOURCE_DIR}/mqtt_websockets/src/include)
include_directories(BEFORE ${CMAKE_SOURCE_DIR}/mqtt_websockets/c-rbuf/include)
+ADD_LIBRARY(mqttwebsockets STATIC
+ ${MQTT_WEBSOCKETS_FILES})
+
+target_compile_options(mqttwebsockets PUBLIC
+ -DMQTT_WSS_CUSTOM_ALLOC
+ -DRBUF_CUSTOM_MALLOC)
+
+target_include_directories(mqttwebsockets PUBLIC
+ ${CMAKE_SOURCE_DIR}/aclk/helpers)
+
+set(NETDATA_COMMON_LIBRARIES ${NETDATA_COMMON_LIBRARIES} mqttwebsockets)
+
+ENDIF()
+
+list(APPEND NETDATA_FILES ${ACLK_ALWAYS_BUILD})
+list(APPEND NETDATA_FILES ${TIMEX_PLUGIN_FILES})
+
# -----------------------------------------------------------------------------
# netdata
@@ -1268,7 +1288,7 @@ IF(LINUX)
list(APPEND NETDATA_FILES daemon/static_threads_linux.c)
list(APPEND NETDATA_COMMON_LIBRARIES rt)
- add_executable(netdata config.h ${NETDATA_FILES}
+ add_executable(netdata ${GENERATED_CONFIG_H} ${NETDATA_FILES}
${CGROUPS_PLUGIN_FILES}
${DISKSPACE_PLUGIN_FILES}
${PROC_PLUGIN_FILES}
@@ -1276,6 +1296,7 @@ IF(LINUX)
)
target_link_libraries (netdata libnetdata ${NETDATA_COMMON_LIBRARIES})
target_include_directories(netdata PUBLIC ${NETDATA_COMMON_INCLUDE_DIRS})
+ target_include_directories(netdata BEFORE PUBLIC ${GENERATED_CONFIG_H_DIR})
target_compile_options(netdata PUBLIC ${NETDATA_COMMON_CFLAGS})
SET(ENABLE_PLUGIN_CGROUP_NETWORK True)
@@ -1286,9 +1307,10 @@ IF(LINUX)
ELSEIF(FREEBSD)
list(APPEND NETDATA_FILES daemon/static_threads_freebsd.c)
- add_executable(netdata config.h ${NETDATA_FILES} ${FREEBSD_PLUGIN_FILES})
+ add_executable(netdata ${GENERATED_CONFIG_H} ${NETDATA_FILES} ${FREEBSD_PLUGIN_FILES})
target_link_libraries (netdata libnetdata ${NETDATA_COMMON_LIBRARIES})
target_include_directories(netdata PUBLIC ${NETDATA_COMMON_INCLUDE_DIRS})
+ target_include_directories(netdata BEFORE PUBLIC ${GENERATED_CONFIG_H_DIR})
target_compile_options(netdata PUBLIC ${NETDATA_COMMON_CFLAGS})
SET(ENABLE_PLUGIN_CGROUP_NETWORK False)
SET(ENABLE_PLUGIN_APPS True)
@@ -1299,9 +1321,10 @@ ELSEIF(FREEBSD)
ELSEIF(MACOS)
list(APPEND NETDATA_FILES daemon/static_threads_macos.c)
- add_executable(netdata config.h ${NETDATA_FILES} ${MACOS_PLUGIN_FILES})
+ add_executable(netdata ${GENERATED_CONFIG_H} ${NETDATA_FILES} ${MACOS_PLUGIN_FILES})
target_link_libraries (netdata libnetdata ${NETDATA_COMMON_LIBRARIES} ${IOKIT} ${FOUNDATION})
target_include_directories(netdata PUBLIC ${NETDATA_COMMON_INCLUDE_DIRS})
+ target_include_directories(netdata BEFORE PUBLIC ${GENERATED_CONFIG_H_DIR})
target_compile_options(netdata PUBLIC ${NETDATA_COMMON_CFLAGS})
SET(ENABLE_PLUGIN_CGROUP_NETWORK False)
SET(ENABLE_PLUGIN_APPS False)
@@ -1344,9 +1367,10 @@ ENDIF()
# -----------------------------------------------------------------------------
# netdatacli
-add_executable(netdatacli config.h ${NETDATACLI_FILES})
+add_executable(netdatacli ${GENERATED_CONFIG_H} ${NETDATACLI_FILES})
target_link_libraries (netdatacli libnetdata ${NETDATA_COMMON_LIBRARIES})
target_include_directories(netdatacli PUBLIC ${NETDATA_COMMON_INCLUDE_DIRS})
+target_include_directories(netdatacli BEFORE PUBLIC ${GENERATED_CONFIG_H_DIR})
target_compile_options(netdatacli PUBLIC ${NETDATA_COMMON_CFLAGS})
@@ -1355,9 +1379,10 @@ target_compile_options(netdatacli PUBLIC ${NETDATA_COMMON_CFLAGS})
IF(ENABLE_PLUGIN_APPS)
message(STATUS "apps.plugin: enabled")
- add_executable(apps.plugin config.h ${APPS_PLUGIN_FILES})
+ add_executable(apps.plugin ${GENERATED_CONFIG_H} ${APPS_PLUGIN_FILES})
target_link_libraries (apps.plugin libnetdata ${NETDATA_COMMON_LIBRARIES} ${CAP_LIBRARIES})
target_include_directories(apps.plugin PUBLIC ${NETDATA_COMMON_INCLUDE_DIRS} ${CAP_INCLUDE_DIRS})
+ target_include_directories(apps.plugin BEFORE PUBLIC ${GENERATED_CONFIG_H_DIR})
target_compile_options(apps.plugin PUBLIC ${NETDATA_COMMON_CFLAGS} ${CAP_CFLAGS_OTHER})
ELSE()
message(STATUS "apps.plugin: disabled")
@@ -1369,9 +1394,10 @@ ENDIF()
IF(ENABLE_PLUGIN_FREEIPMI)
message(STATUS "freeipmi.plugin: enabled")
- add_executable(freeipmi.plugin config.h ${FREEIPMI_PLUGIN_FILES})
+ add_executable(freeipmi.plugin ${GENERATED_CONFIG_H} ${FREEIPMI_PLUGIN_FILES})
target_link_libraries (freeipmi.plugin libnetdata ${NETDATA_COMMON_LIBRARIES} ${IPMI_LIBRARIES})
target_include_directories(freeipmi.plugin PUBLIC ${NETDATA_COMMON_INCLUDE_DIRS} ${IPMI_INCLUDE_DIRS})
+ target_include_directories(freeipmi.plugin BEFORE PUBLIC ${GENERATED_CONFIG_H_DIR})
target_compile_options(freeipmi.plugin PUBLIC ${NETDATA_COMMON_CFLAGS} ${IPMI_CFLAGS_OTHER})
ELSE()
message(STATUS "freeipmi.plugin: disabled (depends on libipmimonitoring)")
@@ -1383,9 +1409,10 @@ ENDIF()
IF(ENABLE_PLUGIN_NFACCT)
message(STATUS "nfacct.plugin: enabled")
- add_executable(nfacct.plugin config.h ${NFACCT_PLUGIN_FILES})
+ add_executable(nfacct.plugin ${GENERATED_CONFIG_H} ${NFACCT_PLUGIN_FILES})
target_link_libraries (nfacct.plugin libnetdata ${NETDATA_COMMON_LIBRARIES} ${MNL_LIBRARIES} ${NFACCT_LIBRARIES})
target_include_directories(nfacct.plugin PUBLIC ${NETDATA_COMMON_INCLUDE_DIRS} ${MNL_INCLUDE_DIRS} ${NFACCT_INCLUDE_DIRS})
+ target_include_directories(nfacct.plugin BEFORE PUBLIC ${GENERATED_CONFIG_H_DIR})
target_compile_options(nfacct.plugin PUBLIC ${NETDATA_COMMON_CFLAGS} ${MNL_CFLAGS_OTHER} ${NFACCT_CFLAGS_OTHER})
ELSE()
message(STATUS "nfacct.plugin: disabled (requires libmnl and libnetfilter_acct)")
@@ -1397,9 +1424,10 @@ ENDIF()
IF(ENABLE_PLUGIN_XENSTAT)
message(STATUS "xenstat.plugin: enabled")
- add_executable(xenstat.plugin config.h ${XENSTAT_PLUGIN_FILES})
+ add_executable(xenstat.plugin ${GENERATED_CONFIG_H} ${XENSTAT_PLUGIN_FILES})
target_link_libraries (xenstat.plugin libnetdata ${NETDATA_COMMON_LIBRARIES} ${XENSTAT_LIBRARIES})
target_include_directories(xenstat.plugin PUBLIC ${NETDATA_COMMON_INCLUDE_DIRS} ${XENSTAT_INCLUDE_DIRS})
+ target_include_directories(xenstat.plugin BEFORE PUBLIC ${GENERATED_CONFIG_H_DIR})
target_compile_options(xenstat.plugin PUBLIC ${NETDATA_COMMON_CFLAGS} ${XENSTAT_CFLAGS_OTHER})
ELSE()
message(STATUS "xenstat.plugin: disabled (requires libxenstat)")
@@ -1411,9 +1439,10 @@ ENDIF()
IF(ENABLE_PLUGIN_PERF)
message(STATUS "perf.plugin: enabled")
- add_executable(perf.plugin config.h ${PERF_PLUGIN_FILES})
+ add_executable(perf.plugin ${GENERATED_CONFIG_H} ${PERF_PLUGIN_FILES})
target_link_libraries (perf.plugin libnetdata ${NETDATA_COMMON_LIBRARIES})
target_include_directories(perf.plugin PUBLIC ${NETDATA_COMMON_INCLUDE_DIRS})
+ target_include_directories(perf.plugin BEFORE PUBLIC ${GENERATED_CONFIG_H_DIR})
target_compile_options(perf.plugin PUBLIC ${NETDATA_COMMON_CFLAGS})
ELSE()
message(STATUS "perf.plugin: disabled")
@@ -1425,9 +1454,10 @@ ENDIF()
IF(ENABLE_PLUGIN_EBPF)
message(STATUS "ebpf.plugin: enabled")
- add_executable(ebpf.plugin config.h ${EBPF_PROCESS_PLUGIN_FILES})
+ add_executable(ebpf.plugin ${GENERATED_CONFIG_H} ${EBPF_PROCESS_PLUGIN_FILES})
target_link_libraries (ebpf.plugin libnetdata ${NETDATA_COMMON_LIBRARIES})
target_include_directories(ebpf.plugin PUBLIC ${NETDATA_COMMON_INCLUDE_DIRS})
+ target_include_directories(ebpf.plugin BEFORE PUBLIC ${GENERATED_CONFIG_H_DIR})
target_compile_options(ebpf.plugin PUBLIC ${NETDATA_COMMON_CFLAGS})
ELSE()
message(STATUS "ebpf.plugin: disabled")
@@ -1439,9 +1469,10 @@ ENDIF()
IF(ENABLE_PLUGIN_SLABINFO)
message(STATUS "slabinfo.plugin: enabled")
- add_executable(slabinfo.plugin config.h ${SLABINFO_PLUGIN_FILES})
+ add_executable(slabinfo.plugin ${GENERATED_CONFIG_H} ${SLABINFO_PLUGIN_FILES})
target_link_libraries (slabinfo.plugin libnetdata ${NETDATA_COMMON_LIBRARIES})
target_include_directories(slabinfo.plugin PUBLIC ${NETDATA_COMMON_INCLUDE_DIRS})
+ target_include_directories(slabinfo.plugin BEFORE PUBLIC ${GENERATED_CONFIG_H_DIR})
target_compile_options(slabinfo.plugin PUBLIC ${NETDATA_COMMON_CFLAGS})
ELSE()
message(STATUS "slabinfo.plugin: disabled")
@@ -1453,9 +1484,10 @@ ENDIF()
IF(ENABLE_PLUGIN_CUPS)
message(STATUS "cups.plugin: enabled")
- add_executable(cups.plugin config.h ${CUPS_PLUGIN_FILES})
+ add_executable(cups.plugin ${GENERATED_CONFIG_H} ${CUPS_PLUGIN_FILES})
target_link_libraries (cups.plugin libnetdata ${NETDATA_COMMON_LIBRARIES} ${CUPS_LIBRARIES})
target_include_directories(cups.plugin PUBLIC ${NETDATA_COMMON_INCLUDE_DIRS} ${CUPS_INCLUDE_DIRS})
+ target_include_directories(cups.plugin BEFORE PUBLIC ${GENERATED_CONFIG_H_DIR})
target_compile_options(cups.plugin PUBLIC ${NETDATA_COMMON_CFLAGS} ${CUPS_CFLAGS_OTHER})
ELSE()
message(STATUS "cups.plugin: disabled")
@@ -1467,9 +1499,10 @@ ENDIF()
IF(ENABLE_PLUGIN_CGROUP_NETWORK)
message(STATUS "cgroup-network: enabled")
- add_executable(cgroup-network config.h ${CGROUP_NETWORK_FILES})
+ add_executable(cgroup-network ${GENERATED_CONFIG_H} ${CGROUP_NETWORK_FILES})
target_link_libraries (cgroup-network libnetdata ${NETDATA_COMMON_LIBRARIES})
target_include_directories(cgroup-network PUBLIC ${NETDATA_COMMON_INCLUDE_DIRS})
+ target_include_directories(cgroup-network BEFORE PUBLIC ${GENERATED_CONFIG_H_DIR})
target_compile_options(cgroup-network PUBLIC ${NETDATA_COMMON_CFLAGS})
ELSE()
message(STATUS "cgroup-network: disabled (requires Linux)")
@@ -1500,6 +1533,7 @@ if(BUILD_TESTING)
exporting/tests/netdata_doubles.c
exporting/tests/system_doubles.c
database/rrdlabels.c
+ database/rrdvar.c
)
set(TEST_NAME exporting_engine)
set(PROMETHEUS_REMOTE_WRITE_LINK_OPTIONS)
@@ -1672,3 +1706,97 @@ endif()
endif()
endif()
+
+
+# generate config.h so that CMake becomes independent of automake
+
+## netdata version
+set(GIT_EXECUTABLE "git")
+execute_process(COMMAND ${GIT_EXECUTABLE} describe OUTPUT_VARIABLE NETDATA_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+IF("${NETDATA_VERSION}" STREQUAL "")
+ file(STRINGS "packaging/version" NETDATA_VERSION LIMIT_COUNT 1)
+ENDIF()
+
+set(NETDATA_USER "netdata" CACHE STRING "use this user to drop privileges")
+
+if(MAC_OS)
+ set(ENABLE_APPS_PLUGIN False)
+else()
+ set(ENABLE_APPS_PLUGIN True)
+endif()
+
+check_include_file(time.h HAVE_TIME_H)
+check_include_file(unistd.h HAVE_UNISTD_H)
+if (HAVE_TIME_H)
+ include(CheckStructHasMember)
+ check_struct_has_member("struct timespec" tv_sec "time.h" HAVE_STRUCT_TIMESPEC)
+endif ()
+
+check_include_file(sys/statfs.h HAVE_SYS_STATFS_H)
+check_include_file(sys/statvfs.h HAVE_SYS_STATVFS_H)
+check_include_file(inttypes.h HAVE_INTTYPES_H)
+check_include_file(stdint.h HAVE_STDINT_H)
+
+include(CheckSymbolExists)
+check_include_file(sys/mkdev.h HAVE_SYS_MKDEV_H)
+if (HAVE_SYS_MKDEV_H)
+ check_symbol_exists(major "sys/mkdev.h" MAJOR_IN_MKDEV)
+endif()
+check_include_file(sys/sysmacros.h HAVE_SYS_SYSMACROS_H)
+if (HAVE_SYS_SYSMACROS_H)
+ check_symbol_exists(major "sys/sysmacros.h" MAJOR_IN_SYSMACROS)
+endif()
+
+if (CRYPTO_FOUND)
+ set(HAVE_CRYPTO True)
+ FIND_LIBRARY(CRYPTO_LIBRARY_LOCATION NAMES crypto)
+ check_library_exists(crypto X509_VERIFY_PARAM_set1_host ${CRYPTO_LIBRARY_LOCATION} HAVE_X509_VERIFY_PARAM_set1_host)
+ if (HAVE_X509_VERIFY_PARAM_set1_host)
+ set(HAVE_X509_VERIFY_PARAM_set1_host True)
+ endif()
+endif()
+
+include(CheckCSourceCompiles)
+check_c_source_compiles("
+ #define _GNU_SOURCE
+ #include <string.h>
+ int main() { char x = *strerror_r(0, &x, sizeof(x)); return 0; }
+ " STRERROR_R_CHAR_P)
+
+IF(${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
+ SET(LIKELY_MACRO "__builtin_expect(!!(x), 1)")
+ SET(UNLIKELY_MACRO "__builtin_expect(!!(x), 0)")
+ELSE()
+ SET(LIKELY_MACRO "(x)")
+ SET(UNLIKELY_MACRO "(x)")
+ENDIF()
+
+IF(${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
+ SET(ALWAYS_UNUSED_MACRO "__attribute__((unused))")
+ SET(MAYBE_UNUSED_MACRO "__attribute__((unused))")
+ELSE()
+ SET(ALWAYS_UNUSED_MACRO "")
+ SET(MAYBE_UNUSED_MACRO "")
+ENDIF()
+
+# -----------------------------------------------------------------------------
+
+check_library_exists(c clock_gettime "" HAVE_CLOCK_GETTIME)
+
+IF(NOT HAVE_CLOCK_GETTIME)
+ CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_CLOCK_GETTIME)
+ENDIF()
+
+IF(HAVE_CLOCK_GETTIME)
+ message("-- clock_gettime(): found")
+ set(NETDATA_REQUIRED_DEFINES "-DHAVE_CLOCK_GETTIME=1 ${NETDATA_REQUIRED_DEFINES}")
+ELSE()
+ message("-- clock_gettime(): not found")
+ENDIF()
+
+# -----------------------------------------------------------------------------
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${NETDATA_REQUIRED_DEFINES}")
+message("CFLAGS=\"${CMAKE_C_FLAGS}\"")
+
+configure_file(config.cmake.h.in config.h)