CMakeLists.txt 92 KB

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