Warning, /education/labplot/CMakeLists.txt is written in an unsupported language. File is not indexed.

0001 project(labplot2)
0002 
0003 cmake_minimum_required (VERSION 3.16.0 FATAL_ERROR)
0004 set(CMAKE_C_STANDARD 99)
0005 set(CMAKE_C_STANDARD_REQUIRED ON)
0006 set(CMAKE_C_EXTENSIONS OFF)
0007 set(CMAKE_CXX_STANDARD 11)
0008 set(CMAKE_CXX_STANDARD_REQUIRED ON)
0009 set(CMAKE_CXX_EXTENSIONS OFF)
0010 
0011 set(QT_MINIMUM_VERSION 5.6.0)
0012 set(KF5_MIN_VERSION "5.16.0")
0013 set(APPLE_SUPPRESS_X11_WARNING ON)
0014 
0015 find_package(ECM REQUIRED NO_MODULE)
0016 set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/ ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
0017 
0018 include(KDEInstallDirs)
0019 include(KDECMakeSettings)
0020 include(KDECompilerSettings NO_POLICY_SCOPE)
0021 
0022 include(ECMInstallIcons)
0023 include(ECMSetupVersion)
0024 include(ECMAddAppIcon)
0025 #include(KDEClangFormat)
0026 #include(GenerateExportHeader)
0027 include(FeatureSummary)
0028 
0029 # build type: "release", "debug", "debugfull"
0030 string (TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE)
0031 find_package(Qt5 ${QT_MIN_VERSION} NO_MODULE REQUIRED COMPONENTS
0032         Concurrent
0033         Gui
0034 #       Qml
0035 #       Quick
0036 #       QuickWidgets
0037         PrintSupport
0038         Sql
0039         Svg
0040         Widgets
0041         Test
0042 )
0043 
0044 find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
0045         Archive
0046         Completion
0047         Config
0048         ConfigWidgets
0049         CoreAddons
0050         Crash
0051         DocTools
0052         I18n
0053         IconThemes
0054         KIO
0055         TextWidgets
0056         WidgetsAddons
0057         XmlGui
0058         NewStuffCore
0059         NewStuff
0060 OPTIONAL_COMPONENTS
0061         Service
0062         Parts
0063         SyntaxHighlighting
0064 )
0065 # TODO: make NewStuff optional?
0066 IF (KF5NewStuff_FOUND)
0067         add_definitions (-DHAVE_KF5_NEW_STUFF)
0068 ELSE ()
0069         MESSAGE (STATUS "KF5 new stuff not found")
0070 ENDIF ()
0071 # TODO: service not used?
0072 IF (NOT KF5Service_FOUND)
0073         MESSAGE (STATUS "KF5 service not found")
0074 ENDIF ()
0075 # TODO: parts not used?
0076 IF (NOT KF5Parts_FOUND)
0077         MESSAGE (STATUS "KF5 parts not found")
0078 ENDIF ()
0079 IF (KF5SyntaxHighlighting_FOUND)
0080         add_definitions (-DHAVE_KF5_SYNTAX_HIGHLIGHTING)
0081 ELSE ()
0082         MESSAGE (STATUS "KF5 syntax highlighting not found")
0083 ENDIF ()
0084 
0085 find_package(KUserFeedback)
0086 IF (KUserFeedback_FOUND)
0087         MESSAGE (STATUS "Found KUserFeedback")
0088         add_definitions (-DHAVE_KUSERFEEDBACK)
0089 ELSE ()
0090         MESSAGE (STATUS "KUserFeedback not found")
0091 ENDIF ()
0092 
0093 find_package(BISON REQUIRED)
0094 
0095 ### compiler flags ######################################
0096 set (GENERIC_FLAGS "-Wall -Wextra -Wundef -Wpointer-arith -Wunreachable-code -Wunused -Wdeprecated-declarations -fno-omit-frame-pointer -fstack-protector")
0097 set (GENERIC_GNU_FLAGS "-O2 -Wcast-align -Wswitch-enum -fvisibility=default -pedantic")
0098 set (GENERIC_C_FLAGS "${GENERIC_FLAGS} -fno-exceptions")
0099 # liborigin needs exceptions
0100 set (GENERIC_CXX_FLAGS "${GENERIC_FLAGS} -fexceptions -std=c++11")
0101 
0102 if ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU")
0103         message(STATUS "GNU C compiler ${CMAKE_C_COMPILER_VERSION} detected, adding compile flags")
0104         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GENERIC_C_FLAGS} ${GENERIC_GNU_FLAGS}")
0105         if (CMAKE_C_COMPILER_VERSION VERSION_GREATER 10.99 AND CMAKE_C_COMPILER_VERSION VERSION_LESS 12)        # GCC 11 fails building readstat 1.1.8
0106                 message(STATUS "Building ReadStat disabled due to GNU C compiler version 11")
0107                 set(DONT_BUILD_READSTAT TRUE)
0108         endif ()
0109 elseif ("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
0110         message(STATUS "Clang C compiler ${CMAKE_C_COMPILER_VERSION} detected, adding compile flags")
0111         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE ${GENERIC_C_FLAGS} ${GENERIC_GNU_FLAGS}")
0112 elseif ("${CMAKE_C_COMPILER_ID}" MATCHES "Intel")
0113         message(STATUS "Intel C compiler detected, adding compile flags")
0114         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE -O3 ${GENERIC_C_FLAGS}")
0115 elseif ("${CMAKE_C_COMPILER_ID}" MATCHES "PGI")
0116         message(STATUS "PGI C compiler detected, adding compile flags")
0117         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE -O3 -D__GCC_ATOMIC_TEST_AND_SET_TRUEVAL=1 -Minform=inform -Mbounds -Mchkstk")
0118 # " x" postfix to work around a bug in CMake that causes "MSVC" to translate to something completely different
0119 elseif (("${CMAKE_C_COMPILER_ID} x" MATCHES "MSVC") OR MSVC)
0120         message(STATUS "MSVC C compiler detected, adding compile flags")
0121         if (CMAKE_BUILD_TYPE STREQUAL Debug)
0122                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Od -W3")
0123         else ()
0124                 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -W3")
0125         endif ()
0126         set(MSVC_FOUND TRUE)
0127 else ()
0128         message(STATUS "UNKNOWN C compiler, adding compile flags")
0129         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GENERIC_C_FLAGS}")
0130 endif()
0131 
0132 if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
0133         message(STATUS "GNU C++ compiler ${CMAKE_CXX_COMPILER_VERSION} detected, adding compile flags")
0134         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GENERIC_CXX_FLAGS} ${GENERIC_GNU_FLAGS} -Wzero-as-null-pointer-constant") # -Wzero-as-null-pointer-constant since version 5
0135 elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
0136         message(STATUS "Clang C++ compiler ${CMAKE_CXX_COMPILER_VERSION} detected, adding compile flags")
0137         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GNU_SOURCE ${GENERIC_CXX_FLAGS} ${GENERIC_GNU_FLAGS} -Wzero-as-null-pointer-constant") # -Wzero-as-null-pointer-constant since version 5
0138 elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel")
0139         message(STATUS "Intel C++ compiler detected, adding compile flags")
0140         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GNU_SOURCE ${GENERIC_CXX_FLAGS}")
0141         #-std=c++0x comes with cmake's general flags, deprecated in icc, remove it
0142         string(REPLACE "-std=c++0x" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
0143 elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "PGI")
0144         message(STATUS "PGI C++ compiler detected, adding compile flags")
0145         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GNU_SOURCE -O3 -D__GCC_ATOMIC_TEST_AND_SET_TRUEVAL=1 -Minform=inform -Mbounds -Mchkstk")
0146 # " x" postfix to work around a bug in CMake that causes "MSVC" to translate to something completely different
0147 elseif (("${CMAKE_CXX_COMPILER_ID} x" MATCHES "MSVC") OR MSVC)
0148         message(STATUS "MSVC C++ compiler detected, adding compile flags")
0149         # -D_ALLOW_KEYWORD_MACROS for "#define private public" in MultiRangeTest.cpp
0150         if(CMAKE_BUILD_TYPE STREQUAL Debug)
0151                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Od -W3 -DPSAPI_VERSION=1")
0152         else()
0153                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -W3 -DPSAPI_VERSION=1")
0154         endif()
0155         set(MSVC_FOUND TRUE)
0156 else ()
0157         message(STATUS "UNKNOWN C++ compiler, adding compile flags")
0158         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GENERIC_CXX_FLAGS}")
0159 endif ()
0160 
0161 ##########################################################
0162 
0163 add_definitions(
0164     -DQT_NO_CAST_TO_ASCII
0165 # TODO: enable and fix problems
0166 #    -DQT_NO_CAST_FROM_ASCII
0167 #    -DQT_NO_CAST_FROM_BYTEARRAY
0168     -DQT_NO_URL_CAST_FROM_STRING
0169     -DQT_USE_QSTRINGBUILDER
0170     -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT
0171     -DQT_NO_SIGNALS_SLOTS_KEYWORDS
0172     -DQT_DEPRECATED_WARNINGS_SINCE=0x060000
0173     -DKF_DEPRECATED_WARNINGS_SINCE=0x060000
0174 )
0175 if (NOT WIN32)
0176     # Strict iterators can't be used on Windows, they lead to a link error
0177     # when application code iterates over a QVector<QPoint> for instance, unless
0178     # Qt itself was also built with strict iterators.
0179     # See example at https://bugreports.qt.io/browse/AUTOSUITE-946
0180     add_definitions(-DQT_STRICT_ITERATORS)
0181 endif()
0182 
0183 include_directories (${QDBUS_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
0184 set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
0185 add_definitions (-DLVERSION=\"2.9.0\")
0186 add_definitions (-DCXX_COMPILER=\"${CMAKE_CXX_COMPILER_ID}\ ${CMAKE_CXX_COMPILER_VERSION}\")
0187 add_definitions (-DCXX_COMPILER_FLAGS=\"${CMAKE_CXX_FLAGS}\")
0188 set(BUILD_SHARED_LIBS true)
0189 
0190 #cmake_policy(SET CMP0002 OLD)
0191 IF (CMAKE_VERSION VERSION_EQUAL "3.3" OR CMAKE_VERSION VERSION_GREATER "3.3")
0192         cmake_policy(SET CMP0063 NEW)
0193 ENDIF()
0194 
0195 if (CMAKE_VERSION VERSION_GREATER "3.5")
0196   set(ENABLE_CLANG_TIDY OFF CACHE BOOL "Add clang-tidy automatically to builds")
0197   if (ENABLE_CLANG_TIDY)
0198     find_program (CLANG_TIDY_EXE NAMES "clang-tidy" PATHS /usr/bin)
0199     if (CLANG_TIDY_EXE)
0200       message(STATUS "Clang-tidy supported, found and enabled: ${CLANG_TIDY_EXE}")
0201       set(CLANG_TIDY_CHECKS "modernize-*,-modernize-use-trailing-return-type,clang-analyzer-*,-clang-analyzer-cplusplus*")
0202       #set(CLANG_TIDY_CHECKS "-*,modernize-*,clang-analyzer-*")
0203       # -extra-arg=--std=c++11
0204       set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-checks=${CLANG_TIDY_CHECKS};-header-filter='${CMAKE_SOURCE_DIR}/*'"
0205         CACHE STRING "" FORCE)
0206     else()
0207       message(AUTHOR_WARNING "clang-tidy not found!")
0208       set(CMAKE_CXX_CLANG_TIDY "" CACHE STRING "" FORCE) # delete it
0209     endif()
0210    else()
0211     message(STATUS "Clang-tidy supported but disabled")
0212   endif()
0213 endif()
0214 
0215 # get git commit hash
0216 execute_process(
0217   COMMAND git describe --always --tags
0218   WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
0219   OUTPUT_VARIABLE GIT_COMMIT
0220   OUTPUT_STRIP_TRAILING_WHITESPACE
0221 )
0222 add_definitions (-DGIT_COMMIT=\"${GIT_COMMIT}\")
0223 
0224 
0225 ### Options ######################################
0226 option(ENABLE_CANTOR "Build with Cantor support" ON)
0227 option(ENABLE_FFTW "Build with FFTW support" ON)
0228 option(ENABLE_HDF5 "Build with HDF5 support" ON)
0229 option(ENABLE_NETCDF "Build with NetCDF support" ON)
0230 option(ENABLE_FITS "Build with FITS support" ON)
0231 option(ENABLE_LIBCERF "Build with libcerf support" ON)
0232 option(ENABLE_LIBORIGIN "Build with liborigin support" ON)
0233 option(ENABLE_ROOT "Build with ROOT (CERN) support" ON)
0234 option(ENABLE_READSTAT "Build with ReadStat support" ON)
0235 option(ENABLE_MATIO "Build with Matio support" ON)
0236 option(ENABLE_TESTS "Build with tests" ON)
0237 option(ENABLE_MQTT "Build with MQTT support" ON)
0238 option(ENABLE_QTSERIALPORT "Build with QtSerialPort support" ON)
0239 option(ENABLE_DISCOUNT "Build with Discount support" ON)
0240 option(ENABLE_REPRODUCIBLE "Enable reproducible builds" OFF)
0241 option(ENABLE_EXCEL "Build with Excel (xlsx) support" ON)
0242 IF (APPLE)
0243         option(ENABLE_TOUCHBAR "Enable touch bar support on macOS" ON)
0244 ENDIF ()
0245 
0246 ### OS macros ####################################
0247 IF (WIN32)
0248         add_definitions (-DHAVE_WINDOWS)
0249         find_library (PSAPI Psapi)
0250         message (STATUS "PSAPI: ${PSAPI}")
0251 ENDIF ()
0252 
0253 ### GSL (required) ###############################
0254 FIND_PACKAGE(GSL REQUIRED)
0255 
0256 FIND_PACKAGE(Poppler "0.62.0" COMPONENTS Qt5)
0257 IF (Poppler_FOUND)
0258         include_directories(${Poppler_INCLUDE_DIRS})
0259         # MESSAGE (STATUS "Poppler libraries: ${Poppler_LIBRARIES}")
0260         add_definitions (-DHAVE_POPPLER)
0261 ENDIF ()
0262 
0263 ### liborigin (included) ###############################
0264 IF (ENABLE_LIBORIGIN)
0265         FIND_PACKAGE (LibOrigin)
0266         IF (NOT LIBORIGIN_FOUND)        # use own version
0267                 IF (CMAKE_BUILD_TYPE STREQUAL "debug" OR CMAKE_BUILD_TYPE STREQUAL "debugfull")
0268                         MESSAGE (STATUS "Origin project import (through internal liborigin) enabled (parser logging enabled)")
0269                         SET (ENABLE_ORIGIN_PARSER_LOG TRUE)
0270                 ELSE ()
0271                         MESSAGE (STATUS "Origin project import (through internal liborigin) enabled (parser logging disabled)")
0272                 ENDIF ()
0273         ENDIF ()
0274 
0275         add_definitions (-DHAVE_LIBORIGIN)
0276 ELSE ()
0277         MESSAGE (STATUS "Origin project import DISABLED")
0278 ENDIF ()
0279 
0280 ### Cantorlibs (optional) ###############################
0281 IF (ENABLE_CANTOR)
0282         FIND_PACKAGE (Cantor)
0283 
0284         IF (Cantor_FOUND)
0285                 MESSAGE (STATUS "Found Cantor Library ${Cantor_VERSION}")
0286 
0287                 IF (${Cantor_VERSION} VERSION_GREATER "19.11")
0288                         add_definitions (-DHAVE_CANTOR_LIBS)
0289                         set(RECENT_CANTOR TRUE)
0290                 ELSE ()
0291                         MESSAGE (STATUS "Cantor Library ${Cantor_VERSION} TOO OLD. Minimum usable version is 19.12")
0292                 ENDIF ()
0293                 IF (${Cantor_VERSION} VERSION_GREATER "20.08.9")
0294                         add_definitions (-DHAVE_NEW_CANTOR_LIBS)
0295                 ENDIF ()
0296         ELSE ()
0297                 MESSAGE (STATUS "Cantor Library NOT FOUND")
0298         ENDIF ()
0299         ELSE ()
0300                 MESSAGE (STATUS "Cantor Library DISABLED")
0301 ENDIF ()
0302 
0303 ### FFTW (optional) #####################################
0304 IF (ENABLE_FFTW)
0305         FIND_PACKAGE (FFTW3)
0306         IF (FFTW3_FOUND)
0307                 add_definitions (-DHAVE_FFTW3)
0308         ELSE ()
0309                 MESSAGE (STATUS "FFTW 3 Library NOT FOUND")
0310         ENDIF ()
0311 ELSE ()
0312         MESSAGE (STATUS "FFTW 3 Library DISABLED")
0313 ENDIF ()
0314 
0315 ### HDF5 (optional) ##############################
0316 IF (ENABLE_HDF5)
0317 FIND_PACKAGE(HDF5 COMPONENTS C)
0318 SET_PACKAGE_PROPERTIES (HDF5 PROPERTIES
0319         DESCRIPTION "Reading and writing self describing array data"
0320         URL "https://www.hdfgroup.org/solutions/hdf5/"
0321 )
0322 IF (HDF5_FOUND)
0323         add_definitions (-DHAVE_HDF5)
0324         IF (MSVC_FOUND)
0325                 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DH5_BUILT_AS_DYNAMIC_LIB")
0326         ENDIF ()
0327         IF (HDF5_VERSION VERSION_GREATER "1.9")
0328                 add_definitions (-DHAVE_AT_LEAST_HDF5_1_10_0)
0329         ENDIF ()
0330         IF (HDF5_VERSION VERSION_GREATER "1.10.0.1")
0331                 add_definitions (-DHAVE_AT_LEAST_HDF5_1_10_0)
0332                 add_definitions (-DHAVE_AT_LEAST_HDF5_1_10_1)
0333         ENDIF ()
0334         include_directories (${HDF5_INCLUDE_DIRS})
0335 ELSE ()
0336         MESSAGE (STATUS "Hierarchical Data Format (HDF5) Library NOT FOUND")
0337         SET(HDF5_LIBRARIES "")
0338 ENDIF ()
0339 ELSE ()
0340         MESSAGE (STATUS "Hierarchical Data Format (HDF5) Library DISABLED")
0341 ENDIF ()
0342 
0343 ### NETCDF (optional) #############################
0344 IF (ENABLE_NETCDF)
0345         FIND_PACKAGE(netCDF)
0346         SET_PACKAGE_PROPERTIES(netCDF PROPERTIES
0347             DESCRIPTION "Interfaces for array-oriented data access"
0348             URL "https://www.unidata.ucar.edu/software/netcdf/"
0349         )
0350         IF (netCDF_FOUND)
0351                 add_definitions (-DHAVE_NETCDF)
0352                 # netCDF on Windows may link to zip.dll
0353                 find_library(Zip_LIBRARIES NAMES zip)
0354                 if (Zip_LIBRARIES)
0355                         MESSAGE (STATUS "Found Zip Library ${Zip_LIBRARIES}")
0356                 endif ()
0357         ELSE ()
0358                 MESSAGE (STATUS "Network Common Data Format (NetCDF) Library NOT FOUND")
0359         ENDIF ()
0360 ELSE ()
0361         MESSAGE (STATUS "Network Common Data Format (NetCDF) Library DISABLED")
0362 ENDIF ()
0363 
0364 ### MQTT (optional) ###############################
0365 IF (ENABLE_MQTT)
0366 # ATTENTION: unit test uses qWaitFor() which needs Qt >= 5.10
0367 # avoid warning for the moment using QUIET
0368         find_package(Qt5Mqtt ${QT_MIN_VERSION} NO_MODULE)
0369         SET_PACKAGE_PROPERTIES (Qt5Mqtt PROPERTIES
0370                 DESCRIPTION "Qt Module to implement MQTT protocol version 3.1 and 3.1.1"
0371                 URL "https://github.com/qt/qtmqtt")
0372         IF (Qt5Mqtt_FOUND)
0373                 MESSAGE (STATUS "Found MQTT Library")
0374                 add_definitions (-DHAVE_MQTT)
0375         ELSE ()
0376                 MESSAGE (STATUS "MQTT Library NOT FOUND")
0377         ENDIF ()
0378 ELSE ()
0379         MESSAGE (STATUS "MQTT Library DISABLED")
0380 ENDIF ()
0381 
0382 ### QtSerialPort (optional) ###############################
0383 IF (ENABLE_QTSERIALPORT)
0384         find_package(Qt5SerialPort ${QT_MIN_VERSION} NO_MODULE)
0385         SET_PACKAGE_PROPERTIES (Qt5SerialPort PROPERTIES
0386                 DESCRIPTION "Qt Serial Port library"
0387                 URL "https://doc.qt.io/qt-5/qtserialport-index.html"
0388                 PURPOSE "Support basic functionality of serial ports.")
0389         IF (Qt5SerialPort_FOUND)
0390                 MESSAGE (STATUS "Found Qt5SerialPort Library")
0391                 add_definitions (-DHAVE_QTSERIALPORT)
0392         ELSE ()
0393                 MESSAGE (STATUS "Qt5SerialPort Library NOT FOUND")
0394         ENDIF ()
0395 ELSE ()
0396         MESSAGE (STATUS "Qt5SerialPort Library DISABLED")
0397 ENDIF ()
0398 
0399 ### FITS (optional) ###############################
0400 IF (ENABLE_FITS)
0401         FIND_PACKAGE (CFitsio)
0402         SET_PACKAGE_PROPERTIES (CFitsio PROPERTIES
0403                 DESCRIPTION "FITS IO Library"
0404                 URL "https://heasarc.gsfc.nasa.gov/fitsio/fitsio.html"
0405                 PURPOSE "Support for the FITS (Flexible Image Transport System) data format.")
0406         IF (CFITSIO_FOUND)
0407                 add_definitions (-DHAVE_FITS)
0408                 include_directories (${CFITSIO_INCLUDE_DIR})
0409         ELSE ()
0410                 MESSAGE (STATUS "Flexible Image Transport System Data Format (FITS) Library NOT FOUND")
0411         ENDIF ()
0412 ELSE ()
0413         MESSAGE (STATUS "Flexible Image Transport System Data Format (FITS) Library DISABLED")
0414 ENDIF ()
0415 
0416 ### LIBCERF (optional) #############################
0417 IF (ENABLE_LIBCERF)
0418         FIND_PACKAGE (LIBCERF)
0419         IF (LIBCERF_FOUND)
0420                 add_definitions (-DHAVE_LIBCERF)
0421                 include_directories (${LIBCERF_INCLUDE_DIR})
0422         ELSE ()
0423                 MESSAGE (STATUS "libcerf library NOT FOUND")
0424         ENDIF ()
0425 ELSE ()
0426         MESSAGE (STATUS "libcerf library DISABLED")
0427 ENDIF ()
0428 
0429 ### ZLIB for ROOT and READSTAT #################
0430 
0431 FIND_PACKAGE(ZLIB)
0432 SET_PACKAGE_PROPERTIES (ZLIB PROPERTIES
0433         DESCRIPTION "General purpose compression library"
0434         URL "https://www.zlib.net/"
0435 )
0436 IF (NOT ZLIB_FOUND)
0437         SET(ZLIB_LIBRARIES "")
0438 ENDIF ()
0439 
0440 ### ROOT (optional) #############################
0441 IF (ENABLE_ROOT)
0442         FIND_PACKAGE(LZ4)
0443         IF (ZLIB_FOUND AND LZ4_FOUND)
0444                 MESSAGE (STATUS "Found ZIP libraries ZLIB and LZ4 (needed for ROOT importer)")
0445                 add_definitions (-DHAVE_ZIP)
0446         ELSE ()
0447                 MESSAGE (STATUS "ZIP libraries ZLIB or LZ4 (needed for ROOT importer) NOT FOUND")
0448         ENDIF ()
0449 ELSE ()
0450         MESSAGE (STATUS "ROOT (CERN) importer DISABLED")
0451 ENDIF ()
0452 
0453 ### ReadStat (optional) #############################
0454 IF (ENABLE_READSTAT)
0455         FIND_PACKAGE (ReadStat)
0456         IF (NOT READSTAT_FOUND AND NOT WIN32 AND NOT DONT_BUILD_READSTAT)       # own version not on Windows and not when forbidden
0457                 MESSAGE (STATUS "ReadStat library NOT FOUND. Building own version")
0458                 set(BUILD_READSTAT TRUE)
0459 
0460                 # link own readstat with iconv
0461                 FIND_LIBRARY (ICONV_LIBRARIES NAMES iconv libiconv libiconv-2)
0462                 IF (ICONV_LIBRARIES) # non-glibc
0463                         MESSAGE (STATUS "Iconv library FOUND (${ICONV_LIBRARIES})")
0464                         set(READSTAT_LIBRARIES ${CMAKE_BINARY_DIR}/src/3rdparty/install/lib/libreadstat.a ${ICONV_LIBRARIES})
0465                 ELSE ()
0466                         MESSAGE (STATUS "Iconv library NOT FOUND")
0467                         set(READSTAT_LIBRARIES ${CMAKE_BINARY_DIR}/src/3rdparty/install/lib/libreadstat.a)
0468                 ENDIF ()
0469                 include_directories (${CMAKE_BINARY_DIR}/src/3rdparty/install/include)
0470         ENDIF ()
0471         IF (READSTAT_FOUND OR BUILD_READSTAT)   # found or build
0472                 add_definitions (-DHAVE_READSTAT)
0473         ELSE ()
0474                 SET(READSTAT_LIBRARIES "")
0475         ENDIF ()
0476 ELSE ()
0477         MESSAGE (STATUS "ReadStat support DISABLED")
0478 ENDIF ()
0479 
0480 ### Excel (optional) #############################
0481 IF (ENABLE_EXCEL)
0482         FIND_PACKAGE (QXlsx)
0483         IF (QXLSX_FOUND)
0484                 MESSAGE (STATUS "QXlsx library FOUND.")
0485                 add_definitions (-DHAVE_EXCEL)
0486         ELSE ()
0487                 if (TARGET Qt5::GuiPrivate)
0488                         set(BUILD_EXCEL TRUE)
0489 
0490                         MESSAGE (STATUS "QXlsx library NOT FOUND. Building own version.")
0491                         add_definitions (-DHAVE_EXCEL)
0492                 ELSE ()
0493                         MESSAGE (STATUS "Missing Qt5::GuiPrivate to build own QXlsx.")
0494                 ENDIF ()
0495         ENDIF ()
0496 
0497 ELSE ()
0498         MESSAGE (STATUS "Excel support DISABLED")
0499 ENDIF ()
0500 
0501 ###  Matio (optional) ##############################################
0502 IF (ENABLE_MATIO)
0503         FIND_PACKAGE (Matio)
0504         IF (MATIO_FOUND)
0505                 add_definitions (-DHAVE_MATIO)
0506         ELSE ()
0507                 MESSAGE (STATUS "Matio library NOT FOUND.")
0508         ENDIF ()
0509 ELSE ()
0510         MESSAGE (STATUS "Matio support DISABLED")
0511 ENDIF ()
0512 
0513 ### Discount (optional) #############################
0514 IF (ENABLE_DISCOUNT)
0515         FIND_PACKAGE(Discount)
0516         SET_PACKAGE_PROPERTIES (Discount PROPERTIES
0517                 DESCRIPTION "A C implementation of the Markdown markup language"
0518                 URL "https://www.pell.portland.or.us/~orc/Code/discount/"
0519                 TYPE OPTIONAL)
0520         IF (Discount_FOUND)
0521                 add_definitions (-DHAVE_DISCOUNT)
0522         ELSE ()
0523                 MESSAGE (STATUS "Discount library NOT FOUND.")
0524         ENDIF ()
0525 ELSE ()
0526         MESSAGE (STATUS "Discount DISABLED")
0527 ENDIF ()
0528 
0529 ### Touch bar on macOS (optional) #############################
0530 IF (APPLE AND ENABLE_TOUCHBAR)
0531         add_definitions (-DHAVE_TOUCHBAR)
0532 ENDIF ()
0533 
0534 #################################################
0535 IF (ENABLE_REPRODUCIBLE)
0536         add_definitions (-DREPRODUCIBLE_BUILD)
0537         message(STATUS "Reproducable build ENABLED")
0538 ELSE ()
0539         message(STATUS "Reproducable build DISABLED")
0540 ENDIF ()
0541 #################################################
0542 #################################################
0543 include(CheckFunctionExists)
0544 
0545 CHECK_FUNCTION_EXISTS(random HAVE_RANDOM_FUNCTION)
0546 #################################################
0547 FIND_PATH (XLOCALE_INCLUDE_DIR xlocale.h
0548         /usr/include
0549         /usr/local/include
0550 )
0551 IF (XLOCALE_INCLUDE_DIR)
0552         add_definitions (-DHAVE_XLOCALE)
0553         include_directories (${XLOCALE_INCLUDE_DIR})
0554 ENDIF()
0555 
0556 add_subdirectory(data)
0557 add_subdirectory(icons)
0558 add_subdirectory(src)
0559 add_subdirectory(doc)
0560 #add_subdirectory(lib)
0561 
0562 if (ENABLE_TESTS)
0563     enable_testing(true)
0564     add_subdirectory(tests)
0565 endif()
0566 
0567 install(FILES org.kde.labplot2.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR})
0568 
0569 # clang format
0570 #file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h *.c)
0571 #kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})
0572 
0573 feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
0574 
0575 find_package(KF5I18n CONFIG REQUIRED)
0576 ki18n_install(po)
0577 find_package(KF5DocTools CONFIG REQUIRED)
0578 kdoctools_install(po)