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