CMakeLists.txt 3.73 KB
Newer Older
1
cmake_minimum_required(VERSION 3.5)
2
set(KF5_VERSION "5.73.0") # handled by release scripts
3

4
project(KCalendarCore VERSION ${KF5_VERSION})
5 6

# ECM setup
7
include(FeatureSummary)
8
find_package(ECM 5.73.0  NO_MODULE)
9
set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules")
10 11
feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES)

12
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
13

14
set(REQUIRED_QT_VERSION 5.12.0)
15

16 17 18 19
include(KDEInstallDirs)
include(KDECMakeSettings)
include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)

20
include(ECMGenerateExportHeader)
21 22
include(ECMGenerateHeaders)
include(ECMGeneratePriFile)
23

24
include(ECMSetupVersion)
Laurent Montel's avatar
Laurent Montel committed
25
include(ECMQtDeclareLoggingCategory)
26 27
include(ECMAddQch)

28 29
set(EXCLUDE_DEPRECATED_BEFORE_AND_AT 0 CACHE STRING "Control the range of deprecated API excluded from the build [default=0].")

30 31
option(BUILD_QCH "Build API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)" OFF)
add_feature_info(QCH ${BUILD_QCH} "API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)")
32

33 34 35
# TODO: remove for KF6
option(KCALENDARCORE_NO_DEPRECATED_NAMESPACE "Disable deprecated KCalCore namespace" OFF)

36 37
if(POLICY CMP0053)
  cmake_policy(SET CMP0053 NEW)
Laurent Montel's avatar
Laurent Montel committed
38
endif()
Laurent Montel's avatar
Laurent Montel committed
39

40
set(KCALENDARCORE_LIB_VERSION ${KF5_VERSION})
41
ecm_setup_version(PROJECT VARIABLE_PREFIX KCALENDARCORE
42 43
  VERSION_HEADER "${KCalendarCore_BINARY_DIR}/kcalendarcore_version.h"
  PACKAGE_VERSION_FILE "${KCalendarCore_BINARY_DIR}/KF5CalendarCoreConfigVersion.cmake"
Allen Winter's avatar
Allen Winter committed
44
  SOVERSION 5
45
)
Àlex Fiestas's avatar
Àlex Fiestas committed
46

47
########### Find packages ###########
48
find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Core Gui)
Allen Winter's avatar
Allen Winter committed
49

Laurent Montel's avatar
Laurent Montel committed
50
set(LibIcal_MIN_VERSION "2.0")
51
find_package(LibIcal ${LibIcal_MIN_VERSION})
52
set_package_properties(LibIcal PROPERTIES TYPE REQUIRED)
53
if(LibIcal_VERSION VERSION_GREATER "2.98")
54
  set(HAVE_ICAL_3 TRUE)
55 56
  add_definitions(-DUSE_ICAL_3)
endif()
Allen Winter's avatar
Allen Winter committed
57

58
########### CMake Config Files ###########
59
set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5CalendarCore")
60

61 62 63 64
if (BUILD_QCH)
    set(PACKAGE_INCLUDE_QCHTARGETS "include(\"\${CMAKE_CURRENT_LIST_DIR}/KF5CalendarCoreQchTargets.cmake\")")
endif()

Laurent Montel's avatar
Laurent Montel committed
65
configure_package_config_file(
66 67
  "${CMAKE_CURRENT_SOURCE_DIR}/KF5CalendarCoreConfig.cmake.in"
  "${CMAKE_CURRENT_BINARY_DIR}/KF5CalendarCoreConfig.cmake"
Allen Winter's avatar
Allen Winter committed
68
  INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}
69 70
)

71

72
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050d00)
73

Laurent Montel's avatar
Laurent Montel committed
74 75
add_definitions(-DQT_NO_FOREACH)

76 77
########### Targets ###########
add_subdirectory(src)
78 79

if(BUILD_TESTING)
Allen Winter's avatar
Allen Winter committed
80 81
  find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Test)
  add_subdirectory(autotests)
82 83
endif()

84 85 86
add_subdirectory(cmake)

########### Install Files ###########
87 88 89 90 91 92 93 94
install(FILES
  "${CMAKE_CURRENT_BINARY_DIR}/KF5CalendarCoreConfig.cmake"
  "${CMAKE_CURRENT_BINARY_DIR}/KF5CalendarCoreConfigVersion.cmake"
  DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
  COMPONENT Devel
)

install(EXPORT KF5CalendarCoreTargets
Allen Winter's avatar
Allen Winter committed
95 96 97
  DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
  FILE KF5CalendarCoreTargets.cmake
  NAMESPACE KF5::
98 99
)

100 101 102 103 104 105 106 107 108
if (BUILD_QCH)
    ecm_install_qch_export(
        TARGETS KF5CalendarCore_QCH
        FILE KF5CalendarCoreQchTargets.cmake
        DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
        COMPONENT Devel
    )
endif()

109
install(FILES
110
  ${CMAKE_CURRENT_BINARY_DIR}/kcalendarcore_version.h
111
  DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5} COMPONENT Devel
112
)
113
if (NOT KCALENDARCORE_NO_DEPRECATED_NAMESPACE)
114 115 116
  ecm_setup_version(PROJECT VARIABLE_PREFIX KCALCORE
    VERSION_HEADER "${KCalendarCore_BINARY_DIR}/kcalcore_version.h"
  )
117
  install(FILES
118 119
    ${CMAKE_CURRENT_BINARY_DIR}/kcalcore_version.h
    DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5} COMPONENT Devel
120 121
  )
endif()
Laurent Montel's avatar
Laurent Montel committed
122

Laurent Montel's avatar
Laurent Montel committed
123
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)