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

4
# write the plugin version to a file
Sven Brauch's avatar
Sven Brauch committed
5
set(KDEVPYTHON_VERSION_MAJOR 5)
6
set(KDEVPYTHON_VERSION_MINOR 3)
Kevin Funk's avatar
Kevin Funk committed
7
set(KDEVPYTHON_VERSION_PATCH 2)
Sven Brauch's avatar
Sven Brauch committed
8

9
# KDevplatform dependency version
10
set( KDEVPLATFORM_VERSION "${KDEVPYTHON_VERSION_MAJOR}.${KDEVPYTHON_VERSION_MINOR}" )
11

12
find_package (ECM "5.14.0" REQUIRED NO_MODULE)
13
set(CMAKE_MODULE_PATH ${kdevpython_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH})
Milian Wolff's avatar
Milian Wolff committed
14

Kevin Funk's avatar
Kevin Funk committed
15
include(KDECompilerSettings NO_POLICY_SCOPE)
16 17 18
include(KDEInstallDirs)
include(KDECMakeSettings)

19
include(GenerateExportHeader)
20

21 22
include(ECMAddTests)
include(ECMSetupVersion)
23
include(ECMQtDeclareLoggingCategory)
24

25 26 27 28 29 30 31 32 33 34
if(NOT CMAKE_VERSION VERSION_LESS "3.10.0")
    # Avoids bogus warnings with CMake 3.10+
    list(APPEND CMAKE_AUTOMOC_MACRO_NAMES "K_PLUGIN_FACTORY_WITH_JSON")
endif()
if(POLICY CMP0071)
    # Avoids compat messages from CMake 3.10+, with Qt < 5.9.4
    # See https://bugreports.qt.io/browse/QTBUG-63442
    cmake_policy(SET CMP0071 OLD)
endif()

35 36 37 38
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wdocumentation")
endif()

39 40
add_definitions( -DTRANSLATION_DOMAIN=\"kdevpython\" )

41 42
# CMake looks for exactly the specified version first and ignores newer versions.
# To avoid that, start looking for the newest supported version and work down.
43
set(Python_ADDITIONAL_VERSIONS 3.7 3.6 3.5 3.4)
44
foreach(_PYTHON_V ${Python_ADDITIONAL_VERSIONS})
45
    find_package(PythonInterp ${_PYTHON_V})
46 47 48 49 50
    if ( PYTHONINTERP_FOUND )
        break()
    endif()
endforeach()
# Must unset before searching for libs, otherwise these are checked before the required version...
51
unset(Python_ADDITIONAL_VERSIONS)
52

53
if ( PYTHONINTERP_FOUND AND PYTHON_VERSION_STRING VERSION_GREATER "3.4" )
54 55 56
    # Find libraries that match the found interpreter (mismatched versions not supported).
    # This assumes libs are available for the newest Python version on the system.
    # KDevelop should _always_ be built against the newest possible version, so notabug.
57
    find_package(PythonLibs "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}" REQUIRED EXACT)
58 59
endif()

60
if ( NOT PYTHONLIBS_FOUND OR PYTHONLIBS_VERSION_STRING VERSION_LESS "3.4.3" )
61
    message(FATAL_ERROR "Python >= 3.4.3 but < 3.8 with --enable-shared is required to build kdev-python")
Alex Richardson's avatar
Alex Richardson committed
62
endif()
63

64
configure_file(kdevpythonversion.h.cmake "${CMAKE_CURRENT_BINARY_DIR}/kdevpythonversion.h" @ONLY)
65

Kevin Funk's avatar
Kevin Funk committed
66
set(QT_MIN_VERSION "5.5.0")
67 68
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED Core Widgets Test)
set(KF5_DEP_VERSION "5.15.0")
69 70 71 72 73
find_package(KF5 ${KF5_DEP_VERSION} REQUIRED
    I18n
    ThreadWeaver
    TextEditor
)
74
find_package(KDevPlatform ${KDEVPLATFORM_VERSION} CONFIG REQUIRED)
75
find_package(KDevelop ${KDEVPLATFORM_VERSION} REQUIRED)
76

