-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
CMakeLists.txt
333 lines (293 loc) · 12.9 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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
#**************************************************************************
#
# QPrompt
# Copyright (C) 2020-2024 Javier O. Cordero Pérez
#
# This file is part of QPrompt.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#**************************************************************************
cmake_minimum_required(VERSION 3.22)
set(RELEASE_SERVICE_VERSION_MAJOR "2")
set(RELEASE_SERVICE_VERSION_MINOR "0")
set(RELEASE_SERVICE_VERSION_MICRO "0")
set(RELEASE_SERVICE_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE_VERSION_MINOR}.${RELEASE_SERVICE_VERSION_MICRO}")
project(qprompt
VERSION ${RELEASE_SERVICE_VERSION}
DESCRIPTION "Teleprompter software for all video creators"
HOMEPAGE_URL "https://qprompt.app/"
LANGUAGES CXX)
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to create code from Qt designer ui files
set(CMAKE_AUTOUIC ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Leave C++ standard at version 17 to build Ubuntu 18.04 compatible AppImage
set(CMAKE_CXX_STANDARD 17)
# Instruct CMake to run moc automatically when needed
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(QT_DEFAULT_MAJOR_VERSION 6)
# Qt 6.6.2 for Ubuntu 24.10, tho ideally we'd use 6.7.2.
set(QT_MIN_VERSION 6.6.2)
# Enabling newer ECM appears to break AutoMOC...
if (WIN32)
set(ECM_MIN_VERSION 5.83.0)
else()
set(ECM_MIN_VERSION 5.68.0)
endif()
# All other KF should go with the latest versions
set(KF_MIN_VERSION 6.5.0)
if (APPLE)
set(APPLE_SUPPRESS_X11_WARNING ON)
endif()
# ------------------------- BEGIN: lists to maintain manually -------------------------
# Directories where Qt Creator can find modules and Kirigami's QML files
list(APPEND QML_DIRS "build/dist/lib/x86_64-linux-gnu/qml")
list(APPEND KIRIGAMI_DIRS "build/dist/lib/x86_64-linux-gnu/qml/org/kde/kirigami")
# Directories where Qt Creator can find these files on your system.
# (This setting is cached in variable QML_IMPORT_DIR, see below. Delete
# ${BUIL_DIR}/CMakeCache.txt to make make changes here effective.)
if (UNIX AND NOT APPLE AND NOT ANDROID)
list(APPEND QML_DIRS "/usr/lib/x86_64-linux-gnu/qt6/qml")
list(APPEND KIRIGAMI_DIRS "/usr/lib/x86_64-linux-gnu/qml/org/kde/kirigami")
elseif (UNIX AND APPLE)
list(APPEND QML_DIRS "/opt/homebrew/lib/qml")
list(APPEND KIRIGAMI_DIRS "/opt/homebrew/lib/qml/org/kde/kirigami")
elseif (WIN32)
list(APPEND QML_DIRS "C:/CraftRoot/qml")
list(APPEND KIRIGAMI_DIRS "C:/CraftRoot/qml/org/kde/kirigami")
endif()
# ------------------------- END: lists to maintain manually -------------------------
# Prevent adding duplicate values at each run of CMake.
list(REMOVE_DUPLICATES QML_DIRS)
# Tell Qt Creator where to find QML files.
# (The build process will work without this, but no code completion etc..)
# The variable is cached in ${BUILD_DIR}/CMakeCache.txt. We need FORCE to change it there immediately.
set(
QML_IMPORT_PATH ${KIRIGAMI_DIRS}
QML_IMPORT_PATH ${QML_DIRS}
CACHE STRING "Qt Creator 4.1 extra qml import paths"
FORCE
)
if(ANDROID)
set(ANDROID_PACKAGE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/android)
if(NOT ANDROID_ABIS)
set(ANDROID_ABIS "arm64-v8a") # armeabi-v7a
endif()
else()
set(DBINARY_ICONS_RESOURCE ON)
endif()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
endif()
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
# Send compiled program and library binaries to "build/bin"
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
find_package(ECM ${ECM_MIN_VERSION} REQUIRED NO_MODULE)
list(APPEND CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
find_package(QT NAMES Qt6)
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
option(GIT_SUBMODULE "Check submodules during build" ON)
if(GIT_SUBMODULE)
message(STATUS "Updating submodules")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules.")
endif()
endif()
endif()
# Common dependencices
find_package(Qt${QT_VERSION_MAJOR} ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS
Core
Quick
Svg
Gui
QuickControls2
Network
ShaderTools
)
find_package(KF${QT_VERSION_MAJOR} ${KF_MIN_VERSION} REQUIRED COMPONENTS
Kirigami
I18n
CoreAddons
)
# Desktop only dependencies
if(NOT ANDROID AND NOT IOS)
find_package(Qt${QT_VERSION_MAJOR} ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS
Widgets
)
endif()
# Platform specific dependencies
if(ANDROID)
find_package(Qt${QT_VERSION_MAJOR} ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS
AndroidExtras
)
elseif(HAIKU)
# Haiku OS icons look nice
find_package(KF${QT_VERSION_MAJOR} ${KF_MIN_VERSION} REQUIRED COMPONENTS
IconThemes
)
find_package(KF${QT_VERSION_MAJOR}Crash ${REQUIRED_KF${QT_VERSION_MAJOR}_VERSION} CONFIG QUIET)
set_package_properties(KF${QT_VERSION_MAJOR}Crash PROPERTIES
DESCRIPTION "Graceful handling of application crashes."
TYPE OPTIONAL
)
# Windows, MacOS, and FreeBSD
else()
find_package(KF${QT_VERSION_MAJOR}Crash ${REQUIRED_KF${QT_VERSION_MAJOR}_VERSION} COMPONENTS)
set_package_properties(KF${QT_VERSION_MAJOR}Crash PROPERTIES
DESCRIPTION "Graceful handling of application crashes."
TYPE OPTIONAL
)
find_package(QHotkey 1.5.0 COMPONENTS
QHotkey
)
# # KDMacTouchBar (Mac only)
# if(APPLE AND NOT IOS)
# if (NOT EXISTS "${PROJECT_SOURCE_DIR}/3rdparty/KDMacTouchBar/CMakeLists.txt")
# message(FATAL_ERROR "KDMacTouchBar was not downloaded. GIT_SUBMODULE was turned off or failed.")
# endif()
# add_subdirectory("3rdparty/KDMacTouchBar" build/kdmactouchbar)
# endif()
endif()
if (WIN32 OR UNIX) # AND NOT ANDROID
include(KDEInstallDirs)
include(KDECMakeSettings)
include(ECMInstallIcons)
include(ECMAddAppIcon)
include(ECMGenerateHeaders)
endif()
include(KDECompilerSettings NO_POLICY_SCOPE)
include(KDEClangFormat)
include(ECMQtDeclareLoggingCategory)
include(ECMSetupVersion)
include(ECMSourceVersionControl)
include(ECMPoQmTools)
include(FeatureSummary)
if (${ECM_SOURCE_UNDER_VERSION_CONTROL})
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Get the latest abbreviated commit hash of the working branch
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
add_definitions(-DGIT_COMMIT_HASH="${GIT_COMMIT_HASH}")
add_definitions(-DGIT_BRANCH="${GIT_BRANCH}")
else()
add_definitions(-DGIT_COMMIT_HASH="${PROJECT_VERSION}")
add_definitions(-DGIT_BRANCH="Stable")
endif()
ecm_setup_version(${PROJECT_VERSION}
VARIABLE_PREFIX QPROMPT
VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/qprompt_version.h"
)
# LICENSING
set(LICENSE_FILE "COPYING")
set(README_FILE "README.md")
set(DESCRIPTION_FILE "DESCRIPTION.txt")
list(APPEND DOCS ${LICENSE_FILE} ${README_FILE} ${DESCRIPTION_FILE} "COPYING.ASSETS")
set(DOC_INSTALL_DIR "share/doc/qprompt")
add_subdirectory(src build)
ki18n_install(po)
if (ANDROID)
configure_file(${ANDROID_PACKAGE_SOURCE_DIR}/version.gradle.in ${CMAKE_BINARY_DIR}/version.gradle)
endif()
if (UNIX AND NOT APPLE AND NOT ANDROID)
set(DOC_INSTALL_DIR "share/doc/qprompt")
set(MAN_INSTALL_DIR "share/man/")
install(FILES docs/manpage/qprompt.1 DESTINATION ${MAN_INSTALL_DIR}/man1)
endif()
if (WIN32 OR UNIX AND NOT APPLE) # AND NOT ANDROID
install(FILES com.cuperino.qprompt.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR})
install(PROGRAMS com.cuperino.qprompt.desktop DESTINATION ${KDE_INSTALL_APPDIR})
install(FILES ${DOCS} DESTINATION ${DOC_INSTALL_DIR})
endif()
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
# CPACK: General Settings
set(CPACK_PACKAGE_VENDOR "Javier O. Cordero Pérez")
set(CPACK_PACKAGE_CONTACT "[email protected]")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/${DESCRIPTION_FILE}")
set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/${README_FILE}")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/${LICENSE_FILE}") # Displays the license on some installers
set(CPACK_VERBATIM_VARIABLES On)
set(CPACK_MONOLITHIC_INSTALL On)
set(CPACK_RPM_PACKAGE_LICENSE "GPLv3") # Also used by FreeBSD generator
set(ICONS_DIR "${CMAKE_SOURCE_DIR}/src/icons")
set(IMAGES_DIR "${CMAKE_SOURCE_DIR}/src/images")
set(COMPRESION_TYPE "xz")
# CPACK: Archive generator settings
set(CPACK_THREADS 0)
set(CPACK_ARCHIVE_THREADS 0)
if(UNIX AND NOT ANDROID AND NOT APPLE)
set(CPACK_GENERATOR "DEB")
# CPACK: DEB specific settings
set(CPACK_DEBIAN_PACKAGE_SECTION "Multimedia")
set(CPACK_DEBIAN_COMPRESSION_TYPE ${COMPRESION_TYPE})
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt6svg6 (>= 6.6.2), qml6-module-qt-labs-platform (>=6.6.2), qml6-module-qtqml (>=6.6.2), qml6-module-qtqml-models (>=6.6.2), qml6-module-qtqml-statemachine (>=6.6.2), qml6-module-qtquick-controls (>=6.6.2), qml6-module-qtquick-dialogs (>=6.6.2), qml6-module-qtquick-shapes (>=6.6.2), libkf6coreaddons6 (>= 6.5.0), kf6-kirigami (>= 6.5.0), libkf6i18n6 (>= 6.5.0), libkf6crash6 (>= 6.5.0)")
# CPACK: RPM specific settings
set(CPACK_RPM_PACKAGE_GROUP "Multimedia/Video")
set(CPACK_RPM_PACKAGE_REQUIRES "qt6-qtbase >= 6.7.2, qt6-qtbase-gui >= 6.7.2, qt6-qtdeclarative >= 6.7.2, qt6-qtsvg >= 6.7.2, qt6-qtquickcontrols >= 6.7.2, qt6-qtquickcontrols2 >= 6.7.2, kf6-kcoreaddons >= 6.5.0, kf6-ki18n >= 6.5.0, kf6-kirigami >= 6.5.0, kf6-kcrash >= 6.5.0")
set(CPACK_RPM_COMPRESSION_TYPE ${COMPRESION_TYPE})
elseif(WIN32)
set(CPACK_GENERATOR "INNOSETUP")
set(CPACK_PACKAGE_EXECUTABLES "QPrompt" "QPrompt")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/${LICENSE_FILE}")
set(CPACK_NSIS_EXECUTABLES_DIRECTORY "${BIN_INSTALL_DIR}")
set(CPACK_NSIS_MUI_ICON "${ICONS_DIR}/qprompt.ico")
set(CPACK_PACKAGE_ICON "${IMAGES_DIR}/installer.bmp")
set(CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP "${IMAGES_DIR}/welcome.bmp")
set(CPACK_NSIS_MUI_UNWELCOMEFINISHPAGE_BITMAP "${IMAGES_DIR}/welcome.bmp")
set(CPACK_NSIS_MUI_HEADERIMAGE "${IMAGES_DIR}/header.bmp")
set(CPACK_NSIS_CONTACT ${CPACK_PACKAGE_CONTACT})
set(CPACK_NSIS_INSTALLED_ICON_NAME "qprompt${CMAKE_EXECUTABLE_SUFFIX}")
set(CPACK_NSIS_MENU_LINKS
"${CMAKE_SOURCE_DIR}/${LICENSE_FILE}" "License"
"${CMAKE_SOURCE_DIR}/${README_FILE}" "Readme"
)
set(CPACK_NSIS_MUI_FINISHPAGE_RUN "${CPACK_NSIS_INSTALLED_ICON_NAME}")
set(InstallRequiredSystemLibraries On)
elseif(APPLE AND NOT IOS)
set(CPACK_GENERATOR "DragNDrop")
set(CPACK_DMG_FORMAT "UDBZ")
set(CPACK_DMG_VOLUME_NAME "QPrompt")
set(CPACK_BUNDLE_NAME "QPrompt")
set(CPACK_BUNDLE_ICON "${ICONS_DIR}/qprompt.icns")
# set(CPACK_BUNDLE_PLIST "Info.plist")
set(CPACK_SYSTEM_NAME "OSX")
set(CPACK_PACKAGE_FILE_NAME "QPrompt-${PROJECT_VERSION}")
set(CPACK_PACKAGE_ICON "${ICONS_DIR}/qprompt.icns")
set(CPACK_DMG_SLA_USE_RESOURCE_FILE_LICENSE ${LICENSE_FILE})
#set(CPACK_DMG_DS_STORE "${IMAGES_DIR}/DSStore")
set(CPACK_DMG_BACKGROUND_IMAGE "${IMAGES_DIR}/DMGBackground.png")
elseif(BSD AND NOT APPLE)
set(CPACK_FREEBSD_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT})
set(CPACK_FREEBSD_PACKAGE_ORIGIN "multimedia")
set(CPACK_FREEBSD_PACKAGE_CATEGORIES "devel/qt6-base, x11-toolkits/qt6-declarative, graphics/qt6-svg, x11-toolkits/qt6-shadertools, multimedia/qt6-multimedia, devel/kf6-kcoreaddons, devel/kf6-ki18n, x11-toolkits/kf6-kirigami, devel/kf6-kcrash, x11-themes/kf6-kiconthemes, x11-toolkits/qhotkey")
endif()
include(CPack)
endif()
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) # INCLUDE_QUIET_PACKAGES
file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h *.hpp)
kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})