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

0001 cmake_minimum_required(VERSION 3.16)
0002 
0003 project(calligra)
0004 
0005 message(STATUS "Using CMake version: ${CMAKE_VERSION}")
0006 
0007 if (POLICY CMP0022)
0008     cmake_policy(SET CMP0022 OLD)
0009 endif ()
0010 if (POLICY CMP0063)
0011     cmake_policy(SET CMP0063 NEW)
0012 endif()
0013 if (POLICY CMP0071)
0014     cmake_policy(SET CMP0071 NEW)
0015 endif()
0016 
0017 # ensure out-of-source build
0018 string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" isBuildInSource)
0019 if(isBuildInSource)
0020     message(FATAL_ERROR "Compiling Calligra inside the source folder is not possible.\nPlease refer to the build instruction: https://community.kde.org/Calligra/Building/3\nYou need to clean up the source folder from all build artifacts just created, otherwise further building attempts will fail again: With a git repo, you can use \"git clean -df\" in the toplevel source folder (attention! will remove also uncommitted changes to the source code). With sources from a file bundle (like a zip file), delete the source folder and unbundle the sources again.")
0021 endif()
0022 
0023 ######################
0024 #######################
0025 ## Constants defines ##
0026 #######################
0027 ######################
0028 
0029 # define common versions of Calligra applications, used to generate calligraversion.h
0030 # update these version for every release:
0031 set(CALLIGRA_VERSION_STRING "3.3.89")
0032 set(CALLIGRA_STABLE_VERSION_MAJOR 3) # 3 for 3.x, 4 for 4.x, etc.
0033 set(CALLIGRA_STABLE_VERSION_MINOR 3) # 0 for 3.0, 1 for 3.1, etc.
0034 set(CALLIGRA_VERSION_RELEASE 89)     # 89 for Alpha, increase for next test releases, set 0 for first Stable, etc.
0035 set(CALLIGRA_ALPHA 1) # uncomment only for Alpha
0036 # set(CALLIGRA_BETA 1) # uncomment only for Beta
0037 #set(CALLIGRA_RC 1) # uncomment only for RC
0038 set(CALLIGRA_YEAR 2021) # update every year
0039 
0040 if(NOT DEFINED CALLIGRA_ALPHA AND NOT DEFINED CALLIGRA_BETA AND NOT DEFINED CALLIGRA_RC)
0041     set(CALLIGRA_STABLE 1) # do not edit
0042 endif()
0043 
0044 message(STATUS "Calligra version: ${CALLIGRA_VERSION_STRING}")
0045 
0046 # Define the generic version of the Calligra libraries here
0047 # This makes it easy to advance it when the next Calligra release comes.
0048 # 14 was the last GENERIC_CALLIGRA_LIB_VERSION_MAJOR of the previous Calligra series
0049 # (2.x) so we're starting with 15 in 3.x series.
0050 if(CALLIGRA_STABLE_VERSION_MAJOR EQUAL 3)
0051     math(EXPR GENERIC_CALLIGRA_LIB_VERSION_MAJOR "${CALLIGRA_STABLE_VERSION_MINOR} + 15")
0052 else()
0053     # let's make sure we won't forget to update the "15"
0054     message(FATAL_ERROR "Reminder: please update offset == 15 used to compute GENERIC_CALLIGRA_LIB_VERSION_MAJOR to something bigger")
0055 endif()
0056 set(GENERIC_CALLIGRA_LIB_VERSION "${GENERIC_CALLIGRA_LIB_VERSION_MAJOR}.0.0")
0057 set(GENERIC_CALLIGRA_LIB_SOVERSION "${GENERIC_CALLIGRA_LIB_VERSION_MAJOR}")
0058 
0059 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
0060     "${CMAKE_SOURCE_DIR}/cmake/modules")
0061 
0062 message("Module path:" ${CMAKE_MODULE_PATH})
0063 
0064 # fetch git revision for the current build
0065 
0066 set(CALLIGRA_GIT_SHA1_STRING "")
0067 set(CALLIGRA_GIT_BRANCH_STRING "")
0068 
0069 include(GetGitRevisionDescription)
0070 get_git_head_revision(GIT_REFSPEC GIT_SHA1)
0071 get_git_branch(GIT_BRANCH)
0072 
0073 if(GIT_SHA1 AND GIT_BRANCH)
0074     string(SUBSTRING ${GIT_SHA1} 0 7 GIT_SHA1)
0075     set(CALLIGRA_GIT_SHA1_STRING ${GIT_SHA1})
0076     set(CALLIGRA_GIT_BRANCH_STRING ${GIT_BRANCH})
0077 endif()
0078 
0079 if(NOT DEFINED RELEASE_BUILD)
0080     # estimate mode by CMAKE_BUILD_TYPE content if not set on cmdline
0081     string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_TOLOWER)
0082     set(RELEASE_BUILD_TYPES "release" "relwithdebinfo" "minsizerel")
0083     list(FIND RELEASE_BUILD_TYPES "${CMAKE_BUILD_TYPE_TOLOWER}" INDEX)
0084     if (INDEX EQUAL -1)
0085         set(RELEASE_BUILD FALSE)
0086     else()
0087         set(RELEASE_BUILD TRUE)
0088     endif()
0089 endif()
0090 message(STATUS "Release build: ${RELEASE_BUILD}")
0091 
0092 ############
0093 #############
0094 ## Options ##
0095 #############
0096 ############
0097 
0098 option(PACKAGERS_BUILD "Build support of multiple CPU architectures in one binary. Should be used by packagers only." ON)
0099 
0100 #######################
0101 ########################
0102 ## Productset setting ##
0103 ########################
0104 #######################
0105 
0106 # For predefined productsets see the definitions in CalligraProducts.cmake and
0107 # in the files in the folder cmake/productsets.
0108 
0109 # Finding out the products & features to build is done in 5 steps:
0110 # 1. have the user define the products/features wanted, by giving a productset
0111 # 2. estimate all additional required products/features
0112 # 3. estimate which of the products/features can be build by external deps
0113 # 4. find which products/features have been temporarily disabled due to problems
0114 # 5. estimate which of the products/features can be build by internal deps
0115 
0116 # get the special macros
0117 include(CalligraProductSetMacros)
0118 
0119 # get the definitions of products, features and product sets
0120 include(CalligraProducts.cmake)
0121 
0122 set(PRODUCTSET_DEFAULT "ALL")
0123 
0124 if(NOT PRODUCTSET)
0125     set(PRODUCTSET ${PRODUCTSET_DEFAULT} CACHE STRING "Set of products/features to build" FORCE)
0126 endif()
0127 
0128 if (RELEASE_BUILD)
0129     set(CALLIGRA_SHOULD_BUILD_STAGING FALSE)
0130     if(BUILD_UNMAINTAINED)
0131         set(CALLIGRA_SHOULD_BUILD_UNMAINTAINED TRUE)
0132     else()
0133         set(CALLIGRA_SHOULD_BUILD_UNMAINTAINED FALSE)
0134     endif()
0135 else ()
0136     set(CALLIGRA_SHOULD_BUILD_STAGING TRUE)
0137     set(CALLIGRA_SHOULD_BUILD_UNMAINTAINED TRUE)
0138 endif ()
0139 
0140 # finally choose products/features to build
0141 calligra_set_productset(${PRODUCTSET})
0142 
0143 ##########################
0144 ###########################
0145 ## Look for ECM, Qt, KF5 ##
0146 ###########################
0147 ##########################
0148 set(REQUIRED_KF5_VERSION "5.76.0")
0149 set(REQUIRED_QT_VERSION "5.12.0")
0150 
0151 set(CMAKE_CXX_STANDARD 17)
0152 set(CMAKE_CXX_STANDARD_REQUIRED ON)
0153 set(CMAKE_CXX_EXTENSIONS OFF)
0154 
0155 find_package(ECM ${REQUIRED_KF5_VERSION} REQUIRED NO_MODULE)
0156 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH})
0157 
0158 # ECM KDE macros (include first, to have their policies and settings effect all other macros)
0159 include(KDEInstallDirs)
0160 include(KDECMakeSettings NO_POLICY_SCOPE)
0161 include(KDECompilerSettings NO_POLICY_SCOPE)
0162 # CMake macros
0163 include(CMakePackageConfigHelpers)
0164 include(WriteBasicConfigVersionFile)
0165 include(CheckFunctionExists)
0166 include(CheckTypeSize)
0167 include(CheckIncludeFile)
0168 include(GenerateExportHeader)
0169 include(FeatureSummary)
0170 # ECM macros
0171 include(ECMOptionalAddSubdirectory)
0172 include(ECMInstallIcons)
0173 include(ECMAddAppIcon)
0174 include(ECMSetupVersion)
0175 include(ECMAddTests)
0176 include(ECMMarkAsTest)
0177 include(ECMMarkNonGuiExecutable)
0178 include(ECMGenerateHeaders)
0179 # own macros
0180 include(MacroBoolTo01)
0181 include(MacroOptionalFindPackage)
0182 include(MacroEnsureVersion)
0183 include(MacroDesktopToJson)
0184 
0185 find_package(KF5 ${REQUIRED_KF5_VERSION} REQUIRED
0186     COMPONENTS
0187     Archive
0188     Codecs
0189     Completion
0190     Config
0191     ConfigWidgets
0192     CoreAddons
0193     Crash
0194     DBusAddons
0195     DocTools
0196     GuiAddons
0197     I18n
0198     IconThemes
0199     ItemViews
0200     JobWidgets
0201     KCMUtils
0202     KIO
0203     Notifications
0204     NotifyConfig
0205     Parts
0206     Sonnet
0207     TextWidgets
0208     Wallet
0209     WidgetsAddons
0210     WindowSystem
0211     XmlGui
0212     )
0213 
0214 find_package(KF5Activities)
0215 
0216 set_package_properties(KF5Activities PROPERTIES
0217     TYPE OPTIONAL
0218     )
0219 
0220 if(KF5Activities_FOUND)
0221     set(HAVE_KACTIVITIES TRUE)
0222 endif()
0223 
0224 find_package(KF5Kross ${REQUIRED_KF5_VERSION})
0225 
0226 find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED
0227     COMPONENTS
0228     Core
0229     Gui
0230     Network
0231     PrintSupport
0232     Svg
0233     Test
0234     Widgets
0235     Xml
0236     )
0237 find_package(Qt5 ${REQUIRED_QT_VERSION} QUIET
0238     COMPONENTS
0239     DBus
0240     OpenGL
0241     Quick
0242     QuickWidgets
0243     Sql
0244 )
0245 
0246 set_package_properties(Qt5DBus PROPERTIES
0247     TYPE RECOMMENDED
0248     )
0249 set_package_properties(Qt5Declarative PROPERTIES
0250     PURPOSE "Required for QtQuick1 components"
0251     TYPE RECOMMENDED
0252     )
0253 set_package_properties(Qt5OpenGL PROPERTIES
0254     PURPOSE "Required for QtQuick1 components"
0255     TYPE RECOMMENDED
0256     )
0257 set_package_properties(Qt5Quick PROPERTIES
0258     PURPOSE "Required for QtQuick2 components"
0259     TYPE RECOMMENDED
0260     )
0261 set_package_properties(Qt5QuickWidgets PROPERTIES
0262     PURPOSE "Required for Calligra Gemini"
0263     TYPE RECOMMENDED
0264     )
0265 set_package_properties(Qt5Sql PROPERTIES
0266     PURPOSE "Optional for Sheets' database connection"
0267     TYPE OPTIONAL
0268     )
0269 set_package_properties(Qt5WebKit PROPERTIES
0270     PURPOSE "Required for Braindump's Web shape"
0271     TYPE OPTIONAL
0272     )
0273 
0274 set(HAVE_OPENGL ${Qt5OpenGL_FOUND})
0275 
0276 find_package(X11)
0277 if(X11_FOUND)
0278     find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED
0279         COMPONENTS
0280         X11Extras
0281         )
0282     set(HAVE_X11 TRUE)
0283     add_definitions(-DHAVE_X11)
0284 else()
0285     set(HAVE_X11 FALSE)
0286 endif()
0287 
0288 # use sane compile flags
0289 remove_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0)
0290 add_definitions(
0291     -DQT_USE_QSTRINGBUILDER
0292     -DQT_STRICT_ITERATORS
0293     -DQT_NO_SIGNALS_SLOTS_KEYWORDS
0294     -DQT_NO_URL_CAST_FROM_STRING
0295     -DQT_NO_CAST_TO_ASCII
0296     -DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x053000
0297     -DQT_DISABLE_DEPRECATED_BEFORE=0x050600
0298     )
0299 
0300 # only with this definition will all the FOO_TEST_EXPORT macro do something
0301 # TODO: check if this can be moved to only those places which make use of it,
0302 # to reduce global compiler definitions that would trigger a recompile of
0303 # everything on a change (like adding/removing tests to/from the build)
0304 if(BUILD_TESTING)
0305     add_definitions(-DCOMPILING_TESTS)
0306 endif()
0307 
0308 # overcome some platform incompatibilities
0309 if(WIN32)
0310     if(NOT MINGW)
0311         include_directories(${CMAKE_CURRENT_SOURCE_DIR}/winquirks)
0312         add_definitions(-D_USE_MATH_DEFINES)
0313         add_definitions(-DNOMINMAX)
0314     endif()
0315     set(WIN32_PLATFORM_NET_LIBS ws2_32.lib netapi32.lib)
0316 endif()
0317 
0318 ###########################
0319 ############################
0320 ## Required dependencies  ##
0321 ############################
0322 ###########################
0323 
0324 find_package(Perl REQUIRED)
0325 find_package(ZLIB REQUIRED)
0326 
0327 add_definitions(-DBOOST_ALL_NO_LIB)
0328 find_package(Boost REQUIRED) # for pigment and stage
0329 if (NOT Boost_FOUND)
0330     message(FATAL_ERROR "Did not find Boost. Boost is required for the core libraries, stage, sheets.")
0331 endif ()
0332 
0333 ###########################
0334 ############################
0335 ## Optional dependencies  ##
0336 ############################
0337 ###########################
0338 
0339 
0340 ##
0341 ## Check for OpenEXR
0342 ##
0343 
0344 macro_optional_find_package(Imath 3.0 CONFIG QUIET)
0345 if(TARGET Imath::Imath)
0346     set(OPENEXR_LIBRARIES Imath::Imath)
0347     set(OpenEXR_FOUND TRUE)
0348 else()
0349     macro_optional_find_package(OpenEXR)
0350 endif()
0351 macro_bool_to_01(OpenEXR_FOUND HAVE_OPENEXR)
0352 
0353 ##
0354 ## Test for GNU Scientific Library
0355 ##
0356 macro_optional_find_package(GSL 1.7)
0357 set_package_properties(GSL_FOUND PROPERTIES
0358     DESCRIPTION "GNU Scientific Library"
0359     URL "https://www.gnu.org/software/gsl"
0360     PURPOSE "Required by Sheets' solver plugin"
0361     TYPE OPTIONAL
0362     )
0363 macro_bool_to_01(GSL_FOUND HAVE_GSL)
0364 configure_file(config-gsl.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-gsl.h )
0365 
0366 ##
0367 ## Test for Phonon4Qt5
0368 ##
0369 find_package(Phonon4Qt5 QUIET)
0370 set_package_properties(Phonon4Qt5 PROPERTIES
0371     DESCRIPTION "Abstraction lib for multimedia applications"
0372     URL "https://www.kde.org/"
0373     PURPOSE "Required by Stage event actions and Videoshape plugin"
0374     TYPE OPTIONAL
0375     )
0376 
0377 ##
0378 ## Test for KF5CalendarCore
0379 ##
0380 find_package(KF5CalendarCore CONFIG QUIET)
0381 set_package_properties(KF5CalendarCore PROPERTIES
0382     DESCRIPTION "KDE Calendar Library"
0383     URL "https://www.kde.org/"
0384     PURPOSE "Optionally used by semantic item Event"
0385     TYPE OPTIONAL
0386     )
0387 
0388 ##
0389 ## Test for KF5Contacts
0390 ##
0391 find_package(KF5Contacts CONFIG QUIET)
0392 set_package_properties(KF5Contacts PROPERTIES
0393     DESCRIPTION "KDE Address book Library"
0394     URL "https://www.kde.org/"
0395     PURPOSE "Optionally used by semantic item Contact"
0396     TYPE OPTIONAL
0397     )
0398 
0399 ##
0400 ## Test for KF5AkonadiCore
0401 ##
0402 find_package(KF5Akonadi CONFIG QUIET)
0403 set_package_properties(KF5Akonadi PROPERTIES
0404     DESCRIPTION "Library for general Access to Akonadi"
0405     URL "https://www.kde.org/"
0406     PURPOSE "Optionally used by semantic items Event and Contact"
0407     TYPE OPTIONAL
0408     )
0409 
0410 ##
0411 ## Test for KChart
0412 ##
0413 macro_optional_find_package(KChart 2.7.0 QUIET)
0414 set_package_properties(KChart PROPERTIES
0415     DESCRIPTION "Library for creating business charts (part of KDiagram)"
0416     URL "https://www.kde.org/"
0417     PURPOSE "Required by Chart shape"
0418     TYPE RECOMMENDED
0419     )
0420 
0421 ##
0422 ## Test for eigen3
0423 ##
0424 macro_optional_find_package(Eigen3)
0425 set_package_properties(Eigen3 PROPERTIES
0426     DESCRIPTION "C++ template library for linear algebra"
0427     URL "http://eigen.tuxfamily.org"
0428     PURPOSE "Required by Calligra Sheets"
0429     TYPE RECOMMENDED
0430     )
0431 
0432 ##
0433 ## Test for QCA2
0434 ##
0435 macro_optional_find_package(Qca-qt5 2.1.0 QUIET)
0436 set_package_properties(Qca-qt5 PROPERTIES
0437     DESCRIPTION "Qt Cryptographic Architecture"
0438     URL "http:/download.kde.org/stable/qca-qt5"
0439     PURPOSE "Required for encrypted OpenDocument files and encrypted xls files support (available as a module in kdesupport)"
0440     TYPE OPTIONAL
0441     )
0442 
0443 ##
0444 ## Test for soprano
0445 ##
0446 # QT5TODO: push for released (and maintained) Qt5 version of Soprano, T462, T461
0447 # macro_optional_find_package(Soprano)
0448 set(Soprano_FOUND FALSE)
0449 set_package_properties(Soprano PROPERTIES
0450     DESCRIPTION "RDF handling library"
0451     URL "http://soprano.sourceforge.net/"
0452     PURPOSE "Required to handle RDF metadata in ODF"
0453     TYPE OPTIONAL
0454     )
0455 if(NOT Soprano_FOUND)
0456     set(SOPRANO_INCLUDE_DIR "")
0457 endif()
0458 
0459 ##
0460 ## Test for marble
0461 ##
0462 # Temporary fix to avoid looking for Marble unnecessarily
0463 # Its only used in RDF so until soprano is ported there is no use for Marble
0464 if (Soprano_FOUND)
0465     macro_optional_find_package(Marble CONFIG)
0466     set(Marble_FOUND FALSE)
0467     set_package_properties(Marble PROPERTIES
0468         DESCRIPTION "World Globe Widget library"
0469         URL "https://marble.kde.org/"
0470         PURPOSE "Required by RDF to show locations on a map"
0471         TYPE OPTIONAL
0472     )
0473 else()
0474     message(STATUS "Soprano not found. Skipped looking for Marble.")
0475 endif()
0476 
0477 ##
0478 ## Test for lcms
0479 ##
0480 macro_optional_find_package(LCMS2 2.4)
0481 set_package_properties(LCMS2 PROPERTIES
0482     DESCRIPTION "LittleCMS, a color management engine"
0483     URL "http://www.littlecms.com"
0484     PURPOSE "Will be used for color management"
0485     TYPE OPTIONAL
0486     )
0487 if(LCMS2_FOUND)
0488     set(HAVE_LCMS2 TRUE)
0489 endif()
0490 
0491 ##
0492 ## Test for Vc
0493 ##
0494 
0495 set(HAVE_VC FALSE)
0496 if (BUILD_VC)
0497     # NOTE: This tampers with cmake variables (at least cmake_minimum_required), so may give build problems
0498     set(OLD_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} )
0499     set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules )
0500     if( NOT MSVC)
0501         macro_optional_find_package(Vc 1.1.0)
0502         set_package_properties(Vc PROPERTIES
0503             DESCRIPTION "Portable, zero-overhead SIMD library for C++"
0504             URL "https://github.com/VcDevel/Vc"
0505             PURPOSE "Required by the pigment for vectorization"
0506             TYPE OPTIONAL
0507             )
0508         macro_bool_to_01(Vc_FOUND HAVE_VC)
0509         macro_bool_to_01(PACKAGERS_BUILD DO_PACKAGERS_BUILD)
0510     endif()
0511     configure_file(config-vc.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-vc.h )
0512 
0513     if(HAVE_VC)
0514         message(STATUS "Vc found!")
0515         set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
0516             "${CMAKE_SOURCE_DIR}/cmake/vc")
0517 
0518         include (VcMacros)
0519 
0520         if(Vc_COMPILER_IS_CLANG)
0521             set(ADDITIONAL_VC_FLAGS "-Wabi -ffp-contract=fast -fPIC")
0522         elseif (NOT MSVC)
0523             set(ADDITIONAL_VC_FLAGS "-Wabi -fabi-version=0 -ffp-contract=fast -fPIC")
0524         endif()
0525 
0526         macro(ko_compile_for_all_implementations_no_scalar _objs _src)
0527             if(PACKAGERS_BUILD)
0528                 vc_compile_for_all_implementations(${_objs} ${_src} FLAGS ${ADDITIONAL_VC_FLAGS} ONLY SSE2 SSSE3 SSE4_1 AVX AVX2+FMA+BMI2)
0529             else()
0530                 set(${_objs} ${_src})
0531             endif()
0532         endmacro()
0533 
0534         macro(ko_compile_for_all_implementations _objs _src)
0535             if(PACKAGERS_BUILD)
0536                 vc_compile_for_all_implementations(${_objs} ${_src} FLAGS ${ADDITIONAL_VC_FLAGS} ONLY Scalar SSE2 SSSE3 SSE4_1 AVX AVX2+FMA+BMI2)
0537             else()
0538                 set(${_objs} ${_src})
0539             endif()
0540         endmacro()
0541 
0542         if (NOT PACKAGERS_BUILD)
0543             # Optimize the whole Calligra for current architecture
0544             set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Vc_DEFINITIONS}")
0545         endif ()
0546     endif()
0547     set(CMAKE_MODULE_PATH ${OLD_CMAKE_MODULE_PATH} )
0548 
0549 else(BUILD_VC)
0550     configure_file(config-vc.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-vc.h )
0551 endif(BUILD_VC)
0552 
0553 if(WIN32)
0554     set(LIB_INSTALL_DIR ${KDE_INSTALL_LIBDIR}
0555         RUNTIME DESTINATION ${KDE_INSTALL_BINDIR}
0556         LIBRARY ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}
0557         ARCHIVE ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} )
0558 endif()
0559 
0560 ##
0561 ## Test for Fontconfig
0562 ##
0563 ## Only test if on non-Windows system
0564 if(NOT WIN32 AND NOT APPLE)
0565     macro_optional_find_package(Fontconfig)
0566     set_package_properties(Fontconfig PROPERTIES
0567         DESCRIPTION "Library for configuring and customizing font access"
0568         URL "http://fontconfig.org"
0569         PURPOSE "Required to handle exact font size"
0570         TYPE RECOMMENDED
0571         )
0572 endif()
0573 
0574 ##
0575 ## Test for Freetype
0576 ##
0577 ## Only test if on non-Windows system
0578 if(NOT WIN32 AND NOT APPLE)
0579     macro_optional_find_package(Freetype)
0580     set_package_properties(Freetype PROPERTIES
0581         DESCRIPTION "A Free, High-Quality, and Portable Font Engine"
0582         URL "http://www.freetype.org/"
0583         PURPOSE "Required to handle exact font size"
0584         TYPE RECOMMENDED
0585         )
0586 endif()
0587 
0588 if(NOT Fontconfig_FOUND OR NOT FREETYPE_FOUND)
0589     set(Fontconfig_INCLUDE_DIRS "")
0590     set(FREETYPE_INCLUDE_DIRS "")
0591 else()
0592     add_definitions( -DSHOULD_BUILD_FONT_CONVERSION )
0593 endif()
0594 
0595 
0596 ##
0597 ## Test endianness
0598 ##
0599 include (TestBigEndian)
0600 test_big_endian(CMAKE_WORDS_BIGENDIAN)
0601 
0602 ##
0603 ## Test SharedMimeInfo
0604 ##
0605 macro_optional_find_package(SharedMimeInfo 1.3)
0606 set_package_properties(SharedMimeInfo PROPERTIES
0607     PURPOSE "Required to determine file types SVM or all of MSOOXML."
0608     TYPE RECOMMENDED
0609     )
0610 
0611 ##
0612 ## Test for Okular
0613 ##
0614 macro_optional_find_package(Okular5 0.99.60 QUIET)
0615 set_package_properties(Okular5 PROPERTIES
0616     DESCRIPTION "A unified document viewer"
0617     URL "https://okular.kde.org/"
0618     PURPOSE "Required to build the plugins for Okular"
0619     TYPE OPTIONAL
0620     )
0621 
0622 ##
0623 ## Test for librevenge
0624 ##
0625 macro_optional_find_package(LibRevenge)
0626 set_package_properties(LibRevenge PROPERTIES
0627     DESCRIPTION "A base library for writing document import filters"
0628     URL "http://sf.net/p/libwpd/librevenge/"
0629     PURPOSE "Required by various import filters"
0630     TYPE OPTIONAL
0631     )
0632 
0633 ##
0634 ## Test for libodfgen
0635 ##
0636 macro_optional_find_package(LibOdfGen)
0637 set_package_properties(LibOdfGen PROPERTIES
0638     DESCRIPTION "Open Document Format Generation Library"
0639     URL "http://sf.net/p/libwpd/libodfgen/"
0640     PURPOSE "Required by various import filters"
0641     TYPE OPTIONAL
0642     )
0643 
0644 ##
0645 ## Test for WordPerfect Document Library
0646 ##
0647 macro_optional_find_package(LibWpd)
0648 set_package_properties(LibWpd PROPERTIES
0649     DESCRIPTION "WordPerfect Document Library"
0650     URL "http://libwpd.sourceforge.net/"
0651     PURPOSE "Required by the Words WPD import filter"
0652     TYPE OPTIONAL
0653     )
0654 
0655 ##
0656 ## Test for WordPerfect Graphics Library
0657 ##
0658 macro_optional_find_package(LibWpg)
0659 set_package_properties(LibWpg PROPERTIES
0660     DESCRIPTION "WordPerfect Graphics Library"
0661     URL "http://libwpg.sourceforge.net/"
0662     PURPOSE "Required by the Karbon WPG import filter"
0663     TYPE OPTIONAL
0664     )
0665 
0666 ##
0667 ## Test for Microsoft Works Document Library
0668 ##
0669 macro_optional_find_package(LibWps)
0670 set_package_properties(LibWps PROPERTIES
0671     DESCRIPTION "Microsoft Works Document Library"
0672     URL "http://libwps.sourceforge.net/"
0673     PURPOSE "Required by the Words WPS import filter"
0674     TYPE OPTIONAL
0675     )
0676 
0677 ##
0678 ## Test for Microsoft Visio Document Library
0679 ##
0680 macro_optional_find_package(LibVisio)
0681 set_package_properties(LibVisio PROPERTIES
0682     DESCRIPTION "Visio Import Filter Library"
0683     URL "https://wiki.documentfoundation.org/DLP/Libraries/libvisio"
0684     PURPOSE "Required by the visio import filter"
0685     TYPE OPTIONAL
0686     )
0687 
0688 ##
0689 ## Test for Apple Keynote Document Library
0690 ##
0691 macro_optional_find_package(LibEtonyek)
0692 set_package_properties(LibEtonyek PROPERTIES
0693     DESCRIPTION "Apple Keynote Document Library"
0694     URL "https://wiki.documentfoundation.org/DLP/Libraries/libetonyek"
0695     PURPOSE "Required by the Stage keynote import filter"
0696     TYPE OPTIONAL
0697     )
0698 
0699 ##
0700 ## Test for qt-poppler
0701 ##
0702 macro_optional_find_package(Poppler 0.83.0 COMPONENTS Qt5)
0703 set_package_properties(Poppler PROPERTIES
0704     DESCRIPTION "A PDF rendering library"
0705     URL "http://poppler.freedesktop.org"
0706     PURPOSE "Required by the Karbon PDF import filter and CSTester PDF feature"
0707     TYPE OPTIONAL
0708     )
0709 
0710 ##
0711 ## Test for qt-poppler not-officially-supported XPDF Headers
0712 ## Installing these is off by default in poppler sources, so lets make
0713 ## sure they're really there before trying to build the pdf import
0714 ##
0715 macro_optional_find_package(PopplerXPDFHeaders)
0716 set_package_properties(PopplerXPDFHeaders PROPERTIES
0717     DESCRIPTION "XPDF headers in the Poppler Qt5 interface library"
0718     URL "http://poppler.freedesktop.org"
0719     PURPOSE "Required by the Karbon PDF import filter"
0720     TYPE OPTIONAL
0721     )
0722 
0723 
0724 ##
0725 ## Test for libgit2
0726 ##
0727 macro_optional_find_package(Libgit2)
0728 
0729 ##
0730 ## Generate a file for prefix information
0731 ##
0732 
0733 ###############################
0734 ################################
0735 ## Add Calligra helper macros ##
0736 ################################
0737 ###############################
0738 
0739 include(MacroCalligraAddBenchmark)
0740 
0741 ####################
0742 #####################
0743 ## Define includes ##
0744 #####################
0745 ####################
0746 
0747 # WARNING: make sure that QT_INCLUDES is the first directory to be added to include_directory before
0748 #          any other include directory
0749 
0750 # for config.h and <toplevel/foo.h> includes (if any?)
0751 include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/interfaces )
0752 
0753 
0754 set(KOVERSION_INCLUDES ${CMAKE_SOURCE_DIR}/libs/version 
0755     ${CMAKE_BINARY_DIR}/libs/version
0756     )
0757 
0758 include_directories(${KOVERSION_INCLUDES})
0759 
0760 # koplugin is at the bottom of the stack
0761 set(KOPLUGIN_INCLUDES ${CMAKE_SOURCE_DIR}/libs/plugin)
0762 
0763 set(KUNDO2_INCLUDES ${CMAKE_SOURCE_DIR}/libs/kundo2
0764     ${CMAKE_BINARY_DIR}/libs/kundo2)
0765 
0766 # koodf is at the bottom of the stack
0767 set(KOODF_INCLUDES ${CMAKE_SOURCE_DIR}/libs/odf
0768     ${CMAKE_SOURCE_DIR}/libs/store
0769     ${CMAKE_BINARY_DIR}/libs/odf
0770     ${CMAKE_BINARY_DIR}/libs/store
0771     ${KOVERSION_INCLUDES}
0772     )
0773 
0774 # pigment depends on koplugin and lcms
0775 set(PIGMENT_INCLUDES ${KOPLUGIN_INCLUDES}
0776     ${KOVERSION_INCLUDES}
0777     ${CMAKE_SOURCE_DIR}/libs/pigment
0778     ${CMAKE_BINARY_DIR}/libs/pigment
0779     ${CMAKE_SOURCE_DIR}/libs/pigment/compositeops
0780     ${CMAKE_SOURCE_DIR}/libs/pigment/resources
0781     ${Boost_INCLUDE_DIRS}
0782 
0783     )
0784 
0785 # flake depends on koodf and pigment
0786 set(FLAKE_INCLUDES ${CMAKE_SOURCE_DIR}/libs/flake
0787     ${KOODF_INCLUDES}
0788     ${PIGMENT_INCLUDES}
0789     ${KUNDO2_INCLUDES}
0790     ${CMAKE_SOURCE_DIR}/libs/widgetutils
0791     ${CMAKE_SOURCE_DIR}/libs/flake/commands
0792     ${CMAKE_SOURCE_DIR}/libs/flake/tools
0793     ${CMAKE_SOURCE_DIR}/libs/flake/svg
0794     ${CMAKE_BINARY_DIR}/libs/flake)
0795 
0796 # vectorimage
0797 set(VECTORIMAGE_INCLUDES
0798     ${CMAKE_SOURCE_DIR}/libs/vectorimage
0799     ${CMAKE_SOURCE_DIR}/libs/vectorimage/libemf
0800     ${CMAKE_SOURCE_DIR}/libs/vectorimage/libsvm
0801     ${CMAKE_SOURCE_DIR}/libs/vectorimage/libwmf)
0802 
0803 # KoText depends on koplugin, odf
0804 set(KOTEXT_INCLUDES
0805     ${CMAKE_SOURCE_DIR}/libs/text
0806     ${CMAKE_BINARY_DIR}/libs/text
0807     ${CMAKE_SOURCE_DIR}/libs/text/changetracker
0808     ${CMAKE_SOURCE_DIR}/libs/text/styles
0809     ${CMAKE_SOURCE_DIR}/libs/text/opendocument
0810     ${SOPRANO_INCLUDE_DIR}
0811     ${FLAKE_INCLUDES}
0812     ${KOODF_INCLUDES})
0813 
0814 # TextLayout depends on kotext
0815 set(TEXTLAYOUT_INCLUDES ${KOTEXT_INCLUDES}
0816     ${CMAKE_SOURCE_DIR}/libs/textlayout
0817     ${CMAKE_BINARY_DIR}/libs/textlayout)
0818 
0819 # Widgets depends on kotext and flake
0820 set(KOWIDGETS_INCLUDES ${KOTEXT_INCLUDES}
0821     ${CMAKE_SOURCE_DIR}/libs/widgetutils
0822     ${CMAKE_BINARY_DIR}/libs/widgetutils
0823     ${CMAKE_SOURCE_DIR}/libs/widgets
0824     ${CMAKE_BINARY_DIR}/libs/widgets)
0825 
0826 # BasicFlakes depends on flake, widgets
0827 set(BASICFLAKES_INCLUDES ${KOWIDGETS_INCLUDES}
0828     ${CMAKE_SOURCE_DIR}/libs/basicflakes
0829     ${CMAKE_SOURCE_DIR}/libs/basicflakes/tools)
0830 
0831 
0832 # komain depends on kotext & flake
0833 set(KOMAIN_INCLUDES 
0834     ${KOWIDGETS_INCLUDES}
0835     ${TEXTLAYOUT_INCLUDES}
0836     ${CMAKE_SOURCE_DIR}/libs/main
0837     ${CMAKE_BINARY_DIR}/libs/main
0838     ${CMAKE_SOURCE_DIR}/libs/main/config)
0839 
0840 set(KORDF_INCLUDES ${KOMAIN_INCLUDES}
0841     ${CMAKE_SOURCE_DIR}/libs/rdf
0842     )
0843 set(KORDF_LIBS kordf)
0844 
0845 if(SHOULD_BUILD_FEATURE_SCRIPTING)
0846     set(KOKROSS_INCLUDES
0847         ${CMAKE_SOURCE_DIR}/libs/kross
0848         ${CMAKE_BINARY_DIR}/libs/kross)
0849 endif()
0850 
0851 # kopageapp
0852 set(KOPAGEAPP_INCLUDES ${TEXTLAYOUT_INCLUDES}
0853     ${PIGMENT_INCLUDES}
0854     ${KOMAIN_INCLUDES}
0855     ${CMAKE_SOURCE_DIR}/libs/widgets
0856     ${CMAKE_SOURCE_DIR}/libs/pageapp
0857     ${CMAKE_SOURCE_DIR}/libs/pageapp/commands
0858     ${CMAKE_BINARY_DIR}/libs/pageapp )
0859 
0860 #############################################
0861 ####           filter libraries          ####
0862 #############################################
0863 
0864 # libodf2
0865 set(KOODF2_INCLUDES
0866     ${CMAKE_SOURCE_DIR}/filters/libodf2
0867     ${CMAKE_SOURCE_DIR}/filters/libodf2/chart
0868     )
0869 
0870 # libodfreader
0871 set(KOODFREADER_INCLUDES
0872     ${CMAKE_SOURCE_DIR}/filters/libodfreader
0873     )
0874 
0875 ###################################################
0876 ####################################################
0877 ## Detect which products/features can be compiled ##
0878 ####################################################
0879 ###################################################
0880 
0881 if (NOT WIN32)
0882     set(NOT_WIN TRUE)
0883 endif()
0884 if (NOT QT_MAC_USE_COCOA)
0885     set(NOT_COCOA TRUE)
0886 endif()
0887 if (KReport_FOUND AND KREPORT_SCRIPTING)
0888     set(KReport_WithScripting_FOUND TRUE)
0889 endif()
0890 
0891 calligra_drop_product_on_bad_condition( FEATURE_RDF
0892     Soprano_FOUND "Soprano not found"
0893     )
0894 
0895 calligra_drop_product_on_bad_condition( FEATURE_SCRIPTING
0896     KF5Kross_FOUND "KF5Kross not found"
0897     )
0898 
0899 calligra_drop_product_on_bad_condition( PART_SHEETS
0900     EIGEN3_FOUND "Eigen devel not found"
0901     )
0902 
0903 calligra_drop_product_on_bad_condition( OKULAR_GENERATOR_ODP
0904     Okular5_FOUND "Okular devel not found"
0905     )
0906 
0907 calligra_drop_product_on_bad_condition( OKULAR_GENERATOR_ODT
0908     Okular5_FOUND "Okular devel not found"
0909     )
0910 
0911 calligra_drop_product_on_bad_condition( PLUGIN_CHARTSHAPE
0912     KChart_FOUND "KChart devel not found"
0913     )
0914 
0915 calligra_drop_product_on_bad_condition( PLUGIN_VIDEOSHAPE
0916     Phonon4Qt5_FOUND "Phonon4Qt5 devel not found"
0917     )
0918 
0919 calligra_drop_product_on_bad_condition( FILTER_KEY_TO_ODP
0920     LIBODFGEN_FOUND "libodfgen devel not found"
0921     LIBETONYEK_FOUND "libetonyek devel not found"
0922     LIBREVENGE_FOUND "librevenge devel not found"
0923     )
0924 
0925 calligra_drop_product_on_bad_condition( FILTER_VISIO_TO_ODG
0926     LIBODFGEN_FOUND "libodfgen devel not found"
0927     LIBVISIO_FOUND "libvisio devel not found"
0928     LIBREVENGE_FOUND "librevenge devel not found"
0929     )
0930 
0931 calligra_drop_product_on_bad_condition( FILTER_WORDPERFECT_TO_ODT
0932     LIBODFGEN_FOUND "libodfgen devel not found"
0933     LIBWPD_FOUND "libwpd devel not found"
0934     LIBWPG_FOUND "libwpg devel not found"
0935     LIBREVENGE_FOUND "librevenge devel not found"
0936     )
0937 
0938 calligra_drop_product_on_bad_condition( FILTER_WORKS_TO_ODT
0939     LIBODFGEN_FOUND "libodfgen devel not found"
0940     LIBWPS_FOUND "libwps devel not found"
0941     LIBREVENGE_FOUND "librevenge devel not found"
0942     )
0943 
0944 calligra_drop_product_on_bad_condition( FILTER_WPG_TO_SVG
0945     LIBWPG_FOUND "libwpg devel not found"
0946     LIBREVENGE_FOUND "librevenge devel not found"
0947     )
0948 
0949 calligra_drop_product_on_bad_condition( FILTER_WPG_TO_ODG
0950     LIBODFGEN_FOUND "libodfgen devel not found"
0951     LIBWPG_FOUND "libwpg devel not found"
0952     LIBREVENGE_FOUND "librevenge devel not found"
0953     )
0954 
0955 calligra_drop_product_on_bad_condition( FILTER_PDF_TO_SVG
0956     NOT_WIN "not supported on Windows"
0957     PopplerXPDFHeaders_FOUND "poppler xpdf headers not found"
0958     Poppler_FOUND "poppler qt5 headers not found"
0959     )
0960 
0961 calligra_drop_product_on_bad_condition( FILTER_HTML_TO_ODS
0962     NOT_WIN "not supported on Windows"
0963     NOT_COCOA "not supported with Qt Cocoa"
0964     )
0965 
0966 calligra_drop_product_on_bad_condition( FILTER_SHEETS_TO_HTML
0967     NOT_WIN "not supported on Windows"
0968     NOT_COCOA "not supported with Qt Cocoa"
0969     )
0970 
0971 calligra_drop_product_on_bad_condition( FILTER_KSPREAD_TO_LATEX
0972     NOT_WIN "not supported on Windows"
0973     NOT_COCOA "not supported with Qt Cocoa"
0974     )
0975 
0976 calligra_drop_product_on_bad_condition( APP_BRAINDUMP
0977     NOT_WIN "unmaintained on Windows"
0978     Qt5WebKitWidgets_FOUND "QWebPage needed for webpage plugin"
0979     )
0980 
0981 calligra_drop_product_on_bad_condition( PLUGIN_CALLIGRAGEMINI_GIT
0982     LIBGIT2_FOUND  "libgit2 devel not found"
0983     )
0984 
0985 calligra_drop_product_on_bad_condition( PART_QTQUICK
0986     Qt5OpenGL_FOUND "Qt OpenGL not found"
0987     Qt5Declarative_FOUND "QtDeclarative not found"
0988     )
0989 
0990 calligra_drop_product_on_bad_condition( PART_COMPONENTS
0991     Qt5Quick_FOUND "QtQuick not found"
0992     )
0993 
0994 calligra_drop_product_on_bad_condition( APP_SLIDECOMPARE
0995     Qt5OpenGL_FOUND "Qt OpenGL not found"
0996     )
0997 
0998 if (Qt5QuickWidgets_FOUND AND Qt5QuickWidgets_VERSION_STRING VERSION_LESS "5.15.0")
0999   calligra_disable_product(GEMINI "Gemini depends on Qt 5.15")
1000 endif ()
1001 
1002 
1003 #############################################
1004 ####  Backward compatibility BUILD_x=off ####
1005 #############################################
1006 
1007 # workaround: disable directly all products which might be activated by internal
1008 # dependencies, but belong to scope of old flag
1009 calligra_drop_products_on_old_flag(braindump APP_BRAINDUMP)
1010 calligra_drop_products_on_old_flag(karbon APP_KARBON)
1011 calligra_drop_products_on_old_flag(sheets PART_SHEETS APP_SHEETS)
1012 calligra_drop_products_on_old_flag(stage  PART_STAGE APP_STAGE)
1013 calligra_drop_products_on_old_flag(words  PART_WORDS APP_WORDS)
1014 
1015 #############################################
1016 ####      Temporarily broken products    ####
1017 #############################################
1018 
1019 # If a product does not build due to some temporary brokenness disable it here,
1020 # by calling calligra_disable_product with the product id and the reason,
1021 # e.g.:
1022 # calligra_disable_product(APP_FOO "isn't buildable at the moment")
1023 
1024 calligra_disable_product(APP_BRAINDUMP "Disabled, will (probably) be removed from Calligra")
1025 
1026 #############################################
1027 ####     Calculate buildable products    ####
1028 #############################################
1029 
1030 calligra_drop_unbuildable_products()
1031 
1032 
1033 #############################################
1034 ####     Setup product-depending vars    ####
1035 #############################################
1036 
1037 if(SHOULD_BUILD_FEATURE_RDF)
1038     add_definitions( -DSHOULD_BUILD_RDF )
1039 endif()
1040 
1041 ###################
1042 ####################
1043 ## Subdirectories ##
1044 ####################
1045 ###################
1046 
1047 add_subdirectory(words)
1048 
1049 add_subdirectory(stage)
1050 
1051 add_subdirectory(sheets)
1052 
1053 if(SHOULD_BUILD_APP_KARBON)
1054     add_subdirectory(karbon)
1055 endif()
1056 
1057 if(SHOULD_BUILD_APP_BRAINDUMP)
1058     add_subdirectory(braindump)
1059 endif()
1060 
1061 if(SHOULD_BUILD_DOC)
1062     add_subdirectory(doc)
1063 endif()
1064 
1065 if(SHOULD_BUILD_PART_QTQUICK)
1066     add_subdirectory(qtquick)
1067 endif()
1068 
1069 if(SHOULD_BUILD_PART_COMPONENTS)
1070     add_subdirectory(components)
1071 endif()
1072 
1073 if(SHOULD_BUILD_GEMINI)
1074     add_subdirectory(gemini)
1075 endif()
1076 
1077 # non-app directories are moved here because they can depend on SHOULD_BUILD_{appname} variables set above
1078 add_subdirectory(libs)
1079 add_subdirectory(interfaces)
1080 add_subdirectory(pics)
1081 add_subdirectory(plugins)
1082 add_subdirectory(servicetypes)
1083 add_subdirectory(devtools)
1084 add_subdirectory(extras)
1085 add_subdirectory(filters)
1086 add_subdirectory(data)
1087 
1088 feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
1089 
1090 calligra_product_deps_report("product_deps")
1091 calligra_log_should_build()
1092 
1093 add_custom_target(apidox doc/api/gendocs.pl WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
1094 
1095 configure_file(KoConfig.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/KoConfig.h )
1096 if (SHOULD_BUILD_DEVEL_HEADERS)
1097     install( FILES  ${CMAKE_CURRENT_BINARY_DIR}/KoConfig.h DESTINATION ${KDE_INSTALL_INCLUDEDIR}/calligra COMPONENT Devel)
1098 endif()
1099 
1100 if (BUILD_TESTING)
1101     add_subdirectory(tests)
1102 endif(BUILD_TESTING)
1103 
1104 ki18n_install(po)
1105 if(KF5DocTools_FOUND)
1106     kdoctools_install(po)
1107 endif()
1108