77
if ( NOT WIN32 )
78
    set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wfatal-errors -Wall")
79
endif ( NOT WIN32 )
80

81
# then, build the plugin
82
include_directories(
83
    ${CMAKE_CURRENT_BINARY_DIR}
84
    ${CMAKE_CURRENT_SOURCE_DIR}
85 86 87
    ${CMAKE_CURRENT_SOURCE_DIR}/duchain
    ${CMAKE_CURRENT_SOURCE_DIR}/parser
    ${CMAKE_CURRENT_BINARY_DIR}/parser
88 89
)

90
add_subdirectory(app_templates)
91
add_subdirectory(parser)
92
add_subdirectory(duchain)
93
add_subdirectory(codecompletion)
94
add_subdirectory(debugger)
95
add_subdirectory(docfilekcm)
96

97
set(kdevpythonlanguagesupport_PART_SRCS
98
    codegen/correctionfilegenerator.cpp
99
    codegen/refactoring.cpp
100
    pythonlanguagesupport.cpp
Piyush Verma's avatar
Piyush Verma committed
101
    pythonparsejob.cpp
102
    pythonhighlighting.cpp
103
    pythonstylechecking.cpp
104

105 106 107 108 109
    # config pages:
    docfilekcm/docfilewizard.cpp
    docfilekcm/docfilemanagerwidget.cpp
    docfilekcm/kcm_docfiles.cpp
    pep8kcm/kcm_pep8.cpp
110
    projectconfig/projectconfigpage.cpp
111
)
112 113 114
ecm_qt_declare_logging_category(kdevpythonlanguagesupport_PART_SRCS
    HEADER codegendebug.h
    IDENTIFIER KDEV_PYTHON_CODEGEN
115
    CATEGORY_NAME "kdevelop.plugins.python.codegen"
116 117 118 119
)
ecm_qt_declare_logging_category(kdevpythonlanguagesupport_PART_SRCS
    HEADER pythondebug.h
    IDENTIFIER KDEV_PYTHON
120
    CATEGORY_NAME "kdevelop.plugins.python"
121
)
122

123 124 125 126 127
ki18n_wrap_ui(kdevpythonlanguagesupport_PART_SRCS
    codegen/correctionwidget.ui
    projectconfig/projectconfig.ui
    pep8kcm/pep8.ui
)
128

Alex Richardson's avatar
Alex Richardson committed
129
kdevplatform_add_plugin(kdevpythonlanguagesupport JSON kdevpythonsupport.json SOURCES ${kdevpythonlanguagesupport_PART_SRCS})
130

131
target_link_libraries(kdevpythonlanguagesupport
132 133
    KDev::Interfaces
    KDev::Language
134
    KDev::Util
135 136
    KF5::ThreadWeaver
    KF5::TextEditor
137 138 139
    kdevpythoncompletion
    kdevpythonparser
    kdevpythonduchain
140
)
141

142 143 144
get_target_property(DEFINESANDINCLUDES_INCLUDE_DIRS KDev::DefinesAndIncludesManager INTERFACE_INCLUDE_DIRECTORIES)
include_directories(${DEFINESANDINCLUDES_INCLUDE_DIRS})

145 146 147
install(DIRECTORY documentation_files DESTINATION ${KDE_INSTALL_DATADIR}/kdevpythonsupport)
install(DIRECTORY correction_files DESTINATION ${KDE_INSTALL_DATADIR}/kdevpythonsupport)
install(FILES codestyle.py DESTINATION ${KDE_INSTALL_DATADIR}/kdevpythonsupport)
148

149 150
install(FILES org.kde.kdev-python.metainfo.xml DESTINATION ${KDE_INSTALL_METAINFODIR})

151 152 153
# kdebugsettings file
install(FILES kdevpythonsupport.categories DESTINATION ${KDE_INSTALL_CONFDIR})

154
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)