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

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