diff --git a/CMakeLists.txt b/CMakeLists.txt index 99109309405..5193eac0087 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -128,6 +128,7 @@ option(FLB_TESTS_INTERNAL_FUZZ "Enable internal fuzz tests" No) option(FLB_TESTS_OSSFUZZ "Enable OSS-Fuzz build" No) option(FLB_MTRACE "Enable mtrace support" No) option(FLB_POSIX_TLS "Force POSIX thread storage" No) +option(FLB_PREFER_SYSTEM_LIBS "Prefer system installed libraries" No) option(FLB_INOTIFY "Enable inotify support" Yes) option(FLB_SQLDB "Enable SQL embedded DB" Yes) option(FLB_HTTP_SERVER "Enable HTTP Server" Yes) @@ -1011,7 +1012,16 @@ endif() # LuaJIT (Scripting Support) # ========================== if(FLB_LUAJIT) - include(cmake/luajit.cmake) + if(FLB_PREFER_SYSTEM_LIBS) + find_package(PkgConfig) + pkg_check_modules(LUAJIT luajit>=2.1.0) + endif() + if(LUAJIT_FOUND) + include_directories(${LUAJIT_INCLUDE_DIRS}) + else() + include(cmake/luajit.cmake) + set(LUAJIT_LIBRARIES "libluajit") + endif() FLB_DEFINITION(FLB_HAVE_LUAJIT) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b6233d9f721..67baec45653 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -221,7 +221,7 @@ endif() if(FLB_LUAJIT) set(extra_libs ${extra_libs} - "libluajit") + ${LUAJIT_LIBRARIES}) endif() if(FLB_SQLDB)