summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlbert Astals Cid <albert.astals.cid@kdab.com>2019-02-12 14:34:40 +0100
committerAlbert Astals Cid <albert.astals.cid@kdab.com>2019-02-12 14:39:33 +0000
commit11acba6504560dde54e94989b84df94157f9cc00 (patch)
tree66a9bd8bf2d65dcde2b5aa4b5fe877bf88b487ac
parentf94fdb35376efb5d2887ecfef67595edff74cbe3 (diff)
cmake: Find and build psql plugin
Change-Id: I8cbc8ab0061f67824d78198cbb926f0625fc7e41 Reviewed-by: Liang Qi <liang.qi@qt.io>
-rw-r--r--src/plugins/sqldrivers/CMakeLists.txt2
-rw-r--r--src/plugins/sqldrivers/configure.cmake4
-rw-r--r--src/plugins/sqldrivers/psql/CMakeLists.txt27
-rwxr-xr-xutil/cmake/configurejson2cmake.py1
4 files changed, 32 insertions, 2 deletions
diff --git a/src/plugins/sqldrivers/CMakeLists.txt b/src/plugins/sqldrivers/CMakeLists.txt
index 95e696f48b..cc39a0fe35 100644
--- a/src/plugins/sqldrivers/CMakeLists.txt
+++ b/src/plugins/sqldrivers/CMakeLists.txt
@@ -15,7 +15,7 @@ qt_feature_module_end(NO_MODULE)
if(QT_FEATURE_sql_psql)
-# TODO add_subdirectory(psql)
+ add_subdirectory(psql)
endif()
if(QT_FEATURE_sql_mysql)
diff --git a/src/plugins/sqldrivers/configure.cmake b/src/plugins/sqldrivers/configure.cmake
index 626a835f0a..8b349a160d 100644
--- a/src/plugins/sqldrivers/configure.cmake
+++ b/src/plugins/sqldrivers/configure.cmake
@@ -6,6 +6,8 @@
#### Libraries
+find_package(PostgreSQL)
+set_package_properties(PostgreSQL PROPERTIES TYPE OPTIONAL)
find_package(SQLite3)
set_package_properties(SQLite3 PROPERTIES TYPE OPTIONAL)
@@ -38,7 +40,7 @@ qt_feature("sql_odbc" PRIVATE
)
qt_feature("sql_psql" PRIVATE
LABEL "PostgreSQL"
- CONDITION libs.psql OR FIXME
+ CONDITION PostgreSQL_FOUND
)
qt_feature("sql_sqlite2" PRIVATE
LABEL "SQLite2"
diff --git a/src/plugins/sqldrivers/psql/CMakeLists.txt b/src/plugins/sqldrivers/psql/CMakeLists.txt
new file mode 100644
index 0000000000..f87a8108b1
--- /dev/null
+++ b/src/plugins/sqldrivers/psql/CMakeLists.txt
@@ -0,0 +1,27 @@
+# Generated from psql.pro.
+
+# FIXME cmake FindPostgreSQL is more exhaustive than the check we have for libpq-fe.h
+# it also checks for catalog/pg_type.h which is a more internal include, we should
+# add a way to tell cmake FindPostgreSQL to optionally only look for the libpq-fe.h one
+find_package(PostgreSQL)
+
+#####################################################################
+## qsqlpsql Plugin:
+#####################################################################
+
+add_qt_plugin(qsqlpsql
+ TYPE sqldrivers
+ SOURCES
+ main.cpp
+ qsql_psql.cpp qsql_psql_p.h
+ DEFINES
+ QT_NO_CAST_TO_ASCII
+ QT_NO_CAST_FROM_ASCII
+ LIBRARIES
+ Qt::CorePrivate
+ Qt::SqlPrivate
+ PostgreSQL::PostgreSQL
+ # OTHER_FILES = "psql.json"
+ # PLUGIN_CLASS_NAME = "QPSQLDriverPlugin"
+ # _LOADED = "qt_plugin"
+)
diff --git a/util/cmake/configurejson2cmake.py b/util/cmake/configurejson2cmake.py
index e99bb27bc2..c46d3167f8 100755
--- a/util/cmake/configurejson2cmake.py
+++ b/util/cmake/configurejson2cmake.py
@@ -80,6 +80,7 @@ def map_library(lib: str) -> Union[str, LibraryMapping, List[str]]:
'pcre2': ['PCRE2', 'REQUIRED'],
'posix_iconv': None,
'pps': 'PPS',
+ 'psql': 'PostgreSQL',
'slog2': 'Slog2',
'sqlite3': 'SQLite3',
'sun_iconv': None,