forked from lxqt/screengrab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
233 lines (189 loc) · 7.11 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
223
224
225
226
227
228
229
230
231
232
233
cmake_minimum_required(VERSION 2.8.11)
# set project's name
project(screengrab)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5X11Extras REQUIRED)
find_package(Qt5Network REQUIRED)
# for translations
find_package(Qt5LinguistTools)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
# add version define
set(SCREENGRAB_VERSION "1.0.83")
set(SCREENGRAB_VERSION_DEV "1.1-dev")
# set(DEV_BUILD True)
if(SCREENGRAB_VERSION_DEV)
if(DEV_BUILD)
# search git executable
find_package(Git)
if(GIT_FOUND)
# executable git for check HEAD rev hash
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
OUTPUT_VARIABLE GIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
set(VERSION "${SCREENGRAB_VERSION} (${SCREENGRAB_VERSION_DEV}-git-${GIT_HASH})")
else()
set(VERSION "${SCREENGRAB_VERSION} (${SCREENGRAB_VERSION_DEV})")
endif()
elseif(NOT SCREENGRAB_VERSION_DEV)
set(VERSION "${SCREENGRAB_VERSION}")
endif(SCREENGRAB_VERSION_DEV)
add_definitions(-DVERSION="${VERSION}")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
if(${CMAKE_BUILD_TYPE} MATCHES "Release")
add_definitions(-DNDEBUG)
add_definitions(-DQT_NO_DEBUG_OUTPUT)
endif()
message(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Woverloaded-virtual -Wall -Wextra")
add_definitions(-DPREFIX="${CMAKE_INSTALL_PREFIX}")
message(STATUS "Install prefix: " ${CMAKE_INSTALL_PREFIX})
# find libs dir
string (COMPARE EQUAL "${CMAKE_SIZEOF_VOID_P}" "8" IS64BITS)
if(IS64BITS)
set(LIBDIR "lib64")
else()
set(LIBDIR "lib")
endif()
set(SG_LIBDIR "${LIBDIR}/screengrab")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${SG_LIBDIR}")
message(STATUS "Library path: ${CMAKE_INSTALL_RPATH}")
# options
option(SG_GLOBALSHORTCUTS "Enable global shortcuts" OFF)
option(SG_XDG_CONFIG_SUPPORT "Put config files into XDGC_ONFIG_HOME" ON)
option(SG_EXT_UPLOADS "Enable upload screenshots to MediaCrush and imgur" ON)
option(SG_EXT_EDIT "Enable ability to edit screenshots in external editor" ON)
# The following line will add additional finders to CMake without the need to be placed in the CMake install path
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
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_XDG_CONFIG_SUPPORT)
add_definitions( -DSG_XDG_CONFIG_SUPPORT="1")
endif()
if(SG_EXT_UPLOADS)
add_definitions( -DSG_EXT_UPLOADS="1")
endif()
if(SG_EXT_EDIT)
add_definitions( -DSG_EXT_EDIT="1")
endif()
message(STATUS "Global shortcuts support: " ${SG_GLOBALSHORTCUTS})
message(STATUS "XDG_CONFIG_HOME support: " ${SG_XDG_CONFIG_SUPPORT})
message(STATUS "Upload to MediaCrush and imgur support: " ${SG_EXT_UPLOADS})
message(STATUS "Editing screenshots in external editor support: " ${SG_EXT_EDIT})
message(STATUS "Use system Qxt Library: " ${SG_USE_SYSTEM_QXT})
# docs
if(NOT SG_DOCDIR)
set(SG_DOCDIR "screengrab" CACHE STRING "Documentation directory name")
endif()
set(DOCPATH "share/doc/${SG_DOCDIR}" CACHE STRING "Documentation directory name")
message(STATUS "Documentation directory: " ${CMAKE_INSTALL_PREFIX}/${DOCPATH})
add_definitions(-DSG_DOCDIR="${CMAKE_INSTALL_PREFIX}/${DOCPATH}")
set(SG_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/src/")
# qtsingleapplication
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/src/common/singleapp/")
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/src/common/qkeysequencewidget/")
include_directories("${SG_INCLUDE}")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src/common/singleapp")
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/main.cpp
src/core/core.cpp
src/core/config.cpp
src/core/regionselect.cpp
src/core/cmdline.cpp
src/core/shortcutmanager.cpp
src/core/modulemanager.cpp
src/ui/configwidget.cpp
src/ui/about.cpp
src/ui/mainwindow.cpp
src/common/netwm/netwm.cpp
)
set(SCREENGRAB_UI
src/ui/configwidget.ui
src/ui/aboutwidget.ui
src/ui/mainwindow.ui
)
# documentation files
set(DOCS
"${CMAKE_CURRENT_SOURCE_DIR}/docs/ChangeLog.txt"
"${CMAKE_CURRENT_SOURCE_DIR}/docs/LICENSE.txt"
"${CMAKE_CURRENT_SOURCE_DIR}/README.md"
)
# Qt resource file
set(SCREENGRAB_QRC
screengrab.qrc
)
qt5_wrap_ui(SCREENGRAB_UI_H ${SCREENGRAB_UI})
qt5_add_resources(QRC_SOURCES ${SCREENGRAB_QRC})
if(Qt5LinguistTools_FOUND)
message(STATUS "Generating localize ...")
file(GLOB SCREENGRAB_TS ${CMAKE_CURRENT_SOURCE_DIR}/translations/*.ts)
qt5_add_translation(SCREENGRAB_QMS ${SCREENGRAB_TS})
add_custom_target(translations ALL DEPENDS ${SCREENGRAB_QMS})
else()
message(FATAL_ERROR "Could NOT find Qt5LinguistTools")
endif()
add_executable( screengrab ${SCREENGRAB_SRC} ${SCREENGRAB_UI_H} ${QRC_SOURCES} )
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()
target_link_libraries(screengrab qkeysequencewidget singleapp X11 Qt5::Widgets)
# make src.tar.gz
add_custom_target(dist @echo create source package)
set(SCREENGRAB_DIST "screengrab-${SCREENGRAB_VERSION}")
add_custom_command(COMMAND cp
ARGS -R ${CMAKE_CURRENT_SOURCE_DIR} "/tmp/${SCREENGRAB_DIST}"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
TARGET dist
)
ADD_CUSTOM_COMMAND(COMMAND tar
ARGS cvfz "${CMAKE_CURRENT_BINARY_DIR}/${SCREENGRAB_DIST}.tar.gz" --exclude=*~ --exclude-vcs --exclude=localize/*qm --exclude=*.kdev4 --exclude=build --exclude=create-src.sh --exclude=win32 -C "/tmp" "${SCREENGRAB_DIST}"
WORKING_DIRECTORY "/tmp"
TARGET dist
)
add_custom_command(COMMAND rm
ARGS -rf "/tmp/${SCREENGRAB_DIST}"
WORKING_DIRECTORY "/tmp"
TARGET dist
)
# installing
install(TARGETS screengrab RUNTIME DESTINATION bin)
# install txt docs
install(FILES ${DOCS} DESTINATION ${DOCPATH})
# install html docs
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/docs/html/" DESTINATION "${DOCPATH}/html")
# install desktop files
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/screengrab.desktop" DESTINATION share/applications)
# install pixmap
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/img/screengrab.png" DESTINATION share/pixmaps)
# install translations
install(DIRECTORY ${SCREENGRAB_QMS} DESTINATION share/screengrab/localize)