9
9
SET (CMAKE_PREFIX_PATH "C:/Qtx86/5.9.2/msvc2015/lib/cmake/" )
10
10
endif ()
11
11
12
+ find_package (Qt5Core REQUIRED )
12
13
find_package (Qt5Sql REQUIRED )
13
14
14
15
if (NOT WIN32 )
@@ -33,6 +34,7 @@ endif()
33
34
34
35
option (QSQLCIPHER_STATIC "Build plugin as a static library" OFF )
35
36
option (QSQLCIPHER_BUILD_TESTS "Build the test binary" ON )
37
+ option (QSQLCIPHER_INSTALL_INTO_QT_PLUGIN_DIRECTORY "Find the Qt plugin directory and install the driver there" OFF )
36
38
set (QSQLCIPHER_COPYTO_DIR "" CACHE PATH "If set, the build artifact of the library will be copied there" )
37
39
38
40
set (CMAKE_CXX_STANDARD 14 )
@@ -42,6 +44,19 @@ if(CMAKE_COMPILER_IS_GNUCC)
42
44
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14" )
43
45
endif ()
44
46
47
+ if (QSQLCIPHER_INSTALL_INTO_QT_PLUGIN_DIRECTORY )
48
+ string (REPLACE "\\ " "/" Qt5Core_DIR "${Qt5Core_DIR} " )
49
+ if ("${Qt5Core_DIR} " STREQUAL "" )
50
+ message (SEND_ERROR "Qt5Core_DIR is not set and can not be used to derive the location of the Qt installation." )
51
+ elseif (NOT "${Qt5Core_DIR} " MATCHES "^(.*)/lib/cmake/Qt5Core" )
52
+ message (SEND_ERROR "Qt5Core_DIR does not end in lib/cmake/Qt5Core, which is unexpected and therefore can not be used to derive the location of the Qt installation." )
53
+ else ()
54
+ string (REGEX REPLACE "^(.*)/lib/cmake/Qt5Core" "\\ 1" QT5_BASE_DIR "${Qt5Core_DIR} " )
55
+ set (QSQLCIPHER_PLUGIN_DIR "${QT5_BASE_DIR} /plugins" )
56
+ message (STATUS "QSQLCIPHER_INSTALL_INTO_QT_PLUGIN_DIRECTORY is set, will install plugin to folder ${QSQLCIPHER_PLUGIN_DIR} /sqldrivers" )
57
+ endif ()
58
+ endif ()
59
+
45
60
if (QSQLCIPHER_STATIC )
46
61
set (LIBTYPE STATIC )
47
62
add_definitions (-DQT_STATICPLUGIN )
@@ -112,6 +127,10 @@ if (NOT ("${QSQLCIPHER_COPYTO_DIR}" STREQUAL ""))
112
127
add_custom_command (TARGET qsqlcipher POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $< TARGET_FILE:qsqlcipher> ${QSQLCIPHER_COPYTO_DIR} /$<TARGET_FILE_NAME:qsqlcipher> )
113
128
endif ()
114
129
130
+ if (NOT ("${QSQLCIPHER_PLUGIN_DIR} " STREQUAL "" ))
131
+ add_custom_command (TARGET qsqlcipher POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $< TARGET_FILE:qsqlcipher> ${QSQLCIPHER_PLUGIN_DIR} /sqldrivers/$<TARGET_FILE_NAME:qsqlcipher> )
132
+ endif ()
133
+
115
134
find_program (DPKG_PROGRAM dpkg DOC "dpkg program of Debian-based systems" )
116
135
if (NOT WIN32 )
117
136
if (DPKG_PROGRAM )
0 commit comments