File tree Expand file tree Collapse file tree 6 files changed +31
-2
lines changed
Expand file tree Collapse file tree 6 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,17 @@ set(CMAKE_AUTOMOC ON)
1313set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} )
1414set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} /sqldrivers)
1515
16- add_library (qsqlcipher MODULE
16+ option (STATIC "Build plugin as a static library" OFF )
17+ if (STATIC )
18+ set (LIBTYPE STATIC )
19+ add_definitions (-DQT_STATICPLUGIN)
20+ add_subdirectory (test -static )
21+ else ()
22+ set (LIBTYPE MODULE)
23+ add_subdirectory (test -shared)
24+ endif ()
25+
26+ add_library (qsqlcipher ${LIBTYPE}
1727 smain.cpp
1828 qt-private /qsql_sqlite.cpp
1929)
@@ -28,4 +38,3 @@ target_link_libraries(qsqlcipher
2838 ${SQLCIPHER_LIBRARIES}
2939)
3040
31- add_subdirectory (test )
Original file line number Diff line number Diff line change @@ -34,6 +34,19 @@ Follow [Qt's plugin deployment guide](http://doc.qt.io/qt-5/deployment-plugins.h
3434In short, put the plugin at `` sqldrivers/libqsqlcipher.so `` relative to your
3535executable.
3636
37+
38+ ## Static linking
39+
40+ You can also build the plugin statically by passing `` -DSTATIC=ON `` to CMake.
41+ When you build your application which uses the static plugin, you'll need to
42+ include the line `` Q_IMPORT_PLUGIN(QSQLCipherDriverPlugin); `` in one of your
43+ source files and define `` QT_STATICPLUGIN `` at compile time. And link to the
44+ static plugin, of course.
45+
46+ Note that setting `` -DSTATIC=ON `` only builds * this plugin* as a static library.
47+ If you also want to link to static versions of Qt and/or SQLCipher, it's up to
48+ you to make sure CMake finds static versions of those libraries.
49+
3750-----
3851
3952## Old version
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change 1+ # Same as for test-shared, but statically link the plugin
2+ include (../test -shared/CMakeLists.txt)
3+ target_link_libraries (qsqlcipher-test qsqlcipher)
Original file line number Diff line number Diff line change 1+ // Same as for test-shared, but manually import the static plugin
2+ #include < QtPlugin>
3+ Q_IMPORT_PLUGIN (QSQLCipherDriverPlugin);
4+ #include " ../test-shared/main.cpp"
You can’t perform that action at this time.
0 commit comments