Only compile the sqlite3 amalgamation if sqlite isnt installed
@@ -9,6 +9,9 @@ set(INCLUDE_DIR include/)
list(FILTER sources EXCLUDE REGEX "(main|linenoise).c")
list(FILTER headers EXCLUDE REGEX "linenoise.h")
+find_library(SQLITE_LIB SQLite3)
+set(THREADS)
+
if(DISABLE_HTTP)
list(FILTER sources EXCLUDE REGEX "http.c")
list(FILTER headers EXCLUDE REGEX "http.h")
@@ -17,6 +20,16 @@ else()
list(APPEND libraries curl)
endif()
+if(NOT SQLITE_LIB)
+ set(THREADS_PREFER_PTHREAD_FLAG ON)
+ find_package(Threads REQUIRED)
+ set(THREADS Threads::Threads)
+else()
+ list(FILTER sources EXCLUDE REGEX "sqlite3.c")
+ list(FILTER headers EXCLUDE REGEX "sqlite3.h")
+ list(APPEND libraries ${SQLITE_LIB})
+endif()
+
if(WIN32)
# ws2_32 is required for winsock2.h to work correctly
list(APPEND libraries ws2_32 bcrypt)
@@ -48,8 +61,5 @@ set_property(TARGET objlib PROPERTY POSITION_INDEPENDENT_CODE 1)
add_library(${PROJECT_NAME}_static STATIC $<TARGET_OBJECTS:objlib>)
add_library(${PROJECT_NAME} SHARED $<TARGET_OBJECTS:objlib>)
-set(THREADS_PREFER_PTHREAD_FLAG ON)
-find_package(Threads REQUIRED)
-
-target_link_libraries(${PROJECT_NAME}_static ${libraries} ${CMAKE_DL_LIBS} Threads::Threads)
-target_link_libraries(${PROJECT_NAME} ${libraries} ${CMAKE_DL_LIBS} Threads::Threads)
+target_link_libraries(${PROJECT_NAME}_static ${libraries} ${CMAKE_DL_LIBS} ${THREADS})
+target_link_libraries(${PROJECT_NAME} ${libraries} ${CMAKE_DL_LIBS} ${THREADS})
