From 0a677f56763ad770f1373bfb88c50ee1be79423d Mon Sep 17 00:00:00 2001 From: Thomas Devoogdt Date: Sun, 10 Nov 2024 12:44:47 +0100 Subject: [PATCH] build: use the system provided sqlite if found Signed-off-by: Thomas Devoogdt --- CMakeLists.txt | 12 +++++++++++- cmake/headers.cmake | 1 - cmake/sqlite.cmake | 6 ++++++ src/CMakeLists.txt | 2 +- 4 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 cmake/sqlite.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 42192a174c1..a7fa1363cec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -210,6 +210,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) @@ -659,8 +660,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 e58251e4a75..06ed89958d2 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 3a9f3ce2f21..fd7a8ed8545 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -239,7 +239,7 @@ if(FLB_SQLDB) ) set(extra_libs ${extra_libs} - "sqlite3") + ${SQLITE_LIBRARIES}) endif() if(FLB_STATIC_CONF)