forked from jasp-stats/jasp-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
247 lines (217 loc) · 6.58 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
# Configures and builds JASP executable.
#
# Notes:
# - There are way too many Qt libraries are linked, some are not necessary; however,
# this is because `qtdeployqt` is not doing a great job at collecting and deploying
# all the necessary libraries. So, if I don't include some of those, the deployment
# process fails to create a proper package!
# - We can either add the resources using the `.qrc` files, or ask CMake to
# build them for us based on the directory that they are in. This can be
# simplified with some GLOBing, then we can just create a new files, and
# don't worry about keeping the `.qrc` files up-to-date. Alternatively, we can
# maintain the QRC files and add them like this.
#
# set(RESOURCE_FILES
# html/html.qrc
# resources/icons.qrc
# resources/resources.qrc
# qml.qrc)
#
list(APPEND CMAKE_MESSAGE_CONTEXT Desktop)
if(APPLE)
configure_file(${CMAKE_SOURCE_DIR}/Tools/macOS/Info.plist.in
${CMAKE_BINARY_DIR}/Info.plist)
endif()
configure_file(${CMAKE_CURRENT_LIST_DIR}/gui/preferencesmodel.cpp.in
${CMAKE_CURRENT_LIST_DIR}/gui/preferencesmodel.cpp)
message(STATUS "preferencesmodel.cpp is successfully generated...")
file(GLOB_RECURSE HEADER_FILES "${CMAKE_CURRENT_LIST_DIR}/*.h")
file(GLOB_RECURSE SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/*.cpp")
file(GLOB_RECURSE BUNDLE_RESOURCES "${CMAKE_SOURCE_DIR}/Resources/*")
qt_add_executable(
JASP
${SYSTEM_TYPE}
${SOURCE_FILES}
${HEADER_FILES}
${BUNDLE_RESOURCES}
$<$<PLATFORM_ID:Windows>:${CMAKE_CURRENT_LIST_DIR}/icon.rc>
$<$<PLATFORM_ID:Darwin>:${_R_Framework}>
$<$<PLATFORM_ID:Windows>:${CMAKE_SOURCE_DIR}/Desktop/JASP.exe.manifest>
)
set(
QML_IMPORT_PATH
"${PROJECT_SOURCE_DIR}/Desktop/components"
"${PROJECT_SOURCE_DIR}/QMLComponents/components"
CACHE
PATH
"Path used to locate CMake modules by Qt Creator"
FORCE
)
if(IWYU_EXECUTABLE AND RUN_IWYU)
set_target_properties(JASP PROPERTIES CXX_INCLUDE_WHAT_YOU_USE
${IWYU_EXECUTABLE})
endif()
add_custom_command(
TARGET JASP
POST_BUILD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E copy_directory Resources/
${CMAKE_BINARY_DIR}/Resources
BYPRODUCTS ${CMAKE_BINARY_DIR}/Resources
COMMENT "------ Updating the Resources")
add_dependencies(JASP JASPEngine)
if(INSTALL_R_MODULES)
add_dependencies(JASP Modules)
endif()
if(APPLE)
add_dependencies(JASP readstat)
endif()
if(WINDOWS)
# This is added to the build folder that JASP doesn't try to recreate the
# junctions in the build folder, they are there anyway!
execute_process(
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} -E touch "junctions-recreated-successfully.log")
endif()
target_include_directories(
JASP
PUBLIC
${CMAKE_CURRENT_LIST_DIR}
${PROJECT_SOURCE_DIR}/Common
${PROJECT_SOURCE_DIR}/Common/jaspColumnEncoder
${PROJECT_SOURCE_DIR}/CommonData
${PROJECT_SOURCE_DIR}/QMLComponents
# ReadStat
$<$<PLATFORM_ID:Windows>:${RTOOLS_LIBREADSTAT_H}>
${LIBREADSTAT_INCLUDE_DIRS}
# JSONCPP
$<$<PLATFORM_ID:Linux>:${_PKGCONFIG_LIB_JSONCPP_INCLUDEDIR}>
$<$<BOOL:${FLATPAK_USED}>:/app/include/QtCore5Compat>
$<$<BOOL:${FLATPAK_USED}>:/app/include/QtWebEngineQuick>
$<$<BOOL:${FLATPAK_USED}>:/app/include/QtWebEngineCore>
${LIBFREEXL_INCLUDE_DIRS}
)
target_link_libraries(
JASP
PUBLIC
Common
CommonData
QMLComponents
Qt::Core
Qt::Gui
Qt::OpenGL
Qt::Widgets
Qt::Qml
$<$<NOT:$<BOOL:${FLATPAK_USED}>>:Qt::WebEngineQuick>
$<$<BOOL:${FLATPAK_USED}>:/app/lib/$ENV{FLATPAK_ARCH}-linux-gnu/libQt6WebEngineQuick.so>
$<$<BOOL:${FLATPAK_USED}>:/app/lib/$ENV{FLATPAK_ARCH}-linux-gnu/libQt6WebEngineCore.so>
$<$<BOOL:${FLATPAK_USED}>:/app/qml/QtWebEngine/libqtwebenginequickplugin.so>
Qt::WebChannel
Qt::WebChannelQuick
Qt::Svg
Qt::Network
#? Qt::PrintSupport
Qt::Xml
Qt::Sql
Qt::Quick
Qt::QuickLayouts
Qt::QuickControls2
Qt::QuickControls2Impl
Qt::QuickWidgets
$<$<NOT:$<BOOL:${FLATPAK_USED}>>:Qt::Core5Compat>
$<$<BOOL:${FLATPAK_USED}>:/app/lib/$ENV{FLATPAK_ARCH}-linux-gnu/libQt6Core5Compat.so>
Qt::QuickTemplates2
Qt::DBus
Qt::QmlWorkerScript
Qt::LabsFolderListModel
# System
ZLIB::ZLIB
Iconv::Iconv
OpenSSL::SSL
OpenSSL::Crypto
# FreeXL
${LIBFREEXL_LIBRARIES}
$<$<NOT:$<BOOL:${LINUX}>>:freexl::freexl>
# ReadStat -----------------------------------
${LIBREADSTAT_LIBRARIES}
# MinGW's ReadStat
$<$<PLATFORM_ID:Windows>:${RTOOLS_LIBREADSTAT_DLL_A}>
# JSONCPP
#$<$<PLATFORM_ID:Linux>:${_PKGCONFIG_LIB_JSONCPP_LIBRARIES}>
#$<$<PLATFORM_ID:Linux>:${_PKGCONFIG_LIB_JSONCPP_LINK_LIBRARIES}>
# R-Framework --------------------------------
$<$<PLATFORM_ID:Darwin>:${_R_Framework}>
)
target_compile_definitions(JASP PUBLIC JASP_USES_QT_HERE)
if(NOT WINDOWS)
target_compile_options(JASP PUBLIC -Wno-deprecated-declarations)
target_link_libraries(
JASP
PUBLIC
# When using Conan, we need to provide the static libraries directly, for some reason!
${Iconv_LIBRARY_LIST})
endif()
if(LINUX)
if(LINUX_LOCAL_BUILD)
target_compile_definitions(JASP PUBLIC LINUX_LOCAL_BUILD)
endif()
if(FLATPAK_USED)
target_compile_definitions(JASP PUBLIC FLATPAK_USED)
endif()
endif()
file(GLOB_RECURSE HTML_RESOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/html/*")
qt_add_resources(
JASP
"html"
PREFIX
"/html"
BASE
"${CMAKE_CURRENT_LIST_DIR}/html"
FILES
${HTML_RESOURCE_FILES})
file(GLOB_RECURSE TRANSLATION_RESOURCE_FILES
"${CMAKE_CURRENT_LIST_DIR}/translations/*.png")
qt_add_resources(
JASP
"translations"
PREFIX
"/translations"
BASE
"${CMAKE_CURRENT_LIST_DIR}/translations"
FILES
${TRANSLATION_RESOURCE_FILES})
file(GLOB_RECURSE ICONS_RESOURCE_FILES
"${CMAKE_CURRENT_LIST_DIR}/resources/icons/*")
qt_add_resources(
JASP
"icons"
PREFIX
"/"
BASE
"${CMAKE_CURRENT_LIST_DIR}/resources"
FILES
${ICONS_RESOURCE_FILES})
file(GLOB_RECURSE QML_RESOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/components/*")
qt_add_resources(
JASP
"widgets"
PREFIX
"/"
BASE
${CMAKE_CURRENT_LIST_DIR}
FILES
${QML_RESOURCE_FILES})
# and some random stuff
set(RESOURCES_RESOURCE_FILES
"resources/../modules/upgrader/upgrades.json"
"resources/fonts/FiraCode-Retina.ttf" "resources/fonts/FreeSans.ttf")
qt_add_resources(
JASP
"resources"
PREFIX
"/"
BASE
"${CMAKE_CURRENT_LIST_DIR}/resources"
FILES
${RESOURCES_RESOURCE_FILES})
list(POP_BACK CMAKE_MESSAGE_CONTEXT)