CMakeLists.txt 4.96 KB
Newer Older
1
# We use an intermediate static library because linking tests directly to an executable is not
Daan De Meyer's avatar
Daan De Meyer committed
2
# possible with CMake yet.
3
add_library(kate-lib STATIC "")
4

Daan De Meyer's avatar
Daan De Meyer committed
5
configure_file(config.h.in config.h)
6

Daan De Meyer's avatar
Daan De Meyer committed
7 8
include(GenerateExportHeader)
generate_export_header(
9
  kate-lib
Daan De Meyer's avatar
Daan De Meyer committed
10 11
  EXPORT_FILE_NAME katetests_export.h
  EXPORT_MACRO_NAME KATE_TESTS_EXPORT
12 13
)

Daan De Meyer's avatar
Daan De Meyer committed
14
target_include_directories(
15
  kate-lib
Daan De Meyer's avatar
Daan De Meyer committed
16 17 18 19
  PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}/session
    ${CMAKE_CURRENT_SOURCE_DIR}/qtsingleapplication
Christoph Cullmann's avatar
Christoph Cullmann committed
20
    ${CMAKE_CURRENT_SOURCE_DIR}/quickopen
Daan De Meyer's avatar
Daan De Meyer committed
21
    ${CMAKE_CURRENT_BINARY_DIR} # katetests_export.h + config.h
22
    ${CMAKE_SOURCE_DIR}/shared
23 24
)

Daan De Meyer's avatar
Daan De Meyer committed
25
find_package(
26
  KF5 ${KF5_DEP_VERSION}
Daan De Meyer's avatar
Daan De Meyer committed
27 28 29 30 31 32 33 34 35
  QUIET
  REQUIRED
  COMPONENTS
    TextEditor
    WindowSystem
    DBusAddons
    Crash
  OPTIONAL_COMPONENTS
    Activities
36 37
)

Daan De Meyer's avatar
Daan De Meyer committed
38
target_link_libraries(
39
  kate-lib
Daan De Meyer's avatar
Daan De Meyer committed
40
  PUBLIC
41
    KF5::TextEditor
42
    KF5::WindowSystem
43
    KF5::DBusAddons
Daan De Meyer's avatar
Daan De Meyer committed
44 45
    KF5::Crash
)
46 47

if(KF5Activities_FOUND)
48
  target_link_libraries(kate-lib PUBLIC KF5::Activities)
49 50
endif()

51 52
# optional KUserFeedback integration
find_package(KUserFeedback)
53 54 55
if (TARGET KUserFeedbackWidgets)
    target_link_libraries(kate-lib PUBLIC KUserFeedbackWidgets)
    target_compile_definitions(kate-lib PUBLIC -DWITH_KUSERFEEDBACK)
56 57
endif()

Daan De Meyer's avatar
Daan De Meyer committed
58
ki18n_wrap_ui(UI_SOURCES ui/sessionconfigwidget.ui session/katesessionmanagedialog.ui)
59
target_sources(kate-lib PRIVATE ${UI_SOURCES})
Christoph Cullmann's avatar
Christoph Cullmann committed
60

Daan De Meyer's avatar
Daan De Meyer committed
61
target_sources(
62
  kate-lib
Daan De Meyer's avatar
Daan De Meyer committed
63 64
  PRIVATE
    data/kate.qrc
65

Daan De Meyer's avatar
Daan De Meyer committed
66 67 68 69 70
    session/katesession.cpp
    session/katesessionmanagedialog.cpp
    session/katesessionmanager.cpp
    session/katesessionsaction.cpp

Christoph Cullmann's avatar
Christoph Cullmann committed
71 72 73 74
    quickopen/katequickopen.cpp
    quickopen/katequickopenmodel.cpp
    quickopen/katequickopenlineedit.cpp

Daan De Meyer's avatar
Daan De Meyer committed
75 76 77 78 79 80 81 82 83 84 85
    kateapp.cpp
    kateappadaptor.cpp
    katecolorschemechooser.cpp
    kateconfigdialog.cpp
    kateconfigplugindialogpage.cpp
    katedocmanager.cpp
    katefileactions.cpp
    katemainwindow.cpp
    katemdi.cpp
    katemwmodonhddialog.cpp
    katepluginmanager.cpp
Christoph Cullmann's avatar
Christoph Cullmann committed
86

Daan De Meyer's avatar
Daan De Meyer committed
87 88 89 90 91 92
    katerunninginstanceinfo.cpp
    katesavemodifieddialog.cpp
    katetabbar.cpp
    kateviewmanager.cpp
    kateviewspace.cpp
    katewaiter.cpp
Waqar Ahmed's avatar
Waqar Ahmed committed
93 94 95

    katecommandbar.cpp
    commandmodel.cpp
Christoph Cullmann's avatar
Christoph Cullmann committed
96 97
)

98 99 100 101
# Executable only adds the main definition.
add_executable(kate-bin main.cpp)
target_link_libraries(kate-bin PRIVATE kate-lib)

Daan De Meyer's avatar
Daan De Meyer committed
102 103
# Use a single application on MacOS + Windows instead of dbus.
if(APPLE OR WIN32)
104
  target_compile_definitions(kate-bin PRIVATE USE_QT_SINGLE_APP)
