diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e2a880b277..b894968f109 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 @@ -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() diff --git a/cmake/headers.cmake b/cmake/headers.cmake index 45a1394ca7f..500c4c3b947 100755 --- a/cmake/headers.cmake +++ b/cmake/headers.cmake @@ -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 diff --git a/cmake/luajit.cmake b/cmake/luajit.cmake index b6774eb4452..f00b843cb35 100644 --- a/cmake/luajit.cmake +++ b/cmake/luajit.cmake @@ -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") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 593e9865bc4..084f2c57d52 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -223,7 +223,7 @@ endif() if(FLB_LUAJIT) set(extra_libs ${extra_libs} - "libluajit") + ${LUAJIT_LIBRARIES}) endif() if(FLB_SQLDB)