File: CMakeLists.txt

package info (click to toggle)
screengrab 1.101-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 1,504 kB
  • sloc: cpp: 4,744; makefile: 11
file content (259 lines) | stat: -rw-r--r-- 7,777 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
# CMP0000: Call the cmake_minimum_required() command at the beginning of the top-level
# CMakeLists.txt file even before calling the project() command.
# The cmake_minimum_required(VERSION) command implicitly invokes the cmake_policy(VERSION)
# command to specify that the current project code is written for the given range of CMake
# versions.
project(screengrab)

include(GNUInstallDirs)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

# options
option(SG_DBUS_NOTIFY "Enable D-Bus notifications" ON)
option(SG_EXT_EDIT "Enable ability to edit screenshots in external editor" ON)
option(SG_EXT_UPLOADS "Enable upload screenshots to Imgur" ON)
option(SG_GLOBALSHORTCUTS "Enable global shortcuts" OFF)
option(UPDATE_TRANSLATIONS "Update source translation translations/*.ts files" OFF)

# Minimum Versions
set(KF5_MINIMUM_VERSION "5.36.0")
set(QT_MINIMUM_VERSION "5.7.1")
set(QTXDG_MINIMUM_VERSION "3.3.1")

find_package(Qt5LinguistTools  ${QT_MINIMUM_VERSION} REQUIRED)
find_package(Qt5Network ${QT_MINIMUM_VERSION} REQUIRED)
find_package(Qt5Widgets ${QT_MINIMUM_VERSION} REQUIRED)
find_package(Qt5X11Extras ${QT_MINIMUM_VERSION} REQUIRED)
find_package(KF5WindowSystem ${KF5_MINIMUM_VERSION} REQUIRED)

find_package(X11)
if (X11_FOUND)
    set(HAVE_X11 1)
endif(X11_FOUND)

find_package(
    XCB MODULE COMPONENTS
        XCB
        SHAPE
        XFIXES
)
find_package(
    X11_XCB MODULE
)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(SCREENGRAB_VERSION "1.101")

if (DEV_VERSION)
    set(VERSION "${SCREENGRAB_VERSION}-dev (${DEV_VERSION})")
else()
    set(VERSION ${SCREENGRAB_VERSION})
endif()

add_definitions(
    -DVERSION="${VERSION}"
    -DQT_NO_FOREACH
)

if(NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE Release)
endif()

message(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
message(STATUS "Install prefix: " ${CMAKE_INSTALL_PREFIX})

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Woverloaded-virtual -Wall -Wextra")

set(SG_LIBDIR "${CMAKE_INSTALL_LIBDIR}/screengrab")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${SG_LIBDIR}")
message(STATUS "Library path: ${CMAKE_INSTALL_RPATH}")

# Although the names, LXQtTranslateTs and LXQtTranslateDesktop, they don't
#   bring any dependency on lxqt.
include(LXQtTranslateTs)
include(LXQtTranslateDesktop)
include(Qt5TranslationLoader)

if(SG_GLOBALSHORTCUTS)
    add_definitions( -DSG_GLOBAL_SHORTCUTS="1")

    if(SG_USE_SYSTEM_QXT)
        # find qxt
        find_package(Qxt REQUIRED COMPONENTS QxtCore, QxtGui)
        include_directories(${QXT_QXTCORE_INCLUDE_DIR} ${QXT_QXTGUI_INCLUDE_DIR})
    endif()
endif(SG_GLOBALSHORTCUTS)

if(SG_EXT_UPLOADS)
    add_definitions( -DSG_EXT_UPLOADS="1")
endif()

if(SG_EXT_EDIT)
    add_definitions( -DSG_EXT_EDIT="1")
    find_package(Qt5Xdg ${QTXDG_MINIMUM_VERSION} REQUIRED)
endif()

if(SG_DBUS_NOTIFY)
    find_package(Qt5DBus ${QT_MINIMUM_VERSION} REQUIRED)
    add_definitions( -DSG_DBUS_NOTIFY="1")
endif()

message(STATUS "Global shortcuts support: " ${SG_GLOBALSHORTCUTS})
message(STATUS "Imgur upload support: " ${SG_EXT_UPLOADS})
message(STATUS "Editing screenshots in external editor support: " ${SG_EXT_EDIT})
message(STATUS "Enable D-Bus notifications: " ${SG_DBUS_NOTIFY})
message(STATUS "Use system Qxt Library: " ${SG_USE_SYSTEM_QXT})
message(STATUS "Update source translation translations/*.ts files: " ${UPDATE_TRANSLATIONS})

# docs
# CMAKE_INSTALL_FULL_DOCDIR = CMAKE_INSTALL_PREFIX/CMAKE_INSTALL_DATADIR/doc/PROJECT_NAME
message(STATUS "Documentation directory: " ${CMAKE_INSTALL_FULL_DOCDIR})
add_definitions(-DSG_DOCDIR="${CMAKE_INSTALL_FULL_DOCDIR}")

# app icon path
add_definitions(-DSG_ICONPATH="${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/pixmaps/screengrab.png")

include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src")
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/src/common/qkeysequencewidget")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src/common/qkeysequencewidget/src")