105

Daan De Meyer's avatar
Daan De Meyer committed
106
  target_sources(
107
    kate-lib
Daan De Meyer's avatar
Daan De Meyer committed
108 109 110 111 112 113 114
    PRIVATE
      qtsingleapplication/qtlocalpeer.cpp
      qtsingleapplication/qtsingleapplication.cpp
      qtsingleapplication/qtlockedfile.cpp
  )

  if(WIN32)
115
    target_sources(kate-lib PRIVATE qtsingleapplication/qtlockedfile_win.cpp)
Daan De Meyer's avatar
Daan De Meyer committed
116
  else()
117
    target_sources(kate-lib PRIVATE qtsingleapplication/qtlockedfile_unix.cpp)
Daan De Meyer's avatar
Daan De Meyer committed
118
  endif()
119 120
endif()

121 122 123 124 125 126
# we have different windows icons, less margins
set(ICONS_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/icons/unix)
if(WIN32)
    set(ICONS_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/icons/windows)
endif()

127 128
# application icon, in all sizes needed to have e.g. nice Windows icons, too
set(ICON_FILES
129 130 131 132 133 134 135 136 137 138 139 140
  ${ICONS_FOLDER}/sc-apps-kate.svg
  ${ICONS_FOLDER}/16-apps-kate.png
  ${ICONS_FOLDER}/22-apps-kate.png
  ${ICONS_FOLDER}/32-apps-kate.png
  ${ICONS_FOLDER}/44-apps-kate.png
  ${ICONS_FOLDER}/48-apps-kate.png
  ${ICONS_FOLDER}/64-apps-kate.png
  ${ICONS_FOLDER}/128-apps-kate.png
  ${ICONS_FOLDER}/150-apps-kate.png
  ${ICONS_FOLDER}/256-apps-kate.png
  ${ICONS_FOLDER}/310-apps-kate.png
  ${ICONS_FOLDER}/512-apps-kate.png
141 142 143
)

# Add icon files to the application's source files to have CMake bundle them in the executable.
144
ecm_add_app_icon(ICONS_SOURCES ICONS ${ICON_FILES})
145 146
target_sources(kate-bin PRIVATE ${ICONS_SOURCES})

Daan De Meyer's avatar
Daan De Meyer committed
147 148 149 150
set_property(
  TARGET kate-bin
  PROPERTY OUTPUT_NAME kate
)
Christoph Cullmann's avatar
Christoph Cullmann committed
151

Daan De Meyer's avatar
Daan De Meyer committed
152
# See https://cmake.org/cmake/help/v3.15/prop_tgt/MACOSX_BUNDLE_INFO_PLIST.html
153
if(APPLE)
Daan De Meyer's avatar
Daan De Meyer committed
154 155 156 157 158 159 160 161 162 163 164
  set_property(
    TARGET kate-bin
    PROPERTY MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/data/MacOSXBundleInfo.plist.in
  )

  # These are substituted by CMake into plist.in.
  set(MACOSX_BUNDLE_DISPLAY_NAME "Kate")
  set(MACOSX_BUNDLE_GUI_IDENTIFIER "org.kde.Kate")
  set(MACOSX_BUNDLE_BUNDLE_NAME "Kate")
  set(MACOSX_BUNDLE_DISPLAY_NAME "Kate")
  set(MACOSX_BUNDLE_INFO_STRING "Kate - Advanced Text Editor")
165 166 167
  set(MACOSX_BUNDLE_LONG_VERSION_STRING "Kate ${RELEASE_SERVICE_VERSION}")
  set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE_VERSION_MINOR}")
  set(MACOSX_BUNDLE_BUNDLE_VERSION "${RELEASE_SERVICE_VERSION}")
168
  set(MACOSX_BUNDLE_COPYRIGHT "2000-2021 The Kate Authors")
169
endif()
170

Daan De Meyer's avatar
Daan De Meyer committed
171
install(TARGETS kate-bin ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
172

Daan De Meyer's avatar
Daan De Meyer committed
173
ecm_install_icons(
174
  ICONS ${ICON_FILES}
175
  DESTINATION ${KDE_INSTALL_ICONDIR}
Daan De Meyer's avatar
Daan De Meyer committed
176 177
  THEME hicolor
)
Christoph Cullmann's avatar
Christoph Cullmann committed
178

Daan De Meyer's avatar
Daan De Meyer committed
179
install(
180
  PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/data/org.kde.kate.desktop
181
  DESTINATION ${KDE_INSTALL_APPDIR}
Daan De Meyer's avatar
Daan De Meyer committed
182
)
Christoph Cullmann's avatar
Christoph Cullmann committed
183

Daan De Meyer's avatar
Daan De Meyer committed
184
install(
185
  FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/org.kde.kate.appdata.xml
186
  DESTINATION ${KDE_INSTALL_METAINFODIR}
Daan De Meyer's avatar
Daan De Meyer committed
187
)
Christoph Cullmann's avatar
Christoph Cullmann committed
188

Daan De Meyer's avatar
Daan De Meyer committed
189 190
if(BUILD_TESTING)
  add_subdirectory(autotests)
Heiko Becker's avatar
Heiko Becker committed
191
endif()