CMakeLists.txt 92 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603
  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_wireless.c
  1014. collectors/proc.plugin/proc_net_ip_vs_stats.c
  1015. collectors/proc.plugin/proc_net_netstat.c
  1016. collectors/proc.plugin/proc_net_rpc_nfs.c
  1017. collectors/proc.plugin/proc_net_rpc_nfsd.c
  1018. collectors/proc.plugin/proc_net_sctp_snmp.c
  1019. collectors/proc.plugin/proc_net_sockstat.c
  1020. collectors/proc.plugin/proc_net_sockstat6.c
  1021. collectors/proc.plugin/proc_net_softnet_stat.c
  1022. collectors/proc.plugin/proc_net_stat_conntrack.c
  1023. collectors/proc.plugin/proc_net_stat_synproxy.c
  1024. collectors/proc.plugin/proc_self_mountinfo.c
  1025. collectors/proc.plugin/proc_self_mountinfo.h
  1026. collectors/proc.plugin/zfs_common.c
  1027. collectors/proc.plugin/zfs_common.h
  1028. collectors/proc.plugin/proc_spl_kstat_zfs.c
  1029. collectors/proc.plugin/proc_stat.c
  1030. collectors/proc.plugin/proc_sys_kernel_random_entropy_avail.c
  1031. collectors/proc.plugin/proc_vmstat.c
  1032. collectors/proc.plugin/proc_uptime.c
  1033. collectors/proc.plugin/proc_pressure.c
  1034. collectors/proc.plugin/proc_pressure.h
  1035. collectors/proc.plugin/sys_kernel_mm_ksm.c
  1036. collectors/proc.plugin/sys_block_zram.c
  1037. collectors/proc.plugin/sys_devices_system_edac_mc.c
  1038. collectors/proc.plugin/sys_devices_system_node.c
  1039. collectors/proc.plugin/sys_class_infiniband.c
  1040. collectors/proc.plugin/sys_fs_btrfs.c
  1041. collectors/proc.plugin/sys_class_power_supply.c
  1042. collectors/proc.plugin/sys_devices_pci_aer.c
  1043. collectors/proc.plugin/sys_class_drm.c
  1044. )
  1045. set(TC_PLUGIN_FILES
  1046. collectors/tc.plugin/plugin_tc.c
  1047. )
  1048. set(LOGS_MANAGEMENT_PLUGIN_FILES
  1049. logsmanagement/circular_buffer.c
  1050. logsmanagement/circular_buffer.h
  1051. logsmanagement/db_api.c
  1052. logsmanagement/db_api.h
  1053. logsmanagement/defaults.h
  1054. logsmanagement/file_info.h
  1055. logsmanagement/flb_plugin.c
  1056. logsmanagement/flb_plugin.h
  1057. logsmanagement/functions.c
  1058. logsmanagement/functions.h
  1059. logsmanagement/helper.h
  1060. logsmanagement/logsmanag_config.c
  1061. logsmanagement/logsmanag_config.h
  1062. logsmanagement/logsmanagement.c
  1063. logsmanagement/parser.c
  1064. logsmanagement/parser.h
  1065. logsmanagement/query.c
  1066. logsmanagement/query.h
  1067. logsmanagement/rrd_api/rrd_api_docker_ev.c
  1068. logsmanagement/rrd_api/rrd_api_docker_ev.h
  1069. logsmanagement/rrd_api/rrd_api_generic.c
  1070. logsmanagement/rrd_api/rrd_api_generic.h
  1071. logsmanagement/rrd_api/rrd_api_kernel.c
  1072. logsmanagement/rrd_api/rrd_api_kernel.h
  1073. logsmanagement/rrd_api/rrd_api_mqtt.c
  1074. logsmanagement/rrd_api/rrd_api_mqtt.h
  1075. logsmanagement/rrd_api/rrd_api_stats.c
  1076. logsmanagement/rrd_api/rrd_api_stats.h
  1077. logsmanagement/rrd_api/rrd_api_systemd.c
  1078. logsmanagement/rrd_api/rrd_api_systemd.h
  1079. logsmanagement/rrd_api/rrd_api_web_log.c
  1080. logsmanagement/rrd_api/rrd_api_web_log.h
  1081. logsmanagement/rrd_api/rrd_api.h
  1082. database/sqlite/sqlite3.c
  1083. database/sqlite/sqlite3.h
  1084. )
  1085. set(NETDATA_FILES
  1086. collectors/all.h
  1087. ${DAEMON_FILES}
  1088. ${API_PLUGIN_FILES}
  1089. ${EXPORTING_ENGINE_FILES}
  1090. ${HEALTH_PLUGIN_FILES}
  1091. ${IDLEJITTER_PLUGIN_FILES}
  1092. ${ML_FILES}
  1093. ${PLUGINSD_PLUGIN_FILES}
  1094. ${RRD_PLUGIN_FILES}
  1095. ${REGISTRY_PLUGIN_FILES}
  1096. ${STATSD_PLUGIN_FILES}
  1097. ${STREAMING_PLUGIN_FILES}
  1098. ${WEB_PLUGIN_FILES}
  1099. ${CLAIM_PLUGIN_FILES}
  1100. ${SPAWN_PLUGIN_FILES}
  1101. ${ACLK_ALWAYS_BUILD}
  1102. ${TIMEX_PLUGIN_FILES}
  1103. ${PROFILE_PLUGIN_FILES}
  1104. )
  1105. if(LINUX)
  1106. list(APPEND NETDATA_FILES
  1107. daemon/static_threads_linux.c
  1108. ${CGROUPS_PLUGIN_FILES}
  1109. ${DISKSPACE_PLUGIN_FILES}
  1110. ${PROC_PLUGIN_FILES}
  1111. ${TC_PLUGIN_FILES}
  1112. )
  1113. elseif(MACOS)
  1114. list(APPEND NETDATA_FILES
  1115. daemon/static_threads_macos.c
  1116. ${MACOS_PLUGIN_FILES}
  1117. )
  1118. elseif(FREEBSD)
  1119. list(APPEND NETDATA_FILES
  1120. daemon/static_threads_freebsd.c
  1121. ${FREEBSD_PLUGIN_FILES}
  1122. )
  1123. endif()
  1124. set(MQTT_WEBSOCKETS_FILES
  1125. mqtt_websockets/src/mqtt_wss_client.c
  1126. mqtt_websockets/src/include/mqtt_wss_client.h
  1127. mqtt_websockets/src/mqtt_wss_log.c
  1128. mqtt_websockets/src/include/mqtt_wss_log.h
  1129. mqtt_websockets/src/ws_client.c
  1130. mqtt_websockets/src/include/ws_client.h
  1131. mqtt_websockets/src/mqtt_ng.c
  1132. mqtt_websockets/src/include/mqtt_ng.h
  1133. mqtt_websockets/src/common_public.c
  1134. mqtt_websockets/src/include/common_public.h
  1135. mqtt_websockets/src/include/common_internal.h
  1136. mqtt_websockets/c-rbuf/src/ringbuffer.c
  1137. mqtt_websockets/c-rbuf/include/ringbuffer.h
  1138. mqtt_websockets/c-rbuf/src/ringbuffer_internal.h
  1139. mqtt_websockets/c_rhash/src/c_rhash.c
  1140. mqtt_websockets/c_rhash/include/c_rhash.h
  1141. mqtt_websockets/c_rhash/src/c_rhash_internal.h
  1142. )
  1143. set(ACLK_PROTO_DEFS
  1144. aclk/aclk-schemas/proto/aclk/v1/lib.proto
  1145. aclk/aclk-schemas/proto/agent/v1/disconnect.proto
  1146. aclk/aclk-schemas/proto/agent/v1/connection.proto
  1147. aclk/aclk-schemas/proto/alarm/v1/config.proto
  1148. aclk/aclk-schemas/proto/alarm/v1/stream.proto
  1149. aclk/aclk-schemas/proto/nodeinstance/connection/v1/connection.proto
  1150. aclk/aclk-schemas/proto/nodeinstance/create/v1/creation.proto
  1151. aclk/aclk-schemas/proto/nodeinstance/info/v1/info.proto
  1152. aclk/aclk-schemas/proto/context/v1/context.proto
  1153. aclk/aclk-schemas/proto/context/v1/stream.proto
  1154. aclk/aclk-schemas/proto/agent/v1/cmds.proto
  1155. )
  1156. set(ACLK_FILES
  1157. aclk/aclk_stats.c
  1158. aclk/aclk_stats.h
  1159. aclk/aclk_query.c
  1160. aclk/aclk_query.h
  1161. aclk/aclk_query_queue.c
  1162. aclk/aclk_query_queue.h
  1163. aclk/aclk_otp.c
  1164. aclk/aclk_otp.h
  1165. aclk/aclk_tx_msgs.c
  1166. aclk/aclk_tx_msgs.h
  1167. aclk/aclk_rx_msgs.c
  1168. aclk/aclk_rx_msgs.h
  1169. aclk/aclk_alarm_api.c
  1170. aclk/aclk_alarm_api.h
  1171. aclk/aclk_contexts_api.c
  1172. aclk/aclk_contexts_api.h
  1173. aclk/schema-wrappers/connection.cc
  1174. aclk/schema-wrappers/connection.h
  1175. aclk/schema-wrappers/node_connection.cc
  1176. aclk/schema-wrappers/node_connection.h
  1177. aclk/schema-wrappers/node_creation.cc
  1178. aclk/schema-wrappers/node_creation.h
  1179. aclk/schema-wrappers/alarm_stream.cc
  1180. aclk/schema-wrappers/alarm_stream.h
  1181. aclk/schema-wrappers/alarm_config.cc
  1182. aclk/schema-wrappers/alarm_config.h
  1183. aclk/schema-wrappers/node_info.cc
  1184. aclk/schema-wrappers/node_info.h
  1185. aclk/schema-wrappers/capability.cc
  1186. aclk/schema-wrappers/capability.h
  1187. aclk/schema-wrappers/proto_2_json.cc
  1188. aclk/schema-wrappers/proto_2_json.h
  1189. aclk/schema-wrappers/context_stream.cc
  1190. aclk/schema-wrappers/context_stream.h
  1191. aclk/schema-wrappers/context.cc
  1192. aclk/schema-wrappers/context.h
  1193. aclk/schema-wrappers/schema_wrappers.h
  1194. aclk/schema-wrappers/schema_wrapper_utils.cc
  1195. aclk/schema-wrappers/schema_wrapper_utils.h
  1196. aclk/schema-wrappers/agent_cmds.cc
  1197. aclk/schema-wrappers/agent_cmds.h
  1198. aclk/helpers/mqtt_wss_pal.h
  1199. aclk/helpers/ringbuffer_pal.h
  1200. )
  1201. set(MONGODB_EXPORTING_FILES
  1202. exporting/mongodb/mongodb.c
  1203. exporting/mongodb/mongodb.h
  1204. )
  1205. set(PROMETHEUS_REMOTE_WRITE_EXPORTING_FILES
  1206. exporting/prometheus/remote_write/remote_write.c
  1207. exporting/prometheus/remote_write/remote_write.h
  1208. exporting/prometheus/remote_write/remote_write_request.cc
  1209. exporting/prometheus/remote_write/remote_write_request.h
  1210. )
  1211. #
  1212. # build h2o
  1213. #
  1214. if(ENABLE_H2O)
  1215. add_library(h2o STATIC ${LIBH2O_FILES})
  1216. target_include_directories(h2o BEFORE PUBLIC
  1217. "${CMAKE_SOURCE_DIR}/web/server/h2o/libh2o/include"
  1218. "${CMAKE_SOURCE_DIR}/web/server/h2o/libh2o/deps/cloexec"
  1219. "${CMAKE_SOURCE_DIR}/web/server/h2o/libh2o/deps/brotli/enc"
  1220. "${CMAKE_SOURCE_DIR}/web/server/h2o/libh2o/deps/golombset"
  1221. "${CMAKE_SOURCE_DIR}/web/server/h2o/libh2o/deps/libgkc"
  1222. "${CMAKE_SOURCE_DIR}/web/server/h2o/libh2o/deps/libyrmcds"
  1223. "${CMAKE_SOURCE_DIR}/web/server/h2o/libh2o/deps/klib"
  1224. "${CMAKE_SOURCE_DIR}/web/server/h2o/libh2o/deps/neverbleed"
  1225. "${CMAKE_SOURCE_DIR}/web/server/h2o/libh2o/deps/picohttpparser"
  1226. "${CMAKE_SOURCE_DIR}/web/server/h2o/libh2o/deps/picotest"
  1227. "${CMAKE_SOURCE_DIR}/web/server/h2o/libh2o/deps/yaml/include"
  1228. "${CMAKE_SOURCE_DIR}/web/server/h2o/libh2o/deps/yoml"
  1229. )
  1230. target_compile_options(h2o PRIVATE
  1231. -Wno-old-style-declaration
  1232. -Wno-deprecated-declarations
  1233. -Wno-unused-parameter
  1234. -Wno-sign-compare
  1235. -Wno-missing-field-initializers)
  1236. target_compile_options(h2o PUBLIC -DH2O_USE_LIBUV=0)
  1237. target_include_directories(h2o BEFORE PRIVATE ${OPENSSL_INCLUDE_DIRS})
  1238. target_compile_options(h2o PRIVATE ${OPENSSL_CFLAGS_OTHER})
  1239. target_link_libraries(h2o PRIVATE ${OPENSSL_LIBRARIES})
  1240. endif()
  1241. #
  1242. # build libjudy
  1243. #
  1244. add_library(judy STATIC ${LIBJUDY_SOURCES})
  1245. target_compile_options(judy PUBLIC
  1246. -Wno-sign-compare
  1247. -Wno-implicit-fallthrough
  1248. )
  1249. target_compile_definitions(judy PUBLIC
  1250. JUDYL
  1251. $<$<EQUAL:${CMAKE_SIZEOF_VOID_P},8>:JU_64BIT>
  1252. )
  1253. target_include_directories(judy PUBLIC
  1254. libnetdata/libjudy/src
  1255. libnetdata/libjudy/src/JudyCommon
  1256. )
  1257. set_source_files_properties(${LIBJUDY_PREV_FILES} PROPERTIES COMPILE_OPTIONS "-DJUDYPREV")
  1258. set_source_files_properties(${LIBJUDY_NEXT_FILES} PROPERTIES COMPILE_OPTIONS "-DJUDYNEXT")
  1259. set_source_files_properties(libnetdata/libjudy/src/JudyL/j__udyLGet.c PROPERTIES COMPILE_OPTIONS "-DJUDYGETINLINE")
  1260. set_source_files_properties(libnetdata/libjudy/src/JudyL/JudyLByCount.c PROPERTIES COMPILE_OPTIONS "-DNOSMARTJBB -DNOSMARTJBU -DNOSMARTJLB")
  1261. set_source_files_properties(JudyLTables.c PROPERTIES COMPILE_OPTIONS "-I${CMAKE_SOURCE_DIR}/libnetdata/libjudy/src/JudyL")
  1262. #
  1263. # build libnetdata
  1264. #
  1265. include(systemd.cmake)
  1266. add_library(libnetdata STATIC ${LIBNETDATA_FILES})
  1267. target_include_directories(libnetdata BEFORE PUBLIC ${CONFIG_H_DIR} ${CMAKE_SOURCE_DIR})
  1268. # pthread (FIXME: use find_package for this)
  1269. # set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
  1270. # set(THREADS_PREFER_PTHREAD_FLAG TRUE)
  1271. # find_package(Threads REQUIRED)
  1272. # add_executable(test test.cpp)
  1273. # target_link_libraries(test Threads::Threads)
  1274. target_link_libraries(libnetdata PUBLIC
  1275. "$<$<NOT:$<BOOL:${HAVE_BUILTIN_ATOMICS}>>:atomic>"
  1276. "$<$<OR:$<BOOL:${LINUX}>,$<BOOL:${FREEBSD}>>:pthread;rt>"
  1277. "$<$<BOOL:${LINK_LIBM}>:m>"
  1278. "${SYSTEMD_LDFLAGS}")
  1279. # ebpf
  1280. if(ENABLE_PLUGIN_EBPF)
  1281. target_link_libraries(libnetdata PUBLIC ${CMAKE_SOURCE_DIR}/externaldeps/libbpf/libbpf.a)
  1282. target_include_directories(libnetdata BEFORE PUBLIC
  1283. ${CMAKE_SOURCE_DIR}/externaldeps/libbpf/include
  1284. ${CMAKE_SOURCE_DIR}/externaldeps/libbpf/include/uapi
  1285. )
  1286. pkg_check_modules(ELF REQUIRED libelf)
  1287. target_include_directories(libnetdata BEFORE PUBLIC ${ELF_INCLUDE_DIRS})
  1288. target_compile_options(libnetdata PUBLIC ${ELF_CFLAGS_OTHER})
  1289. target_link_libraries(libnetdata PUBLIC ${ELF_LIBRARIES})
  1290. endif()
  1291. # judy
  1292. target_link_libraries(libnetdata PUBLIC judy)
  1293. # json-c
  1294. if(ENABLE_BUNDLED_JSONC)
  1295. add_library(jsonc STATIC IMPORTED)
  1296. set_property(TARGET jsonc PROPERTY
  1297. IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/externaldeps/jsonc/libjson-c.a")
  1298. target_include_directories(libnetdata BEFORE PUBLIC "${CMAKE_SOURCE_DIR}/externaldeps/jsonc")
  1299. target_link_libraries(libnetdata PUBLIC jsonc)
  1300. else()
  1301. pkg_check_modules(JSONC REQUIRED json-c)
  1302. target_include_directories(libnetdata BEFORE PUBLIC ${JSONC_INCLUDE_DIRS})
  1303. target_compile_definitions(libnetdata PUBLIC ${JSONC_CFLAGS_OTHER})
  1304. target_link_libraries(libnetdata PUBLIC ${JSONC_LDFLAGS})
  1305. endif()
  1306. # message(FATAL_ERROR "jsonc libraries: ${JSONC_LIBRARIES}")
  1307. # message(FATAL_ERROR "jsonc ldflags: ${JSONC_LDFLAGS}")
  1308. # yaml
  1309. set(HAVE_LIBYAML True)
  1310. if(ENABLE_BUNDLED_YAML)
  1311. add_library(yaml STATIC IMPORTED)
  1312. set_property(TARGET yaml PROPERTY
  1313. IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/externaldeps/libyaml/libyaml.a")
  1314. target_include_directories(libnetdata BEFORE PUBLIC "${CMAKE_SOURCE_DIR}/externaldeps/libyaml")
  1315. target_link_libraries(libnetdata PUBLIC yaml)
  1316. else()
  1317. pkg_check_modules(YAML REQUIRED yaml-0.1)
  1318. target_include_directories(libnetdata BEFORE PUBLIC ${YAML_INCLUDE_DIRS})
  1319. target_compile_definitions(libnetdata PUBLIC ${YAML_CFLAGS_OTHER})
  1320. target_link_libraries(libnetdata PUBLIC ${YAML_LDFLAGS})
  1321. endif()
  1322. # zlib
  1323. pkg_check_modules(ZLIB REQUIRED zlib)
  1324. target_include_directories(libnetdata BEFORE PUBLIC ${ZLIB_INCLUDE_DIRS})
  1325. target_compile_definitions(libnetdata PUBLIC ${ZLIB_CFLAGS_OTHER})
  1326. target_link_libraries(libnetdata PUBLIC ${ZLIB_LDFLAGS})
  1327. # lz4 - try to find a version that is compatible with streaming compression
  1328. # otherwise pick whichever one we can find to support dbengine but don't set
  1329. # ENABLE_LZ4.
  1330. pkg_check_modules(LIBLZ4 liblz4>=1.9.0)
  1331. if(LIBLZ4_FOUND)
  1332. set(ENABLE_LZ4 On)
  1333. else()
  1334. pkg_check_modules(LIBLZ4 REQUIRED liblz4)
  1335. endif()
  1336. target_include_directories(libnetdata BEFORE PUBLIC ${LIBLZ4_INCLUDE_DIRS})
  1337. target_compile_definitions(libnetdata PUBLIC ${LIBLZ4_CFLAGS_OTHER})
  1338. target_link_libraries(libnetdata PUBLIC ${LIBLZ4_LDFLAGS})
  1339. # zstd
  1340. pkg_check_modules(LIBZSTD libzstd)
  1341. if(LIBZSTD_FOUND)
  1342. set(ENABLE_ZSTD On)
  1343. target_include_directories(libnetdata BEFORE PUBLIC ${LIBZSTD_INCLUDE_DIRS})
  1344. target_compile_definitions(libnetdata PUBLIC ${LIBZSTD_CFLAGS_OTHER})
  1345. target_link_libraries(libnetdata PUBLIC ${LIBZSTD_LDFLAGS})
  1346. endif()
  1347. # brotli
  1348. pkg_check_modules(LIBBROTLI libbrotlidec libbrotlienc libbrotlicommon)
  1349. if(LIBBROTLI_FOUND)
  1350. set(ENABLE_BROTLI On)
  1351. target_include_directories(libnetdata BEFORE PUBLIC ${LIBBROTLI_INCLUDE_DIRS})
  1352. target_compile_definitions(libnetdata PUBLIC ${LIBBROTLI_CFLAGS_OTHER})
  1353. target_link_libraries(libnetdata PUBLIC ${LIBBROTLI_LDFLAGS})
  1354. endif()
  1355. # uuid
  1356. pkg_check_modules(UUID REQUIRED uuid)
  1357. target_include_directories(libnetdata BEFORE PUBLIC ${UUID_INCLUDE_DIRS})
  1358. target_compile_definitions(libnetdata PUBLIC ${UUID_CFLAGS_OTHER})
  1359. target_link_libraries(libnetdata PUBLIC ${UUID_LDFLAGS})
  1360. # uv
  1361. pkg_check_modules(LIBUV REQUIRED libuv)
  1362. target_include_directories(libnetdata BEFORE PUBLIC ${LIBUV_INCLUDE_DIRS})
  1363. target_compile_definitions(libnetdata PUBLIC ${LIBUV_CFLAGS_OTHER})
  1364. target_link_libraries(libnetdata PUBLIC ${LIBUV_LDFLAGS})
  1365. # crypto
  1366. target_include_directories(libnetdata BEFORE PUBLIC ${CRYPTO_INCLUDE_DIRS})
  1367. target_compile_options(libnetdata PUBLIC ${CRYPTO_CFLAGS_OTHER})
  1368. target_link_libraries(libnetdata PUBLIC ${CRYPTO_LDFLAGS})
  1369. # openssl
  1370. target_include_directories(libnetdata BEFORE PUBLIC ${OPENSSL_INCLUDE_DIRS})
  1371. target_compile_options(libnetdata PUBLIC ${OPENSSL_CFLAGS_OTHER})
  1372. target_link_libraries(libnetdata PUBLIC ${OPENSSL_LDFLAGS})
  1373. # h2o
  1374. target_link_libraries(libnetdata PUBLIC "$<$<BOOL:${ENABLE_H2O}>:h2o>")
  1375. #
  1376. # helper function to build protos
  1377. #
  1378. function(protoc_generate_cpp INC_DIR OUT_DIR SRCS HDRS)
  1379. if(NOT ARGN)
  1380. message(SEND_ERROR "Error: protoc_generate_cpp() called without any proto files")
  1381. return()
  1382. endif()
  1383. set(${INC_DIR})
  1384. set(${OUT_DIR})
  1385. set(${SRCS})
  1386. set(${HDRS})
  1387. foreach(FIL ${ARGN})
  1388. get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
  1389. get_filename_component(DIR ${ABS_FIL} DIRECTORY)
  1390. get_filename_component(FIL_WE ${FIL} NAME_WE)
  1391. set(GENERATED_PB_CC "${DIR}/${FIL_WE}.pb.cc")
  1392. list(APPEND ${SRCS} ${GENERATED_PB_CC})
  1393. set(GENERATED_PB_H "${DIR}/${FIL_WE}.pb.h")
  1394. list(APPEND ${HDRS} ${GENERATED_PB_H})
  1395. add_custom_command(OUTPUT ${GENERATED_PB_CC} ${GENERATED_PB_H}
  1396. COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} ARGS -I=${INC_DIR} --cpp_out=${OUT_DIR} ${ABS_FIL}
  1397. DEPENDS ${ABS_FIL} ${PROTOBUF_PROTOC_EXECUTABLE}
  1398. COMMENT "Running C++ protocol buffer compiler on ${FIL}"
  1399. VERBATIM)
  1400. endforeach()
  1401. set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES GENERATED TRUE)
  1402. set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES COMPILE_OPTIONS -Wno-deprecated-declarations)
  1403. set(${SRCS} ${${SRCS}} PARENT_SCOPE)
  1404. set(${HDRS} ${${HDRS}} PARENT_SCOPE)
  1405. endfunction()
  1406. #
  1407. # mqtt library
  1408. #
  1409. if (ENABLE_H2O OR ENABLE_ACLK)
  1410. set(ENABLE_MQTTWEBSOCKETS True)
  1411. endif()
  1412. if(ENABLE_MQTTWEBSOCKETS)
  1413. include_directories(BEFORE
  1414. ${CMAKE_SOURCE_DIR}/mqtt_websockets/src/include
  1415. ${CMAKE_SOURCE_DIR}/mqtt_websockets/c-rbuf/include
  1416. ${CMAKE_SOURCE_DIR}/mqtt_websockets/c_rhash/include
  1417. )
  1418. add_library(mqttwebsockets STATIC ${MQTT_WEBSOCKETS_FILES})
  1419. target_compile_options(mqttwebsockets PUBLIC -DMQTT_WSS_CUSTOM_ALLOC
  1420. -DRBUF_CUSTOM_MALLOC
  1421. -DMQTT_WSS_CPUSTATS)
  1422. target_include_directories(mqttwebsockets PUBLIC ${CMAKE_SOURCE_DIR}/aclk/helpers
  1423. ${CMAKE_SOURCE_DIR}/web/server/h2o/libh2o/include)
  1424. target_link_libraries(mqttwebsockets PRIVATE libnetdata)
  1425. endif()
  1426. if(ENABLE_ACLK)
  1427. #
  1428. # proto definitions
  1429. #
  1430. protoc_generate_cpp("${CMAKE_SOURCE_DIR}/aclk/aclk-schemas"
  1431. "${CMAKE_SOURCE_DIR}/aclk/aclk-schemas"
  1432. ACLK_PROTO_BUILT_SRCS
  1433. ACLK_PROTO_BUILT_HDRS
  1434. ${ACLK_PROTO_DEFS})
  1435. list(APPEND ACLK_FILES ${ACLK_PROTO_BUILT_SRCS}
  1436. ${ACLK_PROTO_BUILT_HDRS})
  1437. endif()
  1438. #
  1439. # build plugins
  1440. #
  1441. if(ENABLE_PLUGIN_DEBUGFS)
  1442. pkg_check_modules(CAP QUIET libcap)
  1443. set(DEBUGFS_PLUGIN_FILES collectors/debugfs.plugin/debugfs_plugin.c
  1444. collectors/debugfs.plugin/debugfs_plugin.h
  1445. collectors/debugfs.plugin/debugfs_extfrag.c
  1446. collectors/debugfs.plugin/debugfs_zswap.c
  1447. collectors/debugfs.plugin/sys_devices_virtual_powercap.c)
  1448. add_executable(debugfs.plugin ${DEBUGFS_PLUGIN_FILES})
  1449. target_link_libraries(debugfs.plugin libnetdata ${CAP_LIBRARIES})
  1450. target_include_directories(debugfs.plugin PRIVATE ${CAP_INCLUDE_DIRS})
  1451. target_compile_options(debugfs.plugin PRIVATE ${CAP_CFLAGS_OTHER})
  1452. install(TARGETS debugfs.plugin
  1453. COMPONENT debugfs_plugin
  1454. DESTINATION usr/libexec/netdata/plugins.d)
  1455. endif()
  1456. if(ENABLE_PLUGIN_APPS)
  1457. pkg_check_modules(CAP QUIET libcap)
  1458. set(APPS_PLUGIN_FILES collectors/apps.plugin/apps_plugin.c)
  1459. add_executable(apps.plugin ${APPS_PLUGIN_FILES})
  1460. target_link_libraries(apps.plugin libnetdata ${CAP_LIBRARIES})
  1461. target_include_directories(apps.plugin PRIVATE ${CAP_INCLUDE_DIRS})
  1462. target_compile_options(apps.plugin PRIVATE ${CAP_CFLAGS_OTHER})
  1463. install(TARGETS apps.plugin
  1464. COMPONENT apps_plugin
  1465. DESTINATION usr/libexec/netdata/plugins.d)
  1466. install(FILES collectors/apps.plugin/apps_groups.conf
  1467. COMPONENT apps_plugin
  1468. DESTINATION usr/lib/netdata/conf.d)
  1469. endif()
  1470. if(CAP_FOUND)
  1471. set(HAVE_CAPABILITY True)
  1472. endif()
  1473. if(ENABLE_PLUGIN_FREEIPMI)
  1474. pkg_check_modules(IPMI REQUIRED libipmimonitoring)
  1475. set(FREEIPMI_PLUGIN_FILES collectors/freeipmi.plugin/freeipmi_plugin.c)
  1476. add_executable(freeipmi.plugin ${FREEIPMI_PLUGIN_FILES})
  1477. target_link_libraries (freeipmi.plugin libnetdata ${IPMI_LIBRARIES})
  1478. target_include_directories(freeipmi.plugin PRIVATE ${IPMI_INCLUDE_DIRS})
  1479. target_compile_options(freeipmi.plugin PRIVATE ${IPMI_CFLAGS_OTHER})
  1480. install(TARGETS freeipmi.plugin
  1481. COMPONENT freeipmi_plugin
  1482. DESTINATION usr/libexec/netdata/plugins.d)
  1483. endif()
  1484. if(ENABLE_PLUGIN_NFACCT)
  1485. pkg_check_modules(NFACCT REQUIRED libnetfilter_acct)
  1486. pkg_check_modules(MNL REQUIRED libmnl)
  1487. set(NFACCT_PLUGIN_FILES collectors/nfacct.plugin/plugin_nfacct.c)
  1488. add_executable(nfacct.plugin ${NFACCT_PLUGIN_FILES})
  1489. target_link_libraries (nfacct.plugin libnetdata ${MNL_LIBRARIES} ${NFACCT_LIBRARIES})
  1490. target_include_directories(nfacct.plugin PRIVATE ${MNL_INCLUDE_DIRS} ${NFACCT_INCLUDE_DIRS})
  1491. target_compile_options(nfacct.plugin PRIVATE ${MNL_CFLAGS_OTHER} ${NFACCT_CFLAGS_OTHER})
  1492. install(TARGETS nfacct.plugin
  1493. COMPONENT nfacct_plugin
  1494. DESTINATION usr/libexec/netdata/plugins.d)
  1495. endif()
  1496. if(ENABLE_PLUGIN_XENSTAT)
  1497. pkg_check_modules(XENSTAT REQUIRED xenstat)
  1498. pkg_check_modules(XENLIGHT REQUIRED xenlight)
  1499. set(XENSTAT_PLUGIN_FILES collectors/xenstat.plugin/xenstat_plugin.c)
  1500. add_executable(xenstat.plugin ${XENSTAT_PLUGIN_FILES})
  1501. target_link_libraries (xenstat.plugin libnetdata ${XENLIGHT_LIBRARIES} ${XENSTAT_LIBRARIES})
  1502. target_include_directories(xenstat.plugin PRIVATE ${XENLIGHT_INCLUDE_DIRS} ${XENSTAT_INCLUDE_DIRS})
  1503. target_compile_options(xenstat.plugin PRIVATE ${XENLIGHT_CFLAGS_OTHER} ${XENSTAT_CFLAGS_OTHER})
  1504. install(TARGETS xenstat.plugin
  1505. COMPONENT xenstat_plugin
  1506. DESTINATION usr/libexec/netdata/plugins.d)
  1507. endif()
  1508. if(ENABLE_PLUGIN_PERF)
  1509. set(PERF_PLUGIN_FILES collectors/perf.plugin/perf_plugin.c)
  1510. add_executable(perf.plugin ${PERF_PLUGIN_FILES})
  1511. target_link_libraries(perf.plugin libnetdata)
  1512. install(TARGETS perf.plugin
  1513. COMPONENT perf_plugin
  1514. DESTINATION usr/libexec/netdata/plugins.d)
  1515. endif()
  1516. if(ENABLE_PLUGIN_SLABINFO)
  1517. set(SLABINFO_PLUGIN_FILES collectors/slabinfo.plugin/slabinfo.c)
  1518. add_executable(slabinfo.plugin ${SLABINFO_PLUGIN_FILES})
  1519. target_link_libraries(slabinfo.plugin libnetdata)
  1520. install(TARGETS slabinfo.plugin
  1521. COMPONENT slabinfo_plugin
  1522. DESTINATION usr/libexec/netdata/plugins.d)
  1523. endif()
  1524. if(ENABLE_PLUGIN_LOGS_MANAGEMENT)
  1525. set(ENABLE_LOGSMANAGEMENT True)
  1526. if(ENABLE_LOGS_MANAGEMENT_TESTS)
  1527. list(APPEND LOGS_MANAGEMENT_PLUGIN_FILES logsmanagement/unit_test/unit_test.c
  1528. logsmanagement/unit_test/unit_test.h)
  1529. set(ENABLE_LOGSMANAGEMENT_TESTS True)
  1530. endif()
  1531. add_executable(logs-management.plugin ${LOGS_MANAGEMENT_PLUGIN_FILES})
  1532. target_link_libraries(logs-management.plugin libnetdata)
  1533. install(TARGETS logs-management.plugin
  1534. COMPONENT logs_management_plugin
  1535. DESTINATION usr/libexec/netdata/plugins.d)
  1536. install(DIRECTORY logsmanagement/stock_conf/logsmanagement.d
  1537. COMPONENT logs_management_plugin
  1538. DESTINATION usr/lib/netdata/conf.d)
  1539. install(DIRECTORY DESTINATION etc/netdata/logsmanagement.d)
  1540. endif()
  1541. if(ENABLE_PLUGIN_CUPS)
  1542. pkg_check_modules(CUPS libcups)
  1543. if(NOT CUPS_LIBRARIES)
  1544. pkg_check_modules(CUPS cups)
  1545. if(NOT CUPS_LIBRARIES)
  1546. find_program(CUPS_CONFIG cups-config)
  1547. if(CUPS_CONFIG)
  1548. execute_process(COMMAND ${CUPS_CONFIG} --api-version OUTPUT_VARIABLE CUPS_API_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
  1549. if(CUPS_API_VERSION VERSION_LESS "1.7")
  1550. set(CUPS_FOUND False)
  1551. else()
  1552. execute_process(COMMAND ${CUPS_CONFIG} --cflags OUTPUT_VARIABLE CUPS_CFLAGS_OTHER OUTPUT_STRIP_TRAILING_WHITESPACE)
  1553. execute_process(COMMAND ${CUPS_CONFIG} --libs OUTPUT_VARIABLE CUPS_LIBRARIES OUTPUT_STRIP_TRAILING_WHITESPACE)
  1554. set(CUPS_FOUND True)
  1555. endif()
  1556. endif()
  1557. endif()
  1558. endif()
  1559. if(NOT CUPS_FOUND)
  1560. message(WARNING "Could not find cups cflags and libs.")
  1561. else()
  1562. set(CUPS_PLUGIN_FILES collectors/cups.plugin/cups_plugin.c)
  1563. add_executable(cups.plugin ${CUPS_PLUGIN_FILES})
  1564. target_link_libraries (cups.plugin libnetdata ${CUPS_LIBRARIES})
  1565. target_compile_options(cups.plugin PRIVATE ${CUPS_CFLAGS_OTHER})
  1566. install(TARGETS cups.plugin
  1567. COMPONENT cups_plugin
  1568. DESTINATION usr/libexec/netdata/plugins.d)
  1569. endif()
  1570. endif()
  1571. set(NDSUDO_FILES collectors/plugins.d/ndsudo.c)
  1572. add_executable(ndsudo ${NDSUDO_FILES})
  1573. install(TARGETS ndsudo
  1574. COMPONENT ndsudo
  1575. DESTINATION usr/libexec/netdata/plugins.d)
  1576. if(ENABLE_PLUGIN_CGROUP_NETWORK)
  1577. set(CGROUP_NETWORK_FILES collectors/cgroups.plugin/cgroup-network.c)
  1578. add_executable(cgroup-network ${CGROUP_NETWORK_FILES})
  1579. target_link_libraries(cgroup-network libnetdata)
  1580. install(TARGETS cgroup-network
  1581. COMPONENT cgroup_network_plugin
  1582. DESTINATION usr/libexec/netdata/plugins.d)
  1583. endif()
  1584. if(ENABLE_PLUGIN_SYSTEMD_JOURNAL)
  1585. add_executable(systemd-journal.plugin ${SYSTEMD_JOURNAL_PLUGIN_FILES})
  1586. target_link_libraries(systemd-journal.plugin libnetdata)
  1587. install(TARGETS systemd-journal.plugin
  1588. COMPONENT systemd_journal_plugin
  1589. DESTINATION usr/libexec/netdata/plugins.d)
  1590. endif()
  1591. if(ENABLE_PLUGIN_EBPF)
  1592. set(EBPF_PLUGIN_FILES
  1593. collectors/ebpf.plugin/ebpf.c
  1594. collectors/ebpf.plugin/ebpf.h
  1595. collectors/ebpf.plugin/ebpf_cachestat.c
  1596. collectors/ebpf.plugin/ebpf_cachestat.h
  1597. collectors/ebpf.plugin/ebpf_dcstat.c
  1598. collectors/ebpf.plugin/ebpf_dcstat.h
  1599. collectors/ebpf.plugin/ebpf_disk.c
  1600. collectors/ebpf.plugin/ebpf_disk.h
  1601. collectors/ebpf.plugin/ebpf_fd.c
  1602. collectors/ebpf.plugin/ebpf_fd.h
  1603. collectors/ebpf.plugin/ebpf_hardirq.c
  1604. collectors/ebpf.plugin/ebpf_hardirq.h
  1605. collectors/ebpf.plugin/ebpf_mdflush.c
  1606. collectors/ebpf.plugin/ebpf_mdflush.h
  1607. collectors/ebpf.plugin/ebpf_mount.c
  1608. collectors/ebpf.plugin/ebpf_mount.h
  1609. collectors/ebpf.plugin/ebpf_filesystem.c
  1610. collectors/ebpf.plugin/ebpf_filesystem.h
  1611. collectors/ebpf.plugin/ebpf_oomkill.c
  1612. collectors/ebpf.plugin/ebpf_oomkill.h
  1613. collectors/ebpf.plugin/ebpf_process.c
  1614. collectors/ebpf.plugin/ebpf_process.h
  1615. collectors/ebpf.plugin/ebpf_shm.c
  1616. collectors/ebpf.plugin/ebpf_shm.h
  1617. collectors/ebpf.plugin/ebpf_socket.c
  1618. collectors/ebpf.plugin/ebpf_socket.h
  1619. collectors/ebpf.plugin/ebpf_softirq.c
  1620. collectors/ebpf.plugin/ebpf_softirq.h
  1621. collectors/ebpf.plugin/ebpf_sync.c
  1622. collectors/ebpf.plugin/ebpf_sync.h
  1623. collectors/ebpf.plugin/ebpf_swap.c
  1624. collectors/ebpf.plugin/ebpf_swap.h
  1625. collectors/ebpf.plugin/ebpf_vfs.c
  1626. collectors/ebpf.plugin/ebpf_vfs.h
  1627. collectors/ebpf.plugin/ebpf_apps.c
  1628. collectors/ebpf.plugin/ebpf_apps.h
  1629. collectors/ebpf.plugin/ebpf_cgroup.c
  1630. collectors/ebpf.plugin/ebpf_cgroup.h
  1631. collectors/ebpf.plugin/ebpf_unittest.c
  1632. collectors/ebpf.plugin/ebpf_unittest.h
  1633. collectors/ebpf.plugin/ebpf_functions.c
  1634. collectors/ebpf.plugin/ebpf_functions.h
  1635. )
  1636. add_executable(ebpf.plugin ${EBPF_PLUGIN_FILES})
  1637. target_link_libraries(ebpf.plugin libnetdata)
  1638. install(TARGETS ebpf.plugin
  1639. COMPONENT ebpf_plugin
  1640. DESTINATION usr/libexec/netdata/plugins.d)
  1641. endif()
  1642. if(ENABLE_PLUGIN_LOCAL_LISTENERS)
  1643. set(LOCAL_LISTENERS_FILES collectors/plugins.d/local_listeners.c)
  1644. add_executable(local-listeners ${LOCAL_LISTENERS_FILES})
  1645. target_link_libraries(local-listeners libnetdata)
  1646. install(TARGETS local-listeners
  1647. COMPONENT local_listeners
  1648. DESTINATION usr/libexec/netdata/plugins.d)
  1649. endif()
  1650. #
  1651. # exporters
  1652. #
  1653. if(ENABLE_EXPORTER_MONGODB)
  1654. pkg_check_modules(MONGOC libmongoc-1.0>=1.7)
  1655. if(MONGOC_FOUND)
  1656. SET(HAVE_MONGOC True)
  1657. else()
  1658. SET(ENABLE_EXPORTER_MONGODB False)
  1659. endif()
  1660. endif()
  1661. if(ENABLE_EXPORTER_PROMETHEUS_REMOTE_WRITE)
  1662. pkg_check_modules(SNAPPY snappy)
  1663. if (NOT SNAPPY_FOUND)
  1664. if(HAVE_SNAPPY_LIB)
  1665. set(SNAPPY_INCLUDE_DIRS "")
  1666. set(SNAPPY_CFLAGS_OTHER "")
  1667. set(SNAPPY_LIBRARIES "-lsnappy")
  1668. else()
  1669. message(FATAL_ERROR "Could not find snappy libraries with pkg-config or internal cmake checks.")
  1670. endif()
  1671. endif()
  1672. protoc_generate_cpp("${CMAKE_SOURCE_DIR}/exporting/prometheus/remote_write"
  1673. "${CMAKE_SOURCE_DIR}/exporting/prometheus/remote_write"
  1674. PROMETHEUS_REMOTE_WRITE_BUILT_SRCS
  1675. PROMETHEUS_REMOTE_WRITE_BUILT_HDRS
  1676. "exporting/prometheus/remote_write/remote_write.proto")
  1677. list(APPEND PROMETHEUS_REMOTE_WRITE_EXPORTING_FILES
  1678. ${PROMETHEUS_REMOTE_WRITE_BUILT_SRCS}
  1679. ${PROMETHEUS_REMOTE_WRITE_BUILT_HDRS})
  1680. set(ENABLE_PROMETHEUS_REMOTE_WRITE True)
  1681. endif()
  1682. #
  1683. # build netdata (only Linux ATM)
  1684. #
  1685. add_executable(netdata
  1686. ${NETDATA_FILES}
  1687. "$<$<BOOL:${ENABLE_ACLK}>:${ACLK_FILES}>"
  1688. "$<$<BOOL:${ENABLE_H2O}>:${H2O_FILES}>"
  1689. "$<$<BOOL:${ENABLE_EXPORTER_MONGODB}>:${MONGODB_EXPORTING_FILES}>"
  1690. "$<$<BOOL:${ENABLE_EXPORTER_PROMETHEUS_REMOTE_WRITE}>:${PROMETHEUS_REMOTE_WRITE_EXPORTING_FILES}>"
  1691. )
  1692. target_compile_definitions(netdata PRIVATE
  1693. "$<$<BOOL:${ENABLE_PROTOBUF}>:${PROTOBUF_CFLAGS_OTHER}>"
  1694. "$<$<BOOL:${ENABLE_ML}>:DLIB_NO_GUI_SUPPORT>"
  1695. "$<$<BOOL:${ENABLE_EXPORTER_MONGODB}>:${MONGOC_CFLAGS_OTHER}>"
  1696. "$<$<BOOL:${ENABLE_EXPORTER_PROMETHEUS_REMOTE_WRITE}>:${SNAPPY_CFLAGS_OTHER}>"
  1697. )
  1698. target_include_directories(netdata PRIVATE
  1699. "$<$<BOOL:${ENABLE_PROTOBUF}>:${PROTOBUF_INCLUDE_DIRS}>"
  1700. "$<$<BOOL:${ENABLE_ACLK}>:${CMAKE_SOURCE_DIR}/aclk/aclk-schemas>"
  1701. "$<$<BOOL:${ENABLE_MQTTWEBSOCKETS}>:${CMAKE_SOURCE_DIR}/mqtt_websockets/src/include>"
  1702. "$<$<BOOL:${ENABLE_MQTTWEBSOCKETS}>:${CMAKE_SOURCE_DIR}/mqtt_websockets/c-rbuf/include>"
  1703. "$<$<BOOL:${ENABLE_ML}>:${CMAKE_SOURCE_DIR}/ml/dlib>"
  1704. "$<$<BOOL:${ENABLE_EXPORTER_MONGODB}>:${MONGOC_INCLUDE_DIRS}>"
  1705. "$<$<BOOL:${ENABLE_EXPORTER_PROMETHEUS_REMOTE_WRITE}>:${SNAPPY_INCLUDE_DIRS}>"
  1706. )
  1707. target_link_libraries(netdata PRIVATE
  1708. m
  1709. libnetdata
  1710. "$<$<BOOL:${LINUX}>:rt>"
  1711. "$<$<BOOL:${ENABLE_MQTTWEBSOCKETS}>:mqttwebsockets>"
  1712. "$<$<BOOL:${ENABLE_PROTOBUF}>:${PROTOBUF_LIBRARIES}>"
  1713. "$<$<BOOL:${ENABLE_EXPORTER_MONGODB}>:${MONGOC_LIBRARIES}>"
  1714. "$<$<BOOL:${ENABLE_EXPORTER_PROMETHEUS_REMOTE_WRITE}>:${SNAPPY_LIBRARIES}>"
  1715. "$<$<BOOL:${MACOS}>:${IOKIT};${FOUNDATION}>"
  1716. )
  1717. #
  1718. # build systemd-cat-native
  1719. #
  1720. set(SYSTEMD_CAT_NATIVE_FILES libnetdata/log/systemd-cat-native.c
  1721. libnetdata/log/systemd-cat-native.h)
  1722. add_executable(systemd-cat-native ${SYSTEMD_CAT_NATIVE_FILES})
  1723. target_link_libraries(systemd-cat-native libnetdata)
  1724. install(TARGETS systemd-cat-native
  1725. COMPONENT systemd-cat-native
  1726. DESTINATION usr/sbin)
  1727. #
  1728. # build log2journal
  1729. #
  1730. pkg_check_modules(PCRE2 libpcre2-8)
  1731. if(PCRE2_FOUND)
  1732. set(LOG2JOURNAL_FILES
  1733. ${CONFIG_H}
  1734. collectors/log2journal/log2journal.h
  1735. collectors/log2journal/log2journal.c
  1736. collectors/log2journal/log2journal-help.c
  1737. collectors/log2journal/log2journal-yaml.c
  1738. collectors/log2journal/log2journal-json.c
  1739. collectors/log2journal/log2journal-logfmt.c
  1740. collectors/log2journal/log2journal-pcre2.c
  1741. collectors/log2journal/log2journal-params.c
  1742. collectors/log2journal/log2journal-inject.c
  1743. collectors/log2journal/log2journal-pattern.c
  1744. collectors/log2journal/log2journal-replace.c
  1745. collectors/log2journal/log2journal-rename.c
  1746. collectors/log2journal/log2journal-rewrite.c
  1747. )
  1748. add_executable(log2journal ${LOG2JOURNAL_FILES})
  1749. target_include_directories(log2journal BEFORE PUBLIC ${CONFIG_H_DIR} ${PCRE2_INCLUDE_DIRS})
  1750. target_compile_definitions(log2journal PUBLIC ${PCRE2_CFLAGS_OTHER})
  1751. target_link_libraries(log2journal PUBLIC "${PCRE2_LDFLAGS}")
  1752. if(ENABLE_BUNDLED_YAML)
  1753. target_include_directories(log2journal BEFORE PUBLIC "${CMAKE_SOURCE_DIR}/externaldeps/libyaml")
  1754. target_link_libraries(log2journal PUBLIC yaml)
  1755. else()
  1756. target_include_directories(log2journal BEFORE PUBLIC ${YAML_INCLUDE_DIRS})
  1757. target_compile_definitions(log2journal PUBLIC ${YAML_CFLAGS_OTHER})
  1758. target_link_libraries(log2journal PUBLIC ${YAML_LDFLAGS})
  1759. endif()
  1760. install(TARGETS log2journal
  1761. COMPONENT log2journal
  1762. DESTINATION usr/sbin)
  1763. install(DIRECTORY collectors/log2journal/log2journal.d
  1764. COMPONENT log2journal
  1765. DESTINATION usr/lib/netdata/conf.d)
  1766. endif()
  1767. #
  1768. # build netdatacli
  1769. #
  1770. set(NETDATACLI_FILES
  1771. daemon/commands.h
  1772. daemon/pipename.c
  1773. daemon/pipename.h
  1774. cli/cli.c
  1775. )
  1776. add_executable(netdatacli ${NETDATACLI_FILES})
  1777. target_link_libraries(netdatacli libnetdata)
  1778. install(TARGETS netdatacli
  1779. COMPONENT netdatacli
  1780. DESTINATION usr/sbin)
  1781. #
  1782. # Generate config file
  1783. #
  1784. add_definitions(-DHAVE_CONFIG_H)
  1785. set(STORAGE_WITH_MATH On)
  1786. if(NOT CMAKE_INSTALL_PREFIX STREQUAL "")
  1787. string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
  1788. endif()
  1789. set(CACHE_DIR "${CMAKE_INSTALL_PREFIX}/var/cache/netdata")
  1790. set(CONFIG_DIR "${CMAKE_INSTALL_PREFIX}/etc/netdata")
  1791. set(LIBCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/usr/lib/netdata/conf.d")
  1792. set(LOG_DIR "${CMAKE_INSTALL_PREFIX}/var/log/netdata")
  1793. set(PLUGINS_DIR "${CMAKE_INSTALL_PREFIX}/usr/libexec/netdata/plugins.d")
  1794. set(VARLIB_DIR "${CMAKE_INSTALL_PREFIX}/var/lib/netdata")
  1795. # A non-default value is only used when building Debian packages (/var/lib/netdata/www)
  1796. if(NOT DEFINED WEB_DIR)
  1797. set(WEB_DIR "usr/share/netdata/web")
  1798. else()
  1799. string(REGEX REPLACE "^/" "" WEB_DIR "${WEB_DIR}")
  1800. endif()
  1801. set(WEB_DEST "${WEB_DIR}")
  1802. set(WEB_DIR "${CMAKE_INSTALL_PREFIX}/${WEB_DEST}")
  1803. set(CONFIGURE_COMMAND "dummy-configure-command")
  1804. if (NOT NETDATA_USER)
  1805. set(NETDATA_USER "netdata")
  1806. endif()
  1807. set(VERSION "${GIT_DESCRIBE_OUTPUT}")
  1808. configure_file(config.cmake.h.in config.h)
  1809. #
  1810. # install
  1811. #
  1812. install(TARGETS netdata DESTINATION usr/sbin)
  1813. install(DIRECTORY DESTINATION var/cache/netdata)
  1814. install(DIRECTORY DESTINATION var/log/netdata)
  1815. install(DIRECTORY DESTINATION var/lib/netdata/registry)
  1816. install(DIRECTORY DESTINATION var/lib/netdata/cloud.d)
  1817. install(DIRECTORY DESTINATION var/run)
  1818. install(DIRECTORY DESTINATION etc/netdata)
  1819. install(DIRECTORY DESTINATION etc/netdata/charts.d)
  1820. install(DIRECTORY DESTINATION etc/netdata/custom-plugins.d)
  1821. install(DIRECTORY DESTINATION etc/netdata/ebpf.d)
  1822. install(DIRECTORY DESTINATION etc/netdata/go.d)
  1823. install(DIRECTORY DESTINATION etc/netdata/health.d)
  1824. install(DIRECTORY DESTINATION etc/netdata/python.d)
  1825. install(DIRECTORY DESTINATION etc/netdata/ssl)
  1826. install(DIRECTORY DESTINATION etc/netdata/statsd.d)
  1827. install(DIRECTORY DESTINATION usr/lib/netdata/conf.d)
  1828. install(DIRECTORY DESTINATION usr/libexec/netdata/plugins.d)
  1829. install(DIRECTORY DESTINATION ${WEB_DEST})
  1830. set(libsysdir_POST "${CMAKE_INSTALL_PREFIX}/usr/lib/netdata/system")
  1831. set(pkglibexecdir_POST "${CMAKE_INSTALL_PREFIX}/usr/libexec/netdata")
  1832. set(localstatedir_POST "${CMAKE_INSTALL_PREFIX}/var")
  1833. set(sbindir_POST "${CMAKE_INSTALL_PREFIX}/usr/sbin")
  1834. set(configdir_POST "${CMAKE_INSTALL_PREFIX}/etc/netdata")
  1835. set(libconfigdir_POST "${CMAKE_INSTALL_PREFIX}/usr/lib/netdata/conf.d")
  1836. set(cachedir_POST "${CMAKE_INSTALL_PREFIX}/var/cache/netdata")
  1837. set(registrydir_POST "${CMAKE_INSTALL_PREFIX}/var/lib/netdata/registry")
  1838. set(varlibdir_POST "${CMAKE_INSTALL_PREFIX}/var/lib/netdata")
  1839. set(netdata_user_POST "${NETDATA_USER}")
  1840. # netdata-claim.sh
  1841. if(ENABLE_CLOUD)
  1842. set(enable_cloud_POST "yes")
  1843. else()
  1844. set(enable_cloud_POST "no")
  1845. endif()
  1846. if(ENABLE_ACLK)
  1847. set(enable_aclk_POST "yes")
  1848. else()
  1849. set(enable_aclk_POST "no")
  1850. endif()
  1851. configure_file(claim/netdata-claim.sh.in claim/netdata-claim.sh @ONLY)
  1852. install(PROGRAMS
  1853. ${CMAKE_BINARY_DIR}/claim/netdata-claim.sh
  1854. DESTINATION usr/sbin)
  1855. #
  1856. # We don't check ENABLE_PLUGIN_CGROUP_NETWORK because rpm builds assume
  1857. # the files exists unconditionally.
  1858. #
  1859. configure_file(collectors/cgroups.plugin/cgroup-network-helper.sh.in
  1860. collectors/cgroups.plugin/cgroup-network-helper.sh @ONLY)
  1861. install(PROGRAMS
  1862. ${CMAKE_BINARY_DIR}/collectors/cgroups.plugin/cgroup-network-helper.sh
  1863. COMPONENT cgroup_network_plugin
  1864. DESTINATION usr/libexec/netdata/plugins.d)
  1865. configure_file(collectors/cgroups.plugin/cgroup-name.sh.in
  1866. collectors/cgroups.plugin/cgroup-name.sh @ONLY)
  1867. install(PROGRAMS
  1868. ${CMAKE_BINARY_DIR}/collectors/cgroups.plugin/cgroup-name.sh
  1869. DESTINATION usr/libexec/netdata/plugins.d)
  1870. #
  1871. # statsd
  1872. #
  1873. install(FILES
  1874. collectors/statsd.plugin/asterisk.conf
  1875. collectors/statsd.plugin/example.conf
  1876. collectors/statsd.plugin/k6.conf
  1877. DESTINATION usr/lib/netdata/conf.d/statsd.d)
  1878. #
  1879. # exporting
  1880. #
  1881. install(FILES
  1882. exporting/exporting.conf
  1883. DESTINATION usr/lib/netdata/conf.d)
  1884. #
  1885. # ioping.plugin
  1886. #
  1887. install(FILES
  1888. collectors/ioping.plugin/ioping.conf
  1889. DESTINATION usr/lib/netdata/conf.d)
  1890. #
  1891. # streaming
  1892. #
  1893. install(FILES
  1894. streaming/stream.conf
  1895. DESTINATION usr/lib/netdata/conf.d)
  1896. #
  1897. # swagger
  1898. #
  1899. install(FILES
  1900. web/api/netdata-swagger.json
  1901. web/api/netdata-swagger.yaml
  1902. DESTINATION ${WEB_DEST})
  1903. #
  1904. # service files
  1905. #
  1906. configure_file(system/install-service.sh.in system/install-service.sh @ONLY)
  1907. install(PROGRAMS
  1908. ${CMAKE_BINARY_DIR}/system/install-service.sh
  1909. DESTINATION usr/libexec/netdata)
  1910. configure_file(system/cron/netdata-updater-daily.in system/cron/netdata-updater-daily @ONLY)
  1911. install(FILES
  1912. ${CMAKE_BINARY_DIR}/system/cron/netdata-updater-daily
  1913. DESTINATION usr/lib/netdata/system/cron)
  1914. configure_file(system/launchd/netdata.plist.in system/launchd/netdata.plist @ONLY)
  1915. install(FILES
  1916. ${CMAKE_BINARY_DIR}/system/launchd/netdata.plist
  1917. DESTINATION usr/lib/netdata/system/launchd)
  1918. configure_file(system/freebsd/rc.d/netdata.in system/freebsd/rc.d/netdata @ONLY)
  1919. install(PROGRAMS
  1920. ${CMAKE_BINARY_DIR}/system/freebsd/rc.d/netdata
  1921. DESTINATION usr/lib/netdata/system/freebsd/rc.d)
  1922. configure_file(system/initd/init.d/netdata.in system/initd/init.d/netdata @ONLY)
  1923. install(PROGRAMS
  1924. ${CMAKE_BINARY_DIR}/system/initd/init.d/netdata
  1925. DESTINATION usr/lib/netdata/system/initd/init.d)
  1926. configure_file(system/logrotate/netdata.in system/logrotate/netdata @ONLY)
  1927. install(FILES
  1928. ${CMAKE_BINARY_DIR}/system/logrotate/netdata
  1929. DESTINATION usr/lib/netdata/system/logrotate)
  1930. configure_file(system/lsb/init.d/netdata.in system/lsb/init.d/netdata @ONLY)
  1931. install(PROGRAMS
  1932. ${CMAKE_BINARY_DIR}/system/lsb/init.d/netdata
  1933. DESTINATION usr/lib/netdata/system/lsb/init.d)
  1934. configure_file(system/openrc/conf.d/netdata.in system/openrc/conf.d/netdata @ONLY)
  1935. install(FILES
  1936. ${CMAKE_BINARY_DIR}/system/openrc/conf.d/netdata
  1937. DESTINATION usr/lib/netdata/system/openrc/conf.d)
  1938. configure_file(system/openrc/init.d/netdata.in system/openrc/init.d/netdata @ONLY)
  1939. install(PROGRAMS
  1940. ${CMAKE_BINARY_DIR}/system/openrc/init.d/netdata
  1941. DESTINATION usr/lib/netdata/system/openrc/init.d)
  1942. configure_file(system/runit/run.in system/runit/run @ONLY)
  1943. install(PROGRAMS
  1944. ${CMAKE_BINARY_DIR}/system/runit/run
  1945. DESTINATION usr/lib/netdata/system/runit)
  1946. configure_file(system/systemd/netdata.service.in system/systemd/netdata.service @ONLY)
  1947. install(FILES
  1948. ${CMAKE_BINARY_DIR}/system/systemd/netdata.service
  1949. DESTINATION usr/lib/netdata/system/systemd)
  1950. configure_file(system/systemd/netdata.service.v235.in system/systemd/netdata.service.v235 @ONLY)
  1951. install(FILES
  1952. ${CMAKE_BINARY_DIR}/system/systemd/netdata.service.v235
  1953. DESTINATION usr/lib/netdata/system/systemd)
  1954. configure_file(system/systemd/netdata-updater.service.in system/systemd/netdata-updater.service @ONLY)
  1955. install(FILES
  1956. ${CMAKE_BINARY_DIR}/system/systemd/netdata-updater.service
  1957. DESTINATION usr/lib/netdata/system/systemd)
  1958. install(FILES
  1959. system/systemd/netdata-updater.timer
  1960. DESTINATION usr/lib/netdata/system/systemd)
  1961. install(FILES
  1962. system/systemd/50-netdata.preset
  1963. DESTINATION usr/lib/netdata/system/systemd)
  1964. install(FILES
  1965. system/vnodes/vnodes.conf
  1966. DESTINATION usr/lib/netdata/conf.d/vnodes)
  1967. install(FILES
  1968. system/.install-type
  1969. DESTINATION etc/netdata)
  1970. install(FILES
  1971. system/netdata-updater.conf
  1972. DESTINATION etc/netdata)
  1973. install(PROGRAMS
  1974. system/edit-config
  1975. DESTINATION etc/netdata)
  1976. #
  1977. # TODO: check the following files for correct substitutions
  1978. #
  1979. configure_file(daemon/anonymous-statistics.sh.in daemon/anonymous-statistics.sh @ONLY)
  1980. install(PROGRAMS
  1981. ${CMAKE_BINARY_DIR}/daemon/anonymous-statistics.sh
  1982. DESTINATION usr/libexec/netdata/plugins.d)
  1983. configure_file(daemon/get-kubernetes-labels.sh.in daemon/get-kubernetes-labels.sh @ONLY)
  1984. install(PROGRAMS
  1985. ${CMAKE_BINARY_DIR}/daemon/get-kubernetes-labels.sh
  1986. DESTINATION usr/libexec/netdata/plugins.d)
  1987. install(PROGRAMS
  1988. daemon/system-info.sh
  1989. DESTINATION usr/libexec/netdata/plugins.d)
  1990. #
  1991. # health files
  1992. #
  1993. file(GLOB_RECURSE HEALTH_CONF_FILES "health/health.d/*.conf")
  1994. install(FILES
  1995. ${HEALTH_CONF_FILES}
  1996. DESTINATION usr/lib/netdata/conf.d/health.d)
  1997. configure_file(health/notifications/alarm-notify.sh.in health/notifications/alarm-notify.sh @ONLY)
  1998. install(PROGRAMS
  1999. ${CMAKE_BINARY_DIR}/health/notifications/alarm-notify.sh
  2000. DESTINATION usr/libexec/netdata/plugins.d)
  2001. install(PROGRAMS
  2002. health/notifications/alarm-email.sh
  2003. health/notifications/alarm-test.sh
  2004. DESTINATION usr/libexec/netdata/plugins.d)
  2005. install(FILES
  2006. health/notifications/health_alarm_notify.conf
  2007. health/notifications/health_email_recipients.conf
  2008. DESTINATION usr/lib/netdata/conf.d)
  2009. #
  2010. # test/ files
  2011. #
  2012. configure_file(tests/health_mgmtapi/health-cmdapi-test.sh.in tests/health_mgmtapi/health-cmdapi-test.sh @ONLY)
  2013. configure_file(tests/acls/acl.sh.in tests/acls/acl.sh @ONLY)
  2014. configure_file(tests/urls/request.sh.in tests/urls/request.sh @ONLY)
  2015. configure_file(tests/alarm_repetition/alarm.sh.in tests/alarm_repetition/alarm.sh @ONLY)
  2016. configure_file(tests/template_dimension/template_dim.sh.in tests/template_dimension/template_dim.sh @ONLY)
  2017. configure_file(tests/ebpf/ebpf_thread_function.sh.in tests/ebpf/ebpf_thread_function.sh @ONLY)
  2018. install(FILES
  2019. ${CMAKE_BINARY_DIR}/tests/health_mgmtapi/health-cmdapi-test.sh
  2020. ${CMAKE_BINARY_DIR}/tests/acls/acl.sh
  2021. ${CMAKE_BINARY_DIR}/tests/urls/request.sh
  2022. ${CMAKE_BINARY_DIR}/tests/alarm_repetition/alarm.sh
  2023. ${CMAKE_BINARY_DIR}/tests/template_dimension/template_dim.sh
  2024. ${CMAKE_BINARY_DIR}/tests/ebpf/ebpf_thread_function.sh
  2025. DESTINATION usr/libexec/netdata/plugins.d)
  2026. #
  2027. # charts.d files
  2028. #
  2029. configure_file(collectors/charts.d.plugin/charts.d.plugin.in collectors/charts.d.plugin/charts.d.plugin @ONLY)
  2030. install(PROGRAMS
  2031. ${CMAKE_BINARY_DIR}/collectors/charts.d.plugin/charts.d.plugin
  2032. DESTINATION usr/libexec/netdata/plugins.d)
  2033. install(FILES
  2034. collectors/charts.d.plugin/charts.d.dryrun-helper.sh
  2035. collectors/charts.d.plugin/loopsleepms.sh.inc
  2036. DESTINATION usr/libexec/netdata/plugins.d)
  2037. install(FILES
  2038. collectors/charts.d.plugin/charts.d.conf
  2039. DESTINATION usr/lib/netdata/conf.d)
  2040. #
  2041. # tc-qos-helper
  2042. #
  2043. configure_file(collectors/tc.plugin/tc-qos-helper.sh.in collectors/tc.plugin/tc-qos-helper.sh @ONLY)
  2044. install(PROGRAMS
  2045. ${CMAKE_BINARY_DIR}/collectors/tc.plugin/tc-qos-helper.sh
  2046. DESTINATION usr/libexec/netdata/plugins.d)
  2047. # scripts
  2048. install(FILES
  2049. collectors/charts.d.plugin/ap/ap.chart.sh
  2050. collectors/charts.d.plugin/apcupsd/apcupsd.chart.sh
  2051. collectors/charts.d.plugin/example/example.chart.sh
  2052. collectors/charts.d.plugin/libreswan/libreswan.chart.sh
  2053. collectors/charts.d.plugin/opensips/opensips.chart.sh
  2054. collectors/charts.d.plugin/sensors/sensors.chart.sh
  2055. DESTINATION usr/libexec/netdata/charts.d)
  2056. # confs
  2057. install(FILES
  2058. collectors/charts.d.plugin/ap/ap.conf
  2059. collectors/charts.d.plugin/apcupsd/apcupsd.conf
  2060. collectors/charts.d.plugin/example/example.conf
  2061. collectors/charts.d.plugin/libreswan/libreswan.conf
  2062. collectors/charts.d.plugin/opensips/opensips.conf
  2063. collectors/charts.d.plugin/sensors/sensors.conf
  2064. DESTINATION usr/lib/netdata/conf.d/charts.d)
  2065. #
  2066. # ebpf files
  2067. #
  2068. if(ENABLE_PLUGIN_EBPF)
  2069. install(FILES
  2070. collectors/ebpf.plugin/ebpf.d.conf
  2071. DESTINATION usr/lib/netdata/conf.d)
  2072. install(FILES
  2073. collectors/ebpf.plugin/ebpf.d/cachestat.conf
  2074. collectors/ebpf.plugin/ebpf.d/dcstat.conf
  2075. collectors/ebpf.plugin/ebpf.d/disk.conf
  2076. collectors/ebpf.plugin/ebpf.d/ebpf_kernel_reject_list.txt
  2077. collectors/ebpf.plugin/ebpf.d/fd.conf
  2078. collectors/ebpf.plugin/ebpf.d/filesystem.conf
  2079. collectors/ebpf.plugin/ebpf.d/hardirq.conf
  2080. collectors/ebpf.plugin/ebpf.d/mdflush.conf
  2081. collectors/ebpf.plugin/ebpf.d/mount.conf
  2082. collectors/ebpf.plugin/ebpf.d/network.conf
  2083. collectors/ebpf.plugin/ebpf.d/oomkill.conf
  2084. collectors/ebpf.plugin/ebpf.d/process.conf
  2085. collectors/ebpf.plugin/ebpf.d/shm.conf
  2086. collectors/ebpf.plugin/ebpf.d/softirq.conf
  2087. collectors/ebpf.plugin/ebpf.d/swap.conf
  2088. collectors/ebpf.plugin/ebpf.d/sync.conf
  2089. collectors/ebpf.plugin/ebpf.d/vfs.conf
  2090. DESTINATION usr/lib/netdata/conf.d/ebpf.d)
  2091. endif()
  2092. #
  2093. # python.d files
  2094. #
  2095. configure_file(collectors/python.d.plugin/python.d.plugin.in collectors/python.d.plugin/python.d.plugin @ONLY)
  2096. install(PROGRAMS ${CMAKE_BINARY_DIR}/collectors/python.d.plugin/python.d.plugin
  2097. DESTINATION usr/libexec/netdata/plugins.d)
  2098. install(DIRECTORY collectors/python.d.plugin/python_modules
  2099. DESTINATION usr/libexec/netdata/python.d)
  2100. install(FILES collectors/python.d.plugin/python.d.conf
  2101. DESTINATION usr/lib/netdata/conf.d)
  2102. # conf files
  2103. install(FILES
  2104. collectors/python.d.plugin/adaptec_raid/adaptec_raid.conf
  2105. collectors/python.d.plugin/alarms/alarms.conf
  2106. collectors/python.d.plugin/am2320/am2320.conf
  2107. collectors/python.d.plugin/anomalies/anomalies.conf
  2108. collectors/python.d.plugin/beanstalk/beanstalk.conf
  2109. collectors/python.d.plugin/bind_rndc/bind_rndc.conf
  2110. collectors/python.d.plugin/boinc/boinc.conf
  2111. collectors/python.d.plugin/ceph/ceph.conf
  2112. collectors/python.d.plugin/changefinder/changefinder.conf
  2113. collectors/python.d.plugin/dovecot/dovecot.conf
  2114. collectors/python.d.plugin/example/example.conf
  2115. collectors/python.d.plugin/exim/exim.conf
  2116. collectors/python.d.plugin/fail2ban/fail2ban.conf
  2117. collectors/python.d.plugin/gearman/gearman.conf
  2118. collectors/python.d.plugin/go_expvar/go_expvar.conf
  2119. collectors/python.d.plugin/haproxy/haproxy.conf
  2120. collectors/python.d.plugin/hddtemp/hddtemp.conf
  2121. collectors/python.d.plugin/hpssa/hpssa.conf
  2122. collectors/python.d.plugin/icecast/icecast.conf
  2123. collectors/python.d.plugin/ipfs/ipfs.conf
  2124. collectors/python.d.plugin/litespeed/litespeed.conf
  2125. collectors/python.d.plugin/megacli/megacli.conf
  2126. collectors/python.d.plugin/memcached/memcached.conf
  2127. collectors/python.d.plugin/monit/monit.conf
  2128. collectors/python.d.plugin/nsd/nsd.conf
  2129. collectors/python.d.plugin/nvidia_smi/nvidia_smi.conf
  2130. collectors/python.d.plugin/openldap/openldap.conf
  2131. collectors/python.d.plugin/oracledb/oracledb.conf
  2132. collectors/python.d.plugin/pandas/pandas.conf
  2133. collectors/python.d.plugin/postfix/postfix.conf
  2134. collectors/python.d.plugin/puppet/puppet.conf
  2135. collectors/python.d.plugin/rethinkdbs/rethinkdbs.conf
  2136. collectors/python.d.plugin/retroshare/retroshare.conf
  2137. collectors/python.d.plugin/riakkv/riakkv.conf
  2138. collectors/python.d.plugin/samba/samba.conf
  2139. collectors/python.d.plugin/sensors/sensors.conf
  2140. collectors/python.d.plugin/smartd_log/smartd_log.conf
  2141. collectors/python.d.plugin/spigotmc/spigotmc.conf
  2142. collectors/python.d.plugin/squid/squid.conf
  2143. collectors/python.d.plugin/tomcat/tomcat.conf
  2144. collectors/python.d.plugin/tor/tor.conf
  2145. collectors/python.d.plugin/traefik/traefik.conf
  2146. collectors/python.d.plugin/uwsgi/uwsgi.conf
  2147. collectors/python.d.plugin/varnish/varnish.conf
  2148. collectors/python.d.plugin/w1sensor/w1sensor.conf
  2149. collectors/python.d.plugin/zscores/zscores.conf
  2150. DESTINATION usr/lib/netdata/conf.d/python.d)
  2151. # scripts
  2152. install(FILES
  2153. collectors/python.d.plugin/adaptec_raid/adaptec_raid.chart.py
  2154. collectors/python.d.plugin/alarms/alarms.chart.py
  2155. collectors/python.d.plugin/am2320/am2320.chart.py
  2156. collectors/python.d.plugin/anomalies/anomalies.chart.py
  2157. collectors/python.d.plugin/beanstalk/beanstalk.chart.py
  2158. collectors/python.d.plugin/bind_rndc/bind_rndc.chart.py
  2159. collectors/python.d.plugin/boinc/boinc.chart.py
  2160. collectors/python.d.plugin/ceph/ceph.chart.py
  2161. collectors/python.d.plugin/changefinder/changefinder.chart.py
  2162. collectors/python.d.plugin/dovecot/dovecot.chart.py
  2163. collectors/python.d.plugin/example/example.chart.py
  2164. collectors/python.d.plugin/exim/exim.chart.py
  2165. collectors/python.d.plugin/fail2ban/fail2ban.chart.py
  2166. collectors/python.d.plugin/gearman/gearman.chart.py
  2167. collectors/python.d.plugin/go_expvar/go_expvar.chart.py
  2168. collectors/python.d.plugin/haproxy/haproxy.chart.py
  2169. collectors/python.d.plugin/hddtemp/hddtemp.chart.py
  2170. collectors/python.d.plugin/hpssa/hpssa.chart.py
  2171. collectors/python.d.plugin/icecast/icecast.chart.py
  2172. collectors/python.d.plugin/ipfs/ipfs.chart.py
  2173. collectors/python.d.plugin/litespeed/litespeed.chart.py
  2174. collectors/python.d.plugin/megacli/megacli.chart.py
  2175. collectors/python.d.plugin/memcached/memcached.chart.py
  2176. collectors/python.d.plugin/monit/monit.chart.py
  2177. collectors/python.d.plugin/nsd/nsd.chart.py
  2178. collectors/python.d.plugin/nvidia_smi/nvidia_smi.chart.py
  2179. collectors/python.d.plugin/openldap/openldap.chart.py
  2180. collectors/python.d.plugin/oracledb/oracledb.chart.py
  2181. collectors/python.d.plugin/pandas/pandas.chart.py
  2182. collectors/python.d.plugin/postfix/postfix.chart.py
  2183. collectors/python.d.plugin/puppet/puppet.chart.py
  2184. collectors/python.d.plugin/rethinkdbs/rethinkdbs.chart.py
  2185. collectors/python.d.plugin/retroshare/retroshare.chart.py
  2186. collectors/python.d.plugin/riakkv/riakkv.chart.py
  2187. collectors/python.d.plugin/samba/samba.chart.py
  2188. collectors/python.d.plugin/sensors/sensors.chart.py
  2189. collectors/python.d.plugin/smartd_log/smartd_log.chart.py
  2190. collectors/python.d.plugin/spigotmc/spigotmc.chart.py
  2191. collectors/python.d.plugin/squid/squid.chart.py
  2192. collectors/python.d.plugin/tomcat/tomcat.chart.py
  2193. collectors/python.d.plugin/tor/tor.chart.py
  2194. collectors/python.d.plugin/traefik/traefik.chart.py
  2195. collectors/python.d.plugin/uwsgi/uwsgi.chart.py
  2196. collectors/python.d.plugin/varnish/varnish.chart.py
  2197. collectors/python.d.plugin/w1sensor/w1sensor.chart.py
  2198. collectors/python.d.plugin/zscores/zscores.chart.py
  2199. DESTINATION usr/libexec/netdata/python.d)
  2200. # FIXME: don't install this unconditionally
  2201. configure_file(collectors/ioping.plugin/ioping.plugin.in collectors/ioping.plugin/ioping.plugin @ONLY)
  2202. install(PROGRAMS ${CMAKE_BINARY_DIR}/collectors/ioping.plugin/ioping.plugin DESTINATION usr/libexec/netdata/plugins.d)
  2203. #
  2204. # logs management
  2205. #
  2206. if (ENABLE_PLUGIN_LOGS_MANAGEMENT)
  2207. configure_file(logsmanagement/stock_conf/logsmanagement.d.conf.in logsmanagement/stock_conf/logsmanagement.d.conf @ONLY)
  2208. install(FILES ${CMAKE_BINARY_DIR}/logsmanagement/stock_conf/logsmanagement.d.conf
  2209. COMPONENT logs_management_plugin
  2210. DESTINATION usr/lib/netdata/conf.d)
  2211. endif()
  2212. #
  2213. # dashboard
  2214. #
  2215. include(web/gui/v1/dashboard_v1.cmake)
  2216. include(web/gui/v2/dashboard_v2.cmake)
  2217. include(web/gui/gui.cmake)
  2218. function(cat IN_FILE OUT_FILE)
  2219. file(READ ${IN_FILE} CONTENTS)
  2220. file(APPEND ${OUT_FILE} "${CONTENTS}")
  2221. endfunction()
  2222. file(WRITE ${CMAKE_BINARY_DIR}/web/gui/dashboard.js.in "")
  2223. foreach(JS_FILE ${DASHBOARD_JS_FILES})
  2224. cat(${JS_FILE} ${CMAKE_BINARY_DIR}/dashboard.js.in)
  2225. endforeach()
  2226. configure_file(${CMAKE_BINARY_DIR}/dashboard.js.in
  2227. ${CMAKE_BINARY_DIR}/dashboard.js COPYONLY)
  2228. install(FILES
  2229. ${CMAKE_BINARY_DIR}/dashboard.js
  2230. DESTINATION ${WEB_DEST})
  2231. install(FILES
  2232. web/gui/dashboard_info_custom_example.js
  2233. web/gui/dashboard_info.js
  2234. web/gui/index.html
  2235. web/gui/main.css
  2236. web/gui/main.js
  2237. web/gui/registry-access.html
  2238. web/gui/registry-alert-redirect.html
  2239. web/gui/registry-hello.html
  2240. web/gui/switch.html
  2241. web/gui/ilove.html
  2242. DESTINATION ${WEB_DEST})
  2243. install(FILES
  2244. web/gui/old/index.html
  2245. DESTINATION ${WEB_DEST}/old)
  2246. install(FILES
  2247. web/gui/static/img/netdata-logomark.svg
  2248. DESTINATION ${WEB_DEST}/static/img)
  2249. install(FILES
  2250. web/gui/css/morris-0.5.1.css
  2251. web/gui/css/c3-0.4.18.min.css
  2252. DESTINATION ${WEB_DEST}/css)
  2253. install(FILES
  2254. web/gui/.well-known/dnt/cookies
  2255. DESTINATION ${WEB_DEST}/.well-known/dnt)
  2256. # v0 dashboard
  2257. install(FILES
  2258. web/gui/v0/index.html
  2259. DESTINATION ${WEB_DEST}/v0)