meson.build 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. project(
  2. 'crazytrace',
  3. 'cpp',
  4. license: ['GPL-3.0-or-later'],
  5. default_options: [
  6. 'buildtype=release',
  7. 'optimization=2',
  8. 'warning_level=3',
  9. 'werror=true',
  10. 'cpp_std=c++20'
  11. ]
  12. )
  13. main_file = files('src/main.cpp')
  14. sources = files(
  15. 'src/configuration.cpp',
  16. 'src/crazytrace.cpp',
  17. 'src/loglevel.cpp',
  18. 'src/postup_commands.cpp',
  19. 'src/nodecontainer.cpp',
  20. 'src/nodeinfo.cpp',
  21. 'src/nodereply.cpp',
  22. 'src/noderequest.cpp',
  23. 'src/randomgenerator.cpp',
  24. 'src/tun_tap.cpp'
  25. )
  26. headers = files(
  27. 'src/configuration.hpp',
  28. 'src/crazytrace.hpp',
  29. 'src/deviceclient.hpp',
  30. 'src/loglevel.hpp',
  31. 'src/postup_commands.hpp',
  32. 'src/nodecontainer.hpp',
  33. 'src/nodeinfo.hpp',
  34. 'src/nodereply.hpp',
  35. 'src/noderequest.hpp',
  36. 'src/randomgenerator.hpp',
  37. 'src/tun_tap.hpp'
  38. )
  39. tests_sources = files(
  40. 'tests/loglevel_test.cpp',
  41. 'tests/nodecontainer_test.cpp',
  42. 'tests/nodeinfo_test.cpp',
  43. 'tests/nodeinfo_children_test.cpp',
  44. 'tests/nodereply_test.cpp',
  45. 'tests/noderequest_test.cpp',
  46. 'tests/randomgenerator_test.cpp'
  47. )
  48. cpp_compiler = meson.get_compiler('cpp')
  49. if not cpp_compiler.has_header('unistd.h')
  50. error('crazytrace requires unistd.h')
  51. endif
  52. libtuntap_dep = dependency('libtuntap', required: false, include_type: 'system')
  53. if not libtuntap_dep.found()
  54. libtuntap_dep = cpp_compiler.find_library('libtuntap', has_headers: ['tuntap.h'], required: true)
  55. endif
  56. boost_dep = dependency('boost', modules: ['log'], include_type: 'system')
  57. libtins_dep = dependency('libtins', include_type: 'system')
  58. yamlcpp_dep = dependency('yaml-cpp', include_type: 'system')
  59. gtest_dep = dependency('gtest', main: true, required: false, include_type: 'system')
  60. cppcheck = find_program('cppcheck', required: false)
  61. if cppcheck.found()
  62. run_target('cppcheck', command: [
  63. cppcheck,
  64. # Do not check external libraries
  65. '--suppress=*:*/tins/*',
  66. '--suppress=*:*/boost/*',
  67. '--suppress=*:*/gtest/*',
  68. # Problems with detecting system libraries
  69. '--suppress=missingIncludeSystem',
  70. '--suppress=unmatchedSuppression',
  71. '--enable=warning,style,information,missingInclude',
  72. '--error-exitcode=1',
  73. '--inline-suppr',
  74. '--project=' + join_paths(meson.build_root(), 'compile_commands.json')
  75. ])
  76. endif
  77. flawfinder = find_program('flawfinder', required: false)
  78. if flawfinder.found()
  79. run_target('flawfinder', command: [
  80. flawfinder,
  81. '--error-level=0',
  82. sources + tests_sources + headers
  83. ])
  84. endif
  85. if get_option('install_systemd_unit')
  86. install_data(
  87. 'systemd/crazytrace@.service',
  88. install_dir: 'lib/systemd/system'
  89. )
  90. endif
  91. deps = [libtuntap_dep, boost_dep, libtins_dep, yamlcpp_dep]
  92. if gtest_dep.found()
  93. gtest = executable('gtest', sources + tests_sources, dependencies: [gtest_dep] + deps, include_directories: ['src/'])
  94. test('gtest', gtest)
  95. endif
  96. executable(
  97. 'crazytrace',
  98. sources + main_file,
  99. dependencies: deps,
  100. install : true
  101. )