-
Notifications
You must be signed in to change notification settings - Fork 435
/
CMakeLists.txt
248 lines (196 loc) · 9.01 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
cmake_minimum_required(VERSION 3.16)
# ==========================================================================
# OpenBoard cmake build file
#
# Most important configuration variables:
# CMAKE_INSTALL_PREFIX
# Path to install prefix, defaults to /usr/local (see cmake documentation)
# Typically set to /usr or /opt
# QT_VERSION
# Qt Version to use
# Set to empty, 5 or 6, defaults to auto-selection with preference to 5
#
# Typical invocation
# cmake -S <srcdir> -B <builddir> -DCMAKE_INSTALL_PREFIX:PATH=/usr
# or
# cmake -S <srcdir> -B <builddir> -DCMAKE_INSTALL_PREFIX:PATH=/opt
#
# Build
# cd <builddir>
# cmake --build . [-j<n>]
#
# Package
# cpack -G <DEB|RPM>
# ==========================================================================
# ==========================================================================
# Basic project information
# ==========================================================================
include(cmake/Version.cmake)
project(openboard
VERSION ${VERSION_NUMBER}
DESCRIPTION "OpenBoard is an open source cross-platform interactive white board application designed primarily for use in schools. It was originally forked from Open-Sankoré, which was itself based on Uniboard."
HOMEPAGE_URL "https://www.openboard.org"
LANGUAGES CXX
)
add_compile_definitions(UBVERSION="${VERSION}")
# ==========================================================================
# Configuration options
# ==========================================================================
set(QT_VERSION "" CACHE STRING "Qt major version number to use - empty, 5 or 6")
# Internal setting
set(QAPPLICATION_CLASS QApplication CACHE STRING "Inheritance class for SingleApplication - do not change")
# ==========================================================================
# Non-source file locations
# ==========================================================================
set(OPENBOARD_QRC_FILE resources/OpenBoard.qrc)
set(OPENBOARD_FORMS_DIR resources/forms src/web/simplebrowser)
set(OPENBOARD_TS_DIR resources/i18n)
set(OPENBOARD_FONT_DIR resources/customizations resources/fonts)
set(OPENBOARD_ETC_DIR resources/etc)
set(OPENBOARD_LIBRARY_DIR resources/library)
set(OPENBOARD_STARTUP_HINTS resources/startupHints)
set(OPENBOARD_ETC_FILE ${OPENBOARD_ETC_DIR}/OpenBoard.config
${OPENBOARD_ETC_DIR}/OpenBoard.css
${OPENBOARD_ETC_DIR}/widgets.md5sum)
set(OPENBOARD_TEMPLATE_FILE ${OPENBOARD_ETC_DIR}/asyncAPI.js
${OPENBOARD_ETC_DIR}/intranet-podcast-metadata.template
${OPENBOARD_ETC_DIR}/npapi-wrapper.config.xml)
set(OPENBOARD_ICON_FILE resources/images/ch.openboard.OpenBoard.svg)
set(OPENBOARD_DESKTOP_FILE resources/linux/ch.openboard.OpenBoard.desktop)
set(OPENBOARD_MIMETYPE_FILE resources/linux/ch.openboard.openboard-ubz.xml)
set(OPENBOARD_MIMEICON_FILE resources/linux/ch.openboard.application-ubz.svg)
# ==========================================================================
# Basic compiler settings
# ==========================================================================
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to use - defaults to C++17")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
list(APPEND CMAKE_AUTOUIC_SEARCH_PATHS
${OPENBOARD_FORMS_DIR}
)
message(STATUS "Using C++" ${CMAKE_CXX_STANDARD})
# OpenMP support
include(FindOpenMP)
if(OPENMP_FOUND)
string(APPEND CMAKE_CXX_FLAGS " " ${OpenMP_CXX_FLAGS})
endif()
# ==========================================================================
# Target and dependencies
#
# Note: the executable is using lowercase on all platforms
# ==========================================================================
add_executable(${PROJECT_NAME})
# manage dependencies
include(cmake/DependencyQt.cmake)
include(cmake/DependencyOpenSSL.cmake)
include(cmake/DependencyPoppler.cmake)
include(cmake/DependencyZlib.cmake)
include(cmake/DependencyQuaZip.cmake)
include(cmake/DependencyFFmpeg.cmake)
include(cmake/DependencyX11.cmake)
# add source path to include directories
target_include_directories(${PROJECT_NAME} PRIVATE
src
)
# add sources from subdirectories
add_subdirectory(src/adaptors)
add_subdirectory(src/api)
add_subdirectory(src/board)
add_subdirectory(src/core)
add_subdirectory(src/desktop)
add_subdirectory(src/document)
add_subdirectory(src/domain)
add_subdirectory(src/frameworks)
add_subdirectory(src/globals)
add_subdirectory(src/gui)
add_subdirectory(src/network)
add_subdirectory(src/pdf)
add_subdirectory(src/pdf-merger)
add_subdirectory(src/podcast)
add_subdirectory(src/singleapplication)
add_subdirectory(src/tools)
add_subdirectory(src/web)
add_subdirectory(plugins/cffadaptor/src)
add_subdirectory(resources/forms)
# statically link singleapplication
target_link_libraries(${PROJECT_NAME}
SingleApplication::SingleApplication
)
# ==========================================================================
# Resources
# ==========================================================================
if(Qt5_VERSION AND Qt5_VERSION VERSION_LESS "5.15")
qt5_add_resources(OPENBOARD_RESOURCES ${OPENBOARD_QRC_FILE})
else()
qt_add_resources(OPENBOARD_RESOURCES ${OPENBOARD_QRC_FILE})
endif()
target_sources(${PROJECT_NAME} PRIVATE ${OPENBOARD_RESOURCES})
# ==========================================================================
# Translations
# ==========================================================================
file(GLOB OPENBOARD_TS_FILES ${OPENBOARD_TS_DIR}/*.ts)
set_source_files_properties(${OPENBOARD_TS_FILES} PROPERTIES OUTPUT_LOCATION ${PROJECT_BINARY_DIR}/i18n)
if(Qt5_VERSION AND Qt5_VERSION VERSION_LESS "5.15")
qt5_add_translation(QM_FILES ${OPENBOARD_TS_FILES})
else()
qt_add_translation(QM_FILES ${OPENBOARD_TS_FILES})
endif()
target_sources(${PROJECT_NAME} PRIVATE ${QM_FILES} ${OPENBOARD_TS_FILES})
# ==========================================================================
# Installation
# ==========================================================================
include(GNUInstallDirs)
# set relative install paths
if(CMAKE_INSTALL_PREFIX STREQUAL "/opt")
set(OPENBOARD_INSTALL_SYSCONFDIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/etc)
set(OPENBOARD_INSTALL_DATADIR ${PROJECT_NAME})
set(CMAKE_INSTALL_BINDIR "/usr/bin")
set(CMAKE_INSTALL_DATAROOTDIR "/usr/share")
else()
set(SYSCONF_INSTALL_DIR ${CMAKE_INSTALL_FULL_SYSCONFDIR} CACHE PATH
"Install directory for system-wide configuration files")
set(OPENBOARD_INSTALL_SYSCONFDIR ${SYSCONF_INSTALL_DIR}/${PROJECT_NAME})
set(OPENBOARD_INSTALL_DATADIR ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME})
endif()
# set absolute install paths
set(OPENBOARD_ETC_PREFIX "${OPENBOARD_INSTALL_SYSCONFDIR}")
set(OPENBOARD_APP_PREFIX "${CMAKE_INSTALL_PREFIX}/${OPENBOARD_INSTALL_DATADIR}")
set(OPENBOARD_TPL_PREFIX "${OPENBOARD_APP_PREFIX}/template")
message(STATUS "OpenBoard ETC_PREFIX is " ${OPENBOARD_ETC_PREFIX})
message(STATUS "OpenBoard APP_PREFIX is " ${OPENBOARD_APP_PREFIX})
message(STATUS "OpenBoard TPL_PREFIX is " ${OPENBOARD_TPL_PREFIX})
target_compile_definitions(${PROJECT_NAME} PRIVATE
OPENBOARD_FHS_LAYOUT
OPENBOARD_ETC_PREFIX=${OPENBOARD_ETC_PREFIX}
OPENBOARD_APP_PREFIX=${OPENBOARD_APP_PREFIX}
OPENBOARD_TPL_PREFIX=${OPENBOARD_TPL_PREFIX}
)
# install files
install(TARGETS ${PROJECT_NAME} RUNTIME)
install(DIRECTORY ${OPENBOARD_FONT_DIR} DESTINATION ${OPENBOARD_INSTALL_DATADIR})
install(DIRECTORY ${OPENBOARD_LIBRARY_DIR} DESTINATION ${OPENBOARD_INSTALL_DATADIR})
install(DIRECTORY ${OPENBOARD_STARTUP_HINTS} DESTINATION ${OPENBOARD_INSTALL_DATADIR})
install(DIRECTORY ${PROJECT_BINARY_DIR}/i18n DESTINATION ${OPENBOARD_INSTALL_DATADIR})
install(FILES ${OPENBOARD_ETC_FILE} DESTINATION ${OPENBOARD_INSTALL_SYSCONFDIR})
install(FILES ${OPENBOARD_TEMPLATE_FILE} DESTINATION ${OPENBOARD_INSTALL_DATADIR}/template)
install(FILES ${OPENBOARD_ICON_FILE} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps)
install(FILES ${OPENBOARD_DESKTOP_FILE} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications)
install(FILES ${OPENBOARD_MIMETYPE_FILE} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/mime/packages)
install(FILES ${OPENBOARD_MIMEICON_FILE} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/mimetypes)
# ==========================================================================
# Packaging
# ==========================================================================
include(InstallRequiredSystemLibraries)
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_VERSION "${VERSION}")
set(CPACK_PACKAGE_CONTACT "The OpenBoard team")
set(CPACK_STRIP_FILES TRUE)
# Debian specific settings
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
set(CPACK_DEBIAN_PACKAGE_SUGGESTS onboard)
# RPM specific settings
set(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
set(CPACK_RPM_PACKAGE_SUGGESTS onboard)
# create packager
include(CPack)