0001-build-use-the-system-provided-LuaJIT-if-found.patch 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. From 4f8eb7bb5a39d83374806928b7a5b622136ef055 Mon Sep 17 00:00:00 2001
  2. From: Thomas Devoogdt <thomas@devoogdt.com>
  3. Date: Fri, 28 Apr 2023 10:25:16 +0200
  4. Subject: [PATCH] build: use the system provided LuaJIT if found
  5. e.g. buildroot has logic to build luajit,
  6. so if pkg_check_modules can find a suitable version,
  7. then use that one if -DFLB_PREFER_SYSTEM_LIBS=Yes.
  8. Upstream: https://github.com/fluent/fluent-bit/pull/7286
  9. Signed-off-by: Thomas Devoogdt <thomas@devoogdt.com>
  10. ---
  11. CMakeLists.txt | 12 +++++++++++-
  12. src/CMakeLists.txt | 2 +-
  13. 2 files changed, 12 insertions(+), 2 deletions(-)
  14. diff --git a/CMakeLists.txt b/CMakeLists.txt
  15. index 9af783c79..0601b7c18 100644
  16. --- a/CMakeLists.txt
  17. +++ b/CMakeLists.txt
  18. @@ -123,6 +123,7 @@ option(FLB_TESTS_INTERNAL_FUZZ "Enable internal fuzz tests" No)
  19. option(FLB_TESTS_OSSFUZZ "Enable OSS-Fuzz build" No)
  20. option(FLB_MTRACE "Enable mtrace support" No)
  21. option(FLB_POSIX_TLS "Force POSIX thread storage" No)
  22. +option(FLB_PREFER_SYSTEM_LIBS "Prefer system installed libraries" No)
  23. option(FLB_INOTIFY "Enable inotify support" Yes)
  24. option(FLB_SQLDB "Enable SQL embedded DB" Yes)
  25. option(FLB_HTTP_SERVER "Enable HTTP Server" Yes)
  26. @@ -1003,7 +1004,16 @@ endif()
  27. # LuaJIT (Scripting Support)
  28. # ==========================
  29. if(FLB_LUAJIT)
  30. - include(cmake/luajit.cmake)
  31. + if(FLB_PREFER_SYSTEM_LIBS)
  32. + find_package(PkgConfig)
  33. + pkg_check_modules(LUAJIT luajit>=2.1.0)
  34. + endif()
  35. + if(LUAJIT_FOUND)
  36. + include_directories(${LUAJIT_INCLUDE_DIRS})
  37. + else()
  38. + include(cmake/luajit.cmake)
  39. + set(LUAJIT_LIBRARIES "libluajit")
  40. + endif()
  41. FLB_DEFINITION(FLB_HAVE_LUAJIT)
  42. endif()
  43. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
  44. index 06a206dd4..8b66ddd22 100644
  45. --- a/src/CMakeLists.txt
  46. +++ b/src/CMakeLists.txt
  47. @@ -220,7 +220,7 @@ endif()
  48. if(FLB_LUAJIT)
  49. set(extra_libs
  50. ${extra_libs}
  51. - "libluajit")
  52. + ${LUAJIT_LIBRARIES})
  53. endif()
  54. if(FLB_SQLDB)
  55. --
  56. 2.34.1