cmake: Search and enable the sqlite[3] plugin

Added to QtFeature.cmake a way to be able to run feature_module begin
and end without having an actual module by passing NO_MODULE

Change-Id: Ib708bd3878e2591da193d18563c8932cc4b75e7f
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
Albert Astals Cid 2019-02-12 12:00:49 +01:00
parent 0867dbf2f4
commit 9bef044a0b
7 changed files with 155 additions and 17 deletions

View File

@ -1,9 +1,9 @@
function(qt_feature_module_begin)
qt_parse_all_arguments(arg "qt_feature_module_begin"
"" "LIBRARY;PRIVATE_FILE;PUBLIC_FILE" "PUBLIC_DEPENDENCIES;PRIVATE_DEPENDENCIES" ${ARGN})
"NO_MODULE" "LIBRARY;PRIVATE_FILE;PUBLIC_FILE" "PUBLIC_DEPENDENCIES;PRIVATE_DEPENDENCIES" ${ARGN})
if ("${arg_LIBRARY}" STREQUAL "")
message(FATAL_ERROR "qt_feature_begin_module needs a LIBRARY name!")
if ("${arg_LIBRARY}" STREQUAL "" AND (NOT ${arg_NO_MODULE}))
message(FATAL_ERROR "qt_feature_begin_module needs a LIBRARY name! (or specify NO_MODULE)")
endif()
if ("${arg_PUBLIC_FILE}" STREQUAL "")
message(FATAL_ERROR "qt_feature_begin_module needs a PUBLIC_FILE name!")
@ -357,21 +357,23 @@ function(qt_feature_module_end target)
)
qt_generate_forwarding_headers("${__QtFeature_library}" SOURCE "${__QtFeature_public_file}")
get_target_property(targetType "${target}" TYPE)
if("${targetType}" STREQUAL "INTERFACE_LIBRARY")
set(propertyPrefix "INTERFACE_")
else()
set(propertyPrefix "")
set_target_properties("${target}" PROPERTIES EXPORT_PROPERTIES "QT_ENABLED_PUBLIC_FEATURES;QT_DISABLED_PUBLIC_FEATURES;QT_ENABLED_PRIVATE_FEATURES;QT_DISABLED_PRIVATE_FEATURES")
endif()
foreach(visibility public private)
string(TOUPPER "${visibility}" capitalVisibility)
foreach(state enabled disabled)
string(TOUPPER "${state}" capitalState)
if (NOT ("${target}" STREQUAL "NO_MODULE"))
get_target_property(targetType "${target}" TYPE)
if("${targetType}" STREQUAL "INTERFACE_LIBRARY")
set(propertyPrefix "INTERFACE_")
else()
set(propertyPrefix "")
set_target_properties("${target}" PROPERTIES EXPORT_PROPERTIES "QT_ENABLED_PUBLIC_FEATURES;QT_DISABLED_PUBLIC_FEATURES;QT_ENABLED_PRIVATE_FEATURES;QT_DISABLED_PRIVATE_FEATURES")
endif()
foreach(visibility public private)
string(TOUPPER "${visibility}" capitalVisibility)
foreach(state enabled disabled)
string(TOUPPER "${state}" capitalState)
set_property(TARGET "${target}" PROPERTY ${propertyPrefix}QT_${capitalState}_${capitalVisibility}_FEATURES "${${state}_${visibility}_features}")
set_property(TARGET "${target}" PROPERTY ${propertyPrefix}QT_${capitalState}_${capitalVisibility}_FEATURES "${${state}_${visibility}_features}")
endforeach()
endforeach()
endforeach()
endif()
unset(__QtFeature_library PARENT_SCOPE)
unset(__QtFeature_private_features PARENT_SCOPE)

View File

@ -1,6 +1,6 @@
if (QT_FEATURE_sql)
# TODO add_subdirectory(sqldrivers)
add_subdirectory(sqldrivers)
endif()
if(QT_FEATURE_network AND QT_FEATURE_bearermanagement)

View File

