diff --git a/CMakeLists.txt b/CMakeLists.txt index e3f3a092622..cf8105b82db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -178,6 +178,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 @@ -940,7 +944,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 63a2d8492ab..b4dfca2b296 100644 --- a/cmake/luajit.cmake +++ b/cmake/luajit.cmake @@ -2,4 +2,9 @@ option(LUAJIT_DIR "Path of LuaJIT 2.1 source dir" ON) option(LUAJIT_SETUP_INCLUDE_DIR "Setup include dir if parent is present" OFF) 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)