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