CMakeLists.txt 94 KB

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