diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a14cd7b98e..48a07df7f14 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -217,6 +217,7 @@ option(FLB_PREFER_SYSTEM_LIB_KAFKA "Prefer the libkafka system library" option(FLB_PREFER_SYSTEM_LIB_LUAJIT "Prefer the libluajit system library" ${FLB_PREFER_SYSTEM_LIBS}) option(FLB_PREFER_SYSTEM_LIB_MSGPACK "Prefer the libmsgpack system library" ${FLB_PREFER_SYSTEM_LIBS}) option(FLB_PREFER_SYSTEM_LIB_NGHTTP2 "Prefer the libnghttp2 system library" ${FLB_PREFER_SYSTEM_LIBS}) +option(FLB_PREFER_SYSTEM_LIB_SQLITE "Prefer the libsqlite3 system library" ${FLB_PREFER_SYSTEM_LIBS}) # Enable all features if(FLB_ALL) @@ -689,8 +690,17 @@ if (FLB_SIGNV4) endif() if(FLB_SQLDB) + if(FLB_PREFER_SYSTEM_LIB_SQLITE) + find_package(PkgConfig) + pkg_check_modules(SQLITE sqlite3>=3.0.0) + endif() + if(SQLITE_FOUND) + include_directories(${SQLITE_INCLUDE_DIRS}) + link_directories(${SQLITE_LIBRARY_DIRS}) + else() + include(cmake/sqlite.cmake) + endif() FLB_DEFINITION(FLB_HAVE_SQLDB) - add_subdirectory(${FLB_PATH_LIB_SQLITE}) endif() if(FLB_TRACE) diff --git a/cmake/headers.cmake b/cmake/headers.cmake index 93a92db2f6e..bd74463a5b7 100755 --- a/cmake/headers.cmake +++ b/cmake/headers.cmake @@ -24,7 +24,6 @@ include_directories( ${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 - ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_SQLITE} ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_MPACK}/src ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_MINIZ}/ ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_ONIGMO} diff --git a/cmake/sqlite.cmake b/cmake/sqlite.cmake new file mode 100644 index 00000000000..76585168d98 --- /dev/null +++ b/cmake/sqlite.cmake @@ -0,0 +1,6 @@ +# sqlite cmake +include_directories( + ${FLB_PATH_ROOT_SOURCE}/${FLB_PATH_LIB_SQLITE} +) +add_subdirectory(${FLB_PATH_LIB_SQLITE}) +set(SQLITE_LIBRARIES "sqlite3") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d9e2dba9333..6643fc8c82f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -244,7 +244,7 @@ if(FLB_SQLDB) ) set(extra_libs ${extra_libs} - "sqlite3") + ${SQLITE_LIBRARIES}) endif() if(FLB_STATIC_CONF)