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

0001 # SPDX-FileCopyrightText: 2022 Alexander Lohnau <alexander.lohnau@gmx.de>
0002 
0003 # For all the configurable CMake switches, please see https://invent.kde.org/office/kmymoney/-/wikis/home#cmake-switches
0004 
0005 # The CMake version we require
0006 cmake_minimum_required(VERSION 3.16)
0007 
0008 option(BUILD_STATIC_PLUGINS "Build the plugins statically" OFF)
0009 
0010 set(KF5_MIN_VERSION 5.90)
0011 set(QT_MIN_VERSION 5.15.2)
0012 set(KDE_COMPILERSETTINGS_LEVEL 5.82)
0013 
0014 if (NOT BUILD_STATIC_PLUGINS)
0015     set(AKONADI_MIN_VERSION 5.14.2)
0016 endif()
0017 
0018 
0019 set(RELEASE_SERVICE_VERSION_MAJOR "5")
0020 set(RELEASE_SERVICE_VERSION_MINOR "1")
0021 set(RELEASE_SERVICE_VERSION_MICRO "80")
0022 set(RELEASE_SERVICE_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE_VERSION_MINOR}.${RELEASE_SERVICE_VERSION_MICRO}")
0023 
0024 # Setting the name of the main project
0025 project(KMyMoney VERSION "${RELEASE_SERVICE_VERSION}" LANGUAGES CXX)
0026 
0027 # Minimum versions required for extern packages
0028 set(KMM_ALKIMIA_MIN_VERSION 8.1.72)
0029 set(KMM_KCHART_MIN_VERSION 2.6.0)
0030 # LibOFX uses two different version numbers. find_package looks for the
0031 # library's so version whereas pkg_check_modules retrieves the package
0032 # version. Details can be found in the libofx source code
0033 set(KMM_LIBOFX_MIN_VERSION 0.10.0)
0034 set(KMM_LIBOFX_MIN_SOVERSION 7.0.0)
0035 set(KMM_AQBANKING_MIN_VERSION 6.5.0)
0036 set(KMM_GWENHYWFAR_MIN_VERSION 5.10.1)
0037 
0038 # Determine the GIT reference (if we're based on GIT)
0039 if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
0040   execute_process(COMMAND git rev-parse --short HEAD
0041           WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
0042           OUTPUT_VARIABLE VERSION_SUFFIX
0043           OUTPUT_STRIP_TRAILING_WHITESPACE)
0044   set(VERSION_SUFFIX "-${VERSION_SUFFIX}")
0045   # Add variables which are similar to the build in names of cmake
0046   set(PROJECT_VERSION_SUFFIX "${VERSION_SUFFIX}")
0047   set(${PROJECT_NAME}_VERSION_SUFFIX "${VERSION_SUFFIX}")
0048 elseif(DEFINED VERSION_SUFFIX)
0049   string(REGEX REPLACE "-*(.+)" "\\1" DASHFREE_SUFFIX "${VERSION_SUFFIX}")
0050   set(PROJECT_VERSION_SUFFIX "-${DASHFREE_SUFFIX}")
0051   set(${PROJECT_NAME}_VERSION_SUFFIX "-${DASHFREE_SUFFIX}")
0052 endif()
0053 
0054 if (POLICY CMP0063)
0055   cmake_policy(SET CMP0063 NEW) # Policy introduced in CMake version 3.3
0056 endif()
0057 if (POLICY CMP0127)
0058   cmake_policy(SET CMP0127 NEW) # Policy introduced in CMake version 3.22
0059 endif()
0060 
0061 
0062 ######################### General Requirements ##########################
0063 
0064 if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0.0)
0065     message(FATAL_ERROR "This version of KMyMoney requires at least gcc 6.0.0 to be built successfully")
0066 endif()
0067 
0068 # To build shared libraries in Windows, we set CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS to TRUE.
0069 # See https://cmake.org/cmake/help/v3.4/variable/CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS.html
0070 # See https://blog.kitware.com/create-dlls-on-windows-without-declspec-using-new-cmake-export-all-feature/
0071 set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
0072 
0073 set(APPLE_SUPPRESS_X11_WARNING TRUE)
0074 find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
0075 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
0076 
0077 include(KDEInstallDirs)
0078 include(KDECMakeSettings)
0079 
0080 include(FeatureSummary)
0081 include(CMakeDependentOption)
0082 
0083 include(GenerateExportHeader)
0084 include(KMyMoneyMacros)
0085 
0086 include(KDEGitCommitHooks)
0087 kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT)
0088 
0089 add_definitions(
0090     -DKF_DEPRECATED_WARNINGS_SINCE=0x60000
0091     -DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x56200C
0092     -DQT_DEPRECATED_WARNINGS_SINCE=0x60000
0093     -DQT_DISABLE_DEPRECATED_BEFORE=0x50f02
0094 )
0095 
0096 find_package(PkgConfig)
0097 
0098 find_package(Gpgmepp)
0099 if (Gpgmepp_FOUND)
0100   set(GPG_FOUND TRUE)
0101 else()
0102   set(GPG_FOUND FALSE)
0103   find_package(KF5 ${KF5_MIN_VERSION} OPTIONAL_COMPONENTS QGpgme)
0104 endif()
0105 
0106 if (PkgConfig_FOUND)
0107   pkg_check_modules(SQLCIPHER sqlcipher IMPORTED_TARGET)
0108 endif()
0109 
0110 find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} REQUIRED COMPONENTS Core DBus Widgets Svg Xml Test PrintSupport)
0111 find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} OPTIONAL_COMPONENTS Sql Concurrent QuickWidgets)
0112 
0113 find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Archive CoreAddons Config ConfigWidgets I18n Completion KCMUtils ItemModels ItemViews Service XmlGui TextWidgets Notifications KIO)
0114 
0115 # For KF5 < 5.100 we need to fix a few method names that
0116 # have been deprecated but are not available before that version.
0117 # Once the KF5_MIN_VERSION of this project is >= 5.100 this
0118 # whole block can be removed
0119 if (${KF5_MIN_VERSION} VERSION_LESS "5.100")
0120     if (${KF5_VERSION} VERSION_LESS "5.100")
0121         add_definitions(
0122             -DquestionTwoActions=questionYesNo
0123             -DquestionTwoActionsCancel=questionYesNoCancel
0124             -DwarningTwoActions=warningYesNo
0125             -DwarningTwoActionsCancel=warningYesNoCancel
0126             -DPrimaryAction=Yes
0127             -DSecondaryAction=No
0128         )
0129     endif()
0130 else()
0131     message(FATAL_ERROR "Remove the above logic from CMakeLists.txt since it is not needed anymore")
0132 endif()
0133 
0134 find_package(KF5 ${KF5_MIN_VERSION} OPTIONAL_COMPONENTS DocTools Holidays Contacts Activities)
0135 if (DEFINED AKONADI_MIN_VERSION)
0136   # Akonadi 23.04 moved to KPim5 prefix, deprecating KF5
0137   set(PIMPREFIX KPim5)
0138   find_package(${PIMPREFIX}Akonadi ${AKONADI_MIN_VERSION} QUIET)
0139   if(NOT ${PIMPREFIX}Akonadi_FOUND)
0140     set(PIMPREFIX KF5)
0141     find_package(${PIMPREFIX}Akonadi ${AKONADI_MIN_VERSION} QUIET)
0142   endif()
0143   find_package(${PIMPREFIX}IdentityManagement ${AKONADI_MIN_VERSION} QUIET)
0144 endif()
0145 
0146 find_package(Qt${QT_MAJOR_VERSION}Keychain CONFIG REQUIRED)
0147 
0148 if(LibAlkimia5_DIR)
0149   set(_LibAlkimia5_DIR ${LibAlkimia5_DIR})
0150 endif()
0151 find_package(LibAlkimia${QT_MAJOR_VERSION} ${KMM_ALKIMIA_MIN_VERSION} REQUIRED)
0152 if (NOT LibAlkimia${QT_MAJOR_VERSION}_FOUND)
0153   # restore LibAlkimia5_DIR set to NOTFOUND by first find_package call
0154   if(_LibAlkimia5_DIR)
0155     set(LibAlkimia5_DIR ${_LibAlkimia5_DIR})
0156   endif()
0157   find_package(LibAlkimia5 8.1 REQUIRED)
0158   find_package(Qt5WebEngineWidgets 5.9.3 REQUIRED)
0159 endif()
0160 
0161 find_package(KChart ${KMM_KCHART_MIN_VERSION} QUIET)
0162 
0163 # we want the lowercase 'libofx' package name, for 'libofx_FOUND' compatibility with what pkg-config returns,
0164 # in case it is to be used as fallback
0165 find_package(libofx ${KMM_LIBOFX_MIN_SOVERSION} NAMES LibOFX libofx)
0166 if(NOT libofx_FOUND)
0167     find_package(PkgConfig)
0168 
0169     if(PkgConfig_FOUND)
0170         pkg_check_modules(libofx IMPORTED_TARGET libofx)
0171 
0172         if(libofx_FOUND)
0173             if (${libofx_VERSION} VERSION_GREATER_EQUAL ${KMM_LIBOFX_MIN_VERSION})
0174                 add_library(libofx::libofx INTERFACE IMPORTED)
0175                 target_link_libraries(libofx::libofx INTERFACE PkgConfig::libofx)
0176             else()
0177                 message(STATUS "Version ${libofx_VERSION} of libofx does not meet min. required version ${KMM_LIBOFX_MIN_VERSION}")
0178                 set(libofx_FOUND FALSE)
0179             endif()
0180         endif()
0181     endif()
0182 endif()
0183 
0184 
0185 if(KF5Gpgmepp_FOUND)
0186   set(GPG_FOUND TRUE)
0187 endif()
0188 
0189 cmake_dependent_option(ENABLE_GPG "Enable GPG support." ON
0190                        "GPG_FOUND" OFF)
0191 
0192 add_feature_info("Encryption" ENABLE_GPG "Allows to store your financial data using strong GPG encryption.")
0193 
0194 add_definitions(-DQT_USE_QSTRINGBUILDER -DQT_NO_CAST_TO_ASCII -DQT_NO_URL_CAST_FROM_STRING -DQT_NO_KEYWORDS)
0195 set(CMAKE_CXX_STANDARD 14)
0196 set(CMAKE_CXX_STANDARD_REQUIRED ON)
0197 set(CMAKE_CXX_EXTENSIONS OFF)
0198 
0199 # use DBus only on Linux
0200 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
0201   set(KMM_DBUS 1)
0202 endif()
0203 
0204 set(CMAKE_INCLUDE_CURRENT_DIR ON)
0205 include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
0206 
0207 # check for Doxygen
0208 find_package(Doxygen)
0209 if(DOXYGEN_FOUND)
0210   set(APIDOC_DIR ${CMAKE_CURRENT_BINARY_DIR}/apidocs)
0211 
0212   make_directory("${APIDOC_DIR}")
0213   configure_file(${CMAKE_CURRENT_SOURCE_DIR}/kmymoney.doxygen.in ${CMAKE_CURRENT_BINARY_DIR}/kmymoney.doxygen IMMEDIATE)
0214 
0215   add_custom_target(apidoc "${DOXYGEN}" "${CMAKE_CURRENT_BINARY_DIR}/kmymoney.doxygen")
0216 endif(DOXYGEN_FOUND)
0217 add_feature_info("Doxygen" DOXYGEN_FOUND "Generate API documentation with Doxygen (for devs only).")
0218 
0219 # check some include files exists
0220 set(CMAKE_REQUIRED_DEFINITIONS -D_XOPEN_SOURCE=500 -D_BSD_SOURCE)
0221 include (CheckIncludeFileCXX)
0222 check_include_file_cxx("unistd.h" HAVE_UNISTD_H)
0223 check_include_file_cxx("pwd.h" HAVE_PWD_H)
0224 check_include_file_cxx("windows.h" HAVE_WINDOWS_H)
0225 check_include_file_cxx("lmcons.h" HAVE_LMCONS_H)
0226 check_include_file_cxx("process.h" HAVE_PROCESS_H)
0227 
0228 # include check for members in structs
0229 include (CheckStructHasMember)
0230 
0231 ######################### Special Requirements ##########################
0232 
0233 # This is needed for QtSqlite and QtDesigner
0234 # (they'll install files to ${QT_INSTALL_DIR}/plugins/)
0235 get_filename_component(QT_BIN_DIR "${QT_MOC_EXECUTABLE}" PATH)
0236 get_filename_component(QT_DIR     ${QT_BIN_DIR}        PATH)
0237 set(QT_INSTALL_DIR ${QT_DIR} CACHE PATH
0238   "Qt install prefix defaults to the Qt prefix: ${QT_DIR}")
0239 
0240 cmake_dependent_option(ENABLE_ADDRESSBOOK "Enable addressbook support." ON
0241                        "${PIMPREFIX}IdentityManagement_FOUND;${PIMPREFIX}Akonadi_FOUND;KF5Contacts_FOUND" OFF)
0242 
0243 add_feature_info("Address book" ENABLE_ADDRESSBOOK "Allows fetching payee information from KDE PIM system.")
0244 
0245 cmake_dependent_option(ENABLE_HOLIDAYS "Enable addressbook support." ON
0246                        "KF5Holidays_FOUND" OFF)
0247 
0248 add_feature_info("Holidays" ENABLE_HOLIDAYS "Allows fetching holidays from KDE PIM system.")
0249 
0250 cmake_dependent_option(ENABLE_ACTIVITIES "Enable activities support." ON
0251                        "KF5Activities_FOUND" OFF)
0252 
0253 option(ENABLE_FORECASTVIEW "Enable forecast view" ON)
0254 add_feature_info("Forecast view" ENABLE_FORECASTVIEW "Adds possibility to calculate forecasts.")
0255 cmake_dependent_option(ENABLE_REPORTSVIEW "Enable reports view." ON
0256                        "KChart_FOUND" OFF)
0257 add_feature_info("Reports view" ENABLE_REPORTSVIEW "Adds possibility to display chart and table reports.")
0258 option(ENABLE_BUDGETVIEW "Enable budget view" ON)
0259 add_feature_info("Budget view" ENABLE_BUDGETVIEW "Adds possibility to plan a budget.")
0260 option(ENABLE_ONLINEJOBOUTBOXVIEW "Enable online job outbox view" ON)
0261 add_feature_info("Online job outbox view" ENABLE_ONLINEJOBOUTBOXVIEW "Adds outbox for sending online jobs.")
0262 
0263 cmake_dependent_option(ENABLE_SQLSTORAGE "Enable SQL storage support." ON
0264                        "Qt5Sql_FOUND" OFF)
0265 
0266 add_feature_info("SQL Storage" ENABLE_SQLSTORAGE "Allows storing your financial data in SQL database.")
0267 
0268 cmake_dependent_option(ENABLE_SQLCIPHER "Enable SQLCipher support." ON
0269                        "SQLCIPHER_FOUND" OFF)
0270 
0271 cmake_dependent_option(ENABLE_LIBOFX "Enable LibOFX support." ON "libofx_FOUND" OFF)
0272 add_feature_info("LibOFX" ENABLE_LIBOFX "Enables OFX import, export, and Direct Connect using LibOFX library.")
0273 
0274 cmake_dependent_option(ENABLE_SQLTRACER "Dump SQL requests to console" OFF
0275                        "ENABLE_SQLSTORAGE" OFF)
0276 
0277 # Otherwise compilers halt on something like that:
0278 # ld: library not found for -lsqlcipher
0279 # on MS Windows, FreeBSD, macOS, and Ubuntu 14.04 (Ubuntu has CMake 3.5.1 but I'm not sure if it's the one to blame).
0280 if(ENABLE_SQLCIPHER AND (NOT CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_VERSION VERSION_LESS 3.5.2))
0281   link_directories(${SQLCIPHER_LIBRARY_DIRS})
0282 endif()
0283 
0284 add_feature_info("SQLCipher" ENABLE_SQLCIPHER "Allows encrypting your SQLite3 database.")
0285 
0286 add_feature_info("SQL Tracer" ENABLE_SQLTRACER "It traces the SQL queries to the console.")
0287 
0288 cmake_dependent_option(ENABLE_IBANBICDATA "Enable IBAN/BIC data support." OFF
0289                        "Qt5Sql_FOUND" OFF)
0290 
0291 add_feature_info("IBAN/BIC data" ENABLE_IBANBICDATA "Adds predefined IBAN/BIC numbers to KMyMoney (note: doesn't work yet).")
0292 
0293 # check for optional KBanking support
0294 find_package(aqbanking ${KMM_AQBANKING_MIN_VERSION} QUIET)
0295 find_package(gwenhywfar ${KMM_GWENHYWFAR_MIN_VERSION} QUIET)
0296 find_package(gwengui-cpp QUIET)
0297 find_package(gwengui-qt5 QUIET)
0298 
0299 cmake_dependent_option(ENABLE_KBANKING "Enable KBanking plugin" ON
0300                        "AQBANKING_FOUND;gwengui-cpp_FOUND;gwengui-qt5_FOUND;Qt5QuickWidgets_FOUND" OFF)
0301 
0302 add_feature_info(KBanking ENABLE_KBANKING "Interface for the following online banking protocols: HBCI, EBICS, OFX Direct Connect, Paypal")
0303 
0304 # check for optional Woob support
0305 find_package(Python3 COMPONENTS Interpreter Development)
0306 set_package_properties(Python3 PROPERTIES
0307         TYPE OPTIONAL
0308         PURPOSE "Required by Woob plugin.")
0309 
0310 cmake_dependent_option(ENABLE_WOOB "Enable Woob plugin" ON
0311                        "Python3_FOUND;Qt5Concurrent_FOUND" OFF)
0312 add_feature_info(Woob ENABLE_WOOB "Online banking interface using Woob.")
0313 
0314 
0315 # check for optional ical support
0316 find_package(LibIcal)
0317 cmake_dependent_option(ENABLE_LIBICAL "Enable Calendar plugin" ON
0318                        "LibIcal_FOUND" OFF)
0319 add_feature_info(iCalendar ENABLE_LIBICAL "iCalendar integration.")
0320 
0321 # Setup translations
0322 ki18n_install(po)
0323 
0324 ######################### Settings ##########################
0325 
0326 # If no build type is set, use "Release with Debug Info"
0327 if(NOT CMAKE_BUILD_TYPE)
0328   set(CMAKE_BUILD_TYPE RelWithDebInfo)
0329 endif(NOT CMAKE_BUILD_TYPE)
0330 
0331 set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
0332   "Choose the type of build.
0333 Possible values are: 'Release' 'RelWithDebInfo' 'Debug' 'DebugKMM' 'Debugfull' 'Profile'
0334 The default value is: 'RelWithDebInfo'" FORCE)
0335 
0336 # tells gcc to enable exception handling
0337 include(KDECompilerSettings)
0338 kde_enable_exceptions()
0339 
0340 # Set linker flags
0341 
0342 # There is no way to detect linker in cmake (see https://gitlab.kitware.com/cmake/cmake/issues/17596)
0343 # and linkers aren't compatible with each other, so we need to assume something
0344 if(CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
0345   set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-dead_strip -Wl,-undefined,error")
0346   set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-dead_strip -Wl,-undefined,error -Wl,-mark_dead_strippable_dylib")
0347   set(CMAKE_EXE_LINKER_FLAGS    "${CMAKE_EXE_LINKER_FLAGS}    -Wl,-dead_strip -Wl,-undefined,error")
0348 
0349 elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
0350   set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--as-needed")
0351   set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--as-needed")
0352   # TODO: remove multiple definitions of payeeIdentifierLoader::createPayeeIdentifierFromSqlDatabase
0353   set(CMAKE_EXE_LINKER_FLAGS    "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed -Wl,--allow-multiple-definition")
0354   # CI builds are crashing on FreeBSD with --no-undefined. Probably because -DECM_ENABLE_SANITIZERS='address'
0355   # more can be read on the following site https://bugs.freedesktop.org/show_bug.cgi?id=100120
0356   if(NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
0357     set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined")
0358     set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
0359     set(CMAKE_EXE_LINKER_FLAGS    "${CMAKE_EXE_LINKER_FLAGS}    -Wl,--no-undefined")
0360   endif()
0361 
0362   # TODO: remove multiple definitions of payeeIdentifierLoader::hasItemEditDelegate
0363   if(CMAKE_SYSTEM_NAME MATCHES "Windows")
0364     set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--allow-multiple-definition")
0365     set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--allow-multiple-definition")
0366   endif()
0367 
0368 elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
0369   set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /FORCE:Multiple")
0370 endif()
0371 
0372 option(WARNINGS_AS_ERRORS "Force warnings to be reported as errors" OFF)
0373 add_feature_info("Warnings as errors" WARNINGS_AS_ERRORS "Enforces all warnings to be reported as errors.")
0374 
0375 # Set compiler flags
0376 if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
0377   add_compile_options(-Wall -Wextra -Wlogical-op -Wno-null-dereference -Wshadow -Wunused -Wno-misleading-indentation -Wsuggest-override -Wcast-qual -Wformat=2 -fno-common -Werror=return-type)
0378 
0379   if(WARNINGS_AS_ERRORS)
0380     add_compile_options(-Werror)
0381   endif()
0382 elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
0383   add_compile_options(-Wall -Wextra -Wno-null-dereference -Wshadow -Wunused -Wno-misleading-indentation -Wsuggest-override -Wcast-qual -Wformat=2 -Wunreachable-code -fno-common -Werror=return-type)
0384 
0385   if(WARNINGS_AS_ERRORS)
0386     add_compile_options(-Werror)
0387   endif()
0388 elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
0389   add_compile_options(/experimental:external /external:anglebrackets /external:W0 /W3)
0390 
0391   if(WARNINGS_AS_ERRORS)
0392     add_compile_options(/WX)
0393   endif()
0394 endif()
0395 
0396 
0397 # IDEA: Set on a per target base
0398 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
0399 
0400 if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
0401   # DebugKMM, Debugfull, Profile
0402   set(CMAKE_CXX_FLAGS_DEBUGKMM
0403       "-g -O2 -fno-reorder-blocks -fno-schedule-insns -fno-inline")
0404   set(CMAKE_CXX_FLAGS_DEBUGFULL
0405       "-g3 -fno-inline")
0406   set(CMAKE_CXX_FLAGS_PROFILE
0407       "-g3 -fno-inline -ftest-coverage -fprofile-arcs")
0408 
0409   # preprocessor definitions in case this is a debug build
0410   set(CMAKE_CXX_FLAGS_DEBUGFULL "${CMAKE_CXX_FLAGS_DEBUGFULL} -DQT_STRICT_ITERATORS -DKMM_DEBUG -DQT_FORCE_ASSERTS")
0411   set(CMAKE_CXX_FLAGS_DEBUGKMM  "${CMAKE_CXX_FLAGS_DEBUGKMM} -DKMM_DEBUG -DQT_FORCE_ASSERTS")
0412 endif()
0413 
0414 option(USE_MODELTEST
0415   "Compile with ModelTest code (default=OFF)" OFF)
0416 
0417 add_feature_info("Model test" USE_MODELTEST "Generate modeltest code (for devs only).")
0418 
0419 option(USE_QT_DESIGNER
0420   "Install KMyMoney specific widget library for Qt-Designer (default=OFF)" OFF)
0421 
0422 add_feature_info("QtDesigner" USE_QT_DESIGNER "Qt-Designer library support (for devs only).")
0423 
0424 ######################### The Actual Targets ##########################
0425 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
0426 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
0427 if(WIN32)
0428   set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
0429 else()
0430   set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
0431 endif()
0432 
0433 add_subdirectory( tools )
0434 add_subdirectory( kmymoney )
0435 if(KF5DocTools_FOUND)
0436   add_subdirectory( doc )
0437   kdoctools_install( po )
0438 endif()
0439 
0440 ######################### Output Results #############################
0441 
0442 # create the config.h file out of the config.h.cmake
0443 configure_file("config-kmymoney.h.cmake" "${CMAKE_CURRENT_BINARY_DIR}/config-kmymoney.h")
0444 configure_file("config-kmymoney-version.h.cmake" "${CMAKE_CURRENT_BINARY_DIR}/config-kmymoney-version.h")
0445 
0446 message("
0447 Build type: ${CMAKE_BUILD_TYPE}")
0448 
0449 feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND
0450                 DESCRIPTION "The following REQUIRED packages have not been found:")
0451 
0452 feature_summary(WHAT OPTIONAL_PACKAGES_NOT_FOUND
0453                 DESCRIPTION "The following OPTIONAL packages have not been found:")
0454 
0455 feature_summary(WHAT ENABLED_FEATURES
0456                 DESCRIPTION "The following features have been enabled:")
0457 
0458 feature_summary(WHAT DISABLED_FEATURES
0459                 DESCRIPTION "The following features have been disabled:")