-
Notifications
You must be signed in to change notification settings - Fork 0
/
QuasarAppCITargets.cmake
806 lines (602 loc) · 24.1 KB
/
QuasarAppCITargets.cmake
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
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
#
# Copyright (C) 2018-2024 QuasarApp.
# Distributed under the MIT software license, see the accompanying
# Everyone is permitted to copy and distribute verbatim copies
# of this license document, but changing it is not allowed.
#
# This module implementation next cmake functions :
#
# The library contains 2 methods type it is Added methods and init methods.
# All inits method must be invoked before adds methods. If you change order then some add method will be ignored.
#
# ***Testing***
# addTestsArg( name testExec arg ) // Name target for test utility of your application.
# - name - Prefix for target (any word).
# - testExec - Name of tests utility (without extensions).
# - arg - Arguments for testExec.
#
# addTests (name testExec )// Name target for test utility of your application (without arguments).
# - name - Prefix for target (any word).
# - testExec - Name of tests utility (without extensions).
#
# initTests - Init main test target for tessting all added tests, this method need to call before all invoiced addTests methods.
#
#
# *** Deployment ***
# addDeploy(name targets targetDir) // Add deploy target for deployed your application via CQtDeployer tool.
# - name - This is prefix of added subtarget (any word).
# - targets - This is list of CQtDeployer targets see CQtDeployer help https://github.com/QuasarApp/CQtDeployer/wiki/Options (-bin).
# - targetDir - This is target directory see option targetDir of CQtDeployer help https://github.com/QuasarApp/CQtDeployer/wiki/Options (-targetDir).
#
# addDeployFromFile(name) // Some as addDeploy, but use CQtDeployer.json for configuration.
# - name - This is prefix of added subtarget (any word).
#
# addDeployFromCustomFile(name file) // Some as addDeploy, but use custom path for deployment file for configuration.
# - name - This is prefix of added subtarget (any word).
# - file - This is path to config file of cqtdeployer.
#
# addDeploySnap(name targetDir) // Add to deploy step substeps for create a snap package.
# - name - This is prefix of added subtarget (any word).
# - targetDir - Destanation direcroty for snap files.
# The addDeploySnap method are support the SNAPCRAFT_EXTRA_ARG variable. If you need to use custom snapcraft mode.
# Example:
# set(SNAPCRAFT_EXTRA_ARG "--destructive-mode")
# addDeploySnap("Client" ${TARGET_DIR})
#
# addDeploySignedAPK(name input aliase keystore keystorePass targetDir) // Add subtargets of deploy setep for create signed android apk file.
# - name - This is prefix of added subtarget (any word).
# - android_src - Path to folder with the android_manifest file.
# - aliase - Aliase for key store.
# - keystore - Path of key store.
# - keystorePass - Pass of keystore file.
# - targetDir - Target dir for output apk file.
# - extraLibs - list f the extra libraryes (like the openssl)
#
# addDeployAPK(name input aliase keystore keystorePass targetDir) // Add subtargets of deploy setep for create android apk file.
# - name - This is prefix of added subtarget (any word).
# - android_src - Path to folder with the android_manifest file.
# - targetDir - Target dir for output apk file.
# - extraLibs - list f the extra libraryes (like the openssl)
#
# addDeployIPA name bundle_id targetDir version appleDir
# - name - This is prefix of added subtarget (any word).
# - bundle_id - This is bundle id of application.
# - targetDir - Target dir for output apk file.
# - version - This is ersaion string of package
# - appleDir - This is main platform dir of apple. By default it is "${CMAKE_CURRENT_SOURCE_DIR}/apple"
#
# initDeploy() // Create a main deploy target for all addDeploy subtargets. This method need to call before invoiced of all addDeploy methods.
#
#
# *** Release ***
# initRelease() // Create the general release target for all subtargets addRelease. This method need to call before invoice all addRelease methods.
#
# addReleaseCustom(name pyFile) // This function prepare to run pyFile and add dependencies for release target.
# - name - This is prefix of added subtarget (any word).
# - pyFile This is python script for release project.
#
# addReleaseSnap(name) // Create subtargets for publish snap deployed snap package.
# - name - This is prefix of added subtarget (any word).
#
# addReleaseIpa(name username) // Create subtargets for publish snap deployed snap package.
# - name - This is prefix of added subtarget (any word).
# - username - This is name if user that will release app into testflight
#
# addReleaseQif(name sourceDir targetDir) // Create subtargets for publish the qif package on qif repository.
# - name - This is prefix of added subtarget (any word).
# - sourceDir - Path to folder with qif template.
# - targetDir - Path to target directory.
#
#
# *** Dcumentation ***
# initDoc() // Create the general doc target for all subtargets addDoc. This method need to call before invoice all addDoc methods.
#
# addDoc(name doxygenFile) // Create subtargets for generate documentation of cpp code.
# - name - This is prefix of added subtarget (any word).
# - doxygenFile - This is path to doxygen configuration file.
#
if(DEFINED QUASARAPP_DEFAULT_TARGETS)
return()
else()
set(QUASARAPP_DEFAULT_TARGETS 1)
endif()
set(DOC_TARGETS_LIST "")
set(TEST_TARGETS_LIST "")
set(DEPLOY_TARGETS_LIST "")
set(RELEASE_TARGETS_LIST "")
set(DIR_FOR_TESTING ${PROJECT_SOURCE_DIR}/Testing)
set(QUASAR_MODULE_CURRENT_DIR ${CMAKE_CURRENT_LIST_DIR})
if (ANDROID)
include(${CMAKE_CURRENT_LIST_DIR}/qt-android-cmake/AddQtAndroidApk.cmake)
endif()
if (IOS)
include(${CMAKE_CURRENT_LIST_DIR}/QtStaticCMake/QtStaticCMake.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/QtIosCMake/AddQtIosApp.cmake)
endif()
function(emptyTarget targetName)
if(TARGET ${targetName})
message("the ${targetName} target already created!")
return()
endif(TARGET ${targetName})
ADD_CUSTOM_TARGET(
${targetName}
)
endfunction()
function(initTests)
if(TARGET test)
message("the test target already created!")
return()
endif(TARGET test)
message("test sub targets: ${TEST_TARGETS_LIST}")
ADD_CUSTOM_TARGET(
test
COMMENT "=================== Run Test ==================="
DEPENDS
)
message("prepare tests for ${TEST_TARGETS_LIST}")
endfunction()
function(addTestsArg name testExec arg)
if(TARGET test${name})
message("the test${name} target already created!")
return()
endif(TARGET test${name})
set(EXEC_TEST "${CMAKE_CURRENT_BINARY_DIR}/${testExec}")
set(RUN_CMD "${DIR_FOR_TESTING}/${name}/${testExec}.sh")
if (WIN32)
set(EXEC_TEST "${CMAKE_CURRENT_BINARY_DIR}/${testExec}.exe")
set(RUN_CMD "${DIR_FOR_TESTING}/${name}/${testExec}.exe")
endif (WIN32)
ADD_CUSTOM_TARGET(
deployTest${name}
COMMAND cqtdeployer clear -bin ${EXEC_TEST} -qmake ${QT_QMAKE_EXECUTABLE} -targetDir ${DIR_FOR_TESTING}/${name} -libDir \"${CMAKE_SOURCE_DIR},${CMAKE_BINARY_DIR}\" -recursiveDepth 5
COMMENT "Deploy Test: cqtdeployer clear -bin ${EXEC_TEST} -qmake ${QT_QMAKE_EXECUTABLE} -targetDir ${DIR_FOR_TESTING}/${name} -libDir ${CMAKE_SOURCE_DIR} -recursiveDepth 5"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
ADD_CUSTOM_TARGET(
test${name}
COMMAND ${RUN_CMD} ${arg}
COMMENT "=================== Run Test ==================="
WORKING_DIRECTORY ${DIR_FOR_TESTING}/${name}
DEPENDS deployTest${name}
)
add_dependencies(test test${name})
endfunction()
function(addTests name testExec)
if(TARGET test${name})
message("the test${name} target already created!")
return()
endif(TARGET test${name})
set(EXEC_TEST "${CMAKE_CURRENT_BINARY_DIR}/${testExec}")
set(RUN_CMD "${DIR_FOR_TESTING}/${name}/${testExec}.sh")
if (WIN32)
set(EXEC_TEST "${CMAKE_CURRENT_BINARY_DIR}/${testExec}.exe")
set(RUN_CMD "${DIR_FOR_TESTING}/${name}/${testExec}.exe")
endif (WIN32)
ADD_CUSTOM_TARGET(
deployTest${name}
COMMAND cqtdeployer clear -bin ${EXEC_TEST} -qmake ${QT_QMAKE_EXECUTABLE} -targetDir ${DIR_FOR_TESTING}/${name} -libDir \"${CMAKE_SOURCE_DIR},${CMAKE_BINARY_DIR}\" -recursiveDepth 5
COMMENT "Deploy Test: cqtdeployer clear -bin ${EXEC_TEST} -qmake ${QT_QMAKE_EXECUTABLE} -targetDir ${DIR_FOR_TESTING}/${name} -libDir ${CMAKE_SOURCE_DIR} -recursiveDepth 5"
)
ADD_CUSTOM_TARGET(
test${name}
COMMAND ${RUN_CMD}
COMMENT "=================== Run Test ==================="
WORKING_DIRECTORY ${DIR_FOR_TESTING}/${name}
DEPENDS deployTest${name}
)
add_dependencies(test test${name})
message("prepare tests for ${RUN_CMD}")
endfunction()
function(initDeploy)
if(TARGET deploy)
message("the deploy target already created!")
return()
endif(TARGET deploy)
message("deploy subtargets: ${DEPLOY_TARGETS_LIST}")
ADD_CUSTOM_TARGET(
deploy
COMMENT "=================== Run deploy ==================="
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
endfunction()
function(addDeploy name targets targetDir)
if(TARGET deploy${name})
message("the deploy${name} target already created!")
return()
endif(TARGET deploy${name})
ADD_CUSTOM_TARGET(
deploy${name}
COMMAND cqtdeployer clear -binPrefix \"${CMAKE_BINARY_DIR}\" -bin ${targets} -qmake ${QT_QMAKE_EXECUTABLE} -targetDir ${targetDir}
COMMENT "Deploy: cqtdeployer clear -binPrefix \"${CMAKE_BINARY_DIR}\" -bin ${targets} -qmake ${QT_QMAKE_EXECUTABLE} -targetDir ${targetDir}"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
add_dependencies(deploy deploy${name})
endfunction()
function(addDeployFromFile name)
if(TARGET deploy${name})
message("the deploy${name} target already created!")
return()
endif(TARGET deploy${name})
ADD_CUSTOM_TARGET(
deploy${name}
COMMAND cqtdeployer -qmake ${QT_QMAKE_EXECUTABLE} -binPrefix \"${CMAKE_BINARY_DIR}\"
COMMENT "Deploy: cqtdeployer -qmake ${QT_QMAKE_EXECUTABLE} -binPrefix \"${CMAKE_BINARY_DIR}\""
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
add_dependencies(deploy deploy${name})
endfunction()
function(addDeployFromCustomFile name file)
if(TARGET deploy${name})
message("the deploy${name} target already created!")
return()
endif(TARGET deploy${name})
file(GLOB ${name}files
"${file}*"
)
ADD_CUSTOM_TARGET(
deploy${name}
SOURCES ${${name}files}
COMMAND cqtdeployer -qmake ${QT_QMAKE_EXECUTABLE} -binPrefix \"${CMAKE_BINARY_DIR}\" -confFile ${file}
COMMENT "Deploy: cqtdeployer -qmake ${QT_QMAKE_EXECUTABLE} -binPrefix \"${CMAKE_BINARY_DIR}\" -confFile ${file}"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
add_dependencies(deploy deploy${name})
endfunction()
function(addDeploySnap name targetDir)
if(TARGET snap${name})
message("the snap${name} target already created!")
return()
endif(TARGET snap${name})
find_program(SNAPCRAFT_EXE "snapcraft")
if(NOT EXISTS ${SNAPCRAFT_EXE})
message("please install the snapcraft before deploy this project! Use: sudo snap install snapcraft --classic")
return()
endif(NOT EXISTS ${SNAPCRAFT_EXE})
if(EXISTS "${CMAKE_SOURCE_DIR}/snap/gui")
ADD_CUSTOM_TARGET(
chmodsnap${name}
COMMAND chmod -R 777 "${CMAKE_SOURCE_DIR}/snap/gui"
COMMENT "chmod -R 777 ${CMAKE_SOURCE_DIR}/snap/gui"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
DEPENDS deploy${name}
)
ADD_CUSTOM_TARGET(
snapcraft${name}
COMMAND snapcraft ${SNAPCRAFT_EXTRA_ARG}
COMMENT "create snap: snapcraft ${SNAPCRAFT_EXTRA_ARG}"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
DEPENDS chmodsnap${name}
)
else()
ADD_CUSTOM_TARGET(
snapcraft${name}
COMMAND snapcraft ${SNAPCRAFT_EXTRA_ARG}
COMMENT "create snap: snapcraft ${SNAPCRAFT_EXTRA_ARG}"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
DEPENDS deploy${name}
)
endif()
ADD_CUSTOM_TARGET(
snapcraftCopy${name}
COMMAND ${CMAKE_COMMAND} -E copy *.snap ${targetDir}
COMMENT "copy snap: ${CMAKE_COMMAND} -E copy *.snap ${targetDir}"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
DEPENDS snapcraft${name}
)
ADD_CUSTOM_TARGET(
snap${name}
COMMENT "deploy snap${name}"
DEPENDS snapcraftCopy${name}
)
add_dependencies(deploy snap${name})
endfunction()
function(addDeploySnapOld name targetDir)
if(TARGET snap${name})
message("the snap${name} target already created!")
return()
endif(TARGET snap${name})
find_program(SNAPCRAFT_EXE "snapcraft")
if(NOT EXISTS ${SNAPCRAFT_EXE})
message("please install the snapcraft before deploy this project! Use: sudo snap install snapcraft --classic")
return()
endif(NOT EXISTS ${SNAPCRAFT_EXE})
ADD_CUSTOM_TARGET(
snapClear${name}
COMMAND snapcraft clean ${SNAPCRAFT_MODE}
COMMENT "clear snap: snapcraft clean ${SNAPCRAFT_MODE}"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
ADD_CUSTOM_TARGET(
snapcraft${name}
COMMAND snapcraft ${SNAPCRAFT_MODE}
COMMENT "create snap: snapcraft ${SNAPCRAFT_MODE}"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
DEPENDS deploy${name} snapClear${name}
)
ADD_CUSTOM_TARGET(
snapcraftCopy${name}
COMMAND ${CMAKE_COMMAND} -E copy *.snap ${targetDir}
COMMENT "copy snap: ${CMAKE_COMMAND} -E copy *.snap ${targetDir}"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
DEPENDS snapcraft${name}
)
ADD_CUSTOM_TARGET(
snap${name}
COMMENT "deploy snap${name}"
DEPENDS snapcraftCopy${name}
)
add_dependencies(deploy snap${name})
endfunction()
function(addDeployIPA name bundle_id targetDir version appleDir)
if(TARGET deployIPA${name})
message("the deployIPA${name} target already created!")
return()
endif(TARGET deployIPA${name})
if("${appleDir}" STREQUAL "")
set(appleDir "${CMAKE_CURRENT_SOURCE_DIR}/apple")
endif()
set(QUASAR_CUSTOM_PLIST "${appleDir}/Info.plist")
if (NOT EXISTS "${QUASAR_CUSTOM_PLIST}")
set(QUASAR_CUSTOM_PLIST "${QUASAR_MODULE_CURRENT_DIR}/QtIosCMake/Info.plist.in")
endif()
message("Use Apple dir: ${appleDir}")
add_qt_ios_app(${name}
NAME ${name}
BUNDLE_IDENTIFIER ${bundle_id}
LONG_VERSION ${version}
SHORT_VERSION ${version}
VERSION ${version}
CUSTOM_PLIST ${QUASAR_CUSTOM_PLIST}
COPYRIGHT "QuasarApp 2022-2023"
ASSET_DIR "${appleDir}/Assets.xcassets"
TEAM_ID ${CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM}
QT_IOS_LAUNCHSCREEN_STORYBOARD
LAUNCHSCREEN_STORYBOARD "${appleDir}/LaunchScreen.storyboard"
CATALOG_APPICON "AppIcon"
ORIENTATION_PORTRAIT
ORIENTATION_PORTRAIT_UPDOWN
ORIENTATION_LANDSCAPE_LEFT
ORIENTATION_LANDSCAPE_RIGHT
IPA
UPLOAD_SYMBOL
VERBOSE
)
if (${QT_VERSION_MAJOR} EQUAL 5)
if("${qmlRoot}" STREQUAL "")
set(qmlRoot ${CMAKE_SOURCE_DIR})
endif()
qt_generate_plugin_import(${name} VERBOSE)
# EXTRA_PLUGIN are the one required by plugin loaded by qt_generate_plugin_import
# It's not automatic yet :( All this workflow might change in future version of qt
# with better and better cmake support
qt_generate_qml_plugin_import(${name}
QML_SRC ${qmlRoot}
EXTRA_PLUGIN
QtQuickVirtualKeyboardPlugin
QtQuickVirtualKeyboardSettingsPlugin
QtQuickVirtualKeyboardStylesPlugin
QmlFolderListModelPlugin
QQuickLayoutsPlugin
VERBOSE
)
qt5_import_plugins(${name} INCLUDE Qt5::QSvgPlugin)
endif()
ADD_CUSTOM_TARGET(
deployIPA${name}
COMMAND ${CMAKE_COMMAND} -E copy *.ipa ${targetDir}
COMMENT "copy ipa: ${CMAKE_COMMAND} -E copy *.ipa ${targetDir}"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${name}Ipa"
)
ADD_CUSTOM_TARGET(
deployIPAd${name}
COMMAND ${CMAKE_COMMAND} -E copy *.plist ${targetDir}
COMMENT "copy plist: ${CMAKE_COMMAND} -E copy *.plist ${targetDir}"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${name}Ipa"
)
add_dependencies(deploy deployIPA${name})
add_dependencies(deploy deployIPAd${name})
endfunction()
function(addDeployAPK name android_src targetDir extraLibs)
if(TARGET deployAPK${name})
message("the deployAPK${name} target already created!")
return()
endif(TARGET deployAPK${name})
IF(NOT DEFINED ENV{ANDROID_SDK_ROOT})
message("the ANDROID_SDK_ROOT is not defined. define ANDROID_SDK_ROOT variable and run cmake again!")
return()
endif()
IF(DEFINED ENV{ANDROID_API_VERSION})
set(ANDROID_PLATFORM_LEVEL $ENV{ANDROID_API_VERSION})
else()
set(ANDROID_PLATFORM_LEVEL 30)
endif()
message("The ANDROID_PLATFORM_LEVEL = ${ANDROID_PLATFORM_LEVEL}")
add_qt_android_apk(createAPK${name} ${name}
PACKAGE_SOURCES ${android_src}
DEPENDS ${extraLibs}
)
ADD_CUSTOM_TARGET(
deployAPK${name}
COMMAND ${CMAKE_COMMAND} -E copy *.apk ${targetDir}
COMMENT "copy apk: ${CMAKE_COMMAND} -E copy *.apk ${targetDir}"
WORKING_DIRECTORY ${QT_ANDROID_APP_BINARY_DIR}/build/outputs/apk/debug
DEPENDS createAPK${name}
)
ADD_CUSTOM_TARGET(
deployAAB${name}
COMMAND ${CMAKE_COMMAND} -E copy *.aab ${targetDir}
COMMENT "copy aab: ${CMAKE_COMMAND} -E copy *.aab ${targetDir}"
WORKING_DIRECTORY ${QT_ANDROID_APP_BINARY_DIR}/build/outputs/bundle/release
DEPENDS deployAPK${name}
)
add_dependencies(deploy deployAPK${name})
add_dependencies(deploy deployAAB${name})
endfunction()
function(addDeploySignedAPK name android_src aliase keystore keystorePass targetDir extraLibs)
if(TARGET deployAPK${name})
message("the deployAPK${name} target already created!")
return()
endif(TARGET deployAPK${name})
IF(NOT DEFINED ENV{ANDROID_SDK_ROOT})
message("the ANDROID_SDK_ROOT is not defined. define ANDROID_SDK_ROOT variable and run cmake again!")
return()
endif()
IF(DEFINED ENV{ANDROID_API_VERSION})
set(ANDROID_PLATFORM_LEVEL $ENV{ANDROID_API_VERSION})
else()
set(ANDROID_PLATFORM_LEVEL 30)
endif()
message("The ANDROID_PLATFORM_LEVEL = ${ANDROID_PLATFORM_LEVEL}")
add_qt_android_apk(createAPK${name} ${name}
PACKAGE_SOURCES ${android_src}
KEYSTORE ${keystore} ${aliase}
KEYSTORE_PASSWORD ${keystorePass}
DEPENDS ${extraLibs}
)
ADD_CUSTOM_TARGET(
deployAPK${name}
COMMAND ${CMAKE_COMMAND} -E copy *.apk ${targetDir}
COMMENT "copy apk: ${CMAKE_COMMAND} -E copy *.apk ${targetDir}"
WORKING_DIRECTORY ${QT_ANDROID_APP_BINARY_DIR}/build/outputs/apk/release
DEPENDS createAPK${name}
)
ADD_CUSTOM_TARGET(
deployAAB${name}
COMMAND ${CMAKE_COMMAND} -E copy *.aab ${targetDir}
COMMENT "copy aab: ${CMAKE_COMMAND} -E copy *.aab ${targetDir}"
WORKING_DIRECTORY ${QT_ANDROID_APP_BINARY_DIR}/build/outputs/bundle/release
DEPENDS deployAPK${name}
)
add_dependencies(deploy deployAPK${name})
add_dependencies(deploy deployAAB${name})
endfunction()
function(initRelease)
if(TARGET release)
message("the release target already created!")
return()
endif(TARGET release)
message("release subtargets: ${RELEASE_TARGETS_LIST}")
ADD_CUSTOM_TARGET(
release
COMMENT "=================== Relese project ==================="
)
endfunction()
function(addReleaseCustom name pyFile)
if(TARGET pyRelease${name})
message("the pyRelease${name} target already created!")
return()
endif(TARGET pyRelease${name})
file(GLOB ${name}files
"${pyFile}*"
)
ADD_CUSTOM_TARGET(
pyRelease${name}
SOURCES ${${name}files}
COMMAND python pyFile
COMMENT "pyRelease${name} release: run python ${pyFile}"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
add_dependencies(release pyRelease${name})
endfunction()
function(addReleaseSnap name branch)
if(TARGET snapRelease${name})
message("the snapRelease${name} target already created!")
return()
endif(TARGET snapRelease${name})
SET(SNAP_CHANNEL edge)
if (${branch})
set(SNAP_CHANNEL ${branch})
endif()
ADD_CUSTOM_TARGET(
snapRelease${name}
COMMAND snapcraft upload --release=${SNAP_CHANNEL} *.snap
COMMENT "snapRelease${name} release"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
add_dependencies(release snapRelease${name})
endfunction()
function(addReleaseIpa name userName keychain_key)
if(TARGET ipaRelease${name})
message("the ipaRelease${name} target already created!")
return()
endif(TARGET ipaRelease${name})
ADD_CUSTOM_TARGET(
ipaRelease${name}
COMMAND xcrun altool --upload-app --type ios --file ${CMAKE_CURRENT_BINARY_DIR}/${name}Ipa/${name}.ipa -u ${userName} -p "@keychain:${keychain_key}"
COMMENT "xcrun altool --upload-app --type ios --file ${CMAKE_CURRENT_BINARY_DIR}/${name}Ipa/${name}.ipa"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
add_dependencies(release ipaRelease${name})
endfunction()
function(addReleaseQif name sourceDir targetDir)
if(TARGET qifRelease${name})
message("the qifRelease${name} target already created!")
return()
endif(TARGET qifRelease${name})
find_program(BINARYCREATOR_EXE binarycreator)
IF(NOT EXISTS ${BINARYCREATOR_EXE})
message("the Binarycreator not exits please install or adde path to QtInstaller Framework to PATH and run cmake again!")
return()
endif(NOT EXISTS ${BINARYCREATOR_EXE})
set(OUT_EXE ${targetDir}/${PROJECT_NAME}OfllineInstaller.run)
if (WIN32)
set(OUT_EXE ${targetDir}/${PROJECT_NAME}OfllineInstaller.exe)
endif (WIN32)
ADD_CUSTOM_TARGET(
qifDeployOnline${name}
COMMAND ${BINARYCREATOR_EXE} --online-only -c ${config} -p ${sourceDir}/packages ${OUT_EXE}
COMMENT "deploy qif online: ${BINARYCREATOR_EXE} --online-only -c ${config} -p ${sourceDir}/packages ${OUT_EXE}"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
ADD_CUSTOM_TARGET(
qifRelease${name}
COMMAND ${CMAKE_COMMAND} -E copy_directory
${sourceDir}
${CMAKE_BINARY_DIR}/Repo
COMMENT "qifRelease${name} release ${CMAKE_COMMAND} -E copy_directory ${sourceDir} ${CMAKE_BINARY_DIR}/Repo"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
DEPENDS qifDeployOnline${name}
)
set(RELEASE_TARGETS_LIST ${RELEASE_TARGETS_LIST} qifRelease${name} PARENT_SCOPE)
add_dependencies(release qifRelease${name})
endfunction()
function(addDoc name doxygenFile)
if(TARGET doxygen${name})
message("the doxygen${name} target already created!")
return()
endif(TARGET doxygen${name})
find_program(DOXYGEN_EXECUTABLE doxygen)
IF(NOT EXISTS ${DOXYGEN_EXECUTABLE})
message("the doxygen not exits please install or add a path to doxygen to a PATH envirement variable and run cmake again!")
return()
endif(NOT EXISTS ${DOXYGEN_EXECUTABLE})
file(GLOB ${name}files
"${doxygenFile}*"
)
ADD_CUSTOM_TARGET(
doxygen${name}
SOURCES ${${name}files}
COMMAND ${DOXYGEN_EXECUTABLE} ${doxygenFile}
COMMENT "${DOXYGEN_EXECUTABLE} ${doxygenFile}"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
add_dependencies(doc doxygen${name})
endfunction()
function(initDoc)
if(TARGET doc)
message("the doc target already created!")
return()
endif(TARGET doc)
message("doc subtargets: ${DOC_TARGETS_LIST}")
ADD_CUSTOM_TARGET(
doc
COMMENT "=================== Run generate docs ==================="
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
endfunction()
function(initAll)
initTests()
initDoc()
initDeploy()
initRelease()
endfunction()