Warning, /office/kbibtex/CMakeLists.txt is written in an unsupported language. File is not indexed.

0001 # SPDX-License-Identifier: GPL-2.0-or-later
0002 # SPDX-FileCopyrightText: 2008-2023 Thomas Fischer <fischer@unix-ag.uni-kl.de>
0003 # SPDX-FileContributor: 2013-2021 Pino Toscano <pino@kde.org>
0004 # SPDX-FileContributor: 2014-2021 Yuri Chornoivan <yurchor@ukr.net>
0005 # SPDX-FileContributor: 2015-2021 David Faure <faure@kde.org>
0006 # SPDX-FileContributor: 2016-2021 Andreas Sturmlechner <andreas.sturmlechner@gmail.com>
0007 
0008 cmake_minimum_required(VERSION 3.16.0 FATAL_ERROR)
0009 
0010 project(
0011     kbibtex
0012     VERSION 0.10.50
0013     LANGUAGES CXX
0014 )
0015 
0016 set(CMAKE_CXX_STANDARD 14)
0017 
0018 find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
0019 message(STATUS "Found Qt version ${QT_VERSION_MAJOR}")
0020 if(BUILD_WITH_QT6)
0021     message(STATUS "Using Qt version 6, honoring BUILD_WITH_QT6")
0022     set(QT_VERSION_MAJOR 6)
0023 elseif(BUILD_WITH_QT5)
0024     message(STATUS "Using Qt version 5, honoring BUILD_WITH_QT5")
0025     set(QT_VERSION_MAJOR 5)
0026 elseif(QT_MAJOR_VERSION)
0027     message(STATUS "Using Qt version " ${QT_MAJOR_VERSION} ", honoring QT_MAJOR_VERSION")
0028     set(QT_VERSION_MAJOR ${QT_MAJOR_VERSION})
0029 endif()
0030 
0031 set(KF_MIN_VERSION "5.86")
0032 set(QT_REQUIRED_VERSION "5.15.2")
0033 if (QT_VERSION_MAJOR GREATER_EQUAL 6)
0034     set(QT_REQUIRED_VERSION "6.4.0")
0035     set(KF_MIN_VERSION "5.240.0")
0036 endif()
0037 
0038 set(KDE_COMPILERSETTINGS_LEVEL ${KF_MIN_VERSION})
0039 find_package(ECM ${KF_MIN_VERSION} REQUIRED NO_MODULE)
0040 
0041 set(
0042     CMAKE_MODULE_PATH
0043     ${ECM_MODULE_PATH}
0044     ${CMAKE_MODULE_PATH}
0045 )
0046 
0047 set(KDE_INSTALL_DIRS_NO_DEPRECATED TRUE)
0048 include(KDEInstallDirs)
0049 include(KDECompilerSettings NO_POLICY_SCOPE)
0050 include(KDECMakeSettings)
0051 include(ECMGenerateHeaders)
0052 include(ECMInstallIcons)
0053 include(ECMSetupVersion)
0054 include(ECMAddAppIcon)
0055 include(GenerateExportHeader)
0056 include(ECMQtDeclareLoggingCategory)
0057 
0058 ecm_setup_version(
0059     PROJECT
0060     VARIABLE_PREFIX KBIBTEX
0061     SOVERSION ${KBIBTEX_VERSION_MAJOR}
0062     VERSION_HEADER "${CMAKE_BINARY_DIR}/kbibtex-version.h"
0063     PACKAGE_VERSION_FILE "${CMAKE_BINARY_DIR}/KBibTeXConfigVersion.cmake"
0064 )
0065 
0066 install(
0067     FILES ${CMAKE_BINARY_DIR}/kbibtex-version.h
0068     DESTINATION ${KDE_INSTALL_INCLUDEDIR}/KBibTeX
0069     # FIXME is "Devel" standard?
0070     COMPONENT Devel
0071 )
0072 
0073 
0074 if("${KBIBTEX_VERSION_PATCH}" STREQUAL "")
0075     # Patch level is not set for version numbers like "0.9",
0076     # so set the patch level manually to 0
0077     set(KBIBTEX_VERSION_PATCH 0)
0078 endif()
0079 
0080 if((${KBIBTEX_VERSION_PATCH} GREATER 50) OR (${KBIBTEX_VERSION_PATCH} EQUAL 50))
0081     # If the version number indicates a pre-release version such as
0082     # '0.7.90', i.e. a beta version for the major release 0.8,
0083     # increment release version from 0.7 to 0.8
0084     math(EXPR KBIBTEX_RELEASE_VERSION_MINOR "${KBIBTEX_VERSION_MINOR} + 1")
0085     set(
0086         KBIBTEX_RELEASE_VERSION ${KBIBTEX_VERSION_MAJOR}.${KBIBTEX_RELEASE_VERSION_MINOR}
0087     )
0088 else()
0089     set(
0090         KBIBTEX_RELEASE_VERSION ${KBIBTEX_VERSION_MAJOR}.${KBIBTEX_VERSION_MINOR}
0091     )
0092 endif()
0093 
0094 option(
0095     UNITY_BUILD
0096     "Compile multiple C++ files in one big, merged file (\"Unity build\")\nSee also https://t-fischer.dreamwidth.org/3054.html"
0097 )
0098 if(UNITY_BUILD)
0099     message(STATUS "Unity build enabled")
0100 else(UNITY_BUILD)
0101     message(STATUS "Unity build disabled (default), use option UNITY_BUILD to enable it")
0102 endif(UNITY_BUILD)
0103 
0104 
0105 option(
0106     BUILD_APP_DESKTOP
0107     "Build the desktop app which makes use of widgets"
0108     ON
0109 )
0110 option(
0111     BUILD_APP_COMMAND_LINE
0112     "Build the command line program with minimal dependencies only"
0113     ON
0114 )
0115 option(
0116     BUILD_KPART
0117     "Build KBibTeX's KPart (will be set ON automatically if desktop app is built)"
0118     OFF
0119 )
0120 if(BUILD_APP_DESKTOP)
0121     set(BUILD_KPART ON)
0122 endif()
0123 
0124 find_package(
0125     Python
0126     COMPONENTS
0127       Interpreter
0128     REQUIRED
0129 )
0130 
0131 if (QT_VERSION_MAJOR GREATER_EQUAL 6)
0132     # Should become necessary once migrated from QTextCodec to QStringConverter
0133     find_package(
0134         Qt6 ${QT_REQUIRED_VERSION}
0135         CONFIG
0136         COMPONENTS
0137         Core5Compat
0138     )
0139 endif()
0140 
0141 if (QT_VERSION_MAJOR EQUAL 5)
0142     # Migrate away from QXmlQuery
0143     find_package(
0144         Qt5 ${QT_REQUIRED_VERSION}
0145         CONFIG
0146         COMPONENTS
0147         XmlPatterns
0148     )
0149 endif()
0150 
0151 if(BUILD_KPART OR BUILD_TESTING)
0152     find_package(
0153         Qt${QT_VERSION_MAJOR} ${QT_REQUIRED_VERSION}
0154         CONFIG
0155         COMPONENTS
0156         Gui
0157         Widgets
0158         Network
0159         Concurrent
0160         NetworkAuth
0161         OPTIONAL_COMPONENTS
0162         WebEngineWidgets
0163         WebKitWidgets
0164         Test
0165     )
0166     if (Qt${QT_VERSION_MAJOR}Widgets_FOUND)
0167         add_compile_definitions(HAVE_QTWIDGETS)
0168     endif()
0169 endif()
0170 
0171 if(Qt${QT_VERSION_MAJOR}WebEngineWidgets_FOUND)
0172     add_compile_definitions(HAVE_WEBENGINEWIDGETS)
0173 endif()
0174 
0175 if (Qt${QT_VERSION_MAJOR}XmlPatterns_FOUND)
0176     add_compile_definitions(HAVE_QTXMLPATTERNS)
0177 endif()
0178 
0179 find_package(
0180     KF${QT_VERSION_MAJOR} ${KF_MIN_VERSION}
0181     MODULE
0182     REQUIRED
0183     Config
0184 )
0185 if(BUILD_KPART OR BUILD_TESTING)
0186     find_package(
0187         KF${QT_VERSION_MAJOR} ${KF_MIN_VERSION}
0188         MODULE
0189         REQUIRED
0190         I18n
0191         KIO
0192         IconThemes
0193         CoreAddons
0194         Wallet
0195         Crash
0196         TextEditor
0197         TextWidgets
0198         COMPONENTS
0199         XmlGui
0200         Parts
0201     )
0202 endif()
0203 if (KF5_FOUND)
0204     add_compile_definitions(HAVE_KF5 HAVE_KF)
0205 endif()
0206 if (KF6_FOUND)
0207     add_compile_definitions(HAVE_KF6 HAVE_KF)
0208 endif()
0209 if (KF${QT_VERSION_MAJOR}I18n_FOUND)
0210     add_compile_definitions(HAVE_KFI18N)
0211 endif()
0212 
0213 find_package(
0214     Poppler
0215     MODULE
0216     REQUIRED
0217     Qt${QT_VERSION_MAJOR}
0218 )
0219 if (PKG_Poppler_Qt${QT_VERSION_MAJOR}_FOUND)
0220     add_compile_definitions(HAVE_POPPLERQT${QT_VERSION_MAJOR} HAVE_POPPLERQT)
0221 endif()
0222 
0223 find_package(
0224     ICU
0225     MODULE
0226     OPTIONAL_COMPONENTS
0227     uc i18n
0228 )
0229 
0230 if(ICU_FOUND)
0231     add_compile_definitions(HAVE_ICU)
0232 endif()
0233 
0234 option(
0235     BUILD_TESTING
0236     "Build automated and interactive tests"
0237     OFF
0238 )
0239 if (MSVC)
0240     MESSAGE( STATUS "Disabling building tests when using Microsoft Visual Studio C++ compiler" )
0241     # Note to any developer: Try to enable building tests and see which issues you may encounter.
0242     # Examples may include: (1) char* texts which exceed the size limit supported by MSVC which
0243     # is about 2^16 bytes and (2) characters in strings written in \uXXXX notation not supported
0244     # in 1252 encoding as assumed by MSVC for C++ source files.
0245     set(BUILD_TESTING OFF)
0246 endif()
0247 if(NOT BUILD_TESTING AND Qt${QT_VERSION_MAJOR}Test_FOUND)
0248     message(STATUS
0249         "Testing is disabled, but can be enabled as the Qt::Test library is available"
0250     )
0251 endif()
0252 if(BUILD_TESTING AND NOT Qt${QT_VERSION_MAJOR}Test_FOUND)
0253     message(STATUS
0254         "Disabling building tests as Qt::Test library is not available"
0255     )
0256     set(BUILD_TESTING OFF)
0257 endif()
0258 
0259 if(BUILD_TESTING)
0260     add_compile_definitions(BUILD_TESTING)
0261     if (WRITE_RAWDATAFILE)
0262         add_compile_definitions(WRITE_RAWDATAFILE)
0263     endif(WRITE_RAWDATAFILE)
0264 
0265     set(
0266         TESTSET_DIRECTORY ""
0267         CACHE PATH
0268         "Directory where the local checkout of Git repository 'kbibtex-testset' is located"
0269     )
0270 endif()
0271 
0272 if(TESTSET_DIRECTORY AND ( NOT EXISTS "${TESTSET_DIRECTORY}/bib/minix.bib" OR NOT EXISTS "${TESTSET_DIRECTORY}/bib/backslash.bib" ))
0273     message("Variable TESTSET_DIRECTORY is set to '${TESTSET_DIRECTORY}' but various BibTeX files were not found. Unsetting TESTSET_DIRECTORY.")
0274     unset(TESTSET_DIRECTORY)
0275     unset(TESTSET_DIRECTORY CACHE)
0276 endif()
0277 
0278 
0279 option(
0280     BUILD_SCIHUB
0281     "Support fetching PDF files from SciHub"
0282     ON
0283 )
0284 if(BUILD_SCIHUB)
0285     add_compile_definitions(HAVE_SCIHUB)
0286 endif()
0287 
0288 
0289 add_subdirectory(
0290     config
0291 )
0292 add_subdirectory(
0293     src
0294 )
0295 add_subdirectory(
0296     mime
0297 )
0298 if(KF${QT_VERSION_MAJOR}DocTools_FOUND)
0299     add_subdirectory(doc)
0300     kdoctools_install(po)
0301 endif()
0302 
0303 if(KF${QT_VERSION_MAJOR}I18n_FOUND)
0304     ki18n_install(po)
0305 endif()
0306 
0307 if (ECM_VERSION VERSION_GREATER_EQUAL "5.59.0")
0308     install(FILES kbibtex.categories DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR})
0309 else()
0310     install(FILES kbibtex.categories DESTINATION ${KDE_INSTALL_CONFDIR})
0311 endif()
0312 
0313 feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)