diff --git a/CMakeLists.txt b/CMakeLists.txt index 71e307a7..cc5f9c5a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,228 +1,224 @@ +cmake_minimum_required(VERSION 3.7.2) + if(POLICY CMP0048) cmake_policy(SET CMP0048 NEW) endif(POLICY CMP0048) project( kbibtex VERSION "0.9.50" ) -cmake_minimum_required( - VERSION - 3.7.2 - FATAL_ERROR -) - set( QT_MIN_VERSION "5.9.0" ) set( KF5_MIN_VERSION "5.51.0" ) find_package(ECM 5.19 REQUIRED NO_MODULE) add_definitions( -DTRANSLATION_DOMAIN="kbibtex" -DHAVE_QTWIDGETS -DHAVE_KF5 -DHAVE_ICU ) set( CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_MODULE_PATH} ) include(KDEInstallDirs) include(KDECompilerSettings NO_POLICY_SCOPE) include(KDECMakeSettings) include(ECMGenerateHeaders) include(ECMInstallIcons) include(ECMSetupVersion) include(ECMAddAppIcon) include(GenerateExportHeader) find_package( Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED Core Widgets Network XmlPatterns Concurrent NetworkAuth ) if (MSVC) MESSAGE( STATUS "Disabling building tests when using Microsoft Visual Studio C++ compiler" ) # Note to any developer: Try to enable building tests and see which issues you may encounter. # Examples may include: (1) char* texts which exceed the size limit supported by MSVC which # is about 2^16 bytes and (2) characters in strings written in \uXXXX notation not supported # in 1252 encoding as assumed by MSVC for C++ source files. SET(BUILD_TESTING OFF) endif (MSVC) if( BUILD_TESTING ) find_package( Qt5Test ${QT_MIN_VERSION} CONFIG REQUIRED ) if (WRITE_RAWDATAFILE) add_definitions(-DWRITE_RAWDATAFILE) endif(WRITE_RAWDATAFILE) set( TESTSET_DIRECTORY "" CACHE PATH "Directory where the local checkout of Git repository 'kbibtex-testset' is located" ) endif( BUILD_TESTING ) find_package( Qt5WebEngineWidgets ${QT_MIN_VERSION} QUIET CONFIG ) find_package( Qt5WebKitWidgets ${QT_MIN_VERSION} QUIET CONFIG ) find_package( KF5 ${KF5_MIN_VERSION} REQUIRED I18n XmlGui KIO IconThemes ItemViews Completion Parts CoreAddons Service Wallet Crash ) find_package(KF5DocTools) find_package(KF5TextEditor NO_MODULE) ecm_setup_version( PROJECT VARIABLE_PREFIX KBIBTEX SOVERSION ${KBIBTEX_VERSION_MAJOR} VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kbibtex-version.h" ) if((${KBIBTEX_VERSION_PATCH} GREATER 50) OR (${KBIBTEX_VERSION_PATCH} EQUAL 50)) # If the version number indicates a pre-release version such as # '0.7.90', i.e. a beta version for the major release 0.8, # increment release version from 0.7 to 0.8 math(EXPR KBIBTEX_RELEASE_VERSION_MINOR "${KBIBTEX_VERSION_MINOR} + 1") set( KBIBTEX_RELEASE_VERSION ${KBIBTEX_VERSION_MAJOR}.${KBIBTEX_RELEASE_VERSION_MINOR} ) else((${KBIBTEX_VERSION_PATCH} GREATER 50) OR (${KBIBTEX_VERSION_PATCH} EQUAL 50)) set( KBIBTEX_RELEASE_VERSION ${KBIBTEX_VERSION_MAJOR}.${KBIBTEX_VERSION_MINOR} ) endif((${KBIBTEX_VERSION_PATCH} GREATER 50) OR (${KBIBTEX_VERSION_PATCH} EQUAL 50)) option( UNITY_BUILD "Compile multiple C++ files in one big, merged file (\"Unity build\")\nSee also http://t-fischer.dreamwidth.org/3054.html" ) if(UNITY_BUILD) message(STATUS "Unity build enabled") else(UNITY_BUILD) message(STATUS "Unity build disabled (default), use option UNITY_BUILD to enable it") endif(UNITY_BUILD) # # FIXME may have to be cleaned up a little bit # # Contributed by Jeremy Cribb # if( # APPLE # ) # find_library( # SYS_CONFIG_LIBRARY # SystemConfiguration # ) # mark_as_advanced( # SYS_CONFIG_LIBRARY # ) # # SET(TARGET_EXTERNAL_LIBRARIES iconv ${SYS_CONFIG_LIBRARY}) # set( # ICONV_INCLUDE_DIR # "/opt/local/include" # ) # set( # ICONV_LIBRARIES # "/opt/local/lib/libiconv.dylib" # ) # set( # LIBXSLT_LIBRARIES # "/opt/local/lib/libxslt.dylib" # ) # endif( # APPLE # ) find_package( Poppler REQUIRED COMPONENTS Qt5 ) find_package( ICU REQUIRED COMPONENTS uc i18n ) if( ICU_FOUND ) message( STATUS "Found ICU " ${ICU_VERSION} ) include_directories(${ICU_INCLUDE_DIRS}) endif( ICU_FOUND ) add_subdirectory( config ) add_subdirectory( src ) add_subdirectory( xslt ) add_subdirectory( mime ) if(KF5DocTools_FOUND) add_subdirectory(doc) endif() # macro_optional_add_subdirectory( # po # ) feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 73adfe0b..144ca54d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,77 +1,103 @@ # "Unity build" found at # https://cheind.wordpress.com/2009/12/10/reducing-compilation-time-unity-builds/ function(enable_unity_build UB_SUFFIX SOURCE_VARIABLE_NAME) set(files ${${SOURCE_VARIABLE_NAME}}) # Generate a unique filename for the unity build translation unit set(unit_build_file ${CMAKE_CURRENT_BINARY_DIR}/ub_${UB_SUFFIX}.cpp) # Exclude all translation units from compilation set_source_files_properties(${files} PROPERTIES HEADER_FILE_ONLY true) # Open the ub file file(WRITE ${unit_build_file} "// Unity Build generated by CMake\n") # Add include statement for each translation unit foreach(source_file ${files}) file(APPEND ${unit_build_file} "#include <${source_file}>\n") endforeach(source_file) # Complement list of translation units with the name of ub set(${SOURCE_VARIABLE_NAME} ${${SOURCE_VARIABLE_NAME}} ${unit_build_file} PARENT_SCOPE) endfunction(enable_unity_build) +# Creates kbibtex-git-info.h containing information about the source code's Git revision +# (if source directory is a Git clone) +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/kbibtex-git-info.h + COMMAND + ${CMAKE_COMMAND} + -DSOURCE_DIR=${CMAKE_SOURCE_DIR} + -DBINARY_DIR=${CMAKE_BINARY_DIR} + -P + ${CMAKE_CURRENT_SOURCE_DIR}/getgit.cmake + COMMENT "Determine Git revision in case this source code is a Git checkout" +) +set_source_files_properties( + ${CMAKE_CURRENT_BINARY_DIR}/kbibtex-git-info.h + PROPERTIES + GENERATED 1 + HEADER_FILE_ONLY 1 + SKIP_AUTOMOC ON + SKIP_AUTOUIC ON + SKIP_AUTOGEN ON +) +add_custom_target(generate-kbibtex-git-info + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/kbibtex-git-info.h +) + + if(Qt5WebEngineWidgets_FOUND) add_definitions( -DHAVE_WEBENGINEWIDGETS ) endif(Qt5WebEngineWidgets_FOUND) if(Qt5WebKitWidgets_FOUND) add_definitions( -DHAVE_WEBKITWIDGETS ) endif(Qt5WebKitWidgets_FOUND) if(Qt5WebEngineWidgets_FOUND) if(Qt5WebKitWidgets_FOUND) message(STATUS "Found both QtWebEngine and QtWebKit, preferring to use QtWebEngine") else(Qt5WebKitWidgets_FOUND) message(STATUS "Found QtWebEngine, but not QtWebKit, therefore going to use QtWebEngine") endif(Qt5WebKitWidgets_FOUND) else(Qt5WebEngineWidgets_FOUND) if(Qt5WebKitWidgets_FOUND) message(STATUS "Found QtWebKit, but not QtWebEngine, therefore going to use QtWebKit") else(Qt5WebKitWidgets_FOUND) message(STATUS "Found neither QtWebEngine nor QtWebKit, therefore trying to locate a KPart for HTML data") endif(Qt5WebKitWidgets_FOUND) endif(Qt5WebEngineWidgets_FOUND) add_subdirectory(global) add_subdirectory(config) add_subdirectory(data) add_subdirectory(io) add_subdirectory(processing) add_subdirectory(networking) add_subdirectory(gui) add_subdirectory( program ) add_subdirectory( parts ) if( BUILD_TESTING ) add_subdirectory( test ) endif( BUILD_TESTING ) # install( # FILES # kbibtexnamespace.h # DESTINATION # ${INCLUDE_INSTALL_DIR}/kbibtex # COMPONENT # development # ) diff --git a/src/getgit.cmake b/src/getgit.cmake index d93564f8..de8c78e5 100644 --- a/src/getgit.cmake +++ b/src/getgit.cmake @@ -1,158 +1,153 @@ ############################################################################# -# Copyright (C) 2004-2018 by Thomas Fischer # +# Copyright (C) 2004-2019 by Thomas Fischer # # # # This program is free software; you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # # the Free Software Foundation; either version 2 of the License, or # # (at your option) any later version. # # # # This program is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU General Public License for more details. # # # # You should have received a copy of the GNU General Public License # # along with this program; if not, see . # ############################################################################# # Inspired by: # http://stackoverflow.com/questions/3780667/use-cmake-to-get-build-time-svn-revision -if (DEFINED ENV{GIT_REV} AND DEFINED ENV{GIT_BRANCH} AND NOT("${GIT_REV}" STREQUAL "" OR "${GIT_BRANCH}" STREQUAL "")) +if(DEFINED ENV{GIT_REV} AND DEFINED ENV{GIT_BRANCH} AND NOT("${GIT_REV}" STREQUAL "" OR "${GIT_BRANCH}" STREQUAL "")) message (STATUS "Git information set by environment variables GIT_REV and GIT_BRANCH") set (GIT_REV $ENV{GIT_REV}) set (GIT_BRANCH $ENV{GIT_BRANCH}) -else (DEFINED ENV{GIT_REV} AND DEFINED ENV{GIT_BRANCH} AND NOT("${GIT_REV}" STREQUAL "" OR "${GIT_BRANCH}" STREQUAL "")) +else() set(GIT_REV "") set(GIT_BRANCH "") - if (EXISTS ${SOURCE_DIR}/.git) + if(EXISTS ${SOURCE_DIR}/.git) # Git find_program( GIT_EXECUTABLE NAMES git.bat git ) # for Windows, "git.bat" must be found before "git" - if (GIT_EXECUTABLE) + if(GIT_EXECUTABLE) execute_process ( WORKING_DIRECTORY "${SOURCE_DIR}" COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD OUTPUT_VARIABLE GIT_REV OUTPUT_STRIP_TRAILING_WHITESPACE ) execute_process ( WORKING_DIRECTORY "${SOURCE_DIR}" COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD OUTPUT_VARIABLE GIT_BRANCH OUTPUT_STRIP_TRAILING_WHITESPACE ) - else (GIT_EXECUTABLE) + else() message( "No Git executable" ) - endif (GIT_EXECUTABLE) - else (EXISTS ${SOURCE_DIR}/.git) + endif() + else() message( "Not a Git source directory" ) - endif (EXISTS ${SOURCE_DIR}/.git) -endif (DEFINED ENV{GIT_REV} AND DEFINED ENV{GIT_BRANCH} AND NOT("${GIT_REV}" STREQUAL "" OR "${GIT_BRANCH}" STREQUAL "")) + endif() +endif() # write a header file defining VERSION file( WRITE "${BINARY_DIR}/kbibtex-git-info.h.tmp" "/// This file has been automatically generated by 'getgit.cmake'.\n/// Do not edit or modify it.\n\n" ) -if ("${GIT_REV}" STREQUAL "" OR "${GIT_BRANCH}" STREQUAL "") - file( - APPEND - "${BINARY_DIR}/kbibtex-git-info.h.tmp" - "/// This source code does not come from a Git checkout or\n/// determining the Git revision or branch failed.\n/// Please consider setting environment variables GIT_REV and\n/// GIT_BRANCH before running the build tool (make, ninja, ...).\n\n" - ) -endif ("${GIT_REV}" STREQUAL "" OR "${GIT_BRANCH}" STREQUAL "") file( APPEND "${BINARY_DIR}/kbibtex-git-info.h.tmp" "#ifndef KBIBTEX_GIT_INFO_H\n" ) file( APPEND "${BINARY_DIR}/kbibtex-git-info.h.tmp" "#define KBIBTEX_GIT_INFO_H\n" ) + +if("${GIT_REV}" STREQUAL "" OR "${GIT_BRANCH}" STREQUAL "") + set(GIT_REV "") + set(GIT_BRANCH "") + message( + STATUS + "Source does not come from a Git checkout or determining the Git revision or branch failed" + ) + file( + APPEND + "${BINARY_DIR}/kbibtex-git-info.h.tmp" + "/// This source code does not come from a Git checkout or\n/// determining the Git revision or branch failed.\n/// Please consider setting environment variables GIT_REV and\n/// GIT_BRANCH before running the build tool (make, ninja, ...).\n\n" + ) +else() + message( + STATUS + "Git revision is " + ${GIT_REV} + "\nGit branch is " + ${GIT_BRANCH} + ) +endif() + file( APPEND "${BINARY_DIR}/kbibtex-git-info.h.tmp" "#define KBIBTEX_GIT_REV_STRING \"${GIT_REV}\"\n" ) file( APPEND "${BINARY_DIR}/kbibtex-git-info.h.tmp" "#define KBIBTEX_GIT_BRANCH_STRING \"${GIT_BRANCH}\"\n" ) -if ("${GIT_REV}" STREQUAL "" OR "${GIT_BRANCH}" STREQUAL "") +if("${GIT_REV}" STREQUAL "" OR "${GIT_BRANCH}" STREQUAL "") file( APPEND "${BINARY_DIR}/kbibtex-git-info.h.tmp" "#define KBIBTEX_GIT_INFO_STRING \"\"\n" ) -else ("${GIT_REV}" STREQUAL "" OR "${GIT_BRANCH}" STREQUAL "") +else() file( APPEND "${BINARY_DIR}/kbibtex-git-info.h.tmp" "#define KBIBTEX_GIT_INFO_STRING \"${GIT_REV} (${GIT_BRANCH})\"\n" ) -endif ("${GIT_REV}" STREQUAL "" OR "${GIT_BRANCH}" STREQUAL "") +endif() file( APPEND "${BINARY_DIR}/kbibtex-git-info.h.tmp" "#endif // KBIBTEX_GIT_INFO_H\n" ) -if ("${GIT_REV}" STREQUAL "" OR "${GIT_BRANCH}" STREQUAL "") - message( - STATUS - "Source does not come from a Git checkout or determining the Git revision or branch failed" - ) -else ("${GIT_REV}" STREQUAL "" OR "${GIT_BRANCH}" STREQUAL "") - message( - STATUS - "Git revision is " - ${GIT_REV} - "\nGit branch is " - ${GIT_BRANCH} - ) -endif ("${GIT_REV}" STREQUAL "" OR "${GIT_BRANCH}" STREQUAL "") - if( EXISTS "${BINARY_DIR}/kbibtex-git-info.h.tmp" ) execute_process( COMMAND ${CMAKE_COMMAND} -E copy_if_different "kbibtex-git-info.h.tmp" "kbibtex-git-info.h" WORKING_DIRECTORY "${BINARY_DIR}" ) execute_process( COMMAND ${CMAKE_COMMAND} -E remove "kbibtex-git-info.h.tmp" WORKING_DIRECTORY "${BINARY_DIR}" ) -else( - EXISTS - "${BINARY_DIR}/kbibtex-git-info.h.tmp" -) +else() message( STATUS "${BINARY_DIR}/kbibtex-git-info.h.tmp does not exist" ) -endif( - EXISTS - "${BINARY_DIR}/kbibtex-git-info.h.tmp" -) +endif() diff --git a/src/parts/CMakeLists.txt b/src/parts/CMakeLists.txt index c808555f..cc383bd5 100644 --- a/src/parts/CMakeLists.txt +++ b/src/parts/CMakeLists.txt @@ -1,76 +1,58 @@ # KBibTeX KPart set( kbibtexpart_SRCS part.cpp partfactory.cpp browserextension.cpp logging_parts.cpp ) if(UNITY_BUILD) enable_unity_build(kbibtexpart kbibtexpart_SRCS) endif(UNITY_BUILD) include_directories( ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) -# Creates kbibtex-git-info.h containing information about the source code's Git revision -# (if source directory is a Git clone) -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/kbibtex-git-info.h - COMMAND - ${CMAKE_COMMAND} - -DSOURCE_DIR=${CMAKE_SOURCE_DIR} - -DBINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} - -P - ${CMAKE_SOURCE_DIR}/src/getgit.cmake -) -set_source_files_properties( - ${CMAKE_CURRENT_BINARY_DIR}/kbibtex-git-info.h - PROPERTIES - GENERATED 1 - HEADER_FILE_ONLY 1 - SKIP_AUTOMOC ON - SKIP_AUTOUIC ON - SKIP_AUTOGEN ON -) - add_library( kbibtexpart MODULE ${kbibtexpart_SRCS} - ${CMAKE_CURRENT_BINARY_DIR}/kbibtex-git-info.h +) + +add_dependencies(kbibtexpart + generate-kbibtex-git-info ) target_link_libraries( kbibtexpart KF5::Parts KF5::CoreAddons KF5::ItemViews kbibtexconfig kbibtexdata kbibtexio kbibtexgui kbibtexprocessing ) install( TARGETS kbibtexpart DESTINATION ${KDE_INSTALL_PLUGINDIR} ) kcoreaddons_desktop_to_json(kbibtexpart kbibtexpart.desktop SERVICE_TYPES kpart.desktop) install( FILES kbibtexpart.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} ) install( FILES kbibtexpartui.rc DESTINATION ${KDE_INSTALL_KXMLGUI5DIR}/kbibtexpart ) diff --git a/src/parts/partfactory.cpp b/src/parts/partfactory.cpp index 993d391e..5df8f0ab 100644 --- a/src/parts/partfactory.cpp +++ b/src/parts/partfactory.cpp @@ -1,63 +1,62 @@ /*************************************************************************** * Copyright (C) 2004-2019 by Thomas Fischer * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, see . * ***************************************************************************/ #include "partfactory.h" #include #include #include #include "part.h" #include "kbibtex-version.h" #include "kbibtex-git-info.h" #include "logging_parts.h" class KBibTeXPartFactory::Private { public: KAboutData aboutData; Private() : aboutData(QStringLiteral("kbibtexpart"), i18n("KBibTeXPart"), strlen(KBIBTEX_GIT_INFO_STRING) > 0 ? QLatin1String(KBIBTEX_GIT_INFO_STRING ", near " KBIBTEX_VERSION_STRING) : QLatin1String(KBIBTEX_VERSION_STRING), i18n("A BibTeX editor by KDE"), KAboutLicense::GPL_V2, i18n("Copyright 2004-2019 Thomas Fischer"), QString(), QStringLiteral("https://userbase.kde.org/KBibTeX")) { aboutData.setOrganizationDomain(QByteArray("kde.org")); aboutData.setDesktopFileName(QStringLiteral("org.kde.kbibtex")); aboutData.addAuthor(i18n("Thomas Fischer"), i18n("Maintainer"), QStringLiteral("fischer@unix-ag.uni-kl.de")); + qCInfo(LOG_KBIBTEX_PARTS) << "Creating KBibTeX Part of version" << aboutData.version(); } }; KBibTeXPartFactory::KBibTeXPartFactory() : KPluginFactory(), d(new KBibTeXPartFactory::Private()) { /// nothing } KBibTeXPartFactory::~KBibTeXPartFactory() { delete d; } QObject *KBibTeXPartFactory::create(const char *iface, QWidget *parentWidget, QObject *parent, const QVariantList &args, const QString &keyword) { Q_UNUSED(iface); Q_UNUSED(args) Q_UNUSED(keyword); - qCInfo(LOG_KBIBTEX_PARTS()) << "Creating KBibTeX Part of version" << (strlen(KBIBTEX_GIT_INFO_STRING) > 0 ? QLatin1String(KBIBTEX_GIT_INFO_STRING) : QLatin1String(KBIBTEX_VERSION_STRING)); - KBibTeXPart *part = new KBibTeXPart(parentWidget, parent, d->aboutData); return part; } diff --git a/src/program/CMakeLists.txt b/src/program/CMakeLists.txt index c144d16d..35c71a06 100644 --- a/src/program/CMakeLists.txt +++ b/src/program/CMakeLists.txt @@ -1,140 +1,122 @@ # KBibTeX main program project( kbibtexprogram ) set( kbibtex_SRCS program.cpp mainwindow.cpp documentlist.cpp mdiwidget.cpp docklets/statistics.cpp docklets/referencepreview.cpp docklets/documentpreview.cpp docklets/valuelist.cpp docklets/searchform.cpp docklets/searchresults.cpp docklets/elementform.cpp docklets/filesettings.cpp docklets/zoterobrowser.cpp openfileinfo.cpp logging_program.cpp ) if(UNITY_BUILD AND NOT WIN32) # FIXME: Unity build of programs breaks on Windows enable_unity_build(kbibtex kbibtex_SRCS) endif(UNITY_BUILD AND NOT WIN32) include_directories( ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src/program/docklets ) ecm_add_app_icon( kbibtex_SRCS ICONS ${CMAKE_SOURCE_DIR}/icons/128-apps-kbibtex.png ${CMAKE_SOURCE_DIR}/icons/16-apps-kbibtex.png ${CMAKE_SOURCE_DIR}/icons/22-apps-kbibtex.png ${CMAKE_SOURCE_DIR}/icons/32-apps-kbibtex.png ${CMAKE_SOURCE_DIR}/icons/48-apps-kbibtex.png ${CMAKE_SOURCE_DIR}/icons/64-apps-kbibtex.png ) -# Creates kbibtex-git-info.h containing information about the source code's Git revision -# (if source directory is a Git clone) -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/kbibtex-git-info.h - COMMAND - ${CMAKE_COMMAND} - -DSOURCE_DIR=${CMAKE_SOURCE_DIR} - -DBINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} - -P - ${CMAKE_SOURCE_DIR}/src/getgit.cmake -) -set_source_files_properties( - ${CMAKE_CURRENT_BINARY_DIR}/kbibtex-git-info.h - PROPERTIES - GENERATED 1 - HEADER_FILE_ONLY 1 - SKIP_AUTOMOC ON - SKIP_AUTOUIC ON - SKIP_AUTOGEN ON -) - add_executable( kbibtex ${kbibtex_SRCS} - ${CMAKE_CURRENT_BINARY_DIR}/kbibtex-git-info.h +) + +add_dependencies(kbibtex + generate-kbibtex-git-info ) target_link_libraries( kbibtex Qt5::Core Qt5::Widgets KF5::CoreAddons KF5::I18n KF5::ConfigCore KF5::Service KF5::Parts KF5::IconThemes KF5::KIOCore KF5::KIOFileWidgets KF5::KIOWidgets KF5::KIONTLM KF5::Crash KF5::Wallet kbibtexio kbibtexgui kbibtexnetworking kbibtexprocessing ) if(Qt5WebEngineWidgets_FOUND) target_link_libraries( kbibtex Qt5::WebEngineWidgets ) else(Qt5WebEngineWidgets_FOUND) if(Qt5WebKitWidgets_FOUND) target_link_libraries( kbibtex Qt5::WebKitWidgets ) endif(Qt5WebKitWidgets_FOUND) endif(Qt5WebEngineWidgets_FOUND) install( TARGETS kbibtex ${INSTALL_TARGETS_DEFAULT_ARGS} ) install( PROGRAMS org.kde.kbibtex.desktop DESTINATION ${KDE_INSTALL_APPDIR} ) install( FILES kbibtexui.rc DESTINATION ${KDE_INSTALL_KXMLGUI5DIR}/kbibtex ) install( FILES org.kde.kbibtex.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR} ) ecm_install_icons( ICONS ${CMAKE_SOURCE_DIR}/icons/128-apps-kbibtex.png ${CMAKE_SOURCE_DIR}/icons/16-apps-kbibtex.png ${CMAKE_SOURCE_DIR}/icons/22-apps-kbibtex.png ${CMAKE_SOURCE_DIR}/icons/32-apps-kbibtex.png ${CMAKE_SOURCE_DIR}/icons/48-apps-kbibtex.png ${CMAKE_SOURCE_DIR}/icons/64-apps-kbibtex.png DESTINATION ${KDE_INSTALL_ICONDIR} ) diff --git a/src/program/program.cpp b/src/program/program.cpp index 173b0e6b..9cf17344 100644 --- a/src/program/program.cpp +++ b/src/program/program.cpp @@ -1,125 +1,125 @@ /*************************************************************************** * Copyright (C) 2004-2019 by Thomas Fischer * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, see . * ***************************************************************************/ #include #include #include #include #include #include #include #include #include #include "mainwindow.h" #include "kbibtex-version.h" #include "kbibtex-git-info.h" #include "logging_program.h" int main(int argc, char *argv[]) { if (strlen(KBIBTEX_GIT_INFO_STRING) > 0) { /// In Git versions, enable debugging by default QLoggingCategory::setFilterRules(QStringLiteral("kbibtex.*.debug = true")); } QApplication programCore(argc, argv); KCrash::initialize(); KLocalizedString::setApplicationDomain("kbibtex"); KAboutData aboutData(QStringLiteral("kbibtex"), i18n("KBibTeX"), strlen(KBIBTEX_GIT_INFO_STRING) > 0 ? QLatin1String(KBIBTEX_GIT_INFO_STRING ", near " KBIBTEX_VERSION_STRING) : QLatin1String(KBIBTEX_VERSION_STRING), i18n("A BibTeX editor by KDE"), KAboutLicense::GPL_V2, i18n("Copyright 2004-2019 Thomas Fischer"), QString(), QStringLiteral("https://userbase.kde.org/KBibTeX")); aboutData.setOrganizationDomain(QByteArray("kde.org")); aboutData.setDesktopFileName(QStringLiteral("org.kde.kbibtex")); aboutData.addAuthor(i18n("Thomas Fischer"), i18n("Maintainer"), QStringLiteral("fischer@unix-ag.uni-kl.de")); KAboutData::setApplicationData(aboutData); programCore.setApplicationName(aboutData.componentName()); programCore.setOrganizationDomain(aboutData.organizationDomain()); programCore.setApplicationVersion(aboutData.version()); programCore.setApplicationDisplayName(aboutData.displayName()); programCore.setWindowIcon(QIcon::fromTheme(QStringLiteral("kbibtex"))); - qCInfo(LOG_KBIBTEX_PROGRAM) << "Starting KBibTeX version" << (strlen(KBIBTEX_GIT_INFO_STRING) > 0 ? QLatin1String(KBIBTEX_GIT_INFO_STRING) : QLatin1String(KBIBTEX_VERSION_STRING)); + qCInfo(LOG_KBIBTEX_PROGRAM) << "Starting KBibTeX version" << aboutData.version(); QCommandLineParser cmdLineParser; cmdLineParser.addHelpOption(); cmdLineParser.addVersionOption(); cmdLineParser.addPositionalArgument(QStringLiteral("urls"), i18n("File(s) to load."), QStringLiteral("[urls...]")); cmdLineParser.process(programCore); aboutData.processCommandLine(&cmdLineParser); KBibTeXMainWindow *mainWindow = new KBibTeXMainWindow(); const QStringList urls = cmdLineParser.positionalArguments(); /// Process arguments if (!urls.isEmpty()) { static const QRegularExpression protocolCheckerRegExp(QStringLiteral("^[a-zA-Z]+:")); for (const QString &url : urls) { const QUrl u = protocolCheckerRegExp.match(url).hasMatch() ? QUrl::fromUserInput(url) : QUrl::fromLocalFile(url); mainWindow->openDocument(u); } } mainWindow->show(); KService::Ptr service = KService::serviceByStorageId(QStringLiteral("kbibtexpart.desktop")); if (service.data() == nullptr) { /// Dump some environment variables that may be helpful /// in tracing back why the part's .desktop file was not found qCDebug(LOG_KBIBTEX_PROGRAM) << "PATH=" << getenv("PATH"); qCDebug(LOG_KBIBTEX_PROGRAM) << "LD_LIBRARY_PATH=" << getenv("LD_LIBRARY_PATH"); qCDebug(LOG_KBIBTEX_PROGRAM) << "XDG_DATA_DIRS=" << getenv("XDG_DATA_DIRS"); qCDebug(LOG_KBIBTEX_PROGRAM) << "QT_PLUGIN_PATH=" << getenv("QT_PLUGIN_PATH"); qCDebug(LOG_KBIBTEX_PROGRAM) << "KDEDIRS=" << getenv("KDEDIRS"); qCDebug(LOG_KBIBTEX_PROGRAM) << "QCoreApplication::libraryPaths=" << programCore.libraryPaths().join(QLatin1Char(':')); KMessageBox::error(mainWindow, i18n("KBibTeX seems to be not installed completely. KBibTeX could not locate its own KPart.\n\nOnly limited functionality will be available."), i18n("Incomplete KBibTeX Installation")); } else { qCInfo(LOG_KBIBTEX_PROGRAM) << "Located KPart service:" << service->library() << "with description" << service->comment() << "from library" << service->library(); } /* /// started by session management? if (programCore.isSessionRestored()) { RESTORE(KBibTeXMainWindow()); } else { /// no session.. just start up normally KBibTeXMainWindow *mainWindow = new KBibTeXMainWindow(); KCmdLineArgs *arguments = KCmdLineArgs::parsedArgs(); for (int i = 0; i < arguments->count(); ++i) { const QUrl url = arguments->url(i); if (url.isValid()) mainWindow->openDocument(url); } mainWindow->show(); arguments->clear(); } */ return programCore.exec(); } diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index c6d8b39b..51f26946 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -1,174 +1,168 @@ # KBibTeX test program project( test ) include( AddFileDependencies ) include( ECMMarkAsTest ) configure_file(test-config.h.in test-config.h @ONLY) include_directories( ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) set( kbibtextest_SRCS main.cpp kbibtextest.cpp logging_test.cpp ) set( kbibtexfilestest_SRCS kbibtexfilestest.cpp kbibtexfilestest-rawdata.h ) set( kbibtexnetworkingtest_SRCS kbibtexnetworkingtest.cpp ) set( kbibtexiotest_SRCS kbibtexiotest.cpp ) set( kbibtexdatatest_SRCS kbibtexdatatest.cpp ) if(UNITY_BUILD AND NOT WIN32) # FIXME: Unity build of programs breaks on Windows enable_unity_build(kbibtextest kbibtextest_SRCS) enable_unity_build(kbibtexfilestest kbibtexfilestest_SRCS) enable_unity_build(kbibtexnetworkingtest kbibtexnetworkingtest_SRCS) enable_unity_build(kbibtexiotest kbibtexiotest_SRCS) enable_unity_build(kbibtexdatatest kbibtexdatatest_SRCS) endif(UNITY_BUILD AND NOT WIN32) -# Creates kbibtex-git-info.h containing information about the source code's Git revision -# (if source directory is a Git clone) -add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/kbibtex-git-info.h - COMMAND - ${CMAKE_COMMAND} - -DSOURCE_DIR=${CMAKE_SOURCE_DIR} - -DBINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} - -P - ${CMAKE_SOURCE_DIR}/src/getgit.cmake -) -set_source_files_properties( - ${CMAKE_CURRENT_BINARY_DIR}/kbibtex-git-info.h - PROPERTIES - GENERATED 1 - HEADER_FILE_ONLY 1 - SKIP_AUTOMOC ON - SKIP_AUTOUIC ON - SKIP_AUTOGEN ON -) - add_executable( kbibtextest ${kbibtextest_SRCS} - ${CMAKE_CURRENT_BINARY_DIR}/kbibtex-git-info.h +) + +add_dependencies(kbibtextest + generate-kbibtex-git-info ) add_executable( kbibtexfilestest ${kbibtexfilestest_SRCS} - ${CMAKE_CURRENT_BINARY_DIR}/kbibtex-git-info.h +) + +add_dependencies(kbibtexfilestest + generate-kbibtex-git-info ) add_executable( kbibtexnetworkingtest ${kbibtexnetworkingtest_SRCS} - ${CMAKE_CURRENT_BINARY_DIR}/kbibtex-git-info.h +) + +add_dependencies(kbibtexnetworkingtest + generate-kbibtex-git-info ) add_executable( kbibtexiotest ${kbibtexiotest_SRCS} - ${CMAKE_CURRENT_BINARY_DIR}/kbibtex-git-info.h +) + +add_dependencies(kbibtexiotest + generate-kbibtex-git-info ) add_executable( kbibtexdatatest ${kbibtexdatatest_SRCS} - ${CMAKE_CURRENT_BINARY_DIR}/kbibtex-git-info.h +) + +add_dependencies(kbibtexdatatest + generate-kbibtex-git-info ) target_link_libraries( kbibtextest Qt5::Core KF5::KIOCore KF5::I18n kbibtexconfig kbibtexdata kbibtexio kbibtexprocessing kbibtexgui kbibtexnetworking ) target_link_libraries( kbibtexfilestest Qt5::Test kbibtexdata kbibtexio ) target_link_libraries( kbibtexnetworkingtest Qt5::Test kbibtexnetworking ) target_link_libraries( kbibtexiotest Qt5::Test kbibtexio ) target_link_libraries( kbibtexdatatest Qt5::Test kbibtexdata ) ecm_mark_as_test( kbibtexfilestest kbibtexnetworkingtest kbibtexiotest kbibtexdatatest ) add_test( NAME kbibtexfilestest COMMAND kbibtexfilestest ) add_test( NAME kbibtexnetworkingtest COMMAND kbibtexnetworkingtest ) add_test( NAME kbibtexiotest COMMAND kbibtexiotest ) add_test( NAME kbibtexdatatest COMMAND kbibtexdatatest )