if(SG_EXT_UPLOADS)
    include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src/modules/uploader")
    add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/src/modules/uploader")
endif()

if (SG_EXT_EDIT)
    include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src/modules/extedit")
    add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/src/modules/extedit")
endif()

set(SCREENGRAB_SRC
    src/core/main.cpp
    src/core/singleapp.cpp
    src/core/core.cpp
    src/core/config.cpp
    src/core/regionselect.cpp
    src/core/shortcutmanager.cpp
    src/core/modulemanager.cpp
    src/core/ui/configwidget.cpp
    src/core/ui/about.cpp
    src/core/ui/mainwindow.cpp
)

if(SG_DBUS_NOTIFY)
    set(SCREENGRAB_SRC ${SCREENGRAB_SRC} src/core/dbusnotifier.cpp)
endif()

if(X11_FOUND)
    set(SCREENGRAB_SRC ${SCREENGRAB_SRC} src/core/x11utils.cpp)
endif()

set(SCREENGRAB_HDR
    src/core/singleapp.h
)

set(SCREENGRAB_UI
    src/core/ui/configwidget.ui
    src/core/ui/aboutwidget.ui
    src/core/ui/mainwindow.ui
)

# Qt resource file
set(SCREENGRAB_QRC screengrab.qrc)
qt5_add_resources(QRC_SOURCES ${SCREENGRAB_QRC})

message(STATUS "Generating localize ...")

set(SCREENGRAB_CONFIG_FILES
    screengrab.conf
)

set(SCREENGRAB_DESKTOP_FILES_IN
    screengrab.desktop.in
)

lxqt_translate_ts(SCREENGRAB_QMS
    USE_QT5 TRUE
    UPDATE_TRANSLATIONS ${UPDATE_TRANSLATIONS}
    SOURCES
        ${SCREENGRAB_SRC}
        ${SCREENGRAB_UI}
    INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/translations"
)

lxqt_translate_desktop(SCREENGRAB_DESKTOP_FILES
    SOURCES ${SCREENGRAB_DESKTOP_FILES_IN}
)

qt5_translation_loader(SCREENGRAB_QM_LOADER
    "${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/translations"
    ${PROJECT_NAME}
)

# generating executable
add_executable(screengrab
    ${SCREENGRAB_SRC}
    ${SCREENGRAB_UI_H}
    ${QRC_SOURCES}
    ${SCREENGRAB_QMS}
    ${SCREENGRAB_DESKTOP_FILES}
    ${SCREENGRAB_QM_LOADER}
)

if(SG_GLOBALSHORTCUTS)
    if(SG_USE_SYSTEM_QXT)
        target_link_libraries(screengrab ${QXT_QXTCORE_LIB_RELEASE} ${QXT_QXTGUI_LIB_RELEASE})
    else(SG_USE_SYSTEM_QXT)
        target_link_libraries(screengrab qxt)
    endif(SG_USE_SYSTEM_QXT)
endif()

if(SG_EXT_UPLOADS)
    target_link_libraries(screengrab uploader)
endif()

if(SG_EXT_EDIT)
    target_link_libraries(screengrab extedit)
endif()

if(SG_DBUS_NOTIFY)
    target_link_libraries(screengrab Qt5::DBus)
endif()

if (X11_XCB_FOUND)
    add_definitions( -DX11_XCB_FOUND="1")
    target_link_libraries(screengrab ${X11_XCB_LIBRARIES})
endif()

if (XCB_XCB_FOUND)
    add_definitions( -DXCB_XCB_FOUND="1")
    target_link_libraries(screengrab ${XCB_XCB_LIBRARY})
endif()

if (XCB_SHAPE_FOUND)
    add_definitions( -DXCB_SHAPE_FOUND="1")
    target_link_libraries(screengrab ${XCB_SHAPE_LIBRARY})
endif()

if (XCB_XFIXES_FOUND)
    add_definitions( -DXCB_XFOXES_FOUND="1")
    target_link_libraries(screengrab ${XCB_XFIXES_LIBRARY})
endif()

# Link with Network and X11Extras. See pull#86. TODO: Should be optional when upload module is needed.
target_link_libraries(screengrab qkeysequencewidget Qt5::Widgets KF5::WindowSystem Qt5::X11Extras Qt5::Network ${X11_LIBRARIES})

# installing
install(TARGETS screengrab RUNTIME DESTINATION bin)
# install html docs
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/docs/html" DESTINATION "${CMAKE_INSTALL_FULL_DOCDIR}")
# install config files
install(FILES ${SCREENGRAB_CONFIG_FILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME})
# install desktop files
install(FILES ${SCREENGRAB_DESKTOP_FILES} DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
# install pixmap
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/img/screengrab.png" DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/32x32/apps")