CMakeLists.txt 94 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662
  1. # SPDX-License-Identifier: GPL-3.0-or-later
  2. cmake_minimum_required(VERSION 3.13.0)
  3. #
  4. # version atrocities
  5. #
  6. find_package(Git)
  7. if(GIT_EXECUTABLE)
  8. execute_process(COMMAND ${GIT_EXECUTABLE} describe
  9. WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  10. RESULT_VARIABLE GIT_DESCRIBE_RESULT
  11. OUTPUT_VARIABLE GIT_DESCRIBE_OUTPUT)
  12. if(GIT_DESCRIBE_RESULT)
  13. file(STRINGS packaging/version GIT_DESCRIBE_OUTPUT)
  14. message(WARNING "using version from packaging/version: '${GIT_DESCRIBE_OUTPUT}'")
  15. endif()
  16. else()
  17. file(STRINGS packaging/version GIT_DESCRIBE_OUTPUT)
  18. message(WARNING "using version from packaging/version: '${GIT_DESCRIBE_OUTPUT}'")
  19. endif()
  20. string(STRIP ${GIT_DESCRIBE_OUTPUT} GIT_DESCRIBE_OUTPUT)
  21. string(REGEX MATCH "v?([0-9]+)\\.([0-9]+)\\.([0-9]+)-?([0-9]+)?-?([0-9a-zA-Z]+)?" MATCHES "${GIT_DESCRIBE_OUTPUT}")
  22. if(CMAKE_MATCH_COUNT EQUAL 3)
  23. set(FIELD_MAJOR ${CMAKE_MATCH_1})
  24. set(FIELD_MINOR ${CMAKE_MATCH_2})
  25. set(FIELD_PATCH ${CMAKE_MATCH_3})
  26. set(FIELD_TWEAK 0)
  27. set(FIELD_DESCR "N/A")
  28. elseif(CMAKE_MATCH_COUNT EQUAL 4)
  29. set(FIELD_MAJOR ${CMAKE_MATCH_1})
  30. set(FIELD_MINOR ${CMAKE_MATCH_2})
  31. set(FIELD_PATCH ${CMAKE_MATCH_3})
  32. set(FIELD_TWEAK ${CMAKE_MATCH_4})
  33. set(FIELD_DESCR "N/A")
  34. elseif(CMAKE_MATCH_COUNT EQUAL 5)
  35. set(FIELD_MAJOR ${CMAKE_MATCH_1})
  36. set(FIELD_MINOR ${CMAKE_MATCH_2})
  37. set(FIELD_PATCH ${CMAKE_MATCH_3})
  38. set(FIELD_TWEAK ${CMAKE_MATCH_4})
  39. set(FIELD_DESCR ${CMAKE_MATCH_5})
  40. else()
  41. message(FATAL_ERROR "Wrong version regex match count ${CMAKE_MATCH_COUNT} (should be in 3, 4 or 5)")
  42. endif()
  43. #
  44. # project
  45. #
  46. project(netdata
  47. VERSION ${FIELD_MAJOR}.${FIELD_MINOR}.${FIELD_PATCH}.${FIELD_TWEAK}
  48. DESCRIPTION "Netdata real-time monitoring"
  49. HOMEPAGE_URL "https://www.netdata.cloud"
  50. LANGUAGES C CXX)
  51. find_package(PkgConfig REQUIRED)
  52. set(CMAKE_C_STANDARD 11)
  53. set(CMAKE_CXX_STANDARD 11)
  54. set(CMAKE_C_STANDARD_REQUIRED On)
  55. set(CMAKE_CXX_STANDARD_REQUIRED On)
  56. set(SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
  57. if(NOT CMAKE_BUILD_TYPE)
  58. set(CMAKE_BUILD_TYPE "Release")
  59. endif()
  60. option(ENABLE_ADDRESS_SANITIZER "enable address sanitizer" False)
  61. if(ENABLE_ADDRESS_SANITIZER)
  62. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
  63. endif()
  64. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fexceptions")
  65. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS}")
  66. set(CMAKE_EXPORT_COMPILE_COMMANDS On)
  67. set(CONFIG_H_DIR ${CMAKE_BINARY_DIR})
  68. set(CONFIG_H ${CONFIG_H_DIR}/config.h)
  69. option(ENABLE_CLOUD "enable cloud" True)
  70. option(ENABLE_ACLK "enable aclk" True)
  71. option(ENABLE_ML "enable machine learning" True)
  72. option(ENABLE_H2O "enable h2o" True)
  73. option(ENABLE_DBENGINE "enable dbengine" True)
  74. option(ENABLE_PLUGIN_DEBUGFS "enable debugfs.plugin" True)
  75. option(ENABLE_PLUGIN_APPS "enable apps.plugin" True)
  76. option(ENABLE_PLUGIN_FREEIPMI "enable freeipmi.plugin" True)
  77. option(ENABLE_PLUGIN_NFACCT "enable nfacct.plugin" True)
  78. option(ENABLE_PLUGIN_XENSTAT "enable xenstat.plugin" True)
  79. option(ENABLE_PLUGIN_PERF "enable perf.plugin" True)
  80. option(ENABLE_PLUGIN_SLABINFO "enable slabinfo.plugin" True)
  81. option(ENABLE_PLUGIN_CUPS "enable cups.plugin" True)
  82. option(ENABLE_PLUGIN_CGROUP_NETWORK "enable cgroup-network plugin" True)
  83. option(ENABLE_PLUGIN_EBPF "enable ebpf.plugin" True)
  84. option(ENABLE_PLUGIN_LOCAL_LISTENERS "enable local-listeners" True)
  85. option(ENABLE_PLUGIN_SYSTEMD_JOURNAL "enable systemd-journal.plugin" True)
  86. option(ENABLE_PLUGIN_LOGS_MANAGEMENT "enable logs-management.plugin" True)
  87. option(ENABLE_EXPORTER_PROMETHEUS_REMOTE_WRITE "enable prometheus remote write exporter" True)
  88. option(ENABLE_EXPORTER_MONGODB "enable mongodb exporter" True)
  89. option(ENABLE_BUNDLED_JSONC "enable bundled json-c" False)
  90. option(ENABLE_BUNDLED_YAML "enable bundled yaml" False)
  91. option(ENABLE_BUNDLED_PROTOBUF "enable bundled protobuf" False)
  92. option(ENABLE_LOGS_MANAGEMENT_TESTS "enable logs management tests" True)
  93. #
  94. # handling of extra compiler flags
  95. #
  96. include(CheckCCompilerFlag)
  97. include(CheckCXXCompilerFlag)
  98. # Disable hardening for debug builds by default.
  99. if(CMAKE_BUILD_TYPE STREQUAL "Debug")
  100. option(DISABLE_HARDENING "disable adding extra compiler flags for hardening" TRUE)
  101. else()
  102. option(DISABLE_HARDENING "disable adding extra compiler flags for hardening" FALSE)
  103. endif()
  104. # Construct a pre-processor safe name
  105. function(make_cpp_safe_name value target)
  106. string(REPLACE "-" "_" tmp "${value}")
  107. string(REPLACE "=" "_" tmp "${tmp}")
  108. set(${target} "${tmp}" PARENT_SCOPE)
  109. endfunction()
  110. # Conditionally add an extra compiler flag to C and C++ flags.
  111. #
  112. # If the language flags already match the `match` argument, skip this flag.
  113. # Otherwise, check for support for `flag` and if support is found, add it to
  114. # the language-specific `target` flag group.
  115. function(add_simple_extra_compiler_flag match flag target)
  116. set(CMAKE_REQUIRED_FLAGS "-Werror")
  117. make_cpp_safe_name("${flag}" flag_name)
  118. if(NOT ${CMAKE_C_FLAGS} MATCHES ${match})
  119. check_c_compiler_flag("${flag}" HAVE_C_${flag_name})
  120. if(HAVE_C_${flag_name})
  121. set(${target}_C_FLAGS "${${target}_C_FLAGS} ${flag}" PARENT_SCOPE)
  122. endif()
  123. endif()
  124. if(NOT ${CMAKE_CXX_FLAGS} MATCHES ${match})
  125. check_cxx_compiler_flag("${flag}" HAVE_CXX_${flag_name})
  126. if(HAVE_CXX_${flag_name})
  127. set(${target}_CXX_FLAGS "${${target}_CXX_FLAGS} ${flag}" PARENT_SCOPE)
  128. endif()
  129. endif()
  130. endfunction()
  131. # Same as add_simple_extra_compiler_flag, but check for a second flag if the
  132. # first one is unsupported.
  133. function(add_double_extra_compiler_flag match flag1 flag2 target)
  134. set(CMAKE_REQUIRED_FLAGS "-Werror")
  135. make_cpp_safe_name("${flag1}" flag1_name)
  136. make_cpp_safe_name("${flag2}" flag2_name)
  137. if(NOT ${CMAKE_C_FLAGS} MATCHES ${match})
  138. check_c_compiler_flag("${flag1}" HAVE_C_${flag1_name})
  139. if(HAVE_C_${flag1_name})
  140. set(${target}_C_FLAGS "${${target}_C_FLAGS} ${flag1}" PARENT_SCOPE)
  141. else()
  142. check_c_compiler_flag("${flag2}" HAVE_C_${flag2_name})
  143. if(HAVE_C_${flag2_name})
  144. set(${target}_C_FLAGS "${${target}_C_FLAGS} ${flag2}" PARENT_SCOPE)
  145. endif()
  146. endif()
  147. endif()
  148. if(NOT ${CMAKE_CXX_FLAGS} MATCHES ${match})
  149. check_cxx_compiler_flag("${flag1}" HAVE_CXX_${flag1_name})
  150. if(HAVE_CXX_${flag1_name})
  151. set(${target}_CXX_FLAGS "${${target}_CXX_FLAGS} ${flag1}" PARENT_SCOPE)
  152. else()
  153. check_cxx_compiler_flag("${flag2}" HAVE_CXX_${flag2_name})
  154. if(HAVE_CXX_${flag2_name})
  155. set(${target}_CXX_FLAGS "${${target}_CXX_FLAGS} ${flag2}" PARENT_SCOPE)
  156. endif()
  157. endif()
  158. endif()
  159. endfunction()
  160. set(EXTRA_HARDENING_C_FLAGS "")
  161. set(EXTRA_HARDENING_CXX_FLAGS "")
  162. set(EXTRA_OPT_C_FLAGS "")
  163. set(EXTRA_OPT_CXX_FLAGS "")
  164. if(NOT ${DISABLE_HARDENING})
  165. add_double_extra_compiler_flag("stack-protector" "-fstack-protector-strong" "-fstack-protector" EXTRA_HARDENING)
  166. add_double_extra_compiler_flag("_FORTIFY_SOURCE" "-D_FORTIFY_SOURCE=3" "-D_FORTIFY_SOURCE=2" EXTRA_HARDENING)
  167. add_simple_extra_compiler_flag("stack-clash-protection" "-fstack-clash-protection" EXTRA_HARDENING)
  168. add_simple_extra_compiler_flag("-fcf-protection" "-fcf-protection=full" EXTRA_HARDENING)
  169. add_simple_extra_compiler_flag("branch-protection" "-mbranch-protection=standard" EXTRA_HARDENING)
  170. endif()
  171. foreach(FLAG function-sections data-sections)
  172. add_simple_extra_compiler_flag("${FLAG}" "-f${FLAG}" EXTRA_OPT)
  173. endforeach()
  174. foreach(RELTYP RELEASE DEBUG RELWITHDEBINFO MINSIZEREL)
  175. foreach(L C CXX)
  176. set(CMAKE_${L}_FLAGS_${RELTYP} "${CMAKE_${L}_FLAGS_${RELTYP}} ${EXTRA_HARDENING_C_FLAGS} ${EXTRA_OPT_C_FLAGS}")
  177. endforeach()
  178. endforeach()
  179. #
  180. # detect OS
  181. #
  182. set(LINUX False)
  183. set(FREEBSD False)
  184. set(MACOS False)
  185. if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  186. set(MACOS True)
  187. set(COMPILED_FOR_MACOS True)
  188. find_library(IOKIT IOKit)
  189. find_library(FOUNDATION Foundation)
  190. elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
  191. set(FREEBSD True)
  192. set(COMPILED_FOR_FREEBSD True)
  193. else()
  194. set(LINUX True)
  195. set(COMPILED_FOR_LINUX True)
  196. add_definitions(-D_GNU_SOURCE)
  197. endif()
  198. #
  199. # Libm
  200. #
  201. # checks link with cmake required libs
  202. cmake_policy(SET CMP0075 NEW)
  203. include(CheckFunctionExists)
  204. check_function_exists(log10 HAVE_LOG10)
  205. if(NOT HAVE_LOG10)
  206. unset(HAVE_LOG10 CACHE)
  207. list(APPEND CMAKE_REQUIRED_LIBRARIES m)
  208. check_function_exists(log10 HAVE_LOG10)
  209. if(HAVE_LOG10)
  210. set(LINK_LIBM True CACHE BOOL "" FORCE)
  211. else()
  212. message(FATAL_ERROR "Can not use log10 with/without libm.")
  213. endif()
  214. endif()
  215. #
  216. # check include files
  217. #
  218. include(CheckIncludeFile)
  219. check_include_file("netinet/in.h" HAVE_NETINET_IN_H)
  220. check_include_file("resolv.h" HAVE_RESOLV_H)
  221. check_include_file("netdb.h" HAVE_NETDB_H)
  222. check_include_file("sys/prctl.h" HAVE_SYS_PRCTL_H)
  223. check_include_file("sys/stat.h" HAVE_SYS_STAT_H)
  224. check_include_file("sys/vfs.h" HAVE_SYS_VFS_H)
  225. check_include_file("sys/statfs.h" HAVE_SYS_STATFS_H)
  226. check_include_file("linux/magic.h" HAVE_LINUX_MAGIC_H)
  227. check_include_file("sys/mount.h" HAVE_SYS_MOUNT_H)
  228. check_include_file("sys/statvfs.h" HAVE_SYS_STATVFS_H)
  229. check_include_file("inttypes.h" HAVE_INTTYPES_H)
  230. check_include_file("stdint.h" HAVE_STDINT_H)
  231. check_include_file("sys/capability.h" HAVE_SYS_CAPABILITY_H)
  232. #
  233. # check libraries we need
  234. #
  235. include(CheckLibraryExists)
  236. check_library_exists(snappy snappy_compress "" HAVE_SNAPPY_LIB)
  237. #check_include_file("snappy.h" HAVE_SNAPPY_H)
  238. #
  239. # check symbols
  240. #
  241. include(CheckSymbolExists)
  242. check_symbol_exists(major "sys/sysmacros.h" MAJOR_IN_SYSMACROS)
  243. check_symbol_exists(major "sys/mkdev.h" MAJOR_IN_MKDEV)
  244. check_symbol_exists(clock_gettime "time.h" HAVE_CLOCK_GETTIME)
  245. check_symbol_exists(strerror_r "string.h" HAVE_STRERROR_R)
  246. check_symbol_exists(finite "math.h" HAVE_FINITE)
  247. check_symbol_exists(isfinite "math.h" HAVE_ISFINITE)
  248. check_symbol_exists(dlsym "dlfcn.h" HAVE_DLSYM)
  249. check_function_exists(nice HAVE_NICE)
  250. check_function_exists(recvmmsg HAVE_RECVMMSG)
  251. check_function_exists(getpriority HAVE_GETPRIORITY)
  252. check_function_exists(sched_getscheduler HAVE_SCHED_GETSCHEDULER)
  253. check_function_exists(sched_setscheduler HAVE_SCHED_SETSCHEDULER)
  254. check_function_exists(sched_get_priority_min HAVE_SCHED_GET_PRIORITY_MIN)
  255. check_function_exists(sched_get_priority_max HAVE_SCHED_GET_PRIORITY_MAX)
  256. check_function_exists(close_range HAVE_CLOSE_RANGE)
  257. check_function_exists(backtrace HAVE_BACKTRACE)
  258. #
  259. # check source compilation
  260. #
  261. include(CheckCSourceCompiles)
  262. include(CheckCXXSourceCompiles)
  263. set(CMAKE_REQUIRED_LIBRARIES pthread)
  264. check_c_source_compiles("
  265. #define _GNU_SOURCE
  266. #include <pthread.h>
  267. int main() {
  268. char name[16];
  269. pthread_t thread = pthread_self();
  270. return pthread_getname_np(thread, name, sizeof(name));
  271. }
  272. " HAVE_PTHREAD_GETNAME_NP)
  273. check_c_source_compiles("
  274. #include <stdio.h>
  275. #define mytype(X) _Generic((X), int: 'i', float: 'f', default: 'u')
  276. int main() {
  277. char type = mytype(0);
  278. return 0;
  279. }
  280. " HAVE_C__GENERIC)
  281. check_c_source_compiles("
  282. #include <malloc.h>
  283. int main() {
  284. mallopt(M_ARENA_MAX, 1);
  285. mallopt(M_PERTURB, 0x5A);
  286. return 0;
  287. }
  288. " HAVE_C_MALLOPT)
  289. check_c_source_compiles("
  290. #define _GNU_SOURCE
  291. #include <stdio.h>
  292. #include <sys/socket.h>
  293. int main() {
  294. accept4(0, NULL, NULL, 0);
  295. return 0;
  296. }
  297. " HAVE_ACCEPT4)
  298. check_c_source_compiles("
  299. #define _GNU_SOURCE
  300. #include <string.h>
  301. int main() {
  302. char x = *strerror_r(0, &x, sizeof(x)); return 0;
  303. }
  304. " STRERROR_R_CHAR_P)
  305. check_c_source_compiles("
  306. #ifndef _GNU_SOURCE
  307. #define _GNU_SOURCE
  308. #endif
  309. #include <sched.h>
  310. int main() {
  311. setns(0, 0); return 0;
  312. }
  313. " HAVE_SETNS)
  314. check_cxx_source_compiles("
  315. int main() {
  316. __atomic_load_8(nullptr, 0);
  317. return 0;
  318. }
  319. " HAVE_BUILTIN_ATOMICS)
  320. check_c_source_compiles("
  321. void my_printf(char const *s, ...) __attribute__((format(printf, 1, 2)));
  322. int main() { return 0; }
  323. " HAVE_FUNC_ATTRIBUTE_FORMAT)
  324. check_c_source_compiles("
  325. #include <stdio.h>
  326. #include <stdlib.h>
  327. #include <unistd.h>
  328. void* my_alloc(size_t size) __attribute__((malloc));
  329. int main() {
  330. void *x = my_alloc(1);
  331. free(x);
  332. return 0;
  333. }
  334. void* my_alloc(size_t size) {
  335. void *ret = malloc(size);
  336. if(!ret) exit(1);
  337. return ret;
  338. }
  339. " HAVE_FUNC_ATTRIBUTE_MALLOC)
  340. check_c_source_compiles("
  341. void my_function() __attribute__((noinline));
  342. int main() { my_function(); return 0; }
  343. void my_function() { ; }
  344. " HAVE_FUNC_ATTRIBUTE_NOINLINE)
  345. check_c_source_compiles("
  346. void my_exit_function() __attribute__((noreturn));
  347. int main() {
  348. my_exit_function(); // Call the noreturn function
  349. return 0;
  350. }
  351. void my_exit_function() {
  352. exit(1);
  353. }
  354. " HAVE_FUNC_ATTRIBUTE_NORETURN)
  355. check_c_source_compiles("
  356. #include <stdio.h>
  357. #include <stdlib.h>
  358. #include <unistd.h>
  359. void* my_alloc(size_t size) __attribute__((returns_nonnull));
  360. int main() {
  361. void* ptr = my_alloc(10);
  362. free(ptr);
  363. return 0;
  364. }
  365. void* my_alloc(size_t size) {
  366. void *ret = malloc(size);
  367. if(!ret) exit(1);
  368. return ret;
  369. }
  370. " HAVE_FUNC_ATTRIBUTE_RETURNS_NONNULL)
  371. check_c_source_compiles("
  372. int my_function() __attribute__((warn_unused_result));
  373. int main() {
  374. return my_function();
  375. }
  376. int my_function() {
  377. return 1;
  378. }
  379. " HAVE_FUNC_ATTRIBUTE_WARN_UNUSED_RESULT)
  380. if(FREEBSD OR MACOS)
  381. set(HAVE_BUILTIN_ATOMICS True)
  382. endif()
  383. # openssl/crypto
  384. set(ENABLE_OPENSSL True)
  385. if(NOT MACOS)
  386. pkg_check_modules(CRYPTO libcrypto)
  387. pkg_check_modules(OPENSSL REQUIRED openssl)
  388. else()
  389. # I think this is moot because we can only use openssl 3.x
  390. execute_process(COMMAND
  391. brew --prefix --installed openssl
  392. RESULT_VARIABLE BREW_OPENSSL
  393. OUTPUT_VARIABLE BREW_OPENSSL_PREFIX
  394. OUTPUT_STRIP_TRAILING_WHITESPACE)
  395. if((BREW_OPENSSL NOT EQUAL 0) OR (NOT EXISTS "${BREW_OPENSSL_PREFIX}"))
  396. execute_process(COMMAND
  397. brew --prefix --installed openssl@3
  398. RESULT_VARIABLE BREW_OPENSSL
  399. OUTPUT_VARIABLE BREW_OPENSSL_PREFIX
  400. OUTPUT_STRIP_TRAILING_WHITESPACE)
  401. if((BREW_OPENSSL NOT EQUAL 0) OR (NOT EXISTS "${BREW_OPENSSL_PREFIX}"))
  402. execute_process(COMMAND
  403. brew --prefix --installed openssl@1.1
  404. RESULT_VARIABLE BREW_OPENSSL
  405. OUTPUT_VARIABLE BREW_OPENSSL_PREFIX
  406. OUTPUT_STRIP_TRAILING_WHITESPACE)
  407. if((BREW_OPENSSL NOT EQUAL 0) OR (NOT EXISTS "${BREW_OPENSSL_PREFIX}"))
  408. message(FATAL_ERROR "Could not find openssl prefix with brew")
  409. endif()
  410. endif()
  411. endif()
  412. set(OPENSSL_INCLUDE_DIRS "${BREW_OPENSSL_PREFIX}/include")
  413. set(OPENSSL_CFLAGS_OTHER "")
  414. set(OPENSSL_LDFLAGS "-L${BREW_OPENSSL_PREFIX}/lib;-lssl;-lcrypto")
  415. endif()
  416. #
  417. # figure out if we need protoc/protobuf
  418. #
  419. if(ENABLE_ACLK OR ENABLE_EXPORTER_PROMETHEUS_REMOTE_WRITE)
  420. if(ENABLE_BUNDLED_PROTOBUF)
  421. set(PROTOBUF_PROTOC_EXECUTABLE "${CMAKE_SOURCE_DIR}/externaldeps/protobuf/src/protoc")
  422. set(PROTOBUF_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/externaldeps/protobuf/src")
  423. set(PROTOBUF_LIBRARIES "${CMAKE_SOURCE_DIR}/externaldeps/protobuf/src/.libs/libprotobuf.a")
  424. else()
  425. if (NOT BUILD_SHARED_LIBS)
  426. set(Protobuf_USE_STATIC_LIBS On)
  427. endif()
  428. find_package(Protobuf)
  429. endif()
  430. set(ENABLE_PROTOBUF True)
  431. set(HAVE_PROTOBUF True)
  432. if (ENABLE_BUNDLED_PROTOBUF)
  433. set(BUNDLED_PROTOBUF True)
  434. endif()
  435. endif()
  436. #
  437. # source files
  438. #
  439. set(LIBJUDY_PREV_FILES
  440. libnetdata/libjudy/src/JudyL/JudyLPrev.c
  441. libnetdata/libjudy/src/JudyL/JudyLPrevEmpty.c
  442. )
  443. set(LIBJUDY_NEXT_FILES
  444. libnetdata/libjudy/src/JudyL/JudyLNext.c
  445. libnetdata/libjudy/src/JudyL/JudyLNextEmpty.c
  446. )
  447. set(LIBJUDY_SOURCES
  448. libnetdata/libjudy/src/Judy.h
  449. libnetdata/libjudy/src/JudyCommon/JudyMalloc.c
  450. libnetdata/libjudy/src/JudyCommon/JudyPrivate.h
  451. libnetdata/libjudy/src/JudyCommon/JudyPrivate1L.h
  452. libnetdata/libjudy/src/JudyCommon/JudyPrivateBranch.h
  453. libnetdata/libjudy/src/JudyL/JudyL.h
  454. libnetdata/libjudy/src/JudyL/JudyLByCount.c
  455. libnetdata/libjudy/src/JudyL/JudyLCascade.c
  456. libnetdata/libjudy/src/JudyL/JudyLCount.c
  457. libnetdata/libjudy/src/JudyL/JudyLCreateBranch.c
  458. libnetdata/libjudy/src/JudyL/JudyLDecascade.c
  459. libnetdata/libjudy/src/JudyL/JudyLDel.c
  460. libnetdata/libjudy/src/JudyL/JudyLFirst.c
  461. libnetdata/libjudy/src/JudyL/JudyLFreeArray.c
  462. libnetdata/libjudy/src/JudyL/j__udyLGet.c
  463. libnetdata/libjudy/src/JudyL/JudyLGet.c
  464. libnetdata/libjudy/src/JudyL/JudyLInsArray.c
  465. libnetdata/libjudy/src/JudyL/JudyLIns.c
  466. libnetdata/libjudy/src/JudyL/JudyLInsertBranch.c
  467. libnetdata/libjudy/src/JudyL/JudyLMallocIF.c
  468. libnetdata/libjudy/src/JudyL/JudyLMemActive.c
  469. libnetdata/libjudy/src/JudyL/JudyLMemUsed.c
  470. libnetdata/libjudy/src/JudyL/JudyLTables.c
  471. libnetdata/libjudy/src/JudyHS/JudyHS.c
  472. ${LIBJUDY_PREV_FILES}
  473. ${LIBJUDY_NEXT_FILES}
  474. )
  475. set(LIBNETDATA_FILES
  476. ${CONFIG_H}
  477. libnetdata/adaptive_resortable_list/adaptive_resortable_list.c
  478. libnetdata/adaptive_resortable_list/adaptive_resortable_list.h
  479. libnetdata/config/appconfig.c
  480. libnetdata/config/appconfig.h
  481. libnetdata/aral/aral.c
  482. libnetdata/aral/aral.h
  483. libnetdata/avl/avl.c
  484. libnetdata/avl/avl.h
  485. libnetdata/buffer/buffer.c
  486. libnetdata/buffer/buffer.h
  487. libnetdata/circular_buffer/circular_buffer.c
  488. libnetdata/circular_buffer/circular_buffer.h
  489. libnetdata/clocks/clocks.c
  490. libnetdata/clocks/clocks.h
  491. libnetdata/completion/completion.c
  492. libnetdata/completion/completion.h
  493. libnetdata/datetime/iso8601.c
  494. libnetdata/datetime/iso8601.h
  495. libnetdata/datetime/rfc7231.c
  496. libnetdata/datetime/rfc7231.h
  497. libnetdata/datetime/rfc3339.c
  498. libnetdata/datetime/rfc3339.h
  499. libnetdata/dictionary/dictionary.c
  500. libnetdata/dictionary/dictionary.h
  501. libnetdata/eval/eval.c
  502. libnetdata/eval/eval.h
  503. libnetdata/facets/facets.c
  504. libnetdata/facets/facets.h
  505. libnetdata/functions_evloop/functions_evloop.c
  506. libnetdata/functions_evloop/functions_evloop.h
  507. libnetdata/gorilla/gorilla.cc
  508. libnetdata/gorilla/gorilla.h
  509. libnetdata/health/health.c
  510. libnetdata/health/health.h
  511. libnetdata/july/july.c
  512. libnetdata/july/july.h
  513. libnetdata/inlined.h
  514. libnetdata/json/json.c
  515. libnetdata/json/json.h
  516. libnetdata/json/jsmn.c
  517. libnetdata/json/jsmn.h
  518. libnetdata/libnetdata.c
  519. libnetdata/libnetdata.h
  520. libnetdata/line_splitter/line_splitter.c
  521. libnetdata/line_splitter/line_splitter.h
  522. libnetdata/libnetdata.h
  523. libnetdata/locks/locks.c
  524. libnetdata/locks/locks.h
  525. libnetdata/log/journal.c
  526. libnetdata/log/journal.h
  527. libnetdata/log/log.c
  528. libnetdata/log/log.h
  529. libnetdata/os.c
  530. libnetdata/os.h
  531. libnetdata/simple_hashtable.h
  532. libnetdata/endian.h
  533. libnetdata/onewayalloc/onewayalloc.c
  534. libnetdata/onewayalloc/onewayalloc.h
  535. libnetdata/popen/popen.c
  536. libnetdata/popen/popen.h
  537. libnetdata/procfile/procfile.c
  538. libnetdata/procfile/procfile.h
  539. libnetdata/query_progress/progress.c
  540. libnetdata/query_progress/progress.h
  541. libnetdata/required_dummies.h
  542. libnetdata/socket/security.c
  543. libnetdata/socket/security.h
  544. libnetdata/simple_pattern/simple_pattern.c
  545. libnetdata/simple_pattern/simple_pattern.h
  546. libnetdata/socket/socket.c
  547. libnetdata/socket/socket.h
  548. libnetdata/statistical/statistical.c
  549. libnetdata/statistical/statistical.h
  550. libnetdata/storage_number/storage_number.c
  551. libnetdata/storage_number/storage_number.h
  552. libnetdata/string/string.c
  553. libnetdata/string/string.h
  554. libnetdata/threads/threads.c
  555. libnetdata/threads/threads.h
  556. libnetdata/url/url.c
  557. libnetdata/url/url.h
  558. libnetdata/uuid/uuid.c
  559. libnetdata/uuid/uuid.h
  560. libnetdata/string/utf8.h
  561. libnetdata/worker_utilization/worker_utilization.c
  562. libnetdata/worker_utilization/worker_utilization.h
  563. libnetdata/http/http_access.c
  564. libnetdata/http/http_access.h
  565. libnetdata/http/http_defs.c
  566. libnetdata/http/http_defs.h
  567. libnetdata/http/content_type.c
  568. libnetdata/http/content_type.h
  569. libnetdata/config/dyncfg.c
  570. libnetdata/config/dyncfg.h
  571. )
  572. if(ENABLE_PLUGIN_EBPF)
  573. list(APPEND LIBNETDATA_FILES
  574. libnetdata/ebpf/ebpf.c
  575. libnetdata/ebpf/ebpf.h
  576. )
  577. endif()
  578. set(LIBH2O_FILES
  579. web/server/h2o/libh2o/deps/cloexec/cloexec.c
  580. web/server/h2o/libh2o/deps/libgkc/gkc.c
  581. web/server/h2o/libh2o/deps/libyrmcds/close.c
  582. web/server/h2o/libh2o/deps/libyrmcds/connect.c
  583. web/server/h2o/libh2o/deps/libyrmcds/recv.c
  584. web/server/h2o/libh2o/deps/libyrmcds/send.c
  585. web/server/h2o/libh2o/deps/libyrmcds/send_text.c
  586. web/server/h2o/libh2o/deps/libyrmcds/socket.c
  587. web/server/h2o/libh2o/deps/libyrmcds/strerror.c
  588. web/server/h2o/libh2o/deps/libyrmcds/text_mode.c
  589. web/server/h2o/libh2o/deps/picohttpparser/picohttpparser.c
  590. web/server/h2o/libh2o/lib/common/cache.c
  591. web/server/h2o/libh2o/lib/common/file.c
  592. web/server/h2o/libh2o/lib/common/filecache.c
  593. web/server/h2o/libh2o/lib/common/hostinfo.c
  594. web/server/h2o/libh2o/lib/common/http1client.c
  595. web/server/h2o/libh2o/lib/common/memcached.c
  596. web/server/h2o/libh2o/lib/common/memory.c
  597. web/server/h2o/libh2o/lib/common/multithread.c
  598. web/server/h2o/libh2o/lib/common/serverutil.c
  599. web/server/h2o/libh2o/lib/common/socket.c
  600. web/server/h2o/libh2o/lib/common/socketpool.c
  601. web/server/h2o/libh2o/lib/common/string.c
  602. web/server/h2o/libh2o/lib/common/time.c
  603. web/server/h2o/libh2o/lib/common/timeout.c
  604. web/server/h2o/libh2o/lib/common/url.c
  605. web/server/h2o/libh2o/lib/core/config.c
  606. web/server/h2o/libh2o/lib/core/configurator.c
  607. web/server/h2o/libh2o/lib/core/context.c
  608. web/server/h2o/libh2o/lib/core/headers.c
  609. web/server/h2o/libh2o/lib/core/logconf.c
  610. web/server/h2o/libh2o/lib/core/proxy.c
  611. web/server/h2o/libh2o/lib/core/request.c
  612. web/server/h2o/libh2o/lib/core/token.c
  613. web/server/h2o/libh2o/lib/core/util.c
  614. web/server/h2o/libh2o/lib/handler/access_log.c
  615. web/server/h2o/libh2o/lib/handler/chunked.c
  616. web/server/h2o/libh2o/lib/handler/compress.c
  617. web/server/h2o/libh2o/lib/handler/compress/gzip.c
  618. web/server/h2o/libh2o/lib/handler/errordoc.c
  619. web/server/h2o/libh2o/lib/handler/expires.c
  620. web/server/h2o/libh2o/lib/handler/fastcgi.c
  621. web/server/h2o/libh2o/lib/handler/file.c
  622. web/server/h2o/libh2o/lib/handler/headers.c
  623. web/server/h2o/libh2o/lib/handler/mimemap.c
  624. web/server/h2o/libh2o/lib/handler/proxy.c
  625. web/server/h2o/libh2o/lib/handler/redirect.c
  626. web/server/h2o/libh2o/lib/handler/reproxy.c
  627. web/server/h2o/libh2o/lib/handler/throttle_resp.c
  628. web/server/h2o/libh2o/lib/handler/status.c
  629. web/server/h2o/libh2o/lib/handler/headers_util.c
  630. web/server/h2o/libh2o/lib/handler/status/events.c
  631. web/server/h2o/libh2o/lib/handler/status/requests.c
  632. web/server/h2o/libh2o/lib/handler/http2_debug_state.c
  633. web/server/h2o/libh2o/lib/handler/status/durations.c
  634. web/server/h2o/libh2o/lib/handler/configurator/access_log.c
  635. web/server/h2o/libh2o/lib/handler/configurator/compress.c
  636. web/server/h2o/libh2o/lib/handler/configurator/errordoc.c
  637. web/server/h2o/libh2o/lib/handler/configurator/expires.c
  638. web/server/h2o/libh2o/lib/handler/configurator/fastcgi.c
  639. web/server/h2o/libh2o/lib/handler/configurator/file.c
  640. web/server/h2o/libh2o/lib/handler/configurator/headers.c
  641. web/server/h2o/libh2o/lib/handler/configurator/proxy.c
  642. web/server/h2o/libh2o/lib/handler/configurator/redirect.c
  643. web/server/h2o/libh2o/lib/handler/configurator/reproxy.c
  644. web/server/h2o/libh2o/lib/handler/configurator/throttle_resp.c
  645. web/server/h2o/libh2o/lib/handler/configurator/status.c
  646. web/server/h2o/libh2o/lib/handler/configurator/http2_debug_state.c
  647. web/server/h2o/libh2o/lib/handler/configurator/headers_util.c
  648. web/server/h2o/libh2o/lib/http1.c
  649. web/server/h2o/libh2o/lib/tunnel.c
  650. web/server/h2o/libh2o/lib/http2/cache_digests.c
  651. web/server/h2o/libh2o/lib/http2/casper.c
  652. web/server/h2o/libh2o/lib/http2/connection.c
  653. web/server/h2o/libh2o/lib/http2/frame.c
  654. web/server/h2o/libh2o/lib/http2/hpack.c
  655. web/server/h2o/libh2o/lib/http2/scheduler.c
  656. web/server/h2o/libh2o/lib/http2/stream.c
  657. web/server/h2o/libh2o/lib/http2/http2_debug_state.c
  658. )
  659. set(DAEMON_FILES
  660. daemon/buildinfo.c
  661. daemon/buildinfo.h
  662. daemon/common.c
  663. daemon/common.h
  664. daemon/daemon.c
  665. daemon/daemon.h
  666. daemon/event_loop.c
  667. daemon/event_loop.h
  668. daemon/global_statistics.c
  669. daemon/global_statistics.h
  670. daemon/analytics.c
  671. daemon/analytics.h
  672. daemon/main.c
  673. daemon/main.h
  674. daemon/signals.c
  675. daemon/signals.h
  676. daemon/service.c
  677. daemon/static_threads.c
  678. daemon/static_threads.h
  679. daemon/commands.c
  680. daemon/commands.h
  681. daemon/pipename.c
  682. daemon/pipename.h
  683. daemon/unit_test.c
  684. daemon/unit_test.h
  685. daemon/config/dyncfg.c
  686. daemon/config/dyncfg.h
  687. daemon/config/dyncfg-files.c
  688. daemon/config/dyncfg-unittest.c
  689. daemon/config/dyncfg-inline.c
  690. daemon/config/dyncfg-echo.c
  691. daemon/config/dyncfg-internals.h
  692. daemon/config/dyncfg-intercept.c
  693. daemon/config/dyncfg-tree.c
  694. )
  695. set(H2O_FILES
  696. web/server/h2o/http_server.c
  697. web/server/h2o/http_server.h
  698. web/server/h2o/h2o_utils.c
  699. web/server/h2o/h2o_utils.h
  700. web/server/h2o/streaming.c
  701. web/server/h2o/streaming.h
  702. web/server/h2o/connlist.c
  703. web/server/h2o/connlist.h
  704. )
  705. if(ENABLE_H2O)
  706. list(APPEND DAEMON_FILES ${H2O_FILES})
  707. endif()
  708. set(API_PLUGIN_FILES
  709. web/api/web_api.c
  710. web/api/web_api.h
  711. web/api/web_api_v1.c
  712. web/api/web_api_v1.h
  713. web/api/web_api_v2.c
  714. web/api/web_api_v2.h
  715. web/api/http_auth.c
  716. web/api/http_auth.h
  717. web/api/http_header.c
  718. web/api/http_header.h
  719. web/api/badges/web_buffer_svg.c
  720. web/api/badges/web_buffer_svg.h
  721. web/api/exporters/allmetrics.c
  722. web/api/exporters/allmetrics.h
  723. web/api/exporters/shell/allmetrics_shell.c
  724. web/api/exporters/shell/allmetrics_shell.h
  725. web/api/queries/rrdr.c
  726. web/api/queries/rrdr.h
  727. web/api/queries/query.c
  728. web/api/queries/query.h
  729. web/api/queries/average/average.c
  730. web/api/queries/average/average.h
  731. web/api/queries/countif/countif.c
  732. web/api/queries/countif/countif.h
  733. web/api/queries/incremental_sum/incremental_sum.c
  734. web/api/queries/incremental_sum/incremental_sum.h
  735. web/api/queries/max/max.c
  736. web/api/queries/max/max.h
  737. web/api/queries/min/min.c
  738. web/api/queries/min/min.h
  739. web/api/queries/sum/sum.c
  740. web/api/queries/sum/sum.h
  741. web/api/queries/median/median.c
  742. web/api/queries/median/median.h
  743. web/api/queries/percentile/percentile.c
  744. web/api/queries/percentile/percentile.h
  745. web/api/queries/stddev/stddev.c
  746. web/api/queries/stddev/stddev.h
  747. web/api/queries/ses/ses.c
  748. web/api/queries/ses/ses.h
  749. web/api/queries/des/des.c
  750. web/api/queries/des/des.h
  751. web/api/queries/trimmed_mean/trimmed_mean.c
  752. web/api/queries/trimmed_mean/trimmed_mean.h
  753. web/api/queries/weights.c
  754. web/api/queries/weights.h
  755. web/api/formatters/rrd2json.c
  756. web/api/formatters/rrd2json.h
  757. web/api/formatters/csv/csv.c
  758. web/api/formatters/csv/csv.h
  759. web/api/formatters/json/json.c
  760. web/api/formatters/json/json.h
  761. web/api/formatters/ssv/ssv.c
  762. web/api/formatters/ssv/ssv.h
  763. web/api/formatters/value/value.c
  764. web/api/formatters/value/value.h
  765. web/api/formatters/json_wrapper.c
  766. web/api/formatters/json_wrapper.h
  767. web/api/formatters/charts2json.c
  768. web/api/formatters/charts2json.h
  769. web/api/formatters/rrdset2json.c
  770. web/api/formatters/rrdset2json.h
  771. web/api/health/health_cmdapi.c
  772. web/api/ilove/ilove.c
  773. web/api/ilove/ilove.h
  774. web/rtc/webrtc.c
  775. web/rtc/webrtc.h
  776. )
  777. set(EXPORTING_ENGINE_FILES
  778. exporting/exporting_engine.c
  779. exporting/exporting_engine.h
  780. exporting/graphite/graphite.c
  781. exporting/graphite/graphite.h
  782. exporting/json/json.c
  783. exporting/json/json.h
  784. exporting/opentsdb/opentsdb.c
  785. exporting/opentsdb/opentsdb.h
  786. exporting/prometheus/prometheus.c
  787. exporting/prometheus/prometheus.h
  788. exporting/read_config.c
  789. exporting/clean_connectors.c
  790. exporting/init_connectors.c
  791. exporting/process_data.c
  792. exporting/check_filters.c
  793. exporting/send_data.c
  794. exporting/send_internal_metrics.c
  795. )
  796. set(HEALTH_PLUGIN_FILES
  797. health/health.c
  798. health/health.h
  799. health/health_config.c
  800. health/health_json.c
  801. health/health_log.c
  802. )
  803. set(IDLEJITTER_PLUGIN_FILES collectors/idlejitter.plugin/plugin_idlejitter.c)
  804. if(ENABLE_ML)
  805. set(ML_FILES
  806. ml/ad_charts.h
  807. ml/ad_charts.cc
  808. ml/Config.cc
  809. ml/dlib/dlib/all/source.cpp
  810. ml/ml.h
  811. ml/ml.cc
  812. ml/ml-private.h
  813. )
  814. else()
  815. set(ML_FILES
  816. ml/ml.h
  817. ml/ml-dummy.c
  818. )
  819. endif()
  820. set(PLUGINSD_PLUGIN_FILES
  821. collectors/plugins.d/plugins_d.c
  822. collectors/plugins.d/plugins_d.h
  823. collectors/plugins.d/pluginsd_dyncfg.c
  824. collectors/plugins.d/pluginsd_dyncfg.h
  825. collectors/plugins.d/pluginsd_functions.c
  826. collectors/plugins.d/pluginsd_functions.h
  827. collectors/plugins.d/pluginsd_internals.c
  828. collectors/plugins.d/pluginsd_internals.h
  829. collectors/plugins.d/pluginsd_parser.c
  830. collectors/plugins.d/pluginsd_parser.h
  831. collectors/plugins.d/pluginsd_replication.c
  832. collectors/plugins.d/pluginsd_replication.h
  833. )
  834. set(RRD_PLUGIN_FILES
  835. database/contexts/api_v1.c
  836. database/contexts/api_v2.c
  837. database/contexts/context.c
  838. database/contexts/instance.c
  839. database/contexts/internal.h
  840. database/contexts/metric.c
  841. database/contexts/query_scope.c
  842. database/contexts/query_target.c
  843. database/contexts/rrdcontext.c
  844. database/contexts/rrdcontext.h
  845. database/contexts/worker.c
  846. database/rrdcalc.c
  847. database/rrdcalc.h
  848. database/rrdcalctemplate.c
  849. database/rrdcalctemplate.h
  850. database/rrdcollector.c
  851. database/rrdcollector.h
  852. database/rrddim.c
  853. database/rrddimvar.c
  854. database/rrddimvar.h
  855. database/rrdfamily.c
  856. database/rrdfunctions.c
  857. database/rrdfunctions.h
  858. database/rrdfunctions-inline.c
  859. database/rrdfunctions-inline.h
  860. database/rrdfunctions-progress.c
  861. database/rrdfunctions-progress.h
  862. database/rrdfunctions-streaming.c
  863. database/rrdfunctions-streaming.h
  864. database/rrdhost.c
  865. database/rrdlabels.c
  866. database/rrd.c
  867. database/rrd.h
  868. database/rrdset.c
  869. database/rrdsetvar.c
  870. database/rrdsetvar.h
  871. database/rrdvar.c
  872. database/rrdvar.h
  873. database/storage_engine.c
  874. database/storage_engine.h
  875. database/ram/rrddim_mem.c
  876. database/ram/rrddim_mem.h
  877. database/sqlite/sqlite_metadata.c
  878. database/sqlite/sqlite_metadata.h
  879. database/sqlite/sqlite_functions.c
  880. database/sqlite/sqlite_functions.h
  881. database/sqlite/sqlite_context.c
  882. database/sqlite/sqlite_context.h
  883. database/sqlite/sqlite_db_migration.c
  884. database/sqlite/sqlite_db_migration.h
  885. database/sqlite/sqlite_aclk.c
  886. database/sqlite/sqlite_aclk.h
  887. database/sqlite/sqlite_health.c
  888. database/sqlite/sqlite_health.h
  889. database/sqlite/sqlite_aclk_node.c
  890. database/sqlite/sqlite_aclk_node.h
  891. database/sqlite/sqlite_aclk_alert.c
  892. database/sqlite/sqlite_aclk_alert.h
  893. database/sqlite/sqlite3.c
  894. database/sqlite/sqlite3.h
  895. database/sqlite/sqlite3recover.c
  896. database/sqlite/sqlite3recover.h
  897. database/sqlite/dbdata.c
  898. database/KolmogorovSmirnovDist.c
  899. database/KolmogorovSmirnovDist.h
  900. database/rrdfunctions-inflight.c
  901. database/rrdfunctions-inflight.h
  902. database/rrdfunctions-exporters.c
  903. database/rrdfunctions-exporters.h
  904. database/rrdfunctions-internals.h
  905. database/rrdcollector-internals.h
  906. )
  907. if(ENABLE_DBENGINE)
  908. list(APPEND RRD_PLUGIN_FILES
  909. database/engine/rrdengine.c
  910. database/engine/rrdengine.h
  911. database/engine/rrddiskprotocol.h
  912. database/engine/datafile.c
  913. database/engine/datafile.h
  914. database/engine/journalfile.c
  915. database/engine/journalfile.h
  916. database/engine/rrdenginelib.c
  917. database/engine/rrdenginelib.h
  918. database/engine/rrdengineapi.c
  919. database/engine/rrdengineapi.h
  920. database/engine/pagecache.c
  921. database/engine/pagecache.h
  922. database/engine/page_test.cc
  923. database/engine/page.c
  924. database/engine/page.h
  925. database/engine/cache.c
  926. database/engine/cache.h
  927. database/engine/metric.c
  928. database/engine/metric.h
  929. database/engine/pdc.c
  930. database/engine/pdc.h
  931. )
  932. endif()
  933. set(REGISTRY_PLUGIN_FILES
  934. registry/registry.c
  935. registry/registry.h
  936. registry/registry_db.c
  937. registry/registry_init.c
  938. registry/registry_internals.c
  939. registry/registry_internals.h
  940. registry/registry_log.c
  941. registry/registry_machine.c
  942. registry/registry_machine.h
  943. registry/registry_person.c
  944. registry/registry_person.h
  945. )
  946. set(STATSD_PLUGIN_FILES
  947. collectors/statsd.plugin/statsd.c
  948. )
  949. set(SYSTEMD_JOURNAL_PLUGIN_FILES
  950. collectors/systemd-journal.plugin/systemd-journal.c
  951. collectors/systemd-journal.plugin/systemd-internals.h
  952. collectors/systemd-journal.plugin/systemd-main.c
  953. collectors/systemd-journal.plugin/systemd-units.c
  954. collectors/systemd-journal.plugin/systemd-journal.c
  955. collectors/systemd-journal.plugin/systemd-journal-annotations.c
  956. collectors/systemd-journal.plugin/systemd-journal-files.c
  957. collectors/systemd-journal.plugin/systemd-journal-fstat.c
  958. collectors/systemd-journal.plugin/systemd-journal-watcher.c
  959. collectors/systemd-journal.plugin/systemd-journal-dyncfg.c
  960. )
  961. set(STREAMING_PLUGIN_FILES
  962. streaming/rrdpush.c
  963. streaming/rrdpush.h
  964. streaming/compression.c
  965. streaming/compression.h
  966. streaming/compression_brotli.c
  967. streaming/compression_brotli.h
  968. streaming/compression_gzip.c
  969. streaming/compression_gzip.h
  970. streaming/compression_lz4.c
  971. streaming/compression_lz4.h
  972. streaming/compression_zstd.c
  973. streaming/compression_zstd.h
  974. streaming/receiver.c
  975. streaming/sender.c
  976. streaming/replication.c
  977. streaming/replication.h
  978. streaming/common.h
  979. )
  980. set(WEB_PLUGIN_FILES
  981. web/server/web_client.c
  982. web/server/web_client.h
  983. web/server/web_server.c
  984. web/server/web_server.h
  985. web/server/static/static-threaded.c
  986. web/server/static/static-threaded.h
  987. web/server/web_client_cache.c
  988. web/server/web_client_cache.h
  989. )
  990. set(CLAIM_PLUGIN_FILES
  991. claim/claim.c
  992. claim/claim.h
  993. )
  994. set(SPAWN_PLUGIN_FILES
  995. spawn/spawn.c
  996. spawn/spawn_server.c
  997. spawn/spawn_client.c
  998. spawn/spawn.h
  999. )
  1000. set(ACLK_ALWAYS_BUILD
  1001. aclk/aclk_rrdhost_state.h
  1002. aclk/aclk_proxy.c
  1003. aclk/aclk_proxy.h
  1004. aclk/aclk.c
  1005. aclk/aclk.h
  1006. aclk/aclk_capas.c
  1007. aclk/aclk_capas.h
  1008. aclk/aclk_util.c
  1009. aclk/aclk_util.h
  1010. aclk/https_client.c
  1011. aclk/https_client.h
  1012. )
  1013. set(TIMEX_PLUGIN_FILES
  1014. collectors/timex.plugin/plugin_timex.c
  1015. )
  1016. set(PROFILE_PLUGIN_FILES
  1017. collectors/profile.plugin/plugin_profile.cc
  1018. )
  1019. set(CGROUPS_PLUGIN_FILES
  1020. collectors/cgroups.plugin/sys_fs_cgroup.c
  1021. collectors/cgroups.plugin/sys_fs_cgroup.h
  1022. collectors/cgroups.plugin/cgroup-internals.h
  1023. collectors/cgroups.plugin/cgroup-discovery.c
  1024. collectors/cgroups.plugin/cgroup-charts.c
  1025. collectors/cgroups.plugin/cgroup-top.c
  1026. )
  1027. set(DISKSPACE_PLUGIN_FILES
  1028. collectors/diskspace.plugin/plugin_diskspace.c
  1029. )
  1030. set(MACOS_PLUGIN_FILES
  1031. collectors/macos.plugin/plugin_macos.c
  1032. collectors/macos.plugin/plugin_macos.h
  1033. collectors/macos.plugin/macos_sysctl.c
  1034. collectors/macos.plugin/macos_mach_smi.c
  1035. collectors/macos.plugin/macos_fw.c
  1036. )
  1037. set(FREEBSD_PLUGIN_FILES
  1038. collectors/freebsd.plugin/plugin_freebsd.c
  1039. collectors/freebsd.plugin/plugin_freebsd.h
  1040. collectors/freebsd.plugin/freebsd_sysctl.c
  1041. collectors/freebsd.plugin/freebsd_getmntinfo.c
  1042. collectors/freebsd.plugin/freebsd_getifaddrs.c
  1043. collectors/freebsd.plugin/freebsd_devstat.c
  1044. collectors/freebsd.plugin/freebsd_kstat_zfs.c
  1045. collectors/freebsd.plugin/freebsd_ipfw.c
  1046. collectors/proc.plugin/zfs_common.c
  1047. collectors/proc.plugin/zfs_common.h
  1048. )
  1049. set(PROC_PLUGIN_FILES
  1050. collectors/proc.plugin/ipc.c
  1051. collectors/proc.plugin/plugin_proc.c
  1052. collectors/proc.plugin/plugin_proc.h
  1053. collectors/proc.plugin/proc_sys_fs_file_nr.c
  1054. collectors/proc.plugin/proc_diskstats.c
  1055. collectors/proc.plugin/proc_mdstat.c
  1056. collectors/proc.plugin/proc_interrupts.c
  1057. collectors/proc.plugin/proc_softirqs.c
  1058. collectors/proc.plugin/proc_loadavg.c
  1059. collectors/proc.plugin/proc_meminfo.c
  1060. collectors/proc.plugin/proc_pagetypeinfo.c
  1061. collectors/proc.plugin/proc_net_dev.c
  1062. collectors/proc.plugin/proc_net_dev_renames.c
  1063. collectors/proc.plugin/proc_net_dev_renames.h
  1064. collectors/proc.plugin/proc_net_wireless.c
  1065. collectors/proc.plugin/proc_net_ip_vs_stats.c
  1066. collectors/proc.plugin/proc_net_netstat.c
  1067. collectors/proc.plugin/proc_net_rpc_nfs.c
  1068. collectors/proc.plugin/proc_net_rpc_nfsd.c
  1069. collectors/proc.plugin/proc_net_sctp_snmp.c
  1070. collectors/proc.plugin/proc_net_sockstat.c
  1071. collectors/proc.plugin/proc_net_sockstat6.c
  1072. collectors/proc.plugin/proc_net_softnet_stat.c
  1073. collectors/proc.plugin/proc_net_stat_conntrack.c
  1074. collectors/proc.plugin/proc_net_stat_synproxy.c
  1075. collectors/proc.plugin/proc_self_mountinfo.c
  1076. collectors/proc.plugin/proc_self_mountinfo.h
  1077. collectors/proc.plugin/zfs_common.c
  1078. collectors/proc.plugin/zfs_common.h
  1079. collectors/proc.plugin/proc_spl_kstat_zfs.c
  1080. collectors/proc.plugin/proc_stat.c
  1081. collectors/proc.plugin/proc_sys_kernel_random_entropy_avail.c
  1082. collectors/proc.plugin/proc_vmstat.c
  1083. collectors/proc.plugin/proc_uptime.c
  1084. collectors/proc.plugin/proc_pressure.c
  1085. collectors/proc.plugin/proc_pressure.h
  1086. collectors/proc.plugin/sys_kernel_mm_ksm.c
  1087. collectors/proc.plugin/sys_block_zram.c
  1088. collectors/proc.plugin/sys_devices_system_edac_mc.c
  1089. collectors/proc.plugin/sys_devices_system_node.c
  1090. collectors/proc.plugin/sys_class_infiniband.c
  1091. collectors/proc.plugin/sys_fs_btrfs.c
  1092. collectors/proc.plugin/sys_class_power_supply.c
  1093. collectors/proc.plugin/sys_devices_pci_aer.c
  1094. collectors/proc.plugin/sys_class_drm.c
  1095. )
  1096. set(TC_PLUGIN_FILES
  1097. collectors/tc.plugin/plugin_tc.c
  1098. )
  1099. set(LOGS_MANAGEMENT_PLUGIN_FILES
  1100. logsmanagement/circular_buffer.c
  1101. logsmanagement/circular_buffer.h
  1102. logsmanagement/db_api.c
  1103. logsmanagement/db_api.h
  1104. logsmanagement/defaults.h
  1105. logsmanagement/file_info.h
  1106. logsmanagement/flb_plugin.c
  1107. logsmanagement/flb_plugin.h
  1108. logsmanagement/functions.c
  1109. logsmanagement/functions.h
  1110. logsmanagement/helper.h
  1111. logsmanagement/logsmanag_config.c
  1112. logsmanagement/logsmanag_config.h
  1113. logsmanagement/logsmanagement.c
  1114. logsmanagement/parser.c
  1115. logsmanagement/parser.h
  1116. logsmanagement/query.c
  1117. logsmanagement/query.h
  1118. logsmanagement/rrd_api/rrd_api_docker_ev.c
  1119. logsmanagement/rrd_api/rrd_api_docker_ev.h
  1120. logsmanagement/rrd_api/rrd_api_generic.c
  1121. logsmanagement/rrd_api/rrd_api_generic.h
  1122. logsmanagement/rrd_api/rrd_api_kernel.c
  1123. logsmanagement/rrd_api/rrd_api_kernel.h
  1124. logsmanagement/rrd_api/rrd_api_mqtt.c
  1125. logsmanagement/rrd_api/rrd_api_mqtt.h
  1126. logsmanagement/rrd_api/rrd_api_stats.c
  1127. logsmanagement/rrd_api/rrd_api_stats.h
  1128. logsmanagement/rrd_api/rrd_api_systemd.c
  1129. logsmanagement/rrd_api/rrd_api_systemd.h
  1130. logsmanagement/rrd_api/rrd_api_web_log.c
  1131. logsmanagement/rrd_api/rrd_api_web_log.h
  1132. logsmanagement/rrd_api/rrd_api.h
  1133. database/sqlite/sqlite3.c
  1134. database/sqlite/sqlite3.h
  1135. )
  1136. set(NETDATA_FILES
  1137. collectors/all.h
  1138. ${DAEMON_FILES}
  1139. ${API_PLUGIN_FILES}
  1140. ${EXPORTING_ENGINE_FILES}
  1141. ${HEALTH_PLUGIN_FILES}
  1142. ${IDLEJITTER_PLUGIN_FILES}
  1143. ${ML_FILES}
  1144. ${PLUGINSD_PLUGIN_FILES}
  1145. ${RRD_PLUGIN_FILES}
  1146. ${REGISTRY_PLUGIN_FILES}
  1147. ${STATSD_PLUGIN_FILES}
  1148. ${STREAMING_PLUGIN_FILES}
  1149. ${WEB_PLUGIN_FILES}
  1150. ${CLAIM_PLUGIN_FILES}
  1151. ${SPAWN_PLUGIN_FILES}
  1152. ${ACLK_ALWAYS_BUILD}
  1153. ${TIMEX_PLUGIN_FILES}
  1154. ${PROFILE_PLUGIN_FILES}
  1155. )
  1156. if(LINUX)
  1157. list(APPEND NETDATA_FILES
  1158. daemon/static_threads_linux.c
  1159. ${CGROUPS_PLUGIN_FILES}
  1160. ${DISKSPACE_PLUGIN_FILES}
  1161. ${PROC_PLUGIN_FILES}
  1162. ${TC_PLUGIN_FILES}
  1163. )
  1164. elseif(MACOS)
  1165. list(APPEND NETDATA_FILES
  1166. daemon/static_threads_macos.c
  1167. ${MACOS_PLUGIN_FILES}
  1168. )
  1169. elseif(FREEBSD)
  1170. list(APPEND NETDATA_FILES
  1171. daemon/static_threads_freebsd.c
  1172. ${FREEBSD_PLUGIN_FILES}
  1173. )
  1174. endif()
  1175. set(MQTT_WEBSOCKETS_FILES
  1176. mqtt_websockets/src/mqtt_wss_client.c
  1177. mqtt_websockets/src/include/mqtt_wss_client.h
  1178. mqtt_websockets/src/mqtt_wss_log.c
  1179. mqtt_websockets/src/include/mqtt_wss_log.h
  1180. mqtt_websockets/src/ws_client.c
  1181. mqtt_websockets/src/include/ws_client.h
  1182. mqtt_websockets/src/mqtt_ng.c
  1183. mqtt_websockets/src/include/mqtt_ng.h
  1184. mqtt_websockets/src/common_public.c
  1185. mqtt_websockets/src/include/common_public.h
  1186. mqtt_websockets/src/include/common_internal.h
  1187. mqtt_websockets/c-rbuf/src/ringbuffer.c
  1188. mqtt_websockets/c-rbuf/include/ringbuffer.h
  1189. mqtt_websockets/c-rbuf/src/ringbuffer_internal.h
  1190. mqtt_websockets/c_rhash/src/c_rhash.c
  1191. mqtt_websockets/c_rhash/include/c_rhash.h
  1192. mqtt_websockets/c_rhash/src/c_rhash_internal.h
  1193. )
  1194. set(ACLK_PROTO_DEFS
  1195. aclk/aclk-schemas/proto/aclk/v1/lib.proto
  1196. aclk/aclk-schemas/proto/agent/v1/disconnect.proto
  1197. aclk/aclk-schemas/proto/agent/v1/connection.proto
  1198. aclk/aclk-schemas/proto/alarm/v1/config.proto
  1199. aclk/aclk-schemas/proto/alarm/v1/stream.proto
  1200. aclk/aclk-schemas/proto/nodeinstance/connection/v1/connection.proto
  1201. aclk/aclk-schemas/proto/nodeinstance/create/v1/creation.proto
  1202. aclk/aclk-schemas/proto/nodeinstance/info/v1/info.proto
  1203. aclk/aclk-schemas/proto/context/v1/context.proto
  1204. aclk/aclk-schemas/proto/context/v1/stream.proto
  1205. aclk/aclk-schemas/proto/agent/v1/cmds.proto
  1206. )
  1207. set(ACLK_FILES
  1208. aclk/aclk_stats.c
  1209. aclk/aclk_stats.h
  1210. aclk/aclk_query.c
  1211. aclk/aclk_query.h
  1212. aclk/aclk_query_queue.c
  1213. aclk/aclk_query_queue.h
  1214. aclk/aclk_otp.c
  1215. aclk/aclk_otp.h
  1216. aclk/aclk_tx_msgs.c
  1217. aclk/aclk_tx_msgs.h
  1218. aclk/aclk_rx_msgs.c
  1219. aclk/aclk_rx_msgs.h
  1220. aclk/aclk_alarm_api.c
  1221. aclk/aclk_alarm_api.h
  1222. aclk/aclk_contexts_api.c
  1223. aclk/aclk_contexts_api.h
  1224. aclk/schema-wrappers/connection.cc
  1225. aclk/schema-wrappers/connection.h
  1226. aclk/schema-wrappers/node_connection.cc
  1227. aclk/schema-wrappers/node_connection.h
  1228. aclk/schema-wrappers/node_creation.cc
  1229. aclk/schema-wrappers/node_creation.h
  1230. aclk/schema-wrappers/alarm_stream.cc
  1231. aclk/schema-wrappers/alarm_stream.h
  1232. aclk/schema-wrappers/alarm_config.cc
  1233. aclk/schema-wrappers/alarm_config.h
  1234. aclk/schema-wrappers/node_info.cc
  1235. aclk/schema-wrappers/node_info.h
  1236. aclk/schema-wrappers/capability.cc
  1237. aclk/schema-wrappers/capability.h
  1238. aclk/schema-wrappers/proto_2_json.cc
  1239. aclk/schema-wrappers/proto_2_json.h
  1240. aclk/schema-wrappers/context_stream.cc
  1241. aclk/schema-wrappers/context_stream.h
  1242. aclk/schema-wrappers/context.cc
  1243. aclk/schema-wrappers/context.h
  1244. aclk/schema-wrappers/schema_wrappers.h
  1245. aclk/schema-wrappers/schema_wrapper_utils.cc
  1246. aclk/schema-wrappers/schema_wrapper_utils.h
  1247. aclk/schema-wrappers/agent_cmds.cc
  1248. aclk/schema-wrappers/agent_cmds.h
  1249. aclk/helpers/mqtt_wss_pal.h
  1250. aclk/helpers/ringbuffer_pal.h
  1251. )
  1252. set(MONGODB_EXPORTING_FILES
  1253. exporting/mongodb/mongodb.c
  1254. exporting/mongodb/mongodb.h
  1255. )
  1256. set(PROMETHEUS_REMOTE_WRITE_EXPORTING_FILES
  1257. exporting/prometheus/remote_write/remote_write.c
  1258. exporting/prometheus/remote_write/remote_write.h
  1259. exporting/prometheus/remote_write/remote_write_request.cc
  1260. exporting/prometheus/remote_write/remote_write_request.h
  1261. )
  1262. #
  1263. # build h2o
  1264. #
  1265. if(ENABLE_H2O)
  1266. add_library(h2o STATIC ${LIBH2O_FILES})
  1267. target_include_directories(h2o BEFORE PUBLIC
  1268. "${CMAKE_SOURCE_DIR}/web/server/h2o/libh2o/include"
  1269. "${CMAKE_SOURCE_DIR}/web/server/h2o/libh2o/deps/cloexec"
  1270. "${CMAKE_SOURCE_DIR}/web/server/h2o/libh2o/deps/brotli/enc"
  1271. "${CMAKE_SOURCE_DIR}/web/server/h2o/libh2o/deps/golombset"
  1272. "${CMAKE_SOURCE_DIR}/web/server/h2o/libh2o/deps/libgkc"
  1273. "${CMAKE_SOURCE_DIR}/web/server/h2o/libh2o/deps/libyrmcds"
  1274. "${CMAKE_SOURCE_DIR}/web/server/h2o/libh2o/deps/klib"
  1275. "${CMAKE_SOURCE_DIR}/web/server/h2o/libh2o/deps/neverbleed"
  1276. "${CMAKE_SOURCE_DIR}/web/server/h2o/libh2o/deps/picohttpparser"
  1277. "${CMAKE_SOURCE_DIR}/web/server/h2o/libh2o/deps/picotest"
  1278. "${CMAKE_SOURCE_DIR}/web/server/h2o/libh2o/deps/yaml/include"
  1279. "${CMAKE_SOURCE_DIR}/web/server/h2o/libh2o/deps/yoml"
  1280. )
  1281. target_compile_options(h2o PRIVATE
  1282. -Wno-old-style-declaration
  1283. -Wno-deprecated-declarations
  1284. -Wno-unused-parameter
  1285. -Wno-sign-compare
  1286. -Wno-missing-field-initializers)
  1287. target_compile_options(h2o PUBLIC -DH2O_USE_LIBUV=0)
  1288. target_include_directories(h2o BEFORE PRIVATE ${OPENSSL_INCLUDE_DIRS})
  1289. target_compile_options(h2o PRIVATE ${OPENSSL_CFLAGS_OTHER})
  1290. target_link_libraries(h2o PRIVATE ${OPENSSL_LIBRARIES})
  1291. endif()
  1292. #
  1293. # build libjudy
  1294. #
  1295. add_library(judy STATIC ${LIBJUDY_SOURCES})
  1296. target_compile_options(judy PUBLIC
  1297. -Wno-sign-compare
  1298. -Wno-implicit-fallthrough
  1299. )
  1300. target_compile_definitions(judy PUBLIC
  1301. JUDYL
  1302. $<$<EQUAL:${CMAKE_SIZEOF_VOID_P},8>:JU_64BIT>
  1303. )
  1304. target_include_directories(judy PUBLIC
  1305. libnetdata/libjudy/src
  1306. libnetdata/libjudy/src/JudyCommon
  1307. )
  1308. set_source_files_properties(${LIBJUDY_PREV_FILES} PROPERTIES COMPILE_OPTIONS "-DJUDYPREV")
  1309. set_source_files_properties(${LIBJUDY_NEXT_FILES} PROPERTIES COMPILE_OPTIONS "-DJUDYNEXT")
  1310. set_source_files_properties(libnetdata/libjudy/src/JudyL/j__udyLGet.c PROPERTIES COMPILE_OPTIONS "-DJUDYGETINLINE")
  1311. set_source_files_properties(libnetdata/libjudy/src/JudyL/JudyLByCount.c PROPERTIES COMPILE_OPTIONS "-DNOSMARTJBB -DNOSMARTJBU -DNOSMARTJLB")
  1312. set_source_files_properties(JudyLTables.c PROPERTIES COMPILE_OPTIONS "-I${CMAKE_SOURCE_DIR}/libnetdata/libjudy/src/JudyL")
  1313. #
  1314. # build libnetdata
  1315. #
  1316. include(systemd.cmake)
  1317. add_library(libnetdata STATIC ${LIBNETDATA_FILES})
  1318. target_include_directories(libnetdata BEFORE PUBLIC ${CONFIG_H_DIR} ${CMAKE_SOURCE_DIR})
  1319. # pthread (FIXME: use find_package for this)
  1320. # set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
  1321. # set(THREADS_PREFER_PTHREAD_FLAG TRUE)
  1322. # find_package(Threads REQUIRED)
  1323. # add_executable(test test.cpp)
  1324. # target_link_libraries(test Threads::Threads)
  1325. target_link_libraries(libnetdata PUBLIC
  1326. "$<$<NOT:$<BOOL:${HAVE_BUILTIN_ATOMICS}>>:atomic>"
  1327. "$<$<OR:$<BOOL:${LINUX}>,$<BOOL:${FREEBSD}>>:pthread;rt>"
  1328. "$<$<BOOL:${LINK_LIBM}>:m>"
  1329. "${SYSTEMD_LDFLAGS}")
  1330. # ebpf
  1331. if(ENABLE_PLUGIN_EBPF)
  1332. target_link_libraries(libnetdata PUBLIC ${CMAKE_SOURCE_DIR}/externaldeps/libbpf/libbpf.a)
  1333. target_include_directories(libnetdata BEFORE PUBLIC
  1334. ${CMAKE_SOURCE_DIR}/externaldeps/libbpf/include
  1335. ${CMAKE_SOURCE_DIR}/externaldeps/libbpf/include/uapi
  1336. )
  1337. pkg_check_modules(ELF REQUIRED libelf)
  1338. target_include_directories(libnetdata BEFORE PUBLIC ${ELF_INCLUDE_DIRS})
  1339. target_compile_options(libnetdata PUBLIC ${ELF_CFLAGS_OTHER})
  1340. target_link_libraries(libnetdata PUBLIC ${ELF_LIBRARIES})
  1341. endif()
  1342. # judy
  1343. target_link_libraries(libnetdata PUBLIC judy)
  1344. # json-c
  1345. if(ENABLE_BUNDLED_JSONC)
  1346. add_library(jsonc STATIC IMPORTED)
  1347. set_property(TARGET jsonc PROPERTY
  1348. IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/externaldeps/jsonc/libjson-c.a")
  1349. target_include_directories(libnetdata BEFORE PUBLIC "${CMAKE_SOURCE_DIR}/externaldeps/jsonc")
  1350. target_link_libraries(libnetdata PUBLIC jsonc)
  1351. else()
  1352. pkg_check_modules(JSONC REQUIRED json-c)
  1353. target_include_directories(libnetdata BEFORE PUBLIC ${JSONC_INCLUDE_DIRS})
  1354. target_compile_definitions(libnetdata PUBLIC ${JSONC_CFLAGS_OTHER})
  1355. target_link_libraries(libnetdata PUBLIC ${JSONC_LDFLAGS})
  1356. endif()
  1357. # message(FATAL_ERROR "jsonc libraries: ${JSONC_LIBRARIES}")
  1358. # message(FATAL_ERROR "jsonc ldflags: ${JSONC_LDFLAGS}")
  1359. # yaml
  1360. set(HAVE_LIBYAML True)
  1361. if(ENABLE_BUNDLED_YAML)
  1362. add_library(yaml STATIC IMPORTED)
  1363. set_property(TARGET yaml PROPERTY
  1364. IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/externaldeps/libyaml/libyaml.a")
  1365. target_include_directories(libnetdata BEFORE PUBLIC "${CMAKE_SOURCE_DIR}/externaldeps/libyaml")
  1366. target_link_libraries(libnetdata PUBLIC yaml)
  1367. else()
  1368. pkg_check_modules(YAML REQUIRED yaml-0.1)
  1369. target_include_directories(libnetdata BEFORE PUBLIC ${YAML_INCLUDE_DIRS})
  1370. target_compile_definitions(libnetdata PUBLIC ${YAML_CFLAGS_OTHER})
  1371. target_link_libraries(libnetdata PUBLIC ${YAML_LDFLAGS})
  1372. endif()
  1373. # zlib
  1374. pkg_check_modules(ZLIB REQUIRED zlib)
  1375. target_include_directories(libnetdata BEFORE PUBLIC ${ZLIB_INCLUDE_DIRS})
  1376. target_compile_definitions(libnetdata PUBLIC ${ZLIB_CFLAGS_OTHER})
  1377. target_link_libraries(libnetdata PUBLIC ${ZLIB_LDFLAGS})
  1378. # lz4 - try to find a version that is compatible with streaming compression
  1379. # otherwise pick whichever one we can find to support dbengine but don't set
  1380. # ENABLE_LZ4.
  1381. pkg_check_modules(LIBLZ4 liblz4>=1.9.0)
  1382. if(LIBLZ4_FOUND)
  1383. set(ENABLE_LZ4 On)
  1384. else()
  1385. pkg_check_modules(LIBLZ4 REQUIRED liblz4)
  1386. endif()
  1387. target_include_directories(libnetdata BEFORE PUBLIC ${LIBLZ4_INCLUDE_DIRS})
  1388. target_compile_definitions(libnetdata PUBLIC ${LIBLZ4_CFLAGS_OTHER})
  1389. target_link_libraries(libnetdata PUBLIC ${LIBLZ4_LDFLAGS})
  1390. # zstd
  1391. pkg_check_modules(LIBZSTD libzstd)
  1392. if(LIBZSTD_FOUND)
  1393. set(ENABLE_ZSTD On)
  1394. target_include_directories(libnetdata BEFORE PUBLIC ${LIBZSTD_INCLUDE_DIRS})
  1395. target_compile_definitions(libnetdata PUBLIC ${LIBZSTD_CFLAGS_OTHER})
  1396. target_link_libraries(libnetdata PUBLIC ${LIBZSTD_LDFLAGS})
  1397. endif()
  1398. # brotli
  1399. pkg_check_modules(LIBBROTLI libbrotlidec libbrotlienc libbrotlicommon)
  1400. if(LIBBROTLI_FOUND)
  1401. set(ENABLE_BROTLI On)
  1402. target_include_directories(libnetdata BEFORE PUBLIC ${LIBBROTLI_INCLUDE_DIRS})
  1403. target_compile_definitions(libnetdata PUBLIC ${LIBBROTLI_CFLAGS_OTHER})
  1404. target_link_libraries(libnetdata PUBLIC ${LIBBROTLI_LDFLAGS})
  1405. endif()
  1406. # uuid
  1407. pkg_check_modules(UUID REQUIRED uuid)
  1408. target_include_directories(libnetdata BEFORE PUBLIC ${UUID_INCLUDE_DIRS})
  1409. target_compile_definitions(libnetdata PUBLIC ${UUID_CFLAGS_OTHER})
  1410. target_link_libraries(libnetdata PUBLIC ${UUID_LDFLAGS})
  1411. # uv
  1412. pkg_check_modules(LIBUV REQUIRED libuv)
  1413. target_include_directories(libnetdata BEFORE PUBLIC ${LIBUV_INCLUDE_DIRS})
  1414. target_compile_definitions(libnetdata PUBLIC ${LIBUV_CFLAGS_OTHER})
  1415. target_link_libraries(libnetdata PUBLIC ${LIBUV_LDFLAGS})
  1416. # crypto
  1417. target_include_directories(libnetdata BEFORE PUBLIC ${CRYPTO_INCLUDE_DIRS})
  1418. target_compile_options(libnetdata PUBLIC ${CRYPTO_CFLAGS_OTHER})
  1419. target_link_libraries(libnetdata PUBLIC ${CRYPTO_LDFLAGS})
  1420. # openssl
  1421. target_include_directories(libnetdata BEFORE PUBLIC ${OPENSSL_INCLUDE_DIRS})
  1422. target_compile_options(libnetdata PUBLIC ${OPENSSL_CFLAGS_OTHER})
  1423. target_link_libraries(libnetdata PUBLIC ${OPENSSL_LDFLAGS})
  1424. # h2o
  1425. target_link_libraries(libnetdata PUBLIC "$<$<BOOL:${ENABLE_H2O}>:h2o>")
  1426. #
  1427. # helper function to build protos
  1428. #
  1429. function(protoc_generate_cpp INC_DIR OUT_DIR SRCS HDRS)
  1430. if(NOT ARGN)
  1431. message(SEND_ERROR "Error: protoc_generate_cpp() called without any proto files")
  1432. return()
  1433. endif()
  1434. set(${INC_DIR})
  1435. set(${OUT_DIR})
  1436. set(${SRCS})
  1437. set(${HDRS})
  1438. foreach(FIL ${ARGN})
  1439. get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
  1440. get_filename_component(DIR ${ABS_FIL} DIRECTORY)
  1441. get_filename_component(FIL_WE ${FIL} NAME_WE)
  1442. set(GENERATED_PB_CC "${DIR}/${FIL_WE}.pb.cc")
  1443. list(APPEND ${SRCS} ${GENERATED_PB_CC})
  1444. set(GENERATED_PB_H "${DIR}/${FIL_WE}.pb.h")
  1445. list(APPEND ${HDRS} ${GENERATED_PB_H})
  1446. add_custom_command(OUTPUT ${GENERATED_PB_CC} ${GENERATED_PB_H}
  1447. COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} ARGS -I=${INC_DIR} --cpp_out=${OUT_DIR} ${ABS_FIL}
  1448. DEPENDS ${ABS_FIL} ${PROTOBUF_PROTOC_EXECUTABLE}
  1449. COMMENT "Running C++ protocol buffer compiler on ${FIL}"
  1450. VERBATIM)
  1451. endforeach()
  1452. set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES GENERATED TRUE)
  1453. set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES COMPILE_OPTIONS -Wno-deprecated-declarations)
  1454. set(${SRCS} ${${SRCS}} PARENT_SCOPE)
  1455. set(${HDRS} ${${HDRS}} PARENT_SCOPE)
  1456. endfunction()
  1457. #
  1458. # mqtt library
  1459. #
  1460. if (ENABLE_H2O OR ENABLE_ACLK)
  1461. set(ENABLE_MQTTWEBSOCKETS True)
  1462. endif()
  1463. if(ENABLE_MQTTWEBSOCKETS)
  1464. include_directories(BEFORE
  1465. ${CMAKE_SOURCE_DIR}/mqtt_websockets/src/include
  1466. ${CMAKE_SOURCE_DIR}/mqtt_websockets/c-rbuf/include
  1467. ${CMAKE_SOURCE_DIR}/mqtt_websockets/c_rhash/include
  1468. )
  1469. add_library(mqttwebsockets STATIC ${MQTT_WEBSOCKETS_FILES})
  1470. target_compile_options(mqttwebsockets PUBLIC -DMQTT_WSS_CUSTOM_ALLOC
  1471. -DRBUF_CUSTOM_MALLOC
  1472. -DMQTT_WSS_CPUSTATS)
  1473. target_include_directories(mqttwebsockets PUBLIC ${CMAKE_SOURCE_DIR}/aclk/helpers
  1474. ${CMAKE_SOURCE_DIR}/web/server/h2o/libh2o/include)
  1475. target_link_libraries(mqttwebsockets PRIVATE libnetdata)
  1476. endif()
  1477. if(ENABLE_ACLK)
  1478. #
  1479. # proto definitions
  1480. #
  1481. protoc_generate_cpp("${CMAKE_SOURCE_DIR}/aclk/aclk-schemas"
  1482. "${CMAKE_SOURCE_DIR}/aclk/aclk-schemas"
  1483. ACLK_PROTO_BUILT_SRCS
  1484. ACLK_PROTO_BUILT_HDRS
  1485. ${ACLK_PROTO_DEFS})
  1486. list(APPEND ACLK_FILES ${ACLK_PROTO_BUILT_SRCS}
  1487. ${ACLK_PROTO_BUILT_HDRS})
  1488. endif()
  1489. #
  1490. # build plugins
  1491. #
  1492. if(ENABLE_PLUGIN_DEBUGFS)
  1493. pkg_check_modules(CAP QUIET libcap)
  1494. set(DEBUGFS_PLUGIN_FILES collectors/debugfs.plugin/debugfs_plugin.c
  1495. collectors/debugfs.plugin/debugfs_plugin.h
  1496. collectors/debugfs.plugin/debugfs_extfrag.c
  1497. collectors/debugfs.plugin/debugfs_zswap.c
  1498. collectors/debugfs.plugin/sys_devices_virtual_powercap.c)
  1499. add_executable(debugfs.plugin ${DEBUGFS_PLUGIN_FILES})
  1500. target_link_libraries(debugfs.plugin libnetdata ${CAP_LIBRARIES})
  1501. target_include_directories(debugfs.plugin PRIVATE ${CAP_INCLUDE_DIRS})
  1502. target_compile_options(debugfs.plugin PRIVATE ${CAP_CFLAGS_OTHER})
  1503. install(TARGETS debugfs.plugin
  1504. COMPONENT debugfs_plugin
  1505. DESTINATION usr/libexec/netdata/plugins.d)
  1506. endif()
  1507. if(ENABLE_PLUGIN_APPS)
  1508. pkg_check_modules(CAP QUIET libcap)
  1509. set(APPS_PLUGIN_FILES collectors/apps.plugin/apps_plugin.c)
  1510. add_executable(apps.plugin ${APPS_PLUGIN_FILES})
  1511. target_link_libraries(apps.plugin libnetdata ${CAP_LIBRARIES})
  1512. target_include_directories(apps.plugin PRIVATE ${CAP_INCLUDE_DIRS})
  1513. target_compile_options(apps.plugin PRIVATE ${CAP_CFLAGS_OTHER})
  1514. install(TARGETS apps.plugin
  1515. COMPONENT apps_plugin
  1516. DESTINATION usr/libexec/netdata/plugins.d)
  1517. install(FILES collectors/apps.plugin/apps_groups.conf
  1518. COMPONENT apps_plugin
  1519. DESTINATION usr/lib/netdata/conf.d)
  1520. endif()
  1521. if(CAP_FOUND)
  1522. set(HAVE_CAPABILITY True)
  1523. endif()
  1524. if(ENABLE_PLUGIN_FREEIPMI)
  1525. pkg_check_modules(IPMI REQUIRED libipmimonitoring)
  1526. set(FREEIPMI_PLUGIN_FILES collectors/freeipmi.plugin/freeipmi_plugin.c)
  1527. add_executable(freeipmi.plugin ${FREEIPMI_PLUGIN_FILES})
  1528. target_link_libraries (freeipmi.plugin libnetdata ${IPMI_LIBRARIES})
  1529. target_include_directories(freeipmi.plugin PRIVATE ${IPMI_INCLUDE_DIRS})
  1530. target_compile_options(freeipmi.plugin PRIVATE ${IPMI_CFLAGS_OTHER})
  1531. install(TARGETS freeipmi.plugin
  1532. COMPONENT freeipmi_plugin
  1533. DESTINATION usr/libexec/netdata/plugins.d)
  1534. endif()
  1535. if(ENABLE_PLUGIN_NFACCT)
  1536. pkg_check_modules(NFACCT REQUIRED libnetfilter_acct)
  1537. pkg_check_modules(MNL REQUIRED libmnl)
  1538. set(NFACCT_PLUGIN_FILES collectors/nfacct.plugin/plugin_nfacct.c)
  1539. add_executable(nfacct.plugin ${NFACCT_PLUGIN_FILES})
  1540. target_link_libraries (nfacct.plugin libnetdata ${MNL_LIBRARIES} ${NFACCT_LIBRARIES})
  1541. target_include_directories(nfacct.plugin PRIVATE ${MNL_INCLUDE_DIRS} ${NFACCT_INCLUDE_DIRS})
  1542. target_compile_options(nfacct.plugin PRIVATE ${MNL_CFLAGS_OTHER} ${NFACCT_CFLAGS_OTHER})
  1543. install(TARGETS nfacct.plugin
  1544. COMPONENT nfacct_plugin
  1545. DESTINATION usr/libexec/netdata/plugins.d)
  1546. endif()
  1547. if(ENABLE_PLUGIN_XENSTAT)
  1548. pkg_check_modules(XENSTAT REQUIRED xenstat)
  1549. pkg_check_modules(XENLIGHT REQUIRED xenlight)
  1550. set(XENSTAT_PLUGIN_FILES collectors/xenstat.plugin/xenstat_plugin.c)
  1551. add_executable(xenstat.plugin ${XENSTAT_PLUGIN_FILES})
  1552. target_link_libraries (xenstat.plugin libnetdata ${XENLIGHT_LIBRARIES} ${XENSTAT_LIBRARIES})
  1553. target_include_directories(xenstat.plugin PRIVATE ${XENLIGHT_INCLUDE_DIRS} ${XENSTAT_INCLUDE_DIRS})
  1554. target_compile_options(xenstat.plugin PRIVATE ${XENLIGHT_CFLAGS_OTHER} ${XENSTAT_CFLAGS_OTHER})
  1555. install(TARGETS xenstat.plugin
  1556. COMPONENT xenstat_plugin
  1557. DESTINATION usr/libexec/netdata/plugins.d)
  1558. endif()
  1559. if(ENABLE_PLUGIN_PERF)
  1560. set(PERF_PLUGIN_FILES collectors/perf.plugin/perf_plugin.c)
  1561. add_executable(perf.plugin ${PERF_PLUGIN_FILES})
  1562. target_link_libraries(perf.plugin libnetdata)
  1563. install(TARGETS perf.plugin
  1564. COMPONENT perf_plugin
  1565. DESTINATION usr/libexec/netdata/plugins.d)
  1566. endif()
  1567. if(ENABLE_PLUGIN_SLABINFO)
  1568. set(SLABINFO_PLUGIN_FILES collectors/slabinfo.plugin/slabinfo.c)
  1569. add_executable(slabinfo.plugin ${SLABINFO_PLUGIN_FILES})
  1570. target_link_libraries(slabinfo.plugin libnetdata)
  1571. install(TARGETS slabinfo.plugin
  1572. COMPONENT slabinfo_plugin
  1573. DESTINATION usr/libexec/netdata/plugins.d)
  1574. endif()
  1575. if(ENABLE_PLUGIN_LOGS_MANAGEMENT)
  1576. set(ENABLE_LOGSMANAGEMENT True)
  1577. if(ENABLE_LOGS_MANAGEMENT_TESTS)
  1578. list(APPEND LOGS_MANAGEMENT_PLUGIN_FILES logsmanagement/unit_test/unit_test.c
  1579. logsmanagement/unit_test/unit_test.h)
  1580. set(ENABLE_LOGSMANAGEMENT_TESTS True)
  1581. endif()
  1582. add_executable(logs-management.plugin ${LOGS_MANAGEMENT_PLUGIN_FILES})
  1583. target_link_libraries(logs-management.plugin libnetdata)
  1584. install(TARGETS logs-management.plugin
  1585. COMPONENT logs_management_plugin
  1586. DESTINATION usr/libexec/netdata/plugins.d)
  1587. install(DIRECTORY logsmanagement/stock_conf/logsmanagement.d
  1588. COMPONENT logs_management_plugin
  1589. DESTINATION usr/lib/netdata/conf.d)
  1590. install(DIRECTORY DESTINATION etc/netdata/logsmanagement.d)
  1591. endif()
  1592. if(ENABLE_PLUGIN_CUPS)
  1593. pkg_check_modules(CUPS libcups)
  1594. if(NOT CUPS_LIBRARIES)
  1595. pkg_check_modules(CUPS cups)
  1596. if(NOT CUPS_LIBRARIES)
  1597. find_program(CUPS_CONFIG cups-config)
  1598. if(CUPS_CONFIG)
  1599. execute_process(COMMAND ${CUPS_CONFIG} --api-version OUTPUT_VARIABLE CUPS_API_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
  1600. if(CUPS_API_VERSION VERSION_LESS "1.7")
  1601. set(CUPS_FOUND False)
  1602. else()
  1603. execute_process(COMMAND ${CUPS_CONFIG} --cflags OUTPUT_VARIABLE CUPS_CFLAGS_OTHER OUTPUT_STRIP_TRAILING_WHITESPACE)
  1604. execute_process(COMMAND ${CUPS_CONFIG} --libs OUTPUT_VARIABLE CUPS_LIBRARIES OUTPUT_STRIP_TRAILING_WHITESPACE)
  1605. set(CUPS_FOUND True)
  1606. endif()
  1607. endif()
  1608. endif()
  1609. endif()
  1610. if(NOT CUPS_FOUND)
  1611. message(WARNING "Could not find cups cflags and libs.")
  1612. else()
  1613. set(CUPS_PLUGIN_FILES collectors/cups.plugin/cups_plugin.c)
  1614. add_executable(cups.plugin ${CUPS_PLUGIN_FILES})
  1615. target_link_libraries (cups.plugin libnetdata ${CUPS_LIBRARIES})
  1616. target_compile_options(cups.plugin PRIVATE ${CUPS_CFLAGS_OTHER})
  1617. install(TARGETS cups.plugin
  1618. COMPONENT cups_plugin
  1619. DESTINATION usr/libexec/netdata/plugins.d)
  1620. endif()
  1621. endif()
  1622. set(NDSUDO_FILES collectors/plugins.d/ndsudo.c)
  1623. add_executable(ndsudo ${NDSUDO_FILES})
  1624. install(TARGETS ndsudo
  1625. COMPONENT ndsudo
  1626. DESTINATION usr/libexec/netdata/plugins.d)
  1627. if(ENABLE_PLUGIN_CGROUP_NETWORK)
  1628. set(CGROUP_NETWORK_FILES collectors/cgroups.plugin/cgroup-network.c)
  1629. add_executable(cgroup-network ${CGROUP_NETWORK_FILES})
  1630. target_link_libraries(cgroup-network libnetdata)
  1631. install(TARGETS cgroup-network
  1632. COMPONENT cgroup_network_plugin
  1633. DESTINATION usr/libexec/netdata/plugins.d)
  1634. endif()
  1635. if(ENABLE_PLUGIN_SYSTEMD_JOURNAL)
  1636. add_executable(systemd-journal.plugin ${SYSTEMD_JOURNAL_PLUGIN_FILES})
  1637. target_link_libraries(systemd-journal.plugin libnetdata)
  1638. install(TARGETS systemd-journal.plugin
  1639. COMPONENT systemd_journal_plugin
  1640. DESTINATION usr/libexec/netdata/plugins.d)
  1641. endif()
  1642. if(ENABLE_PLUGIN_EBPF)
  1643. set(EBPF_PLUGIN_FILES
  1644. collectors/ebpf.plugin/ebpf.c
  1645. collectors/ebpf.plugin/ebpf.h
  1646. collectors/ebpf.plugin/ebpf_cachestat.c
  1647. collectors/ebpf.plugin/ebpf_cachestat.h
  1648. collectors/ebpf.plugin/ebpf_dcstat.c
  1649. collectors/ebpf.plugin/ebpf_dcstat.h
  1650. collectors/ebpf.plugin/ebpf_disk.c
  1651. collectors/ebpf.plugin/ebpf_disk.h
  1652. collectors/ebpf.plugin/ebpf_fd.c
  1653. collectors/ebpf.plugin/ebpf_fd.h
  1654. collectors/ebpf.plugin/ebpf_hardirq.c
  1655. collectors/ebpf.plugin/ebpf_hardirq.h
  1656. collectors/ebpf.plugin/ebpf_mdflush.c
  1657. collectors/ebpf.plugin/ebpf_mdflush.h
  1658. collectors/ebpf.plugin/ebpf_mount.c
  1659. collectors/ebpf.plugin/ebpf_mount.h
  1660. collectors/ebpf.plugin/ebpf_filesystem.c
  1661. collectors/ebpf.plugin/ebpf_filesystem.h
  1662. collectors/ebpf.plugin/ebpf_oomkill.c
  1663. collectors/ebpf.plugin/ebpf_oomkill.h
  1664. collectors/ebpf.plugin/ebpf_process.c
  1665. collectors/ebpf.plugin/ebpf_process.h
  1666. collectors/ebpf.plugin/ebpf_shm.c
  1667. collectors/ebpf.plugin/ebpf_shm.h
  1668. collectors/ebpf.plugin/ebpf_socket.c
  1669. collectors/ebpf.plugin/ebpf_socket.h
  1670. collectors/ebpf.plugin/ebpf_softirq.c
  1671. collectors/ebpf.plugin/ebpf_softirq.h
  1672. collectors/ebpf.plugin/ebpf_sync.c
  1673. collectors/ebpf.plugin/ebpf_sync.h
  1674. collectors/ebpf.plugin/ebpf_swap.c
  1675. collectors/ebpf.plugin/ebpf_swap.h
  1676. collectors/ebpf.plugin/ebpf_vfs.c
  1677. collectors/ebpf.plugin/ebpf_vfs.h
  1678. collectors/ebpf.plugin/ebpf_apps.c
  1679. collectors/ebpf.plugin/ebpf_apps.h
  1680. collectors/ebpf.plugin/ebpf_cgroup.c
  1681. collectors/ebpf.plugin/ebpf_cgroup.h
  1682. collectors/ebpf.plugin/ebpf_unittest.c
  1683. collectors/ebpf.plugin/ebpf_unittest.h
  1684. collectors/ebpf.plugin/ebpf_functions.c
  1685. collectors/ebpf.plugin/ebpf_functions.h
  1686. )
  1687. add_executable(ebpf.plugin ${EBPF_PLUGIN_FILES})
  1688. target_link_libraries(ebpf.plugin libnetdata)
  1689. install(TARGETS ebpf.plugin
  1690. COMPONENT ebpf_plugin
  1691. DESTINATION usr/libexec/netdata/plugins.d)
  1692. endif()
  1693. if(ENABLE_PLUGIN_LOCAL_LISTENERS)
  1694. set(LOCAL_LISTENERS_FILES collectors/plugins.d/local_listeners.c)
  1695. add_executable(local-listeners ${LOCAL_LISTENERS_FILES})
  1696. target_link_libraries(local-listeners libnetdata)
  1697. install(TARGETS local-listeners
  1698. COMPONENT local_listeners
  1699. DESTINATION usr/libexec/netdata/plugins.d)
  1700. endif()
  1701. #
  1702. # exporters
  1703. #
  1704. if(ENABLE_EXPORTER_MONGODB)
  1705. pkg_check_modules(MONGOC libmongoc-1.0>=1.7)
  1706. if(MONGOC_FOUND)
  1707. SET(HAVE_MONGOC True)
  1708. else()
  1709. SET(ENABLE_EXPORTER_MONGODB False)
  1710. endif()
  1711. endif()
  1712. if(ENABLE_EXPORTER_PROMETHEUS_REMOTE_WRITE)
  1713. pkg_check_modules(SNAPPY snappy)
  1714. if (NOT SNAPPY_FOUND)
  1715. if(HAVE_SNAPPY_LIB)
  1716. set(SNAPPY_INCLUDE_DIRS "")
  1717. set(SNAPPY_CFLAGS_OTHER "")
  1718. set(SNAPPY_LIBRARIES "-lsnappy")
  1719. else()
  1720. message(FATAL_ERROR "Could not find snappy libraries with pkg-config or internal cmake checks.")
  1721. endif()
  1722. endif()
  1723. protoc_generate_cpp("${CMAKE_SOURCE_DIR}/exporting/prometheus/remote_write"
  1724. "${CMAKE_SOURCE_DIR}/exporting/prometheus/remote_write"
  1725. PROMETHEUS_REMOTE_WRITE_BUILT_SRCS
  1726. PROMETHEUS_REMOTE_WRITE_BUILT_HDRS
  1727. "exporting/prometheus/remote_write/remote_write.proto")
  1728. list(APPEND PROMETHEUS_REMOTE_WRITE_EXPORTING_FILES
  1729. ${PROMETHEUS_REMOTE_WRITE_BUILT_SRCS}
  1730. ${PROMETHEUS_REMOTE_WRITE_BUILT_HDRS})
  1731. set(ENABLE_PROMETHEUS_REMOTE_WRITE True)
  1732. endif()
  1733. #
  1734. # build netdata (only Linux ATM)
  1735. #
  1736. add_executable(netdata
  1737. ${NETDATA_FILES}
  1738. "$<$<BOOL:${ENABLE_ACLK}>:${ACLK_FILES}>"
  1739. "$<$<BOOL:${ENABLE_H2O}>:${H2O_FILES}>"
  1740. "$<$<BOOL:${ENABLE_EXPORTER_MONGODB}>:${MONGODB_EXPORTING_FILES}>"
  1741. "$<$<BOOL:${ENABLE_EXPORTER_PROMETHEUS_REMOTE_WRITE}>:${PROMETHEUS_REMOTE_WRITE_EXPORTING_FILES}>"
  1742. )
  1743. target_compile_definitions(netdata PRIVATE
  1744. "$<$<BOOL:${ENABLE_PROTOBUF}>:${PROTOBUF_CFLAGS_OTHER}>"
  1745. "$<$<BOOL:${ENABLE_ML}>:DLIB_NO_GUI_SUPPORT>"
  1746. "$<$<BOOL:${ENABLE_EXPORTER_MONGODB}>:${MONGOC_CFLAGS_OTHER}>"
  1747. "$<$<BOOL:${ENABLE_EXPORTER_PROMETHEUS_REMOTE_WRITE}>:${SNAPPY_CFLAGS_OTHER}>"
  1748. )
  1749. target_include_directories(netdata PRIVATE
  1750. "$<$<BOOL:${ENABLE_PROTOBUF}>:${PROTOBUF_INCLUDE_DIRS}>"
  1751. "$<$<BOOL:${ENABLE_ACLK}>:${CMAKE_SOURCE_DIR}/aclk/aclk-schemas>"
  1752. "$<$<BOOL:${ENABLE_MQTTWEBSOCKETS}>:${CMAKE_SOURCE_DIR}/mqtt_websockets/src/include>"
  1753. "$<$<BOOL:${ENABLE_MQTTWEBSOCKETS}>:${CMAKE_SOURCE_DIR}/mqtt_websockets/c-rbuf/include>"
  1754. "$<$<BOOL:${ENABLE_ML}>:${CMAKE_SOURCE_DIR}/ml/dlib>"
  1755. "$<$<BOOL:${ENABLE_EXPORTER_MONGODB}>:${MONGOC_INCLUDE_DIRS}>"
  1756. "$<$<BOOL:${ENABLE_EXPORTER_PROMETHEUS_REMOTE_WRITE}>:${SNAPPY_INCLUDE_DIRS}>"
  1757. )
  1758. target_link_libraries(netdata PRIVATE
  1759. m
  1760. libnetdata
  1761. "$<$<BOOL:${LINUX}>:rt>"
  1762. "$<$<BOOL:${ENABLE_MQTTWEBSOCKETS}>:mqttwebsockets>"
  1763. "$<$<BOOL:${ENABLE_PROTOBUF}>:${PROTOBUF_LIBRARIES}>"
  1764. "$<$<BOOL:${ENABLE_EXPORTER_MONGODB}>:${MONGOC_LIBRARIES}>"
  1765. "$<$<BOOL:${ENABLE_EXPORTER_PROMETHEUS_REMOTE_WRITE}>:${SNAPPY_LIBRARIES}>"
  1766. "$<$<BOOL:${MACOS}>:${IOKIT};${FOUNDATION}>"
  1767. )
  1768. #
  1769. # build systemd-cat-native
  1770. #
  1771. set(SYSTEMD_CAT_NATIVE_FILES libnetdata/log/systemd-cat-native.c
  1772. libnetdata/log/systemd-cat-native.h)
  1773. add_executable(systemd-cat-native ${SYSTEMD_CAT_NATIVE_FILES})
  1774. target_link_libraries(systemd-cat-native libnetdata)
  1775. install(TARGETS systemd-cat-native
  1776. COMPONENT systemd-cat-native
  1777. DESTINATION usr/sbin)
  1778. #
  1779. # build log2journal
  1780. #
  1781. pkg_check_modules(PCRE2 libpcre2-8)
  1782. if(PCRE2_FOUND)
  1783. set(LOG2JOURNAL_FILES
  1784. ${CONFIG_H}
  1785. collectors/log2journal/log2journal.h
  1786. collectors/log2journal/log2journal.c
  1787. collectors/log2journal/log2journal-help.c
  1788. collectors/log2journal/log2journal-yaml.c
  1789. collectors/log2journal/log2journal-json.c
  1790. collectors/log2journal/log2journal-logfmt.c
  1791. collectors/log2journal/log2journal-pcre2.c
  1792. collectors/log2journal/log2journal-params.c
  1793. collectors/log2journal/log2journal-inject.c
  1794. collectors/log2journal/log2journal-pattern.c
  1795. collectors/log2journal/log2journal-replace.c
  1796. collectors/log2journal/log2journal-rename.c
  1797. collectors/log2journal/log2journal-rewrite.c
  1798. )
  1799. add_executable(log2journal ${LOG2JOURNAL_FILES})
  1800. target_include_directories(log2journal BEFORE PUBLIC ${CONFIG_H_DIR} ${PCRE2_INCLUDE_DIRS})
  1801. target_compile_definitions(log2journal PUBLIC ${PCRE2_CFLAGS_OTHER})
  1802. target_link_libraries(log2journal PUBLIC "${PCRE2_LDFLAGS}")
  1803. if(ENABLE_BUNDLED_YAML)
  1804. target_include_directories(log2journal BEFORE PUBLIC "${CMAKE_SOURCE_DIR}/externaldeps/libyaml")
  1805. target_link_libraries(log2journal PUBLIC yaml)
  1806. else()
  1807. target_include_directories(log2journal BEFORE PUBLIC ${YAML_INCLUDE_DIRS})
  1808. target_compile_definitions(log2journal PUBLIC ${YAML_CFLAGS_OTHER})
  1809. target_link_libraries(log2journal PUBLIC ${YAML_LDFLAGS})
  1810. endif()
  1811. install(TARGETS log2journal
  1812. COMPONENT log2journal
  1813. DESTINATION usr/sbin)
  1814. install(DIRECTORY collectors/log2journal/log2journal.d
  1815. COMPONENT log2journal
  1816. DESTINATION usr/lib/netdata/conf.d)
  1817. endif()
  1818. #
  1819. # build netdatacli
  1820. #
  1821. set(NETDATACLI_FILES
  1822. daemon/commands.h
  1823. daemon/pipename.c
  1824. daemon/pipename.h
  1825. cli/cli.c
  1826. )
  1827. add_executable(netdatacli ${NETDATACLI_FILES})
  1828. target_link_libraries(netdatacli libnetdata)
  1829. install(TARGETS netdatacli
  1830. COMPONENT netdatacli
  1831. DESTINATION usr/sbin)
  1832. #
  1833. # Generate config file
  1834. #
  1835. add_definitions(-DHAVE_CONFIG_H)
  1836. set(STORAGE_WITH_MATH On)
  1837. if(NOT CMAKE_INSTALL_PREFIX STREQUAL "")
  1838. string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
  1839. endif()
  1840. set(CACHE_DIR "${CMAKE_INSTALL_PREFIX}/var/cache/netdata")
  1841. set(CONFIG_DIR "${CMAKE_INSTALL_PREFIX}/etc/netdata")
  1842. set(LIBCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/usr/lib/netdata/conf.d")
  1843. set(LOG_DIR "${CMAKE_INSTALL_PREFIX}/var/log/netdata")
  1844. set(PLUGINS_DIR "${CMAKE_INSTALL_PREFIX}/usr/libexec/netdata/plugins.d")
  1845. set(VARLIB_DIR "${CMAKE_INSTALL_PREFIX}/var/lib/netdata")
  1846. # A non-default value is only used when building Debian packages (/var/lib/netdata/www)
  1847. if(NOT DEFINED WEB_DIR)
  1848. set(WEB_DIR "usr/share/netdata/web")
  1849. else()
  1850. string(REGEX REPLACE "^/" "" WEB_DIR "${WEB_DIR}")
  1851. endif()
  1852. set(WEB_DEST "${WEB_DIR}")
  1853. set(WEB_DIR "${CMAKE_INSTALL_PREFIX}/${WEB_DEST}")
  1854. set(CONFIGURE_COMMAND "dummy-configure-command")
  1855. if (NOT NETDATA_USER)
  1856. set(NETDATA_USER "netdata")
  1857. endif()
  1858. set(VERSION "${GIT_DESCRIBE_OUTPUT}")
  1859. configure_file(config.cmake.h.in config.h)
  1860. #
  1861. # install
  1862. #
  1863. install(TARGETS netdata DESTINATION usr/sbin)
  1864. install(DIRECTORY DESTINATION var/cache/netdata)
  1865. install(DIRECTORY DESTINATION var/log/netdata)
  1866. install(DIRECTORY DESTINATION var/lib/netdata/registry)
  1867. install(DIRECTORY DESTINATION var/lib/netdata/cloud.d)
  1868. install(DIRECTORY DESTINATION var/run)
  1869. install(DIRECTORY DESTINATION etc/netdata)
  1870. install(DIRECTORY DESTINATION etc/netdata/charts.d)
  1871. install(DIRECTORY DESTINATION etc/netdata/custom-plugins.d)
  1872. install(DIRECTORY DESTINATION etc/netdata/ebpf.d)
  1873. install(DIRECTORY DESTINATION etc/netdata/go.d)
  1874. install(DIRECTORY DESTINATION etc/netdata/health.d)
  1875. install(DIRECTORY DESTINATION etc/netdata/python.d)
  1876. install(DIRECTORY DESTINATION etc/netdata/ssl)
  1877. install(DIRECTORY DESTINATION etc/netdata/statsd.d)
  1878. install(DIRECTORY DESTINATION usr/lib/netdata/conf.d)
  1879. install(DIRECTORY DESTINATION usr/lib/netdata/conf.d/schema.d)
  1880. install(DIRECTORY DESTINATION usr/libexec/netdata/plugins.d)
  1881. install(DIRECTORY DESTINATION ${WEB_DEST})
  1882. set(libsysdir_POST "${CMAKE_INSTALL_PREFIX}/usr/lib/netdata/system")
  1883. set(pkglibexecdir_POST "${CMAKE_INSTALL_PREFIX}/usr/libexec/netdata")
  1884. set(localstatedir_POST "${CMAKE_INSTALL_PREFIX}/var")
  1885. set(sbindir_POST "${CMAKE_INSTALL_PREFIX}/usr/sbin")
  1886. set(configdir_POST "${CMAKE_INSTALL_PREFIX}/etc/netdata")
  1887. set(libconfigdir_POST "${CMAKE_INSTALL_PREFIX}/usr/lib/netdata/conf.d")
  1888. set(cachedir_POST "${CMAKE_INSTALL_PREFIX}/var/cache/netdata")
  1889. set(registrydir_POST "${CMAKE_INSTALL_PREFIX}/var/lib/netdata/registry")
  1890. set(varlibdir_POST "${CMAKE_INSTALL_PREFIX}/var/lib/netdata")
  1891. set(netdata_user_POST "${NETDATA_USER}")
  1892. # netdata-claim.sh
  1893. if(ENABLE_CLOUD)
  1894. set(enable_cloud_POST "yes")
  1895. else()
  1896. set(enable_cloud_POST "no")
  1897. endif()
  1898. if(ENABLE_ACLK)
  1899. set(enable_aclk_POST "yes")
  1900. else()
  1901. set(enable_aclk_POST "no")
  1902. endif()
  1903. configure_file(claim/netdata-claim.sh.in claim/netdata-claim.sh @ONLY)
  1904. install(PROGRAMS
  1905. ${CMAKE_BINARY_DIR}/claim/netdata-claim.sh
  1906. DESTINATION usr/sbin)
  1907. #
  1908. # We don't check ENABLE_PLUGIN_CGROUP_NETWORK because rpm builds assume
  1909. # the files exists unconditionally.
  1910. #
  1911. configure_file(collectors/cgroups.plugin/cgroup-network-helper.sh.in
  1912. collectors/cgroups.plugin/cgroup-network-helper.sh @ONLY)
  1913. install(PROGRAMS
  1914. ${CMAKE_BINARY_DIR}/collectors/cgroups.plugin/cgroup-network-helper.sh
  1915. COMPONENT cgroup_network_plugin
  1916. DESTINATION usr/libexec/netdata/plugins.d)
  1917. configure_file(collectors/cgroups.plugin/cgroup-name.sh.in
  1918. collectors/cgroups.plugin/cgroup-name.sh @ONLY)
  1919. install(PROGRAMS
  1920. ${CMAKE_BINARY_DIR}/collectors/cgroups.plugin/cgroup-name.sh
  1921. DESTINATION usr/libexec/netdata/plugins.d)
  1922. #
  1923. # statsd
  1924. #
  1925. install(FILES
  1926. collectors/statsd.plugin/asterisk.conf
  1927. collectors/statsd.plugin/example.conf
  1928. collectors/statsd.plugin/k6.conf
  1929. DESTINATION usr/lib/netdata/conf.d/statsd.d)
  1930. #
  1931. # exporting
  1932. #
  1933. install(FILES
  1934. exporting/exporting.conf
  1935. DESTINATION usr/lib/netdata/conf.d)
  1936. #
  1937. # ioping.plugin
  1938. #
  1939. install(FILES
  1940. collectors/ioping.plugin/ioping.conf
  1941. DESTINATION usr/lib/netdata/conf.d)
  1942. #
  1943. # streaming
  1944. #
  1945. install(FILES
  1946. streaming/stream.conf
  1947. DESTINATION usr/lib/netdata/conf.d)
  1948. #
  1949. # swagger
  1950. #
  1951. install(FILES
  1952. web/api/netdata-swagger.json
  1953. web/api/netdata-swagger.yaml
  1954. DESTINATION ${WEB_DEST})
  1955. #
  1956. # service files
  1957. #
  1958. configure_file(system/install-service.sh.in system/install-service.sh @ONLY)
  1959. install(PROGRAMS
  1960. ${CMAKE_BINARY_DIR}/system/install-service.sh
  1961. DESTINATION usr/libexec/netdata)
  1962. configure_file(system/cron/netdata-updater-daily.in system/cron/netdata-updater-daily @ONLY)
  1963. install(FILES
  1964. ${CMAKE_BINARY_DIR}/system/cron/netdata-updater-daily
  1965. DESTINATION usr/lib/netdata/system/cron)
  1966. configure_file(system/launchd/netdata.plist.in system/launchd/netdata.plist @ONLY)
  1967. install(FILES
  1968. ${CMAKE_BINARY_DIR}/system/launchd/netdata.plist
  1969. DESTINATION usr/lib/netdata/system/launchd)
  1970. configure_file(system/freebsd/rc.d/netdata.in system/freebsd/rc.d/netdata @ONLY)
  1971. install(PROGRAMS
  1972. ${CMAKE_BINARY_DIR}/system/freebsd/rc.d/netdata
  1973. DESTINATION usr/lib/netdata/system/freebsd/rc.d)
  1974. configure_file(system/initd/init.d/netdata.in system/initd/init.d/netdata @ONLY)
  1975. install(PROGRAMS
  1976. ${CMAKE_BINARY_DIR}/system/initd/init.d/netdata
  1977. DESTINATION usr/lib/netdata/system/initd/init.d)
  1978. configure_file(system/logrotate/netdata.in system/logrotate/netdata @ONLY)
  1979. install(FILES
  1980. ${CMAKE_BINARY_DIR}/system/logrotate/netdata
  1981. DESTINATION usr/lib/netdata/system/logrotate)
  1982. configure_file(system/lsb/init.d/netdata.in system/lsb/init.d/netdata @ONLY)
  1983. install(PROGRAMS
  1984. ${CMAKE_BINARY_DIR}/system/lsb/init.d/netdata
  1985. DESTINATION usr/lib/netdata/system/lsb/init.d)
  1986. configure_file(system/openrc/conf.d/netdata.in system/openrc/conf.d/netdata @ONLY)
  1987. install(FILES
  1988. ${CMAKE_BINARY_DIR}/system/openrc/conf.d/netdata
  1989. DESTINATION usr/lib/netdata/system/openrc/conf.d)
  1990. configure_file(system/openrc/init.d/netdata.in system/openrc/init.d/netdata @ONLY)
  1991. install(PROGRAMS
  1992. ${CMAKE_BINARY_DIR}/system/openrc/init.d/netdata
  1993. DESTINATION usr/lib/netdata/system/openrc/init.d)
  1994. configure_file(system/runit/run.in system/runit/run @ONLY)
  1995. install(PROGRAMS
  1996. ${CMAKE_BINARY_DIR}/system/runit/run
  1997. DESTINATION usr/lib/netdata/system/runit)
  1998. configure_file(system/systemd/netdata.service.in system/systemd/netdata.service @ONLY)
  1999. install(FILES
  2000. ${CMAKE_BINARY_DIR}/system/systemd/netdata.service
  2001. DESTINATION usr/lib/netdata/system/systemd)
  2002. configure_file(system/systemd/netdata.service.v235.in system/systemd/netdata.service.v235 @ONLY)
  2003. install(FILES
  2004. ${CMAKE_BINARY_DIR}/system/systemd/netdata.service.v235
  2005. DESTINATION usr/lib/netdata/system/systemd)
  2006. configure_file(system/systemd/netdata-updater.service.in system/systemd/netdata-updater.service @ONLY)
  2007. install(FILES
  2008. ${CMAKE_BINARY_DIR}/system/systemd/netdata-updater.service
  2009. DESTINATION usr/lib/netdata/system/systemd)
  2010. install(FILES
  2011. system/systemd/netdata-updater.timer
  2012. DESTINATION usr/lib/netdata/system/systemd)
  2013. install(FILES
  2014. system/systemd/50-netdata.preset
  2015. DESTINATION usr/lib/netdata/system/systemd)
  2016. install(FILES
  2017. system/vnodes/vnodes.conf
  2018. DESTINATION usr/lib/netdata/conf.d/vnodes)
  2019. install(FILES
  2020. system/.install-type
  2021. DESTINATION etc/netdata)
  2022. install(FILES
  2023. system/netdata-updater.conf
  2024. DESTINATION etc/netdata)
  2025. install(PROGRAMS
  2026. system/edit-config
  2027. DESTINATION etc/netdata)
  2028. #
  2029. # TODO: check the following files for correct substitutions
  2030. #
  2031. configure_file(daemon/anonymous-statistics.sh.in daemon/anonymous-statistics.sh @ONLY)
  2032. install(PROGRAMS
  2033. ${CMAKE_BINARY_DIR}/daemon/anonymous-statistics.sh
  2034. DESTINATION usr/libexec/netdata/plugins.d)
  2035. configure_file(daemon/get-kubernetes-labels.sh.in daemon/get-kubernetes-labels.sh @ONLY)
  2036. install(PROGRAMS
  2037. ${CMAKE_BINARY_DIR}/daemon/get-kubernetes-labels.sh
  2038. DESTINATION usr/libexec/netdata/plugins.d)
  2039. install(PROGRAMS
  2040. daemon/system-info.sh
  2041. DESTINATION usr/libexec/netdata/plugins.d)
  2042. #
  2043. # health files
  2044. #
  2045. file(GLOB_RECURSE HEALTH_CONF_FILES "health/health.d/*.conf")
  2046. install(FILES
  2047. ${HEALTH_CONF_FILES}
  2048. DESTINATION usr/lib/netdata/conf.d/health.d)
  2049. configure_file(health/notifications/alarm-notify.sh.in health/notifications/alarm-notify.sh @ONLY)
  2050. install(PROGRAMS
  2051. ${CMAKE_BINARY_DIR}/health/notifications/alarm-notify.sh
  2052. DESTINATION usr/libexec/netdata/plugins.d)
  2053. install(PROGRAMS
  2054. health/notifications/alarm-email.sh
  2055. health/notifications/alarm-test.sh
  2056. DESTINATION usr/libexec/netdata/plugins.d)
  2057. install(FILES
  2058. health/notifications/health_alarm_notify.conf
  2059. health/notifications/health_email_recipients.conf
  2060. DESTINATION usr/lib/netdata/conf.d)
  2061. #
  2062. # test/ files
  2063. #
  2064. configure_file(tests/health_mgmtapi/health-cmdapi-test.sh.in tests/health_mgmtapi/health-cmdapi-test.sh @ONLY)
  2065. configure_file(tests/acls/acl.sh.in tests/acls/acl.sh @ONLY)
  2066. configure_file(tests/urls/request.sh.in tests/urls/request.sh @ONLY)
  2067. configure_file(tests/alarm_repetition/alarm.sh.in tests/alarm_repetition/alarm.sh @ONLY)
  2068. configure_file(tests/template_dimension/template_dim.sh.in tests/template_dimension/template_dim.sh @ONLY)
  2069. configure_file(tests/ebpf/ebpf_thread_function.sh.in tests/ebpf/ebpf_thread_function.sh @ONLY)
  2070. install(FILES
  2071. ${CMAKE_BINARY_DIR}/tests/health_mgmtapi/health-cmdapi-test.sh
  2072. ${CMAKE_BINARY_DIR}/tests/acls/acl.sh
  2073. ${CMAKE_BINARY_DIR}/tests/urls/request.sh
  2074. ${CMAKE_BINARY_DIR}/tests/alarm_repetition/alarm.sh
  2075. ${CMAKE_BINARY_DIR}/tests/template_dimension/template_dim.sh
  2076. ${CMAKE_BINARY_DIR}/tests/ebpf/ebpf_thread_function.sh
  2077. DESTINATION usr/libexec/netdata/plugins.d)
  2078. #
  2079. # charts.d files
  2080. #
  2081. configure_file(collectors/charts.d.plugin/charts.d.plugin.in collectors/charts.d.plugin/charts.d.plugin @ONLY)
  2082. install(PROGRAMS
  2083. ${CMAKE_BINARY_DIR}/collectors/charts.d.plugin/charts.d.plugin
  2084. DESTINATION usr/libexec/netdata/plugins.d)
  2085. install(FILES
  2086. collectors/charts.d.plugin/charts.d.dryrun-helper.sh
  2087. collectors/charts.d.plugin/loopsleepms.sh.inc
  2088. DESTINATION usr/libexec/netdata/plugins.d)
  2089. install(FILES
  2090. collectors/charts.d.plugin/charts.d.conf
  2091. DESTINATION usr/lib/netdata/conf.d)
  2092. #
  2093. # tc-qos-helper
  2094. #
  2095. configure_file(collectors/tc.plugin/tc-qos-helper.sh.in collectors/tc.plugin/tc-qos-helper.sh @ONLY)
  2096. install(PROGRAMS
  2097. ${CMAKE_BINARY_DIR}/collectors/tc.plugin/tc-qos-helper.sh
  2098. DESTINATION usr/libexec/netdata/plugins.d)
  2099. # scripts
  2100. install(FILES
  2101. collectors/charts.d.plugin/ap/ap.chart.sh
  2102. collectors/charts.d.plugin/apcupsd/apcupsd.chart.sh
  2103. collectors/charts.d.plugin/example/example.chart.sh
  2104. collectors/charts.d.plugin/libreswan/libreswan.chart.sh
  2105. collectors/charts.d.plugin/opensips/opensips.chart.sh
  2106. collectors/charts.d.plugin/sensors/sensors.chart.sh
  2107. DESTINATION usr/libexec/netdata/charts.d)
  2108. # confs
  2109. install(FILES
  2110. collectors/charts.d.plugin/ap/ap.conf
  2111. collectors/charts.d.plugin/apcupsd/apcupsd.conf
  2112. collectors/charts.d.plugin/example/example.conf
  2113. collectors/charts.d.plugin/libreswan/libreswan.conf
  2114. collectors/charts.d.plugin/opensips/opensips.conf
  2115. collectors/charts.d.plugin/sensors/sensors.conf
  2116. DESTINATION usr/lib/netdata/conf.d/charts.d)
  2117. install(FILES
  2118. collectors/systemd-journal.plugin/schema.d/systemd-journal:monitored-directories.json
  2119. DESTINATION usr/lib/netdata/conf.d/schema.d)
  2120. #
  2121. # ebpf files
  2122. #
  2123. if(ENABLE_PLUGIN_EBPF)
  2124. install(FILES
  2125. collectors/ebpf.plugin/ebpf.d.conf
  2126. DESTINATION usr/lib/netdata/conf.d)
  2127. install(FILES
  2128. collectors/ebpf.plugin/ebpf.d/cachestat.conf
  2129. collectors/ebpf.plugin/ebpf.d/dcstat.conf
  2130. collectors/ebpf.plugin/ebpf.d/disk.conf
  2131. collectors/ebpf.plugin/ebpf.d/ebpf_kernel_reject_list.txt
  2132. collectors/ebpf.plugin/ebpf.d/fd.conf
  2133. collectors/ebpf.plugin/ebpf.d/filesystem.conf
  2134. collectors/ebpf.plugin/ebpf.d/hardirq.conf
  2135. collectors/ebpf.plugin/ebpf.d/mdflush.conf
  2136. collectors/ebpf.plugin/ebpf.d/mount.conf
  2137. collectors/ebpf.plugin/ebpf.d/network.conf
  2138. collectors/ebpf.plugin/ebpf.d/oomkill.conf
  2139. collectors/ebpf.plugin/ebpf.d/process.conf
  2140. collectors/ebpf.plugin/ebpf.d/shm.conf
  2141. collectors/ebpf.plugin/ebpf.d/softirq.conf
  2142. collectors/ebpf.plugin/ebpf.d/swap.conf
  2143. collectors/ebpf.plugin/ebpf.d/sync.conf
  2144. collectors/ebpf.plugin/ebpf.d/vfs.conf
  2145. DESTINATION usr/lib/netdata/conf.d/ebpf.d)
  2146. endif()
  2147. #
  2148. # python.d files
  2149. #
  2150. configure_file(collectors/python.d.plugin/python.d.plugin.in collectors/python.d.plugin/python.d.plugin @ONLY)
  2151. install(PROGRAMS ${CMAKE_BINARY_DIR}/collectors/python.d.plugin/python.d.plugin
  2152. DESTINATION usr/libexec/netdata/plugins.d)
  2153. install(DIRECTORY collectors/python.d.plugin/python_modules
  2154. DESTINATION usr/libexec/netdata/python.d)
  2155. install(FILES collectors/python.d.plugin/python.d.conf
  2156. DESTINATION usr/lib/netdata/conf.d)
  2157. # conf files
  2158. install(FILES
  2159. collectors/python.d.plugin/adaptec_raid/adaptec_raid.conf
  2160. collectors/python.d.plugin/alarms/alarms.conf
  2161. collectors/python.d.plugin/am2320/am2320.conf
  2162. collectors/python.d.plugin/anomalies/anomalies.conf
  2163. collectors/python.d.plugin/beanstalk/beanstalk.conf
  2164. collectors/python.d.plugin/bind_rndc/bind_rndc.conf
  2165. collectors/python.d.plugin/boinc/boinc.conf
  2166. collectors/python.d.plugin/ceph/ceph.conf
  2167. collectors/python.d.plugin/changefinder/changefinder.conf
  2168. collectors/python.d.plugin/dovecot/dovecot.conf
  2169. collectors/python.d.plugin/example/example.conf
  2170. collectors/python.d.plugin/exim/exim.conf
  2171. collectors/python.d.plugin/fail2ban/fail2ban.conf
  2172. collectors/python.d.plugin/gearman/gearman.conf
  2173. collectors/python.d.plugin/go_expvar/go_expvar.conf
  2174. collectors/python.d.plugin/haproxy/haproxy.conf
  2175. collectors/python.d.plugin/hddtemp/hddtemp.conf
  2176. collectors/python.d.plugin/hpssa/hpssa.conf
  2177. collectors/python.d.plugin/icecast/icecast.conf
  2178. collectors/python.d.plugin/ipfs/ipfs.conf
  2179. collectors/python.d.plugin/litespeed/litespeed.conf
  2180. collectors/python.d.plugin/megacli/megacli.conf
  2181. collectors/python.d.plugin/memcached/memcached.conf
  2182. collectors/python.d.plugin/monit/monit.conf
  2183. collectors/python.d.plugin/nsd/nsd.conf
  2184. collectors/python.d.plugin/nvidia_smi/nvidia_smi.conf
  2185. collectors/python.d.plugin/openldap/openldap.conf
  2186. collectors/python.d.plugin/oracledb/oracledb.conf
  2187. collectors/python.d.plugin/pandas/pandas.conf
  2188. collectors/python.d.plugin/postfix/postfix.conf
  2189. collectors/python.d.plugin/puppet/puppet.conf
  2190. collectors/python.d.plugin/rethinkdbs/rethinkdbs.conf
  2191. collectors/python.d.plugin/retroshare/retroshare.conf
  2192. collectors/python.d.plugin/riakkv/riakkv.conf
  2193. collectors/python.d.plugin/samba/samba.conf
  2194. collectors/python.d.plugin/sensors/sensors.conf
  2195. collectors/python.d.plugin/smartd_log/smartd_log.conf
  2196. collectors/python.d.plugin/spigotmc/spigotmc.conf
  2197. collectors/python.d.plugin/squid/squid.conf
  2198. collectors/python.d.plugin/tomcat/tomcat.conf
  2199. collectors/python.d.plugin/tor/tor.conf
  2200. collectors/python.d.plugin/traefik/traefik.conf
  2201. collectors/python.d.plugin/uwsgi/uwsgi.conf
  2202. collectors/python.d.plugin/varnish/varnish.conf
  2203. collectors/python.d.plugin/w1sensor/w1sensor.conf
  2204. collectors/python.d.plugin/zscores/zscores.conf
  2205. DESTINATION usr/lib/netdata/conf.d/python.d)
  2206. # scripts
  2207. install(FILES
  2208. collectors/python.d.plugin/adaptec_raid/adaptec_raid.chart.py
  2209. collectors/python.d.plugin/alarms/alarms.chart.py
  2210. collectors/python.d.plugin/am2320/am2320.chart.py
  2211. collectors/python.d.plugin/anomalies/anomalies.chart.py
  2212. collectors/python.d.plugin/beanstalk/beanstalk.chart.py
  2213. collectors/python.d.plugin/bind_rndc/bind_rndc.chart.py
  2214. collectors/python.d.plugin/boinc/boinc.chart.py
  2215. collectors/python.d.plugin/ceph/ceph.chart.py
  2216. collectors/python.d.plugin/changefinder/changefinder.chart.py
  2217. collectors/python.d.plugin/dovecot/dovecot.chart.py
  2218. collectors/python.d.plugin/example/example.chart.py
  2219. collectors/python.d.plugin/exim/exim.chart.py
  2220. collectors/python.d.plugin/fail2ban/fail2ban.chart.py
  2221. collectors/python.d.plugin/gearman/gearman.chart.py
  2222. collectors/python.d.plugin/go_expvar/go_expvar.chart.py
  2223. collectors/python.d.plugin/haproxy/haproxy.chart.py
  2224. collectors/python.d.plugin/hddtemp/hddtemp.chart.py
  2225. collectors/python.d.plugin/hpssa/hpssa.chart.py
  2226. collectors/python.d.plugin/icecast/icecast.chart.py
  2227. collectors/python.d.plugin/ipfs/ipfs.chart.py
  2228. collectors/python.d.plugin/litespeed/litespeed.chart.py
  2229. collectors/python.d.plugin/megacli/megacli.chart.py
  2230. collectors/python.d.plugin/memcached/memcached.chart.py
  2231. collectors/python.d.plugin/monit/monit.chart.py
  2232. collectors/python.d.plugin/nsd/nsd.chart.py
  2233. collectors/python.d.plugin/nvidia_smi/nvidia_smi.chart.py
  2234. collectors/python.d.plugin/openldap/openldap.chart.py
  2235. collectors/python.d.plugin/oracledb/oracledb.chart.py
  2236. collectors/python.d.plugin/pandas/pandas.chart.py
  2237. collectors/python.d.plugin/postfix/postfix.chart.py
  2238. collectors/python.d.plugin/puppet/puppet.chart.py
  2239. collectors/python.d.plugin/rethinkdbs/rethinkdbs.chart.py
  2240. collectors/python.d.plugin/retroshare/retroshare.chart.py
  2241. collectors/python.d.plugin/riakkv/riakkv.chart.py
  2242. collectors/python.d.plugin/samba/samba.chart.py
  2243. collectors/python.d.plugin/sensors/sensors.chart.py
  2244. collectors/python.d.plugin/smartd_log/smartd_log.chart.py
  2245. collectors/python.d.plugin/spigotmc/spigotmc.chart.py
  2246. collectors/python.d.plugin/squid/squid.chart.py
  2247. collectors/python.d.plugin/tomcat/tomcat.chart.py
  2248. collectors/python.d.plugin/tor/tor.chart.py
  2249. collectors/python.d.plugin/traefik/traefik.chart.py
  2250. collectors/python.d.plugin/uwsgi/uwsgi.chart.py
  2251. collectors/python.d.plugin/varnish/varnish.chart.py
  2252. collectors/python.d.plugin/w1sensor/w1sensor.chart.py
  2253. collectors/python.d.plugin/zscores/zscores.chart.py
  2254. DESTINATION usr/libexec/netdata/python.d)
  2255. # FIXME: don't install this unconditionally
  2256. configure_file(collectors/ioping.plugin/ioping.plugin.in collectors/ioping.plugin/ioping.plugin @ONLY)
  2257. install(PROGRAMS ${CMAKE_BINARY_DIR}/collectors/ioping.plugin/ioping.plugin DESTINATION usr/libexec/netdata/plugins.d)
  2258. #
  2259. # logs management
  2260. #
  2261. if (ENABLE_PLUGIN_LOGS_MANAGEMENT)
  2262. configure_file(logsmanagement/stock_conf/logsmanagement.d.conf.in logsmanagement/stock_conf/logsmanagement.d.conf @ONLY)
  2263. install(FILES ${CMAKE_BINARY_DIR}/logsmanagement/stock_conf/logsmanagement.d.conf
  2264. COMPONENT logs_management_plugin
  2265. DESTINATION usr/lib/netdata/conf.d)
  2266. endif()
  2267. #
  2268. # dashboard
  2269. #
  2270. include(web/gui/v1/dashboard_v1.cmake)
  2271. include(web/gui/v2/dashboard_v2.cmake)
  2272. include(web/gui/gui.cmake)
  2273. function(cat IN_FILE OUT_FILE)
  2274. file(READ ${IN_FILE} CONTENTS)
  2275. file(APPEND ${OUT_FILE} "${CONTENTS}")
  2276. endfunction()
  2277. file(WRITE ${CMAKE_BINARY_DIR}/web/gui/dashboard.js.in "")
  2278. foreach(JS_FILE ${DASHBOARD_JS_FILES})
  2279. cat(${JS_FILE} ${CMAKE_BINARY_DIR}/dashboard.js.in)
  2280. endforeach()
  2281. configure_file(${CMAKE_BINARY_DIR}/dashboard.js.in
  2282. ${CMAKE_BINARY_DIR}/dashboard.js COPYONLY)
  2283. install(FILES
  2284. ${CMAKE_BINARY_DIR}/dashboard.js
  2285. DESTINATION ${WEB_DEST})
  2286. install(FILES
  2287. web/gui/dashboard_info_custom_example.js
  2288. web/gui/dashboard_info.js
  2289. web/gui/index.html
  2290. web/gui/main.css
  2291. web/gui/main.js
  2292. web/gui/registry-access.html
  2293. web/gui/registry-alert-redirect.html
  2294. web/gui/registry-hello.html
  2295. web/gui/switch.html
  2296. web/gui/ilove.html
  2297. DESTINATION ${WEB_DEST})
  2298. install(FILES
  2299. web/gui/old/index.html
  2300. DESTINATION ${WEB_DEST}/old)
  2301. install(FILES
  2302. web/gui/static/img/netdata-logomark.svg
  2303. DESTINATION ${WEB_DEST}/static/img)
  2304. install(FILES
  2305. web/gui/css/morris-0.5.1.css
  2306. web/gui/css/c3-0.4.18.min.css
  2307. DESTINATION ${WEB_DEST}/css)
  2308. install(FILES
  2309. web/gui/.well-known/dnt/cookies
  2310. DESTINATION ${WEB_DEST}/.well-known/dnt)
  2311. # v0 dashboard
  2312. install(FILES
  2313. web/gui/v0/index.html
  2314. DESTINATION ${WEB_DEST}/v0)