summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVille Voutilainen <ville.voutilainen@qt.io>2019-09-03 13:44:39 +0300
committerVille Voutilainen <ville.voutilainen@qt.io>2019-09-04 09:50:15 +0000
commit95c9c5a308a87d91dc1d0797ad186aee7bd7e012 (patch)
tree06ecde8989d5f5c83556c99a2a6f3548f0413628
parent3f8ba1e55e20cec0110e25cfad662ae3982a54e7 (diff)
cmake: Enable building of the db2 plugin
Change-Id: I26810cccba5f3128cb47e0bf53b5ec78de2eec8c Reviewed-by: Qt CMake Build Bot Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rw-r--r--cmake/FindDB2.cmake59
-rw-r--r--src/plugins/sqldrivers/CMakeLists.txt2
-rw-r--r--src/plugins/sqldrivers/configure.cmake3
-rw-r--r--src/plugins/sqldrivers/db2/CMakeLists.txt35
-rw-r--r--util/cmake/helper.py1
5 files changed, 98 insertions, 2 deletions
diff --git a/cmake/FindDB2.cmake b/cmake/FindDB2.cmake
new file mode 100644
index 0000000000..59eadab7d5
--- /dev/null
+++ b/cmake/FindDB2.cmake
@@ -0,0 +1,59 @@
+#.rst:
+# FindDB2
+# ---------
+#
+# Try to locate the db2 client library.
+# If found, this will define the following variables:
+#
+# ``DB2_FOUND``
+# True if the db2 library is available
+# ``DB2_INCLUDE_DIRS``
+# The db2 include directories
+# ``DB2_LIBRARIES``
+# The db2 libraries for linking
+#
+# If ``DB2_FOUND`` is TRUE, it will also define the following
+# imported target:
+#
+# ``DB2::DB2``
+# The db2 client library
+
+if (NOT DEFINED DB2_INCLUDE_DIR)
+ find_path(DB2_INCLUDE_DIRS
+ NAMES sqlcli1.h
+ HINTS ENV DB2_HOME
+ PATH_SUFFIXES include)
+else()
+ find_path(DB2_INCLUDE_DIRS
+ NAMES sqlcli1.h
+ HINTS ${DB2_INCLUDE_DIR})
+endif()
+
+if (NOT DEFINED DB2_LIBRARY_DIR)
+ find_library(DB2_LIBRARIES
+ NAMES db2
+ HINTS ENV DB2LIB)
+else()
+ find_library(DB2_LIBRARIES
+ NAMES db2
+ HINTS ${DB2_LIBRARY_DIR})
+endif()
+
+if (NOT DB2_INCLUDE_DIRS STREQUAL "DB2_INCLUDE_DIRS-NOTFOUND" AND NOT DB2_LIBRARIES STREQUAL "DB2_LIBRARIES-NOTFOUND")
+ set(DB2_FOUND ON)
+endif()
+
+if(DB2_FOUND AND NOT TARGET DB2::DB2)
+ add_library(DB2::DB2 UNKNOWN IMPORTED)
+ set_target_properties(DB2::DB2 PROPERTIES
+ IMPORTED_LOCATION "${DB2_LIBRARIES}"
+ INTERFACE_INCLUDE_DIRECTORIES "${DB2_INCLUDE_DIRS}")
+endif()
+
+mark_as_advanced(DB2_INCLUDE_DIRS DB2_LIBRARIES)
+
+include(FeatureSummary)
+set_package_properties(DB2 PROPERTIES
+ URL "https://www.ibm.com"
+ DESCRIPTION "IBM DB2 client library")
+
diff --git a/src/plugins/sqldrivers/CMakeLists.txt b/src/plugins/sqldrivers/CMakeLists.txt
index 61d0da800c..67101d4e96 100644
--- a/src/plugins/sqldrivers/CMakeLists.txt
+++ b/src/plugins/sqldrivers/CMakeLists.txt
@@ -35,7 +35,7 @@ if(QT_FEATURE_sql_oci)
endif()
if(QT_FEATURE_sql_db2)
-# TODO add_subdirectory(db2)
+ add_subdirectory(db2)
endif()
if(QT_FEATURE_sql_sqlite)
diff --git a/src/plugins/sqldrivers/configure.cmake b/src/plugins/sqldrivers/configure.cmake
index e8609fb50d..f57b469318 100644
--- a/src/plugins/sqldrivers/configure.cmake
+++ b/src/plugins/sqldrivers/configure.cmake
@@ -6,6 +6,7 @@
#### Libraries
+qt_find_package(DB2 PROVIDED_TARGETS DB2::DB2)
qt_find_package(MySQL PROVIDED_TARGETS MySQL::MySQL)
qt_find_package(PostgreSQL PROVIDED_TARGETS PostgreSQL::PostgreSQL)
qt_find_package(ODBC PROVIDED_TARGETS ODBC::ODBC)
@@ -20,7 +21,7 @@ qt_find_package(SQLite3 PROVIDED_TARGETS SQLite::SQLite3)
qt_feature("sql_db2" PRIVATE
LABEL "DB2 (IBM)"
- CONDITION libs.db2 OR FIXME
+ CONDITION DB2_FOUND
)
qt_feature("sql_ibase" PRIVATE
LABEL "InterBase"
diff --git a/src/plugins/sqldrivers/db2/CMakeLists.txt b/src/plugins/sqldrivers/db2/CMakeLists.txt
new file mode 100644
index 0000000000..45df43837f
--- /dev/null
+++ b/src/plugins/sqldrivers/db2/CMakeLists.txt
@@ -0,0 +1,35 @@
+# Generated from db2.pro.
+
+#####################################################################
+## qsqldb2 Plugin:
+#####################################################################
+
+add_qt_plugin(qsqldb2
+ TYPE sqldrivers
+ CLASS_NAME QDB2DriverPlugin
+ SOURCES
+ main.cpp
+ qsql_db2.cpp qsql_db2_p.h
+ DEFINES
+ QT_NO_CAST_FROM_ASCII
+ QT_NO_CAST_TO_ASCII
+ LIBRARIES
+ Qt::CorePrivate
+ Qt::SqlPrivate
+ PUBLIC_LIBRARIES
+ DB2::DB2
+ Qt::Core
+ Qt::Sql
+)
+
+#### Keys ignored in scope 1:.:.:db2.pro:<TRUE>:
+# OTHER_FILES = "db2.json"
+# PLUGIN_CLASS_NAME = "QDB2DriverPlugin"
+
+## Scopes:
+#####################################################################
+
+extend_target(qsqldb2 CONDITION (TEST_architecture_arch STREQUAL "x86_64")
+ DEFINES
+ ODBC64
+)
diff --git a/util/cmake/helper.py b/util/cmake/helper.py
index b1a07a0a11..77ef783965 100644
--- a/util/cmake/helper.py
+++ b/util/cmake/helper.py
@@ -190,6 +190,7 @@ _library_map = [
LibraryMapping('atspi', 'ATSPI2', 'PkgConfig::ATSPI2'),
LibraryMapping('corewlan', None, None),
LibraryMapping('cups', 'Cups', 'Cups::Cups'),
+ LibraryMapping('db2', 'DB2', 'DB2::DB2'),
LibraryMapping('dbus', 'WrapDBus1', 'dbus-1', resultVariable="DBus1"),
LibraryMapping('doubleconversion', None, None),
LibraryMapping('drm', 'Libdrm', 'Libdrm::Libdrm'),