Warning, /libraries/kdb/src/CMakeLists.txt is written in an unsupported language. File is not indexed.

0001 # Private options (visible only within KDb)
0002 simple_option(KDB_EXPRESSION_DEBUG "Debugging of Expression classes" OFF)
0003 simple_option(KDB_DRIVERMANAGER_DEBUG "Debugging of the Driver Manager class" OFF)
0004 simple_option(KDB_TRANSACTIONS_DEBUG "Debugging of the Transaction class" OFF)
0005 simple_option(KDB_TABLESCHEMACHANGELISTENER_DEBUG "Debugging of the KDbTableSchemaChangeListener class" OFF)
0006 simple_option(KDB_QUERYSCHEMA_DEBUG "Debugging of the QuerySchema class" OFF)
0007 simple_option(KDB_SQLPARSER_DEBUG "Debugging of the SQL parser" OFF)
0008 
0009 # Public options (affecting public behavior or contents of KDb)
0010 simple_option(KDB_DEBUG_GUI "GUI for debugging" OFF)
0011 # NOTE: always add public options to KDbConfig.cmake.in as well
0012 
0013 include(CheckIncludeFile)
0014 check_include_file(unistd.h HAVE_UNISTD_H)
0015 
0016 #add_definitions(
0017 #    TODO  -DKDE_DEFAULT_DEBUG_AREA=44000
0018 #)
0019 
0020 ########### generate parser/lexer files ###############
0021 # as described at https://public.kitware.com/pipermail/cmake/2002-September/003028.html
0022 
0023 # Create target for the parser
0024 add_custom_target(parser echo "Creating parser/lexer files")
0025 
0026 set(PARSER_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/parser)
0027 
0028 # Create custom command for flex/lex (note the outputs)
0029 # TODO(GEN) uncomment GENERATED if we ever use this patch: https://phabricator.kde.org/D357 "No more generated parser/scanner files in the source dir"
0030 add_custom_command(
0031     TARGET parser
0032     COMMAND ${PARSER_SOURCE_DIR}/generate_parser_code.sh
0033     DEPENDS ${PARSER_SOURCE_DIR}/KDbSqlParser.y
0034             ${PARSER_SOURCE_DIR}/KDbSqlScanner.l
0035             ${PARSER_SOURCE_DIR}/generate_parser_code.sh
0036     OUTPUT
0037     #TODO(GEN)     ${PARSER_SOURCE_DIR}/generated/sqlparser.h
0038     #TODO(GEN)     ${PARSER_SOURCE_DIR}/generated/sqlparser.cpp
0039     #TODO(GEN)     ${PARSER_SOURCE_DIR}/generated/sqlscanner.cpp
0040     #TODO(GEN)     ${PARSER_SOURCE_DIR}/generated/KDbToken.h
0041     #TODO(GEN)     ${PARSER_SOURCE_DIR}/generated/KDbToken.cpp
0042 )
0043 
0044 if(NOT HAVE_UNISTD_H)
0045     set(EXTRA_SCANNER_COMPILE_FLAGS "-DYY_NO_UNISTD_H=1")
0046 endif()
0047 
0048 if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
0049     set(EXTRA_SCANNER_COMPILE_FLAGS "${EXTRA_SCANNER_COMPILE_FLAGS} -Wno-sign-compare -Wno-unused-function -Wno-deprecated-register -Wno-zero-as-null-pointer-constant")
0050 elseif(MSVC)
0051     set(EXTRA_SCANNER_COMPILE_FLAGS "${EXTRA_SCANNER_COMPILE_FLAGS} /wd4018") # disable warning C4018: '<' : signed/unsigned mismatch
0052 endif()
0053 
0054 # Mark files as generated, set compile flags
0055 set_source_files_properties(${PARSER_SOURCE_DIR}/generated/sqlparser.cpp
0056     PROPERTIES
0057         #TODO(GEN) GENERATED TRUE
0058         SKIP_AUTOMOC ON
0059         # YYERROR_VERBOSE=1 needed to get a token table for tokenName() even for release builds
0060         COMPILE_FLAGS "-DYYERROR_VERBOSE=1 ${EXTRA_PARSER_COMPILE_FLAGS} "
0061 )
0062 # TODO(GEN) set_source_files_properties(${PARSER_SOURCE_DIR}/generated/sqlparser.h PROPERTIES GENERATED TRUE)
0063 # TODO(GEN) set_source_files_properties(${PARSER_SOURCE_DIR}/generated/KDbToken.h PROPERTIES GENERATED TRUE)
0064 set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/KDbConnectionData_sdc.cpp
0065     PROPERTIES
0066         GENERATED TRUE
0067         SKIP_AUTOMOC ON
0068 )
0069 
0070 set_source_files_properties(
0071     ${PARSER_SOURCE_DIR}/generated/sqlscanner.cpp
0072     PROPERTIES
0073         #TODO(GEN) GENERATED TRUE
0074         SKIP_AUTOMOC ON
0075         COMPILE_FLAGS "${EXTRA_SCANNER_COMPILE_FLAGS} "
0076 )
0077 
0078 set(kdb_LIB_SRCS
0079    parser/generated/sqlscanner.cpp
0080    parser/generated/sqlparser.cpp
0081    parser/generated/KDbToken.cpp
0082    parser/KDbParser.cpp
0083    parser/KDbParser_p.cpp
0084    parser/KDbSqlParser.y
0085    parser/KDbSqlScanner.l
0086    parser/generate_parser_code.sh
0087    parser/extract_tokens.sh
0088    parser/TODO
0089 
0090    tools/KDbJsonTrader_p.cpp # mostly copied from KReport's KReportJsonTrader_p.cpp
0091    tools/KDbValidator.cpp
0092    tools/KDbFieldValidator.cpp
0093    tools/KDbLongLongValidator.cpp
0094    tools/KDbObjectNameValidator.cpp
0095    tools/KDbIdentifierValidator.cpp
0096    tools/KDbUtils.cpp
0097    #TODO tools/debuggui.cpp
0098    #TODO tools/KDbSimpleCommandLineApp.cpp
0099 
0100    tools/transliteration/transliteration_table.cpp
0101    tools/transliteration/generate_transliteration_table.sh
0102    tools/transliteration/transliteration_table.readme
0103 
0104    KDbDateTime.cpp
0105    KDbEscapedString.cpp
0106    KDbResult.cpp
0107    KDbQueryAsterisk.cpp
0108    KDbConnectionData.cpp
0109    KDbVersionInfo.cpp
0110    ${CMAKE_CURRENT_BINARY_DIR}/KDbConnectionData_sdc.cpp
0111    KDbField.cpp
0112    KDbQuerySchemaParameter.cpp
0113    expression/KDbExpression.cpp
0114    expression/KDbNArgExpression.cpp
0115    expression/KDbUnaryExpression.cpp
0116    expression/KDbBinaryExpression.cpp
0117    expression/KDbConstExpression.cpp
0118    expression/KDbQueryParameterExpression.cpp
0119    expression/KDbVariableExpression.cpp
0120    expression/KDbFunctionExpression.cpp
0121    KDbFieldList.cpp
0122    KDbTableSchema.cpp
0123    KDbTableSchemaChangeListener.cpp
0124    KDbIndexSchema.cpp
0125    KDbOrderByColumn.cpp
0126    KDbQuerySchema.cpp
0127    KDbQuerySchema_p.cpp
0128    KDbQueryColumnInfo.cpp
0129    KDbTableOrQuerySchema.cpp
0130    KDbDriverManager.cpp
0131    KDbDriver.cpp
0132    KDbDriver_p.cpp
0133    KDbDriverMetaData.cpp
0134    KDbConnection.cpp
0135    KDbConnectionProxy.cpp
0136    generated/sqlkeywords.cpp
0137    KDbObject.cpp
0138    KDb.cpp
0139    KDbRecordData.cpp
0140    KDbCursor.cpp
0141    KDbTransaction.cpp
0142    KDbGlobal.cpp
0143    KDbRelationship.cpp
0144    KDbRecordEditBuffer.cpp
0145    KDbMessageHandler.cpp
0146    KDbPreparedStatement.cpp
0147    KDbProperties.cpp
0148    KDbAdmin.cpp
0149    KDbLookupFieldSchema.cpp
0150    KDbAlter.cpp
0151    KDbNativeStatementBuilder.cpp
0152    kdb_debug.cpp
0153 
0154    views/KDbTableViewData.cpp
0155    views/KDbTableViewColumn.cpp
0156    views/chartable.txt
0157 
0158    sql/KDbSqlField.cpp
0159    sql/KDbSqlRecord.cpp
0160    sql/KDbSqlResult.cpp
0161 
0162    # private:
0163    tools/KDbUtils_p.h
0164 
0165    # non-source:
0166    Mainpage.dox
0167    Messages.sh
0168 )
0169 
0170 ecm_create_qm_loader(kdb_LIB_SRCS kdb_qt)
0171 
0172 add_library(KDb SHARED ${kdb_LIB_SRCS})
0173 set_coinstallable_lib_version(KDb)
0174 
0175 kdb_create_shared_data_classes(
0176     kdb_GENERATED_SHARED_DATA_CLASS_HEADERS # output variable with list of headers
0177     NO_PREFIX # subdirectory in which the headers should be generated
0178     KDbConnectionData.shared.h
0179     KDbObject.shared.h
0180     KDbQuerySchemaParameter.shared.h
0181     KDbResult.shared.h
0182     KDbSelectStatementOptions.shared.h
0183     KDbVersionInfo.shared.h
0184 )
0185 
0186 kdb_remove_extensions(
0187     kdb_GENERATED_SHARED_DATA_CLASS_BASENAMES
0188     ${kdb_GENERATED_SHARED_DATA_CLASS_HEADERS}
0189 )
0190 
0191 #message(STATUS "kdb_GENERATED_SHARED_DATA_CLASS_HEADERS: ${kdb_GENERATED_SHARED_DATA_CLASS_HEADERS}")
0192 
0193 #add_dependencies(KDb _shared_classes) # generate shared classes before they can be used in KDb
0194 
0195 generate_export_header(KDb)
0196 
0197 set(kdb_INCLUDE_DIRS
0198     ${CMAKE_CURRENT_SOURCE_DIR}
0199     ${CMAKE_CURRENT_SOURCE_DIR}/expression
0200     ${CMAKE_CURRENT_SOURCE_DIR}/interfaces
0201     ${CMAKE_CURRENT_SOURCE_DIR}/parser
0202     ${CMAKE_CURRENT_SOURCE_DIR}/parser/generated
0203     ${CMAKE_CURRENT_SOURCE_DIR}/sql
0204     ${CMAKE_CURRENT_SOURCE_DIR}/tools
0205     ${CMAKE_CURRENT_SOURCE_DIR}/views
0206 )
0207 
0208 target_include_directories(KDb
0209     PUBLIC "$<BUILD_INTERFACE:${kdb_INCLUDE_DIRS}>"
0210     INTERFACE "$<INSTALL_INTERFACE:${KDB_INCLUDE_INSTALL_DIR}>"
0211 )
0212 
0213 target_link_libraries(KDb
0214     PUBLIC
0215         Qt5::Core
0216         Qt5::Gui
0217         Qt5::Widgets
0218         KF5::CoreAddons
0219     PRIVATE
0220         Qt5::Xml
0221         ICU::i18n
0222 )
0223 
0224 string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER)
0225 if("${CMAKE_BUILD_TYPE_LOWER}" MATCHES "debug")
0226    target_compile_definitions(KDb PRIVATE -DYYDEBUG=1) # needed where sqlparser.h is used
0227 endif()
0228 
0229 set(QT_ISODATEWITHMS_MIN_VERSION 5.8.0)
0230 if(Qt5_VERSION VERSION_LESS ${QT_ISODATEWITHMS_MIN_VERSION})
0231     message(STATUS "Qt ${Qt5_VERSION} does not have Qt::ISODateWithMs APIs, minimal version is \
0232 ${QT_ISODATEWITHMS_MIN_VERSION}. KDb's implementation will be compiled-in.")
0233 else()
0234     # Qt::ISODateWithMs APIs present
0235     target_compile_definitions(KDb PRIVATE -DHAVE_QT_ISODATEWITHMS)
0236 endif()
0237 
0238 if(BUILD_TEST_COVERAGE)
0239     target_link_libraries(KDb
0240         PRIVATE
0241             gcov
0242     )
0243 endif()
0244 
0245 # Create a Config.cmake and a ConfigVersion.cmake file and install them
0246 set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/${KDB_BASE_NAME}")
0247 
0248 ecm_setup_version(${PROJECT_VERSION}
0249     VARIABLE_PREFIX KDB
0250     SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
0251     VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kdb_version.h"
0252     PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KDbConfigVersion.cmake"
0253 )
0254 
0255 install(TARGETS KDb
0256         EXPORT KDbTargets
0257         ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
0258 
0259 configure_package_config_file(
0260     "${CMAKE_CURRENT_SOURCE_DIR}/KDbConfig.cmake.in"
0261     "${CMAKE_CURRENT_BINARY_DIR}/KDbConfig.cmake"
0262     INSTALL_DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
0263 )
0264 
0265 install(FILES
0266         "${CMAKE_CURRENT_BINARY_DIR}/KDbConfig.cmake"
0267         "${CMAKE_CURRENT_BINARY_DIR}/KDbConfigVersion.cmake"
0268         DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
0269         COMPONENT Devel)
0270 
0271 install(EXPORT KDbTargets
0272         DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
0273         FILE KDbTargets.cmake)
0274 
0275 ecm_generate_pri_file(
0276     BASE_NAME ${KDB_BASE_NAME}
0277     LIB_NAME ${KDB_BASE_NAME}
0278     DEPS "widgets xml"
0279     FILENAME_VAR PRI_FILENAME
0280     INCLUDE_INSTALL_DIR ${KDB_INCLUDE_INSTALL_DIR}
0281 )
0282 
0283 install(FILES ${PRI_FILENAME}
0284         DESTINATION ${ECM_MKSPECS_INSTALL_DIR})
0285 
0286 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/kdb_version.h"
0287         DESTINATION "${KDB_INCLUDE_INSTALL_DIR}"
0288         COMPONENT Devel)
0289 
0290 ecm_generate_headers(kdb_FORWARDING_HEADERS
0291     REQUIRED_HEADERS kdb_HEADERS
0292     ORIGINAL CAMELCASE
0293     HEADER_NAMES
0294         KDb
0295         KDbAdmin
0296         KDbAlter
0297         KDbQueryAsterisk
0298         KDbConnection
0299         KDbConnectionOptions
0300         KDbConnectionProxy
0301         KDbCursor
0302         KDbDateTime
0303         KDbDriver
0304         KDbDriverBehavior
0305         KDbDriverManager
0306         KDbDriverMetaData
0307         KDbError
0308         KDbEscapedString
0309         KDbField
0310         KDbFieldList
0311         KDbGlobal
0312         KDbIndexSchema
0313         KDbLookupFieldSchema
0314         KDbMessageHandler
0315         KDbNativeStatementBuilder
0316         KDbPreparedStatement
0317         KDbProperties
0318         KDbQueryColumnInfo
0319         KDbOrderByColumn
0320         KDbQuerySchema
0321         KDbRecordData
0322         KDbRecordEditBuffer
0323         KDbRelationship
0324         KDbTableOrQuerySchema
0325         KDbTableSchema
0326         KDbTableSchemaChangeListener
0327         KDbTransaction
0328         KDbTransactionData
0329         KDbTransactionGuard
0330 )
0331 
0332 ecm_generate_headers(kdb_FORWARDING_HEADERS
0333     REQUIRED_HEADERS kdb_HEADERS
0334     ORIGINAL CAMELCASE
0335     RELATIVE expression
0336     HEADER_NAMES
0337         KDbExpression
0338         KDbExpressionData
0339 )
0340 
0341 ecm_generate_headers(kdb_FORWARDING_HEADERS
0342     REQUIRED_HEADERS kdb_HEADERS
0343     ORIGINAL CAMELCASE
0344     RELATIVE interfaces
0345     HEADER_NAMES
0346         KDbPreparedStatementInterface
0347 )
0348 
0349 ecm_generate_headers(kdb_FORWARDING_HEADERS
0350     REQUIRED_HEADERS kdb_HEADERS
0351     ORIGINAL CAMELCASE
0352     RELATIVE parser
0353     HEADER_NAMES
0354         KDbParser
0355 )
0356 
0357 ecm_generate_headers(kdb_FORWARDING_HEADERS
0358     REQUIRED_HEADERS kdb_HEADERS
0359     ORIGINAL CAMELCASE
0360     RELATIVE parser/generated
0361     HEADER_NAMES
0362         KDbToken
0363 )
0364 
0365 ecm_generate_headers(kdb_FORWARDING_HEADERS
0366     REQUIRED_HEADERS kdb_HEADERS
0367     ORIGINAL CAMELCASE
0368     RELATIVE sql
0369     HEADER_NAMES
0370         KDbSqlField
0371         KDbSqlRecord
0372         KDbSqlResult
0373         KDbSqlString
0374 )
0375 
0376 ecm_generate_headers(kdb_FORWARDING_HEADERS
0377     REQUIRED_HEADERS kdb_HEADERS
0378     ORIGINAL CAMELCASE
0379     RELATIVE views
0380     HEADER_NAMES
0381         KDbTableViewData
0382         KDbTableViewColumn
0383 )
0384 
0385 ecm_generate_headers(kdb_FORWARDING_HEADERS
0386     REQUIRED_HEADERS kdb_HEADERS
0387     ORIGINAL CAMELCASE
0388     RELATIVE tools
0389     HEADER_NAMES
0390         KDbValidator
0391         KDbUtils
0392         KDbTristate
0393         #todo KDbSimpleCommandLineApp
0394         KDbLongLongValidator
0395         KDbIdentifierValidator
0396         KDbFieldValidator
0397         KDbObjectNameValidator
0398 )
0399 
0400 #message(STATUS "%% ${kdb_GENERATED_SHARED_DATA_CLASS_BASENAMES}")
0401 
0402 ecm_generate_headers(kdb_FORWARDING_HEADERS_FROM_BUILDDIR
0403     REQUIRED_HEADERS kdb_HEADERS_FROM_BUILDDIR
0404     ORIGINAL CAMELCASE
0405     SOURCE_DIR ${PROJECT_BINARY_DIR}/src
0406     HEADER_NAMES
0407         ${kdb_GENERATED_SHARED_DATA_CLASS_BASENAMES}
0408 )
0409 
0410 #message(STATUS "%%kdb_HEADERS_FROM_BUILDDIR ${kdb_HEADERS_FROM_BUILDDIR}")
0411 
0412 install(
0413     FILES
0414         ${kdb_HEADERS}
0415         ${kdb_HEADERS_FROM_BUILDDIR}
0416     DESTINATION ${KDB_INCLUDE_INSTALL_DIR}
0417     COMPONENT Devel
0418 )
0419 
0420 install(
0421     FILES
0422         ${kdb_FORWARDING_HEADERS}
0423         ${kdb_FORWARDING_HEADERS_FROM_BUILDDIR}
0424         ${PROJECT_BINARY_DIR}/src/kdb_export.h
0425         ${PROJECT_BINARY_DIR}/src/config-kdb.h
0426     DESTINATION ${KDB_INCLUDE_INSTALL_DIR}
0427     COMPONENT Devel
0428 )
0429 
0430 # KDb/Private includes
0431 # install( FILES
0432 #   Connection_p.h
0433 #   Driver_p.h
0434 #   DESTINATION ${KDB_INCLUDE_INSTALL_DIR}/Private COMPONENT Devel
0435 # )
0436 
0437 # KDb/Interfaces includes
0438 # install( FILES
0439 #   Interfaces/KDbPreparedStatementInterface.h includes/KDb/Interfaces/KDbPreparedStatementInterface
0440 #   DESTINATION ${KDB_INCLUDE_INSTALL_DIR}/Interfaces COMPONENT Devel
0441 # )
0442 
0443 if(BUILD_QCH)
0444     ecm_add_qch(
0445         KDb_QCH
0446         NAME KDb
0447         BASE_NAME ${KDB_BASE_NAME}
0448         VERSION ${PROJECT_VERSION}
0449         ORG_DOMAIN org.kde.${KDB_BASE_NAME}
0450         SOURCES
0451             Mainpage.dox
0452             ${kdb_HEADERS}
0453             ${kdb_HEADERS_FROM_BUILDDIR}
0454         LINK_QCHS
0455             Qt5Core_QCH
0456             Qt5Gui_QCH
0457             Qt5Widgets_QCH
0458             KF5CoreAddons_QCH
0459         INCLUDE_DIRS
0460             ${CMAKE_CURRENT_BINARY_DIR}
0461             ${kdb_INCLUDE_DIRS}
0462         BLANK_MACROS
0463             KDB_EXPORT
0464             KDB_DEPRECATED
0465         TAGFILE_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR}
0466         QCH_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR}
0467         COMPONENT Devel
0468     )
0469     set(kdb_qch_targets KDb_QCH)
0470 endif()
0471 
0472 ecm_install_qch_export(
0473     TARGETS ${kdb_qch_targets}
0474     FILE KDbQCHTargets.cmake
0475 ​    DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
0476 ​    COMPONENT Devel
0477 ​)
0478 
0479 add_subdirectory(drivers)
0480 
0481 enable_testing()
0482 
0483 configure_file(config-kdb.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kdb.h)
0484 configure_file(config-kdb-private.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kdb-private.h)
0485 target_sources(KDb
0486     PRIVATE ${PROJECT_BINARY_DIR}/src/config-kdb-private.h
0487 )