CMakeLists.txt 7.32 KB
Newer Older
Kevin Funk's avatar
Kevin Funk committed
1
cmake_minimum_required(VERSION 3.0)
2
project(KDevelop VERSION 5.4.40)
3

4 5
# KDevelop SOVERSION
# E.g. for KDevelop 5.2.0 => SOVERSION 52 (we only promise ABI compatibility between patch version updates)
6
set(KDEVELOP_SOVERSION 55)
7

8
# plugin version as used e.g. in plugin installation path
9
set(KDEV_PLUGIN_VERSION 33)
10

11
# we need some parts of the ECM CMake helpers
12
find_package (ECM 5.28.0 REQUIRED NO_MODULE)
13
set(CMAKE_MODULE_PATH ${KDevelop_SOURCE_DIR}/cmake/modules ${ECM_MODULE_PATH})
14

15 16
include(KDEInstallDirs)
include(KDECMakeSettings)
17
include(KDECompilerSettings NO_POLICY_SCOPE) # needs to be first, as set policies influence following macros
18

19 20
include(ECMOptionalAddSubdirectory)
include(ECMInstallIcons)
21
include(ECMAddAppIcon)
22
include(ECMSetupVersion)
23
include(ECMAddTests)
24 25
include(ECMMarkNonGuiExecutable)
include(ECMGenerateHeaders)
26
include(ECMQtDeclareLoggingCategory)
27

28
include(GenerateExportHeader)
29 30 31 32 33
include(CMakePackageConfigHelpers)
include(FeatureSummary)
include(WriteBasicConfigVersionFile)
include(CheckFunctionExists)

34 35
include(KDevelopMacrosInternal)

36
if(POLICY CMP0071)
37 38 39
  # CMake 3.10 generates warnings when projects combine AUTOMOC with qt5_wrap_ui() or qt5_add_resources()
  # Avoid that by setting this policy (cf. https://bugreports.qt.io/browse/QTBUG-63442)
  # Note: Once we depend on a Qt which has this fix (likely Qt 5.9.4+), remove this
40 41 42
  cmake_policy(SET CMP0071 OLD)
endif()

43
set(QT_MIN_VERSION "5.7.0")
44
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED Widgets Concurrent Quick QuickWidgets)
45 46 47
if(BUILD_TESTING)
  find_package(Qt5Test ${QT_MIN_VERSION} CONFIG REQUIRED)
endif()
48
set(KF5_DEP_VERSION "5.28.0")
Kevin Funk's avatar
Kevin Funk committed
49
find_package(KF5 ${KF5_DEP_VERSION} REQUIRED COMPONENTS
50
  Config
51
  Declarative
52 53
  DocTools
  IconThemes
54 55
  I18n
  ItemModels
Kevin Funk's avatar
Kevin Funk committed
56
  ItemViews
57 58 59 60
  JobWidgets
  KCMUtils
  KIO
  NewStuff
Kevin Funk's avatar
Kevin Funk committed
61
  NotifyConfig
62
  Parts
Kevin Funk's avatar
Kevin Funk committed
63
  Service
64 65
  TextEditor
  ThreadWeaver
Kevin Funk's avatar
Kevin Funk committed
66
  XmlGui
67
  WindowSystem
68
  Crash
69 70 71
  GuiAddons
  Archive
  Notifications
72
)
Kevin Funk's avatar
Kevin Funk committed
73
find_package(KF5SysGuard CONFIG)
74 75
set_package_properties(KF5SysGuard PROPERTIES
    PURPOSE "Framework for process listing. Required for the 'Attach to Process' feature"
76
    TYPE RECOMMENDED
77
)
Kevin Funk's avatar
Kevin Funk committed
78
find_package(KDevelop-PG-Qt 1.90.90 CONFIG)
79 80
set_package_properties(KDevelop-PG-Qt PROPERTIES
    PURPOSE "KDevelop parser generator library. Required for the QMake Builder/Manager plugin."
81
    TYPE RECOMMENDED
82 83
)

84 85
find_package(SharedMimeInfo REQUIRED)

86 87 88 89 90 91 92
if(NOT CMAKE_VERSION VERSION_LESS "3.10.0" AND KF5_VERSION VERSION_LESS "5.42.0")
  # CMake 3.9+ warns about automoc on files without Q_OBJECT, and doesn't know about other macros.
  # 3.10+ lets us provide more macro names that require automoc.
  # KF5 >= 5.42 takes care itself of adding its macros in its cmake config files
  list(APPEND CMAKE_AUTOMOC_MACRO_NAMES
       "K_PLUGIN_FACTORY_WITH_JSON" "K_EXPORT_PLASMA_DATAENGINE_WITH_JSON" "K_EXPORT_PLASMA_RUNNER")
endif()
93
if(NOT CMAKE_VERSION VERSION_LESS "3.9.0" AND KF5_VERSION VERSION_LESS "5.44.0")
94 95 96 97 98 99 100 101 102 103 104 105
    # CMake's automoc needs help to find names of plugin metadata files in case Q_PLUGIN_METADATA
    # is indirectly used via other C++ preprocessor macros
    # 3.9+ lets us provide some filter rule pairs (keyword, regexp) to match the names of such files
    # in the plain text of the sources. See AUTOMOC_DEPEND_FILTERS docs for details.
    list(APPEND CMAKE_AUTOMOC_DEPEND_FILTERS
        "K_PLUGIN_FACTORY_WITH_JSON"
        "[\n^][ \t]*K_PLUGIN_FACTORY_WITH_JSON[ \t\n]*\\([^,]*,[ \t\n]*\"([^\"]+)\""
        "K_EXPORT_PLASMA_DATAENGINE_WITH_JSON"
        "[\n^][ \t]*K_EXPORT_PLASMA_DATAENGINE_WITH_JSON[ \t\n]*\\([^,]*,[^,]*,[ \t\n]*\"([^\"]+)\""
    )
