Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(c/driver/sqlite): Fix detection of extension loading in sqlite CMake #1878

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions c/driver/sqlite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,25 @@ else()
find_package(unofficial-sqlite3 CONFIG REQUIRED)
set(SQLite3_LINK_LIBRARIES unofficial::sqlite3::sqlite3)
set(SQLite3_INCLUDE_DIRS)
set(ADBC_SQLITE_WITH_LOAD_EXTENSION ON)
endif()

# Check for sqlite3_load_extension() in sqlite3.h
if(EXISTS "${SQLite3_INCLUDE_DIRS}/sqlite3.h")
if(NOT ADBC_SQLITE_WITH_LOAD_EXTENSION AND EXISTS "${SQLite3_INCLUDE_DIRS}/sqlite3.h")
file(READ "${SQLite3_INCLUDE_DIRS}/sqlite3.h" ADBC_SQLITE_H_CONTENT)
string(FIND "${ADBC_SQLITE_H_CONTENT}" "sqlite3_load_extension"
ADBC_SQLITE_WITH_LOAD_EXTENSION)
ADBC_SQLITE3_LOAD_EXTENSION_POS)

if(ADBC_SQLITE3_LOAD_EXTENSION_POS EQUAL -1)
set(ADBC_SQLITE_WITH_LOAD_EXTENSION OFF)
else()
set(ADBC_SQLITE_WITH_LOAD_EXTENSION ON)
endif()
message(STATUS "Inferred SQLite3 extension support from ${SQLite3_INCLUDE_DIRS}/sqlite3.h (${ADBC_SQLITE_WITH_LOAD_EXTENSION})"
)
else()
message(STATUS "Can't detect SQLite3 extension support (defaulting to ON)")
set(ADBC_SQLITE_WITH_LOAD_EXTENSION ON)
endif()

if(NOT ADBC_SQLITE_WITH_LOAD_EXTENSION)
Expand Down
Loading