-
Notifications
You must be signed in to change notification settings - Fork 34
/
CMakeLists.txt
449 lines (386 loc) · 13.5 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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
cmake_minimum_required(VERSION 3.14)
project(Strategr)
set(CMAKE_CXX_STANDARD 17)
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost COMPONENTS filesystem REQUIRED)
find_package(Catch2 REQUIRED)
find_package(Qt5 COMPONENTS Widgets Test REQUIRED)
find_library(utf8Proc_LIBRARY_PATH libutf8proc.a utf8proc.lib utf8proc)
if (APPLE)
find_package(Qt5 COMPONENTS MacExtras REQUIRED)
find_library(Sparkle_FRAMEWORK_PATH Sparkle)
add_compile_options("-fobjc-arc")
endif ()
if (WIN32)
find_package(Qt5 COMPONENTS WinExtras REQUIRED)
find_library(WinSparkle_PATH WinSparkle)
endif ()
include_directories(.)
include_directories(core)
include_directories(core/apple)
include_directories(ui)
include_directories(utility)
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
set(CMAKE_MODULE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules
${CMAKE_MODULE_PATH})
include(GenerateVersionFile)
if (APPLE)
set(CORE_PLATFORM_FILES
core/apple/STGCalendarManager.m
core/apple/STGCalendarManager.h
core/apple/STGCalendarExporter.h
core/apple/STGCalendarExporter.mm
core/apple/STGCalendarImporter.mm
core/apple/STGCalendarImporter.h
core/apple/STGCalendarImportViewModel.h
core/apple/STGCalendarImportViewModel.m
core/apple/STGCalendarExportViewModel.h
core/apple/STGCalendarExportViewModel.m
core/apple/color.mm
core/apple/stgstring.mm
core/apple/file_bookmark.mm)
endif ()
set(CORE ${CORE_PLATFORM_FILES}
core/version.h
${CORE_VERSION_FILE}
core/activity.cpp
core/activity.h
core/strategy.cpp
core/strategy.h
core/activityinvalidpropertyexception.cpp
core/activityinvalidpropertyexception.h
core/activitylist.cpp
core/activitylist.h
core/privatelist.h
core/notifiableonchange.h
core/timeslot.cpp
core/timeslot.h
core/timeslotsstate.cpp
core/timeslotsstate.h
core/sessionslist.cpp
core/sessionslist.h
core/streamablelist.h
core/strategyhistory.cpp
core/strategyhistory.h
core/session.cpp
core/dragoperation.cpp
core/dragoperation.h
core/resizeoperation.cpp
core/resizeoperation.h
core/overview.cpp
core/overview.h
core/time_utils.cpp
core/time_utils.h
core/json.cpp
core/json.h
core/currenttimemarker.cpp
core/currenttimemarker.h
core/geometry.h
core/notifier.cpp
core/notifier.h
core/utility.h
core/mousehandler.cpp
core/mousehandler.h
core/mousehandleroperations.h
core/selection.cpp
core/selection.h
core/event.cpp
core/event.h
core/color.cpp
core/color.h
core/theme.cpp
core/theme.h
core/timer.cpp
core/timer.h
core/action.hpp
core/actioncenter.cpp
core/actioncenter.h
core/stgstring.cpp
core/stgstring.h
core/persistent.cpp
core/persistent.h
core/notifications.cpp
core/notifications.h
core/file_bookmark.cpp
core/file_bookmark.h)
set(CORE_TESTS
core/tests/strategy_settings_test.cpp
core/tests/strategy_timeslots_test.cpp
core/tests/strategy_activities_slots_interaction_test.cpp
core/tests/strategy_history_test.cpp
core/tests/json_tests.cpp
core/tests/persistent_test.cpp
core/tests/time_utils_test.cpp
core/tests/notifier_immeadiate_test.cpp
core/tests/notifier_scheduled_test.cpp)
set(CORE_LIBRARIES ${utf8Proc_LIBRARY_PATH})
set(UI
ui/mainwindow.cpp
ui/mainwindow.h
ui/windowgeometrymanager.cpp
ui/windowgeometrymanager.h
ui/applicationmenu.cpp
ui/applicationmenu.h
ui/mainscene.cpp
ui/mainscene.cpp
ui/mainscene.h
third-party/slidingstackedwidget.cpp
third-party/slidingstackedwidget.h
ui/sessionsmainwidget.cpp
ui/sessionsmainwidget.h
ui/activitylistwidget.cpp
ui/activitylistwidget.h
ui/activitywidget.cpp
ui/activitywidget.h
ui/strategysettingswidget.cpp
ui/strategysettingswidget.h
ui/slotboardwidget.cpp
ui/slotboardwidget.h
ui/slidinganimator.cpp
ui/slidinganimator.h
ui/slotswidget.cpp
ui/slotboardwidget.h
ui/slotruler.cpp
ui/slotruler.h
ui/sessionwidget.cpp
ui/sessionwidget.h
ui/selectionwidget.cpp
ui/selectionwidget.h
ui/navbar.cpp
ui/navbar.h
ui/colorpicker.cpp
ui/colorpicker.h
ui/colorpickeritem.cpp
ui/colorpicker.h
ui/enterpresseater.cpp
ui/mainscene.h
ui/activityeditormenu.cpp
ui/activityeditormenu.h
ui/currenttimemarkerwidget.cpp
ui/currenttimemarkerwidget.h
ui/reactivelist.hpp
ui/currentsessionwidget.cpp
ui/currentsessionwidget.h
ui/abstractspinboxdecorator.cpp
ui/abstractspinboxdecorator.h
ui/alert.cpp
ui/alert.h
ui/application.cpp
ui/application.h
ui/rowwidget.cpp
ui/rowwidget.h
ui/coloredlabel.cpp
ui/coloredlabel.h
ui/colorprovider.cpp
ui/colorprovider.h
ui/macoswindow.h
ui/cursorprovider.cpp
ui/cursorprovider.h
ui/separator.cpp
ui/separator.h
ui/aboutwindow.cpp
ui/aboutwindow.h
ui/applicationicon.cpp
ui/applicationicon.h
ui/overviewwidget.cpp
ui/overviewwidget.h
ui/searchboxwidget.cpp
ui/searchboxwidget.h
ui/dynamicpalette.cpp
ui/dynamicpalette.h
ui/iconwidget.cpp
ui/iconwidget.h
ui/slotboardscrollarea.cpp
ui/slotboardscrollarea.h
ui/dataproviderwidget.cpp
ui/dataproviderwidget.h
ui/drawingutils.h)
set(UTILITY
${VERSION_FILE}
utility/filesystemiomanager.cpp
utility/filesystemiomanager.h
utility/applicationsettings.h
utility/utils.cpp
utility/utils.h
utility/notifierbackend.h
utility/notifierbackend.cpp
utility/fontutils.cpp
utility/fontutils.h
utility/backends.h)
set(UI_TESTS
ui/tests/main_window_test.cpp
utility/testutils.h)
qt5_add_resources(RESOURCES
resources/fonts.qrc)
if (APPLE)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.13)
set(CORE_PLATFORM_LIBRARIES
"-framework Foundation"
"-framework AppKit"
"-framework EventKit")
set(PLATFORM_LIBRARIES
"-framework Foundation"
"-framework AppKit"
"-framework UserNotifications"
"-framework CoreImage"
"-framework QuartzCore"
${Sparkle_FRAMEWORK_PATH}
Qt5::MacExtras)
set(PLATFORM_FILES
ui/application.mm
ui/alert.mm
ui/macoswindow.mm
ui/applicationicon.mm
utility/notifierbackend.mm
utility/cocoautils.h
utility/cocoautils.mm
utility/macoscalendarexporter.mm
utility/macoscalendarexporter.h
third-party/TAAdaptiveSpaceItem/TAAdaptiveSpaceItem.m
third-party/TAAdaptiveSpaceItem/TAAdaptiveSpaceItem.h
third-party/TAAdaptiveSpaceItem/TAAdaptiveSpaceItemView.m
third-party/TAAdaptiveSpaceItem/TAAdaptiveSpaceItemView.h
ui/cocoa/STGCalendarExportViewController.m
ui/cocoa/STGCalendarExportViewController.h
ui/cocoa/STGCalendarExportProgressWindow.h
ui/cocoa/STGCalendarExportProgressWindow.m
ui/cocoa/STGCalendarExportView.h
ui/cocoa/STGCalendarExportView.m
ui/cocoa/STGProgressWindow.h
ui/cocoa/STGProgressWindow.m
ui/cocoa/STGCalendarImportExportView.h
ui/cocoa/STGCalendarImportExportViewSubclass.h
ui/cocoa/STGCalendarImportExportView.m
ui/cocoa/STGCalendarImportView.h
ui/cocoa/STGCalendarImportView.m
ui/cocoa/STGColoredCheckBoxView.h
ui/cocoa/STGColoredCheckBoxView.m
ui/colorprovider.mm
ui/cocoa/STGCalendarImportViewController.m
ui/cocoa/STGCalendarImportViewController.h
ui/cocoa/STGToolbar.mm
ui/cocoa/STGToolbar.h)
set(PLATFORM_RESOURCES
deployment/Strategr.icns
deployment/Strategy.icns)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Strategr.app/Contents/Frameworks)
set_source_files_properties(ui/application.mm PROPERTIES COMPILE_FLAGS -fno-objc-arc)
set_source_files_properties(ui/macoswindow.mm PROPERTIES COMPILE_FLAGS -fno-objc-arc)
endif ()
if (WIN32)
set(PLATFORM_RESOURCES
${CMAKE_CURRENT_BINARY_DIR}/Strategr.rc)
set(PLATFORM_LIBRARIES
${WinSparkle_PATH}
Qt5::WinExtras)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Strategr)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Strategr)
endif ()
add_executable(core_tests
tests_main.cpp
${CORE}
${CORE_TESTS})
target_link_libraries(core_tests
Catch2::Catch2
Boost::filesystem
${CORE_LIBRARIES}
${CORE_PLATFORM_LIBRARIES})
option(COVERAGE "Generate code coverage" OFF)
if (COVERAGE)
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES Clang)
target_compile_options(core_tests PUBLIC -fprofile-instr-generate -fcoverage-mapping)
target_link_options(core_tests PUBLIC -fprofile-instr-generate)
#Uncomment in case of linker errors
# target_link_libraries(core_tests clang_rt.profile-x86_64)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL GNU)
target_compile_options(core_tests PUBLIC --coverage)
#Uncomment in case of linker errors
#target_link_libraries(core_tests gcov)
endif ()
endif ()
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
add_library(StrategrCore SHARED ${CORE})
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS OFF)
target_compile_definitions(StrategrCore PUBLIC UTF8PROC_STATIC)
target_link_libraries(StrategrCore
${CORE_LIBRARIES}
${CORE_PLATFORM_LIBRARIES})
set_target_properties(StrategrCore PROPERTIES
FRAMEWORK TRUE
PUBLIC_HEADER core/strategy.h
VERSION ${VERSION_SHORT}
MACOSX_FRAMEWORK_LONG_VERSION_STRING ${VERSION}
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${VERSION_SHORT}
MACOSX_FRAMEWORK_BUNDLE_VERSION ${VERSION}
XCODE_ATTRIBUTE_INSTALL_PATH @executable_path/../Frameworks/)
# Instruct CMake to run moc automatically when needed
set(CMAKE_AUTOMOC ON)
add_executable(Strategr
MACOSX_BUNDLE
main.cpp
${PLATFORM_FILES}
${UI}
${UTILITY}
${RESOURCES}
${PLATFORM_RESOURCES})
add_executable(ui_tests
qt_tests_main.cpp
${PLATFORM_FILES}
${UI}
${UTILITY}
${UI_TESTS}
${RESOURCES})
target_compile_definitions(ui_tests PRIVATE STG_UI_TEST)
target_link_libraries(ui_tests
StrategrCore
Catch2::Catch2
Qt5::Widgets
Qt5::Test
${PLATFORM_LIBRARIES})
target_link_libraries(Strategr
StrategrCore
Qt5::Widgets
${PLATFORM_LIBRARIES})
if (APPLE)
if (CMAKE_BUILD_TYPE MATCHES Rel)
file(COPY ${Sparkle_FRAMEWORK_PATH} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/Strategr.app/Contents/Frameworks)
add_custom_command(TARGET Strategr
POST_BUILD
COMMAND ${CMAKE_SOURCE_DIR}/scripts/macos_deploy.sh ${CMAKE_CURRENT_BINARY_DIR} ${VERSION})
endif (CMAKE_BUILD_TYPE MATCHES Rel)
endif ()
if (WIN32)
# Configure resource file
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/deployment/Strategr.rc"
"${CMAKE_CURRENT_BINARY_DIR}/Strategr.rc")
# Copy icons
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/deployment/Strategr.ico"
DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/deployment/Strategy.ico"
DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
# Copy non-Qt dlls
string(REGEX REPLACE "\\.lib" ".dll" WinSparkle_DLL "${WinSparkle_PATH}")
file(COPY "${WinSparkle_DLL}" DESTINATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
if (CMAKE_BUILD_TYPE MATCHES Rel)
set_target_properties(Strategr PROPERTIES WIN32_EXECUTABLE ON)
# Configure installer scripts
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/deployment/Strategr_x86.template.iss"
"${CMAKE_CURRENT_SOURCE_DIR}/deployment/Strategr_x86.iss")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/deployment/Strategr_x64.template.iss"
"${CMAKE_CURRENT_SOURCE_DIR}/deployment/Strategr_x64.iss")
# Deploy Qt
add_custom_command(TARGET Strategr
POST_BUILD
COMMAND ${Qt5_DIR}/../../../bin/windeployqt.exe --no-translations ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif (CMAKE_BUILD_TYPE MATCHES Rel)
endif ()
# Set a custom plist file for the app bundle
set_target_properties(Strategr PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/deployment/Info.plist
MACOSX_BUNDLE_BUNDLE_VERSION ${VERSION}
MACOSX_BUNDLE_LONG_VERSION_STRING ${VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${VERSION_SHORT}
RESOURCE "${PLATFORM_RESOURCES}")