cmake: Enable building of the db2 plugin

Change-Id: I26810cccba5f3128cb47e0bf53b5ec78de2eec8c
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Ville Voutilainen 2019-09-03 13:44:39 +03:00
parent 3f8ba1e55e
commit 95c9c5a308
5 changed files with 98 additions and 2 deletions

59
cmake/FindDB2.cmake Normal file
View File

@ -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")

View File

@ -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)

View File

@ -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"

View File

@ -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
)

View File

@ -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'),