forked from variar/klogg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
313 lines (260 loc) · 8.63 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
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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
cmake_minimum_required(VERSION 3.12)
project(
klogg
VERSION 23.08.0
DESCRIPTION "klogg log viewer"
LANGUAGES C CXX ASM
)
set(PROJECT_HOMEPAGE_URL "https://github.com/variar/klogg")
string(TIMESTAMP PRODUCT_CURRENT_YEAR "%Y")
set(COMPANY "Anton Filimonov")
set(COPYRIGHT "Copyright (c) ${PRODUCT_CURRENT_YEAR} Nicolas Bonnefon, Anton Filimonov and other contributors.")
set(IDENTIFIER "com.github.variar.klogg")
set(PROJECT_DESCRIPTION "${PROJECT_NAME} log viewer")
option(KLOGG_BUILD_TESTS "Build tests" ON)
option(KLOGG_USE_LTO "Use link time optimization" ON)
option(KLOGG_USE_SENTRY "Use Sentry" OFF)
option(KLOGG_GENERIC_CPU "Build for generic CPU" OFF)
option(KLOGG_OSX_DEPLOYMENT_TARGET "Override target MacOS version" "")
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(KLOGG_ARCH 32)
else()
set(KLOGG_ARCH 64)
endif()
if(WIN32)
if(KLOGG_ARCH EQUAL 64)
option(KLOGG_USE_HYPERSCAN "Use Hyperscan" ON)
else()
option(KLOGG_USE_HYPERSCAN "Use Hyperscan" OFF)
endif()
else()
option(KLOGG_USE_HYPERSCAN "Use Hyperscan" ON)
endif()
set(BUILD_VERSION
$ENV{KLOGG_VERSION}
CACHE STRING "build version"
)
set(BUILD_NUMBER
""
CACHE STRING "build number"
)
set(NOTICE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/NOTICE)
set(COPYING_FILE ${CMAKE_CURRENT_SOURCE_DIR}/COPYING)
set(README_FILE ${CMAKE_CURRENT_SOURCE_DIR}/README.md)
set(DOCUMENTATION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/DOCUMENTATION.md)
set(DOCUMENTATION_HTML ${CMAKE_BINARY_DIR}/generated/documentation.html)
set(DOCUMENTATION_RESOURCE ${CMAKE_BINARY_DIR}/generated/documentation.qrc)
if(WIN32)
set(ICON_NAME klogg.ico)
elseif(APPLE)
set(ICON_NAME klogg.icns)
endif()
if(NOT
${ICON_NAME}
STREQUAL
""
)
set(ICON_FILE ${CMAKE_CURRENT_SOURCE_DIR}/Resources/${ICON_NAME})
endif()
if(MSVC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.14)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /experimental:external /external:W0 ")
set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "/external:I ")
endif()
set(out_dir "${CMAKE_BINARY_DIR}/output")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${out_dir}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${out_dir}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${out_dir}")
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
#set(CMAKE_CXX_EXTENSIONS OFF)
include(StandardProjectSettings)
include(ucm)
include(prepare_version)
include(FindPkgConfig)
include(GNUInstallDirs)
if(MSVC)
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(
REGEX
REPLACE "/W[0-4]"
"/W4"
CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS}"
)
else(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
if(CMAKE_C_FLAGS MATCHES "/W[0-4]")
string(
REGEX
REPLACE "/W[0-4]"
"/W4"
CMAKE_C_FLAGS
"${CMAKE_C_FLAGS}"
)
else(CMAKE_C_FLAGS MATCHES "/W[0-4]")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
endif(CMAKE_C_FLAGS MATCHES "/W[0-4]")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj ")
else()
ucm_add_flags(CXX "-fno-sized-deallocation -fno-omit-frame-pointer")
ucm_add_flags(C CXX "-mmmx -msse -msse2 -msse3 -mssse3 -mpopcnt")
if(KLOGG_GENERIC_CPU)
ucm_add_flags(C CXX "-march=x86-64 -mtune=generic")
else()
ucm_add_flags(C CXX "-march=native -mtune=generic")
endif()
endif(MSVC)
if(WIN32)
set(SYMS_TOOLS ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/dump_syms/win)
elseif(APPLE)
set(SYMS_TOOLS ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/dump_syms/mac)
else()
set(SYMS_TOOLS ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/dump_syms/linux)
endif()
message("Dump symbols tools path ${SYMS_TOOLS}")
# standard compiler warnings
# Link this 'library' to use the warnings specified in CompilerWarnings.cmake
include(CompilerWarnings)
add_library(project_warnings INTERFACE)
set_project_warnings(project_warnings)
# Link this 'library' to set the c++ standard / compile-time options requested
include(CompilerFlags)
add_library(project_options INTERFACE)
set_project_compile_flags(project_options)
# sanitizer options if supported by compiler
include(Sanitizers)
enable_sanitizers(project_options)
# allow for static analysis options
include(StaticAnalyzers)
ucm_print_flags()
find_package(
QT
NAMES
Qt6
Qt5
COMPONENTS Core
Widgets
Concurrent
Network
Xml
REQUIRED
)
find_package(
Qt${QT_VERSION_MAJOR}
COMPONENTS Core
Widgets
Concurrent
Network
Xml
REQUIRED
)
set(KLOGG_QT_VERSION ${Qt${QT_VERSION_MAJOR}Core_VERSION})
message("Qt version ${KLOGG_QT_VERSION}")
message("LTO ${KLOGG_USE_LTO}")
if(APPLE)
if(${KLOGG_OSX_DEPLOYMENT_TARGET})
set(CMAKE_OSX_DEPLOYMENT_TARGET ${KLOGG_OSX_DEPLOYMENT_TARGET})
message("OSX target ${CMAKE_OSX_DEPLOYMENT_TARGET}")
endif()
endif()
set(CMAKE_AUTOMOC OFF)
set(CMAKE_INCLUDE_CURRENT_DIR OFF)
set(BUILD_SHARED_LIBS OFF)
add_custom_target(ci_build)
add_subdirectory(3rdparty)
add_subdirectory(src)
add_subdirectory(website)
enable_testing()
add_test(NAME klogg_smoke COMMAND klogg -platform offscreen -v)
if(${KLOGG_BUILD_TESTS})
add_subdirectory(tests)
endif()
# Installation and packaging
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY true)
set(CPACK_SOURCE_IGNORE_FILES "build_root;.git")
set(CPACK_OUTPUT_FILE_PREFIX "packages")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${PROJECT_DESCRIPTION})
set(CPACK_PACKAGE_VENDOR ${COMPANY})
set(CPACK_PACKAGE_CONTACT "[email protected]")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/packaging/description.txt")
set(CPACK_RESOURCE_FILE_LICENSE "${COPYING_FILE}")
set(CPACK_PACKAGE_VERSION
"${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}.${PROJECT_VERSION_TWEAK}"
)
set(CPACK_PACKAGE_ICON "${ICON_FILE}")
if(UNIX)
include(InstallRequiredSystemLibraries)
set(CPACK_STRIP_FILES "bin/klogg")
if(APPLE)
set(CPACK_GENERATOR "DragNDrop")
set(CPACK_DMG_FORMAT "UDBZ")
set(CPACK_DMG_VOLUME_NAME "${PROJECT_NAME}")
set(CPACK_SYSTEM_NAME "OSX")
set(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_CURRENT_SOURCE_DIR}/packaging/osx/dmg_background.tif")
set(CPACK_DMG_DS_STORE_SETUP_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/packaging/osx/dmg_setup.scpt")
else()
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/app/images/hicolor/16x16/klogg.png
DESTINATION share/icons/hicolor/16x16/apps
)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/app/images/hicolor/32x32/klogg.png
DESTINATION share/icons/hicolor/32x32/apps
)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/app/images/hicolor/48x48/klogg.png
DESTINATION share/icons/hicolor/48x48/apps
)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/app/images/hicolor/scalable/klogg.svg
DESTINATION share/icons/hicolor/scalable/apps
)
install(
FILES ${COPYING_FILE}
${NOTICE_FILE}
${README_FILE}
${DOCUMENTATION_HTML}
${DOCUMENTATION_FILE}
DESTINATION ${CMAKE_INSTALL_DOCDIR}
)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/packaging/linux/klogg.desktop DESTINATION share/applications)
set(CPACK_GENERATOR DEB)
#deb
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
set(CPACK_DEBIAN_PACKAGE_SECTION "utils")
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "http://github.com/variar/klogg")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Anton Filimonov <${CPACK_PACKAGE_CONTACT}>")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS YES)
#RPM
set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64")
set(CPACK_RPM_PACKAGE_LICENSE "GPLv3")
set(CPACK_RPM_PACKAGE_AUTOREQ YES)
#set(CPACK_RPM_PACKAGE_REQUIRES "qt5-qtbase >= ${KLOGG_QT_VERSION}")
set(CPACK_RPM_PACKAGE_URL "http://github.com/variar/klogg")
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION
/usr/share/applications
/usr/share/icons
/usr/share/icons/hicolor
/usr/share/icons/hicolor/16x16
/usr/share/icons/hicolor/16x16/apps
/usr/share/icons/hicolor/32x32
/usr/share/icons/hicolor/32x32/apps
/usr/share/icons/hicolor/scalable
/usr/share/icons/hicolor/scalable/apps
)
endif()
include(CPack)
endif()
# for IDE grouping
add_custom_target(
installation
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/packaging/windows/klogg.nsi
${CMAKE_CURRENT_SOURCE_DIR}/packaging/linux/klogg.desktop
${CMAKE_CURRENT_SOURCE_DIR}/cmake/MacOSXBundleInfo.plist.in
)
add_custom_target(
klogg_docs
SOURCES ${README_FILE}
${COPYING_FILE}
${NOTICE_FILE}
${DOCUMENTATION_FILE}
)
add_custom_target(klogg_stuff SOURCES .clang-format .clang-tidy .cmake-format)