@ -0,0 +1,51 @@
# Generated from sqldrivers.pro.
# TODO sqldrivers_standalone {
# _QMAKE_CACHE_ = $$shadowed($$SQLDRV_SRC_TREE)/.qmake.conf
# load(qt_configure)
# }
qt_feature_module_begin(
NO_MODULE
PUBLIC_FILE "qtsqldrivers-config.h"
PRIVATE_FILE "qtsqldrivers-config_p.h"
)
include(configure.cmake)
qt_feature_module_end(NO_MODULE)
if(QT_FEATURE_sql_psql)
# TODO add_subdirectory(psql)
endif()
if(QT_FEATURE_sql_mysql)
# TODO add_subdirectory(mysql)
endif()
if(QT_FEATURE_sql_odbc)
# TODO add_subdirectory(odbc)
endif()
if(QT_FEATURE_sql_tds)
# TODO add_subdirectory(tds)
endif()
if(QT_FEATURE_sql_oci)
# TODO add_subdirectory(oci)
endif()
if(QT_FEATURE_sql_db2)
# TODO add_subdirectory(db2)
endif()
if(QT_FEATURE_sql_sqlite)
add_subdirectory(sqlite)
endif()
if(QT_FEATURE_sql_sqlite2)
# TODO add_subdirectory(sqlite2)
endif()
if(QT_FEATURE_sql_ibase)
# TODO add_subdirectory(ibase)
endif()

View File

@ -0,0 +1,54 @@
#### Inputs
#### Libraries
find_package(SQLite3)
set_package_properties(SQLite3 PROPERTIES TYPE OPTIONAL)
#### Tests
#### Features
qt_feature("sql_db2" PRIVATE
LABEL "DB2 (IBM)"
CONDITION libs.db2 OR FIXME
)
qt_feature("sql_ibase" PRIVATE
LABEL "InterBase"
CONDITION libs.ibase OR FIXME
)
qt_feature("sql_mysql" PRIVATE
LABEL "MySql"
CONDITION libs.mysql OR FIXME
)
qt_feature("sql_oci" PRIVATE
LABEL "OCI (Oracle)"
CONDITION libs.oci OR FIXME
)
qt_feature("sql_odbc" PRIVATE
LABEL "ODBC"
CONDITION QT_FEATURE_datestring AND libs.odbc OR FIXME
)
qt_feature("sql_psql" PRIVATE
LABEL "PostgreSQL"
CONDITION libs.psql OR FIXME
)
qt_feature("sql_sqlite2" PRIVATE
LABEL "SQLite2"
CONDITION libs.sqlite2 OR FIXME
)
qt_feature("sql_sqlite" PRIVATE
LABEL "SQLite"
CONDITION QT_FEATURE_datestring AND SQLite3_FOUND
)
qt_feature("sql_tds" PRIVATE
LABEL "TDS (Sybase)"
CONDITION QT_FEATURE_datestring AND libs.tds OR FIXME
)

View File

@ -0,0 +1,25 @@
# Generated from sqlite.pro.
find_package(SQLite3)
#####################################################################
## qsqlite Plugin:
#####################################################################
add_qt_plugin(qsqlite
TYPE sqldrivers
SOURCES
qsql_sqlite.cpp qsql_sqlite_p.h
smain.cpp
DEFINES
QT_NO_CAST_TO_ASCII
QT_NO_CAST_FROM_ASCII
LIBRARIES
Qt::CorePrivate
Qt::SqlPrivate
SQLite::SQLite3
# OTHER_FILES = "sqlite.json"
# PLUGIN_CLASS_NAME = "QSQLiteDriverPlugin"
# QT_FOR_CONFIG = "sqldrivers-private"
# _LOADED = "qt_plugin"
)

View File

@ -81,6 +81,7 @@ def map_library(lib: str) -> Union[str, LibraryMapping, List[str]]:
'posix_iconv': None,
'pps': 'PPS',
'slog2': 'Slog2',
'sqlite3': 'SQLite3',
'sun_iconv': None,
'tslib': 'Tslib',
'udev': 'Libudev',
@ -731,6 +732,9 @@ def parseFeature(ctx, feature, data, cm_fh):
'separate_debug_info': None,
'shared': None,
'silent': None,
'sql-sqlite' : {
'condition': 'QT_FEATURE_datestring AND SQLite3_FOUND',
},
'stack-protector-strong': None,
'static': None,
'static_runtime': None,
@ -746,6 +750,7 @@ def parseFeature(ctx, feature, data, cm_fh):
'system-jpeg': None,
'system-pcre2': None,
'system-png': None,
'system-sqlite': None,
'system-xcb': None,
'system-zlib': None,
'use_gold_linker': None,

View File

@ -215,6 +215,7 @@ libray_mapping = {
'libproxy': 'LibProxy::LibProxy',
'librt': 'WrapRt',
'pcre2': 'PCRE2',
'sqlite': 'SQLite3',
'x11sm': '${X11_SM_LIB} ${X11_ICE_LIB}',
'xcb_icccm': 'XCB::ICCCM',
'xcb_image': 'XCB::IMAGE',