endif()

106

Kevin Funk's avatar
Kevin Funk committed
107 108
add_definitions(
    -DQT_DEPRECATED_WARNINGS
109
    -DQT_DISABLE_DEPRECATED_BEFORE=0x050700
110
    -DQT_NO_SIGNALS_SLOTS_KEYWORDS
Kevin Funk's avatar
Kevin Funk committed
111
    -DQT_NO_URL_CAST_FROM_STRING
112 113 114
    -DQT_NO_CAST_FROM_ASCII
    -DQT_NO_CAST_TO_ASCII
    -DQT_NO_CAST_FROM_BYTEARRAY
Kevin Funk's avatar
Kevin Funk committed
115
    -DQT_STRICT_ITERATORS
116
    -DQT_USE_QSTRINGBUILDER
117
    -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT
Kevin Funk's avatar
Kevin Funk committed
118
)
119

120
# Turn off missing-field-initializers warning for GCC to avoid noise from false positives with empty {}
121
# See discussion: https://mail.kde.org/pipermail/kdevelop-devel/2014-February/046910.html
122
add_compile_flag_if_supported(-Wno-missing-field-initializers)
123
add_compile_flag_if_supported(-Werror=switch)
124 125
add_compile_flag_if_supported(-Werror=undefined-bool-conversion)
add_compile_flag_if_supported(-Werror=tautological-undefined-compare)
126
add_compile_flag_if_supported(-Werror=implicit-fallthrough)    # Use Q_FALLTHROUGH for false positives.
127
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
128
    add_compile_flag_if_supported(-Wdocumentation)
129
    add_compile_flag_if_supported(-Wcovered-switch-default)
130
    add_compile_flag_if_supported(-Wunreachable-code-break)
131 132 133
    # This warning is triggered by every call to qCDebug()
    add_compile_flag_if_supported(-Wno-gnu-zero-variadic-macro-arguments)
endif()
134
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
135
    add_compile_flag_if_supported(-pedantic)
136 137 138 139
    add_compile_flag_if_supported(-Wzero-as-null-pointer-constant CXX_ONLY)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
    add_compile_flag_if_supported(-Wsuggest-override CXX_ONLY)
140
endif()
141

142 143 144 145 146 147 148 149
string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_TOLOWER)
if(CMAKE_BUILD_TYPE_TOLOWER MATCHES "debug"
  OR CMAKE_BUILD_TYPE_TOLOWER STREQUAL "")
  set(COMPILER_OPTIMIZATIONS_DISABLED TRUE)
else()
  set(COMPILER_OPTIMIZATIONS_DISABLED FALSE)
endif()

150 151
# create config-kdevelop.h
configure_file(config-kdevelop.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kdevelop.h)
152
include_directories(${KDevelop_BINARY_DIR}) # for config-kdevelop.h
Alexander Dymo's avatar
Alexander Dymo committed
153

154
add_subdirectory(kdevplatform)
Kevin Funk's avatar
Kevin Funk committed
155 156
add_subdirectory(plugins)

157
add_subdirectory(pics)
158
add_subdirectory(app)
159
add_subdirectory(app_templates)
160
add_subdirectory(file_templates)
161
add_subdirectory(shortcuts)
162
add_subdirectory(doc)
163
add_subdirectory(share)
164

Kevin Funk's avatar
Kevin Funk committed
165
set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KDevelop")
Kevin Funk's avatar
Kevin Funk committed
166
configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/KDevelopConfig.cmake.in"
Kevin Funk's avatar
Kevin Funk committed
167 168 169
                                  "${CMAKE_CURRENT_BINARY_DIR}/KDevelopConfig.cmake"
                                  INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}
)
Sven Brauch's avatar
Sven Brauch committed
170
ecm_setup_version(${KDevelop_VERSION_MAJOR}.${KDevelop_VERSION_MINOR}.${KDevelop_VERSION_PATCH}
Kevin Funk's avatar
Kevin Funk committed
171 172 173 174 175 176 177 178 179 180 181 182
                  VARIABLE_PREFIX KDEVELOP
                  VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kdevelop_version.h"
                  PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KDevelopConfigVersion.cmake"
)
install(FILES
        "${CMAKE_CURRENT_BINARY_DIR}/kdevelop_version.h"
        DESTINATION "${KDE_INSTALL_INCLUDEDIR}/kdevelop")
install(FILES
        "${CMAKE_CURRENT_BINARY_DIR}/KDevelopConfig.cmake"
        "${CMAKE_CURRENT_BINARY_DIR}/KDevelopConfigVersion.cmake"
        DESTINATION "${CMAKECONFIG_INSTALL_DIR}" )
install(EXPORT KDevelopTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" NAMESPACE KDev:: FILE KDevelopTargets.cmake)
Milian Wolff's avatar
Milian Wolff committed
183

184
# kdebugsettings file
185
install_qt_logging_categories(TYPE APP_PLUGIN)
186

Milian Wolff's avatar
Milian Wolff committed
187 188 189
# CTestCustom.cmake has to be in the CTEST_BINARY_DIR.
# in the KDE build system, this is the same as CMAKE_BINARY_DIR.
configure_file(${CMAKE_SOURCE_DIR}/CTestCustom.cmake ${CMAKE_BINARY_DIR}/CTestCustom.cmake)
190

191
install(FILES org.kde.kdevelop.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR})
192

193
# Make it possible to use the po files fetched by the fetch-translations step
194
ki18n_install(po)
195

196
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)