From 9bef044a0bec636ff08f7dcd6e16f6fadd612532 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Tue, 12 Feb 2019 12:00:49 +0100 Subject: [PATCH] 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 --- cmake/QtFeature.cmake | 34 ++++++------ src/plugins/CMakeLists.txt | 2 +- src/plugins/sqldrivers/CMakeLists.txt | 51 ++++++++++++++++++ src/plugins/sqldrivers/configure.cmake | 54 ++++++++++++++++++++ src/plugins/sqldrivers/sqlite/CMakeLists.txt | 25 +++++++++ util/cmake/configurejson2cmake.py | 5 ++ util/cmake/helper.py | 1 + 7 files changed, 155 insertions(+), 17 deletions(-) create mode 100644 src/plugins/sqldrivers/CMakeLists.txt create mode 100644 src/plugins/sqldrivers/configure.cmake create mode 100644 src/plugins/sqldrivers/sqlite/CMakeLists.txt diff --git a/cmake/QtFeature.cmake b/cmake/QtFeature.cmake index 4a8449405e..13d0203612 100644 --- a/cmake/QtFeature.cmake +++ b/cmake/QtFeature.cmake @@ -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) diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index 1daaf47be7..0d470824f9 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -1,6 +1,6 @@ if (QT_FEATURE_sql) -# TODO add_subdirectory(sqldrivers) + add_subdirectory(sqldrivers) endif() if(QT_FEATURE_network AND QT_FEATURE_bearermanagement) diff --git a/src/plugins/sqldrivers/CMakeLists.txt b/src/plugins/sqldrivers/CMakeLists.txt new file mode 100644 index 0000000000..95e696f48b --- /dev/null +++ b/src/plugins/sqldrivers/CMakeLists.txt @@ -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() diff --git a/src/plugins/sqldrivers/configure.cmake b/src/plugins/sqldrivers/configure.cmake new file mode 100644 index 0000000000..626a835f0a --- /dev/null +++ b/src/plugins/sqldrivers/configure.cmake @@ -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 +) diff --git a/src/plugins/sqldrivers/sqlite/CMakeLists.txt b/src/plugins/sqldrivers/sqlite/CMakeLists.txt new file mode 100644 index 0000000000..77a112a406 --- /dev/null +++ b/src/plugins/sqldrivers/sqlite/CMakeLists.txt @@ -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" +) diff --git a/util/cmake/configurejson2cmake.py b/util/cmake/configurejson2cmake.py index 870c56d4d6..e99bb27bc2 100755 --- a/util/cmake/configurejson2cmake.py +++ b/util/cmake/configurejson2cmake.py @@ -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, diff --git a/util/cmake/helper.py b/util/cmake/helper.py index 16502fd274..6234d26d09 100644 --- a/util/cmake/helper.py +++ b/util/cmake/helper.py @@ -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',