-
Notifications
You must be signed in to change notification settings - Fork 42
/
CMakeLists.txt
222 lines (179 loc) · 6.38 KB
/
CMakeLists.txt
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
cmake_minimum_required(VERSION 3.18.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(UPDATE_TRANSLATIONS "Update source translation translations/*.ts files" OFF)
# Minimum Versions
set(KF6_MINIMUM_VERSION "6.0.0")
set(QT_MINIMUM_VERSION "6.6.0")
set(QTXDG_MINIMUM_VERSION "4.1.0")
find_package(Qt6Network ${QT_MINIMUM_VERSION} REQUIRED)
find_package(Qt6Widgets ${QT_MINIMUM_VERSION} REQUIRED)
find_package(Qt6LinguistTools ${QT_MINIMUM_VERSION} REQUIRED)
find_package(KF6WindowSystem ${KF6_MINIMUM_VERSION} REQUIRED)
# right now we declare it as required
find_package(X11 REQUIRED)
set(HAVE_X11 1)
find_package(
XCB REQUIRED MODULE COMPONENTS
XCB
SHAPE
XFIXES
)
find_package(
X11_XCB REQUIRED MODULE
)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SCREENGRAB_VERSION "2.9.0")
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")
# Although the names, LXQtTranslateTs and LXQtTranslateDesktop, they don't
# bring any dependency on lxqt.
include(LXQtTranslateTs)
include(LXQtTranslateDesktop)
include(Qt6TranslationLoader)
if(SG_EXT_EDIT)
add_definitions( -DSG_EXT_EDIT="1")
find_package(Qt6Xdg ${QTXDG_MINIMUM_VERSION} REQUIRED)
endif()
if(SG_DBUS_NOTIFY)
find_package(Qt6DBus ${QT_MINIMUM_VERSION} REQUIRED)
add_definitions( -DSG_DBUS_NOTIFY="1")
endif()
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}/icons/hicolor/scalable/apps/screengrab.svg")
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_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)
qt6_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
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}
USE_YAML
)
qt6_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_EXT_EDIT)
target_link_libraries(screengrab extedit)
endif()
if(SG_DBUS_NOTIFY)
target_link_libraries(screengrab Qt6::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. See pull#86. TODO: Should be optional when upload module is needed.
target_link_libraries(screengrab qkeysequencewidget Qt6::Widgets KF6::WindowSystem Qt6::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.svg" DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps")
install(FILES screengrab.metainfo.xml
DESTINATION ${CMAKE_INSTALL_DATADIR}/metainfo
)