CMakeLists.txt 4.34 KB
Newer Older
Daan De Meyer's avatar
Daan De Meyer committed
1 2
# We use an intermediate static library because linking tests directly to an executable is not 
# 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 20
  PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}/session
    ${CMAKE_CURRENT_SOURCE_DIR}/qtsingleapplication
    ${CMAKE_CURRENT_BINARY_DIR} # katetests_export.h + config.h
21 22
)

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

Daan De Meyer's avatar
Daan De Meyer committed
37
target_link_libraries(
38
  kate-lib
Daan De Meyer's avatar
Daan De Meyer committed
39
  PUBLIC
40 41
    KF5::TextEditor
    KF5::IconThemes
Daan De Meyer's avatar
Daan De Meyer committed
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()

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

Daan De Meyer's avatar
Daan De Meyer committed
54 55 56 57 58 59 60
set(ICONS_PNG
  ${CMAKE_CURRENT_SOURCE_DIR}/icons/16-apps-kate.png
  ${CMAKE_CURRENT_SOURCE_DIR}/icons/22-apps-kate.png
  ${CMAKE_CURRENT_SOURCE_DIR}/icons/32-apps-kate.png
  ${CMAKE_CURRENT_SOURCE_DIR}/icons/48-apps-kate.png
  ${CMAKE_CURRENT_SOURCE_DIR}/icons/64-apps-kate.png
  ${CMAKE_CURRENT_SOURCE_DIR}/icons/128-apps-kate.png
Christoph Cullmann's avatar
Christoph Cullmann committed
61 62
)

Daan De Meyer's avatar
Daan De Meyer committed
63 64 65 66
set(ICONS_SVG ${CMAKE_CURRENT_SOURCE_DIR}/icons/sc-apps-kate.svgz)

# Add icon files to the application's source files to have CMake bundle them in the executable.
ecm_add_app_icon(ICONS_SOURCES ICONS ${ICONS_PNG})
67
target_sources(kate-lib PRIVATE ${ICONS_SOURCES})
Daan De Meyer's avatar
Daan De Meyer committed
68 69

target_sources(
70
  kate-lib 
Daan De Meyer's avatar
Daan De Meyer committed
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
  PRIVATE
    data/kate.qrc
    
    session/katesession.cpp
    session/katesessionmanagedialog.cpp
    session/katesessionmanager.cpp
    session/katesessionsaction.cpp

    kateapp.cpp
    kateappadaptor.cpp
    katecolorschemechooser.cpp
    kateconfigdialog.cpp
    kateconfigplugindialogpage.cpp
    katedocmanager.cpp
    katefileactions.cpp
    katemainwindow.cpp
    katemdi.cpp
    katemwmodonhddialog.cpp
    katepluginmanager.cpp
    katequickopen.cpp
    katequickopenmodel.cpp
    katerunninginstanceinfo.cpp
    katesavemodifieddialog.cpp
    katetabbar.cpp
    katetabbutton.cpp
    kateviewmanager.cpp
    kateviewspace.cpp
    katewaiter.cpp
Christoph Cullmann's avatar
Christoph Cullmann committed
99 100
)

Daan De Meyer's avatar
Daan De Meyer committed
101 102
# Use a single application on MacOS + Windows instead of dbus.
if(APPLE OR WIN32)
103
  target_compile_definitions(kate-lib PRIVATE USE_QT_SINGLE_APP)
Daan De Meyer's avatar
Daan De Meyer committed
104 105
  
  target_sources(
106
    kate-lib
Daan De Meyer's avatar
Daan De Meyer committed
107 108 109 110 111 112 113
    PRIVATE
      qtsingleapplication/qtlocalpeer.cpp
      qtsingleapplication/qtsingleapplication.cpp
      qtsingleapplication/qtlockedfile.cpp
  )

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

Daan De Meyer's avatar
Daan De Meyer committed
120 121
# Executable only adds the main definition.
add_executable(kate-bin main.cpp)
122
target_link_libraries(kate-bin PRIVATE kate-lib)
Christoph Cullmann's avatar
Christoph Cullmann committed
123

Daan De Meyer's avatar
Daan De Meyer committed
124 125 126 127
set_property(
  TARGET kate-bin
  PROPERTY OUTPUT_NAME kate
)
Christoph Cullmann's avatar
Christoph Cullmann committed
128

Daan De Meyer's avatar
Daan De Meyer committed
129
# See https://cmake.org/cmake/help/v3.15/prop_tgt/MACOSX_BUNDLE_INFO_PLIST.html
130
if(APPLE)
Daan De Meyer's avatar
Daan De Meyer committed
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
  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")
  set(MACOSX_BUNDLE_LONG_VERSION_STRING "Kate ${KDE_APPLICATIONS_VERSION}")
  set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${KDE_APPLICATIONS_VERSION_MAJOR}.${KDE_APPLICATIONS_VERSION_MINOR}")
  set(MACOSX_BUNDLE_BUNDLE_VERSION "${KDE_APPLICATIONS_VERSION}")
  set(MACOSX_BUNDLE_COPYRIGHT "2000-2016 The Kate Authors")
146
endif()
147

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

Daan De Meyer's avatar
Daan De Meyer committed
150 151 152 153 154
ecm_install_icons(
  ICONS ${ICONS_PNG} ${ICONS_SVG} 
  DESTINATION ${ICON_INSTALL_DIR} 
  THEME hicolor
)
Christoph Cullmann's avatar
Christoph Cullmann committed
155

Daan De Meyer's avatar
Daan De Meyer committed
156 157
install(
  PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/data/org.kde.kate.desktop 
158
  DESTINATION ${KDE_INSTALL_APPDIR}
Daan De Meyer's avatar
Daan De Meyer committed
159
)
Christoph Cullmann's avatar
Christoph Cullmann committed
160

Daan De Meyer's avatar
Daan De Meyer committed
161 162 163 164
install(
  FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/org.kde.kate.appdata.xml 
  DESTINATION ${CMAKE_INSTALL_METAINFODIR}
)
Christoph Cullmann's avatar
Christoph Cullmann committed
165

Daan De Meyer's avatar
Daan De Meyer committed
166 167
if(BUILD_TESTING)
  add_subdirectory(autotests)
Heiko Becker's avatar
Heiko Becker committed
168
endif()