Skip to content

Commit

Permalink
build: use the system provided LuaJIT if found
Browse files Browse the repository at this point in the history
e.g. buildroot has logic to build luajit,
so if pkg_check_modules can find a suitable version,
then use that one if -DFLB_PREFER_SYSTEM_LIB_LUAJIT=Yes.

Signed-off-by: Thomas Devoogdt <[email protected]>
  • Loading branch information
ThomasDevoogdt committed Jul 4, 2024
1 parent 66970cb commit 1be51c5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
15 changes: 14 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ option(FLB_HTTP_CLIENT_DEBUG "Enable HTTP Client debug callbacks" No)
# Run ldconfig on package post-install
option(FLB_RUN_LDCONFIG "Enable execution of ldconfig after installation" No)

# Prefer system libraries if available
option(FLB_PREFER_SYSTEM_LIBS "Prefer system libraries" No)
option(FLB_PREFER_SYSTEM_LIB_LUAJIT "Prefer the libluajit system library" ${FLB_PREFER_SYSTEM_LIBS})

# Enable all features
if(FLB_ALL)
# Global
Expand Down Expand Up @@ -923,7 +927,16 @@ endif()
# LuaJIT (Scripting Support)
# ==========================
if(FLB_LUAJIT)
include(cmake/luajit.cmake)
if(FLB_PREFER_SYSTEM_LIB_LUAJIT)
find_package(PkgConfig)
pkg_check_modules(LUAJIT luajit>=2.1.0)
endif()
if(LUAJIT_FOUND)
include_directories(${LUAJIT_INCLUDE_DIRS})
link_directories(${LUAJIT_LIBRARY_DIRS})
else()
include(cmake/luajit.cmake)
endif()
FLB_DEFINITION(FLB_HAVE_LUAJIT)
endif()

Expand Down
4 changes: 0 additions & 4 deletions cmake/headers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ include_directories(
${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_CHUNKIO}/include
${CMAKE_CURRENT_BINARY_DIR}/lib/chunkio/include

# LuaJIT
${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_LUAJIT}/src
${CMAKE_CURRENT_BINARY_DIR}/lib/luajit-cmake

${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_MONKEY}/include
${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_MONKEY}/include/monkey
${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_MBEDTLS}/include
Expand Down
5 changes: 5 additions & 0 deletions cmake/luajit.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# luajit cmake
option(LUAJIT_DIR "Path of LuaJIT 2.1 source dir" ON)
set(LUAJIT_DIR ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_LUAJIT})
include_directories(
${LUAJIT_DIR}/src
${CMAKE_CURRENT_BINARY_DIR}/lib/luajit-cmake
)
add_subdirectory("lib/luajit-cmake")
set(LUAJIT_LIBRARIES "libluajit")
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ endif()
if(FLB_LUAJIT)
set(extra_libs
${extra_libs}
"libluajit")
${LUAJIT_LIBRARIES})
endif()

if(FLB_SQLDB)
Expand Down

0 comments on commit 1be51c5

Please sign in to comment.