File tree Expand file tree Collapse file tree 6 files changed +34
-2
lines changed Expand file tree Collapse file tree 6 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -233,7 +233,13 @@ endif ()
233233## Build provided copy of SQLite3 C library ##
234234
235235option (SQLITECPP_INTERNAL_SQLITE "Add the internal SQLite3 source to the project." ON )
236- if (SQLITECPP_INTERNAL_SQLITE)
236+ option (SQLITECPP_IN_EXTENSION "Use SQLiteCpp in the implementation of a SQLite3 loadable extension" OFF )
237+ if (SQLITECPP_IN_EXTENSION)
238+ # To use within a SQLite3 loadable extension, we must not target_link_libraries() SQLite3 itself; the
239+ # host program will already have loaded it (possibly a statically-linked version) and we'll receive its
240+ # API pointers via sqlite3_extension_init().
241+ target_compile_definitions (SQLiteCpp PUBLIC SQLITECPP_IN_EXTENSION)
242+ elseif (SQLITECPP_INTERNAL_SQLITE)
237243 message (STATUS "Compile sqlite3 from source in subdirectory" )
238244 option (SQLITE_ENABLE_JSON1 "Enable JSON1 extension when building internal sqlite3 library." ON )
239245 # build the SQLite3 C library (for ease of use/compatibility) versus Linux sqlite3-dev package
@@ -285,7 +291,7 @@ else (SQLITECPP_INTERNAL_SQLITE)
285291 target_link_libraries (SQLiteCpp PRIVATE ${sqlcipher_LIBRARY} )
286292 endif ()
287293 endif ()
288- endif (SQLITECPP_INTERNAL_SQLITE )
294+ endif (SQLITECPP_IN_EXTENSION )
289295
290296# Link target with pthread and dl for Unix
291297if (UNIX )
Original file line number Diff line number Diff line change 1313
1414#include < SQLiteCpp/Exception.h>
1515
16+ #if !defined(SQLITECPP_IN_EXTENSION) || defined(SQLITE_CORE)
1617#include < sqlite3.h>
18+ #else
19+ #include < sqlite3ext.h>
20+ extern " C" const sqlite3_api_routines *sqlite3_api;
21+ #endif
1722
1823namespace SQLite
1924{
Original file line number Diff line number Diff line change 1010 */
1111#include < SQLiteCpp/Column.h>
1212
13+ #if !defined(SQLITECPP_IN_EXTENSION) || defined(SQLITE_CORE)
1314#include < sqlite3.h>
15+ #else
16+ #include < sqlite3ext.h>
17+ extern " C" const sqlite3_api_routines *sqlite3_api;
18+ #endif
1419
1520#include < iostream>
1621
Original file line number Diff line number Diff line change 1515#include < SQLiteCpp/Exception.h>
1616#include < SQLiteCpp/Statement.h>
1717
18+ #if !defined(SQLITECPP_IN_EXTENSION) || defined(SQLITE_CORE)
1819#include < sqlite3.h>
20+ #else
21+ #include < sqlite3ext.h>
22+ extern " C" const sqlite3_api_routines *sqlite3_api;
23+ #endif
24+
1925#include < fstream>
2026#include < string.h>
2127
Original file line number Diff line number Diff line change 1010 */
1111#include < SQLiteCpp/Exception.h>
1212
13+ #if !defined(SQLITECPP_IN_EXTENSION) || defined(SQLITE_CORE)
1314#include < sqlite3.h>
15+ #else
16+ #include < sqlite3ext.h>
17+ extern " C" const sqlite3_api_routines *sqlite3_api;
18+ #endif
1419
1520
1621namespace SQLite
Original file line number Diff line number Diff line change 1515#include < SQLiteCpp/Assertion.h>
1616#include < SQLiteCpp/Exception.h>
1717
18+ #if !defined(SQLITECPP_IN_EXTENSION) || defined(SQLITE_CORE)
1819#include < sqlite3.h>
20+ #else
21+ #include < sqlite3ext.h>
22+ extern " C" const sqlite3_api_routines *sqlite3_api;
23+ #endif
1924
2025namespace SQLite
2126{
You can’t perform that action at this time.
0 commit comments