-
Notifications
You must be signed in to change notification settings - Fork 15
/
AddQtIosApp.cmake
611 lines (547 loc) · 27.2 KB
/
AddQtIosApp.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
#
# CMake Script by Olivier Le Doeuff
# Copyright (c) 2019 - All Right Reserved
# add_qt_ios_app help you deploy iOs application with Qt.
#
cmake_minimum_required(VERSION 3.5.1 FATAL_ERROR)
# find the Qt root directoryn might break in future release
# Dependant on Qt5
if(NOT Qt5Core_DIR)
find_package(Qt5Core REQUIRED)
endif()
get_filename_component(QT_IOS_QT_ROOT "${Qt5Core_DIR}/../../.." ABSOLUTE)
if(QT_IOS_QT_ROOT)
message(STATUS "Found Qt Sdk for Ios: ${QT_IOS_QT_ROOT}")
else()
message(FATAL_ERROR "Fail to find Qt Sdk path.")
endif()
# Keep track of our own directory for future use (and default value of plist.in)
set(QT_IOS_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR})
# This little macro lets you set any Xcode specific property.
# This is from iOs CMake Toolchain
macro(qt_ios_set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE XCODE_RELVERSION)
set(XCODE_RELVERSION_I "${XCODE_RELVERSION}")
if(XCODE_RELVERSION_I STREQUAL "All")
set_property(TARGET ${TARGET} PROPERTY XCODE_ATTRIBUTE_${XCODE_PROPERTY} "${XCODE_VALUE}")
else()
set_property(TARGET ${TARGET} PROPERTY XCODE_ATTRIBUTE_${XCODE_PROPERTY}[variant=${XCODE_RELVERSION_I}] "${XCODE_VALUE}")
endif()
endmacro() # qt_ios_set_xcode_property
# We need that to parse arguments
include(CMakeParseArguments)
# Usage :
# add_qt_ios_app(MyApp
# NAME "My App"
# BUNDLE_IDENTIFIER "com.company.app"
# VERSION "1.2.3"
# SHORT_VERSION "1.2.3"
# LONG_VERSION "1.2.3.456"
# CUSTOM_PLIST "path/to/Info.plist.in"
# CODE_SIGN_IDENTITY "iPhone Developer"
# TEAM_ID "AAAAAAAA"
# PROVISIONING_PROFILE_SPECIFIER "profile-name"
# COPYRIGHT "My Cool Copyright"
# QML_DIR "${QT_IOS_QT_ROOT}/qml"
# ASSET_DIR "path/to/Assets.xcassets"
# MAIN_STORYBOARD "/path/to/Main.storyboard"
# LAUNCHSCREEN_STORYBOARD "path/to/LaunchScreen.storyboard"
# CATALOG_APPICON "AppIcon"
# CATALOG_LAUNCHIMAGE "LaunchImage"
# ORIENTATION_PORTRAIT
# ORIENTATION_PORTRAIT_UPDOWN
# ORIENTATION_LANDSCAPE_LEFT
# ORIENTATION_LANDSCAPE_RIGHT
# PHOTO_LIBRARY_USAGE_DESCRIPTION "My App needs to access your photo library."
# SUPPORT_IPHONE
# SUPPORT_IPAD
# REQUIRES_FULL_SCREEN
# HIDDEN_STATUS_BAR
# IPA
# UPLOAD_SYMBOL
# DISTRIBUTION_METHOD "app-store"
# VERBOSE
# )
function(add_qt_ios_app TARGET)
set(QT_IOS_OPTIONS VERBOSE
ORIENTATION_PORTRAIT
ORIENTATION_PORTRAIT_UPDOWN
ORIENTATION_LANDSCAPE_LEFT
ORIENTATION_LANDSCAPE_RIGHT
SUPPORT_IPHONE
SUPPORT_IPAD
REQUIRES_FULL_SCREEN
HIDDEN_STATUS_BAR
IPA
UPLOAD_SYMBOL
ITS_ENCRYPTION_EXPORT_COMPLIANCE_CODE
)
set(QT_IOS_ONE_VALUE_ARG NAME
BUNDLE_IDENTIFIER
VERSION
SHORT_VERSION
LONG_VERSION
CUSTOM_PLIST
CODE_SIGN_IDENTITY
TEAM_ID
PROVISIONING_PROFILE_SPECIFIER
COPYRIGHT
QML_DIR
ASSET_DIR
LAUNCHSCREEN_STORYBOARD
MAIN_STORYBOARD
CATALOG_APPICON
CATALOG_LAUNCHIMAGE
DISTRIBUTION_METHOD
PHOTO_LIBRARY_USAGE_DESCRIPTION
)
set(QT_IOS_MULTI_VALUE_ARG
RESOURCE_FILES
)
# parse the macro arguments
cmake_parse_arguments(ARGIOS "${QT_IOS_OPTIONS}" "${QT_IOS_ONE_VALUE_ARG}" "${QT_IOS_MULTI_VALUE_ARG}" ${ARGN})
# Copy arg variables to local variables
set(QT_IOS_TARGET ${TARGET})
set(QT_IOS_NAME ${ARGIOS_NAME})
set(QT_IOS_BUNDLE_IDENTIFIER ${ARGIOS_BUNDLE_IDENTIFIER})
set(QT_IOS_VERSION ${ARGIOS_VERSION})
set(QT_IOS_SHORT_VERSION ${ARGIOS_SHORT_VERSION})
set(QT_IOS_LONG_VERSION ${ARGIOS_LONG_VERSION})
set(QT_IOS_CUSTOM_PLIST ${ARGIOS_CUSTOM_PLIST})
if(NOT QT_IOS_CODE_SIGN_IDENTITY)
set(QT_IOS_CODE_SIGN_IDENTITY ${ARGIOS_CODE_SIGN_IDENTITY})
endif()
if("${QT_IOS_CODE_SIGN_IDENTITY}" STREQUAL "")
set(QT_IOS_CODE_SIGN_IDENTITY "iPhone Developer")
endif()
if(NOT QT_IOS_TEAM_ID)
set(QT_IOS_TEAM_ID ${ARGIOS_TEAM_ID})
endif()
if(NOT QT_IOS_PROVISIONING_PROFILE_SPECIFIER AND ARGIOS_PROVISIONING_PROFILE_SPECIFIER)
set(QT_IOS_PROVISIONING_PROFILE_SPECIFIER ${ARGIOS_PROVISIONING_PROFILE_SPECIFIER})
endif()
set(QT_IOS_COPYRIGHT ${ARGIOS_COPYRIGHT})
set(QT_IOS_QML_DIR ${ARGIOS_QML_DIR})
set(QT_IOS_ASSET_DIR ${ARGIOS_ASSET_DIR})
set(QT_IOS_LAUNCHSCREEN_STORYBOARD ${ARGIOS_LAUNCHSCREEN_STORYBOARD})
set(QT_IOS_MAIN_STORYBOARD ${ARGIOS_MAIN_STORYBOARD})
set(QT_IOS_CATALOG_APPICON ${ARGIOS_CATALOG_APPICON})
set(QT_IOS_CATALOG_LAUNCHIMAGE ${ARGIOS_CATALOG_LAUNCHIMAGE})
set(QT_IOS_RESOURCE_FILES "${ARGIOS_RESOURCE_FILES}")
set(QT_IOS_ORIENTATION_PORTRAIT ${ARGIOS_ORIENTATION_PORTRAIT})
set(QT_IOS_ORIENTATION_PORTRAIT_UPDOWN ${ARGIOS_ORIENTATION_PORTRAIT_UPDOWN})
set(QT_IOS_ORIENTATION_LANDSCAPE_LEFT ${ARGIOS_ORIENTATION_LANDSCAPE_LEFT})
set(QT_IOS_ORIENTATION_LANDSCAPE_RIGHT ${ARGIOS_ORIENTATION_LANDSCAPE_RIGHT})
set(QT_IOS_SUPPORT_IPHONE ${ARGIOS_SUPPORT_IPHONE})
set(QT_IOS_SUPPORT_IPAD ${ARGIOS_SUPPORT_IPAD})
set(QT_IOS_REQUIRES_FULL_SCREEN ${ARGIOS_REQUIRES_FULL_SCREEN})
set(QT_IOS_HIDDEN_STATUS_BAR ${ARGIOS_HIDDEN_STATUS_BAR})
set(QT_IOS_PHOTO_LIBRARY_USAGE_DESCRIPTION ${ARGIOS_PHOTO_LIBRARY_USAGE_DESCRIPTION})
set(QT_IOS_IPA ${ARGIOS_IPA})
set(QT_IOS_UPLOAD_SYMBOL ${ARGIOS_UPLOAD_SYMBOL})
if(NOT QT_IOS_DISTRIBUTION_METHOD)
set(QT_IOS_DISTRIBUTION_METHOD ${ARGIOS_DISTRIBUTION_METHOD})
endif()
if("${QT_IOS_DISTRIBUTION_METHOD}" STREQUAL "")
set(QT_IOS_DISTRIBUTION_METHOD "app-store")
endif()
# Allow user to override QT_IOS_ITS_ENCRYPTION_EXPORT_COMPLIANCE_CODE from cache/command line
if(NOT QT_IOS_ITS_ENCRYPTION_EXPORT_COMPLIANCE_CODE)
set(QT_IOS_ITS_ENCRYPTION_EXPORT_COMPLIANCE_CODE ${ARGIOS_ITS_ENCRYPTION_EXPORT_COMPLIANCE_CODE})
endif()
# QT_IOS_ITS_ENCRYPTION_KEYS is used in Info.plist.in
if(QT_IOS_ITS_ENCRYPTION_EXPORT_COMPLIANCE_CODE)
set(QT_IOS_ITS_ENCRYPTION_KEYS "<key>ITSAppUsesNonExemptEncryption</key><true/>\n <key>ITSEncryptionExportComplianceCode</key>\n <string>${QT_IOS_ITS_ENCRYPTION_EXPORT_COMPLIANCE_CODE}</string>" PARENT_SCOPE)
else()
set(QT_IOS_ITS_ENCRYPTION_KEYS "<key>ITSAppUsesNonExemptEncryption</key><false/>" PARENT_SCOPE)
endif()
set(QT_IOS_VERBOSE ${ARGIOS_VERBOSE})
if(NOT ARGIOS_NAME)
if(QT_IOS_VERBOSE)
message(STATUS "NAME not provided when calling add_qt_ios_app. Name will be default to ${QT_IOS_TARGET}")
endif()
set(QT_IOS_NAME ${QT_IOS_TARGET})
endif()
# Warning if no default BUNDLE_IDENTIFIER is set
if(NOT ARGIOS_BUNDLE_IDENTIFIER)
if(QT_IOS_VERBOSE)
message(STATUS "BUNDLE_IDENTIFIER not set when calling add_qt_ios_app. "
"You can fix this by hand in XCode. "
"The BUNDLE_IDENTIFIER is defaulted to ${CMAKE_PROJECT_NAME}")
endif() # QT_IOS_VERBOSE
set(QT_IOS_BUNDLE_IDENTIFIER ${CMAKE_PROJECT_NAME}.${QT_IOS_TARGET})
endif() # NOT ARGIOS_BUNDLE_IDENTIFIER
# Warning if no version
if(NOT ARGIOS_VERSION)
set(QT_IOS_VERSION ${CMAKE_PROJECT_VERSION})
if("${QT_IOS_VERSION}" STREQUAL "")
set(QT_IOS_VERSION "1.0.0")
endif()
if(QT_IOS_VERBOSE)
message(STATUS "VERSION not set when calling add_qt_ios_app. "
"Default VERSION to ${QT_IOS_VERSION}")
endif() # QT_IOS_VERBOSE
endif() # NOT ARGIOS_VERSION
# Default value for SHORT_VERSION
if(NOT QT_IOS_SHORT_VERSION)
if(QT_IOS_VERBOSE)
message(STATUS "SHORT_VERSION not specified, default to ${QT_IOS_VERSION}")
endif() # QT_IOS_VERBOSE
set(QT_IOS_SHORT_VERSION ${QT_IOS_VERSION})
endif() # NOT QT_IOS_SHORT_VERSION
# Default value for long version
if(NOT QT_IOS_LONG_VERSION)
if(QT_IOS_VERBOSE)
message(STATUS "LONG_VERSION not specified, default to ${QT_IOS_VERSION}")
endif() # QT_IOS_VERBOSE
set(QT_IOS_LONG_VERSION ${QT_IOS_VERSION})
endif() # NOT QT_IOS_LONG_VERSION
# Default value for plist file
if(NOT QT_IOS_CUSTOM_PLIST)
set(QT_IOS_CUSTOM_PLIST ${QT_IOS_SOURCE_DIR}/Info.plist.in)
if(QT_IOS_VERBOSE)
message(STATUS "CUSTOM_PLIST not specified, default to ${QT_IOS_CUSTOM_PLIST}")
endif() # QT_IOS_VERBOSE
endif() # NOT QT_IOS_CUSTOM_PLIST
# Default for qml dir set to qt sdk root
if(NOT QT_IOS_QML_DIR)
set(QT_IOS_QML_DIR "${QT_IOS_QT_ROOT}/qml")
if(QT_IOS_VERBOSE)
message(STATUS "QML_DIR not specified, default to ${QT_IOS_QML_DIR}")
endif() # QT_IOS_VERBOSE
endif() # NOT QT_IOS_QML_DIR
if(NOT QT_IOS_CATALOG_APPICON)
set(QT_IOS_CATALOG_APPICON "AppIcon")
if(QT_IOS_VERBOSE)
message(STATUS "CATALOG_APPICON not specified, default to ${QT_IOS_CATALOG_APPICON}.")
endif() # QT_IOS_VERBOSE
endif() # NOT QT_IOS_CATALOG_APPICON
# Print macro configuration
if(QT_IOS_VERBOSE)
message(STATUS "------ QtIosCMake Configuration ------")
message(STATUS "TARGET : ${QT_IOS_TARGET}")
message(STATUS "NAME : ${QT_IOS_NAME}")
message(STATUS "BUNDLE_IDENTIFIER : ${QT_IOS_BUNDLE_IDENTIFIER}")
message(STATUS "VERSION : ${QT_IOS_VERSION}")
message(STATUS "SHORT_VERSION : ${QT_IOS_SHORT_VERSION}")
message(STATUS "LONG_VERSION : ${QT_IOS_LONG_VERSION}")
message(STATUS "CUSTOM_PLIST : ${QT_IOS_CUSTOM_PLIST}")
message(STATUS "CODE_SIGN_IDENTITY : ${QT_IOS_CODE_SIGN_IDENTITY}")
message(STATUS "TEAM_ID : ${QT_IOS_TEAM_ID}")
if(QT_IOS_PROVISIONING_PROFILE_SPECIFIER)
message(STATUS "PROVISIONING_PROFILE_SPECIFIER : ${QT_IOS_PROVISIONING_PROFILE_SPECIFIER}")
endif()
message(STATUS "COPYRIGHT : ${QT_IOS_COPYRIGHT}")
message(STATUS "QML_DIR : ${QT_IOS_QML_DIR}")
message(STATUS "ASSET_DIR : ${QT_IOS_ASSET_DIR}")
message(STATUS "CATALOG_APPICON : ${QT_IOS_CATALOG_APPICON}")
message(STATUS "CATALOG_LAUNCHIMAGE : ${QT_IOS_CATALOG_LAUNCHIMAGE}")
message(STATUS "LAUNCHSCREEN_STORYBOARD : ${QT_IOS_LAUNCHSCREEN_STORYBOARD}")
message(STATUS "MAIN_STORYBOARD : ${QT_IOS_MAIN_STORYBOARD}")
message(STATUS "ORIENTATION_PORTRAIT : ${QT_IOS_ORIENTATION_PORTRAIT}")
message(STATUS "ORIENTATION_PORTRAIT_UPDOWN : ${QT_IOS_ORIENTATION_PORTRAIT_UPDOWN}")
message(STATUS "ORIENTATION_LANDSCAPE_LEFT : ${QT_IOS_ORIENTATION_LANDSCAPE_LEFT}")
message(STATUS "ORIENTATION_LANDSCAPE_RIGHT : ${QT_IOS_ORIENTATION_LANDSCAPE_RIGHT}")
if(QT_IOS_PHOTO_LIBRARY_USAGE_DESCRIPTION)
message(STATUS "PHOTO_LIBRARY_USAGE_DESCRIPTION : ${QT_IOS_PHOTO_LIBRARY_USAGE_DESCRIPTION}")
endif()
message(STATUS "SUPPORT_IPHONE : ${QT_IOS_SUPPORT_IPHONE}")
message(STATUS "SUPPORT_IPAD : ${QT_IOS_SUPPORT_IPAD}")
message(STATUS "REQUIRES_FULL_SCREEN : ${QT_IOS_REQUIRES_FULL_SCREEN}")
message(STATUS "HIDDEN_STATUS_BAR : ${QT_IOS_HIDDEN_STATUS_BAR}")
message(STATUS "IPA : ${QT_IOS_IPA}")
message(STATUS "UPLOAD_SYMBOL : ${QT_IOS_UPLOAD_SYMBOL}")
message(STATUS "DISTRIBUTION_METHOD : ${QT_IOS_DISTRIBUTION_METHOD}")
message(STATUS "RESOURCE_FILES : ${QT_IOS_RESOURCE_FILES}")
message(STATUS "------ QtIosCMake END Configuration ------")
endif() # QT_IOS_VERBOSE
# Bundle executable.
if(QT_IOS_VERBOSE)
message(STATUS "Set property MACOSX_BUNDLE to ${QT_IOS_TARGET}")
endif() # QT_IOS_VERBOSE
set_target_properties(${QT_IOS_TARGET} PROPERTIES MACOSX_BUNDLE ON)
# Qt Mess
function(qt_ios_clean_paths)
foreach(_path_group ${ARGN})
foreach(_path ${${_path_group}})
get_filename_component(_path_cleaned ${_path} REALPATH)
file(TO_NATIVE_PATH ${_path_cleaned} _path_cleaned)
set(_path_group_cleaned ${_path_group_cleaned} ${_path_cleaned})
endforeach()
set(${_path_group} ${_path_group_cleaned} PARENT_SCOPE)
endforeach()
endfunction()
macro(qt_ios_handle_cyclical_linking LIBS)
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT APPLE))
set(${LIBS} -Wl,--start-group ${${LIBS}} -Wl,--end-group)
endif()
endmacro()
# let's not be picky, just throw all the available static libraries at the linker and let it figure out which ones are actually needed
# a 'foreach' is used because 'target_link_libraries' doesn't handle lists correctly (the ; messes it up and nothing actually gets linked against)
if(QT_IOS_TARGET_IS_WINDOWS)
set(_DEBUG_SUFFIX d)
elseif(QT_IOS_TARGET_IS_IOS OR QT_IOS_TARGET_IS_MAC)
set(_DEBUG_SUFFIX _debug)
else()
set(_DEBUG_SUFFIX)
endif()
set(_LIBS_BASE_DIR "${QT_IOS_QT_ROOT}/lib")
qt_ios_clean_paths(_LIBS_BASE_DIR)
file(GLOB_RECURSE _QT_LIBS "${_LIBS_BASE_DIR}/*${CMAKE_STATIC_LIBRARY_SUFFIX}")
foreach(_QT_LIB ${_QT_LIBS})
string(REGEX MATCH ".*${_DEBUG_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}$" _IS_DEBUG_LIB ${_QT_LIB})
string(REGEX MATCH ".*_iphonesimulator${_DEBUG_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}$" _IS_DEBUG_SIM_LIB ${_QT_LIB})
string(REGEX MATCH ".*_iphonesimulator${CMAKE_STATIC_LIBRARY_SUFFIX}$" _IS_SIM_LIB ${_QT_LIB})
string(REGEX MATCH ".*Qt5Bootstrap.*" _IS_BOOTSTRAP ${_QT_LIB})
string(REGEX MATCH ".*Qt5QmlDevTools.*" _IS_DEVTOOLS ${_QT_LIB})
if(NOT _IS_BOOTSTRAP AND NOT _IS_DEVTOOLS AND NOT _IS_DEBUG_SIM_LIB AND NOT _IS_SIM_LIB)
if(_IS_DEBUG_LIB OR NOT _DEBUG_SUFFIX)
set(QT_EXTRA_LIBS ${QT_EXTRA_LIBS} debug "${_QT_LIB}")
endif()
if(NOT _IS_DEBUG_LIB OR NOT _DEBUG_SUFFIX)
set(QT_EXTRA_LIBS ${QT_EXTRA_LIBS} optimized "${_QT_LIB}")
endif()
endif()
endforeach()
set(_QML_BASE_DIR "${QT_IOS_QML_DIR}")
qt_ios_clean_paths(_QML_BASE_DIR)
file(GLOB_RECURSE _QML_PLUGINS "${_QML_BASE_DIR}/*${CMAKE_STATIC_LIBRARY_SUFFIX}")
foreach(_QML_PLUGIN ${_QML_PLUGINS})
string(REGEX MATCH ".*${_DEBUG_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}$" _IS_DEBUG_LIB ${_QML_PLUGIN})
string(REGEX MATCH ".*_iphonesimulator${_DEBUG_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}$" _IS_DEBUG_SIM_LIB ${_QML_PLUGIN})
string(REGEX MATCH ".*_iphonesimulator${CMAKE_STATIC_LIBRARY_SUFFIX}$" _IS_SIM_LIB ${_QML_PLUGIN})
if(NOT _IS_DEBUG_SIM_LIB AND NOT _IS_SIM_LIB)
if(_IS_DEBUG_LIB OR NOT _DEBUG_SUFFIX)
set(QT_EXTRA_LIBS ${QT_EXTRA_LIBS} debug "${_QML_PLUGIN}")
endif()
if(NOT _IS_DEBUG_LIB OR NOT _DEBUG_SUFFIX)
set(QT_EXTRA_LIBS ${QT_EXTRA_LIBS} optimized "${_QML_PLUGIN}")
endif()
endif()
endforeach()
set(_PLUGINS_BASE_DIR "${QT_IOS_QT_ROOT}/plugins")
qt_ios_clean_paths(_PLUGINS_BASE_DIR)
file(GLOB_RECURSE _QT_PLUGINS "${_PLUGINS_BASE_DIR}/*${CMAKE_STATIC_LIBRARY_SUFFIX}")
foreach(_QT_PLUGIN ${_QT_PLUGINS})
string(REGEX MATCH ".*${_DEBUG_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}$" _IS_DEBUG_LIB ${_QT_PLUGIN})
string(REGEX MATCH ".*_iphonesimulator${_DEBUG_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}$" _IS_DEBUG_SIM_LIB ${_QT_PLUGIN})
string(REGEX MATCH ".*_iphonesimulator${CMAKE_STATIC_LIBRARY_SUFFIX}$" _IS_SIM_LIB ${_QT_PLUGIN})
if(NOT _IS_DEBUG_SIM_LIB AND NOT _IS_SIM_LIB)
if(_IS_DEBUG_LIB OR NOT _DEBUG_SUFFIX)
set(QT_EXTRA_LIBS ${QT_EXTRA_LIBS} debug "${_QT_PLUGIN}")
endif()
if(NOT _IS_DEBUG_LIB OR NOT _DEBUG_SUFFIX)
set(QT_EXTRA_LIBS ${QT_EXTRA_LIBS} optimized "${_QT_PLUGIN}")
endif()
endif()
endforeach()
# static linking
set(QT_LIBRARIES ${QT_LIBRARIES} ${QT_EXTRA_LIBS})
qt_ios_handle_cyclical_linking(QT_LIBRARIES)
# Define entry point for correct initialization.
# Maybe set this optionnal in the future if user wants to set his own entry point ?
if(QT_IOS_VERBOSE)
message(STATUS "Add -e _qt_main_wrapper linker flag to ${QT_IOS_TARGET} to change application entry point to create UIApplication before QApplication")
endif() # QT_IOS_VERBOSE
target_link_libraries(${QT_IOS_TARGET} PUBLIC ${QT_LIBRARIES} "-e _qt_main_wrapper")
# Set XCode property for automatic code sign
if(QT_IOS_CODE_SIGN_IDENTITY)
qt_ios_set_xcode_property(${QT_IOS_TARGET} CODE_SIGN_IDENTITY ${QT_IOS_CODE_SIGN_IDENTITY} "All")
endif()
if(QT_IOS_TEAM_ID)
qt_ios_set_xcode_property(${QT_IOS_TARGET} DEVELOPMENT_TEAM ${QT_IOS_TEAM_ID} "All")
set(CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM ${QT_IOS_TEAM_ID} CACHE INTERNAL "" FORCE)
endif()
if(QT_IOS_PROVISIONING_PROFILE_SPECIFIER)
qt_ios_set_xcode_property(${QT_IOS_TARGET} PROVISIONING_PROFILE_SPECIFIER ${QT_IOS_PROVISIONING_PROFILE_SPECIFIER} "All")
endif()
# Ugly but working
if(QT_IOS_SUPPORT_IPAD AND QT_IOS_SUPPORT_IPHONE)
qt_ios_set_xcode_property(${QT_IOS_TARGET} TARGETED_DEVICE_FAMILY "1,2" "All")
elseif(QT_IOS_SUPPORT_IPAD)
qt_ios_set_xcode_property(${QT_IOS_TARGET} TARGETED_DEVICE_FAMILY "2" "All")
elseif(QT_IOS_SUPPORT_IPHONE)
qt_ios_set_xcode_property(${QT_IOS_TARGET} TARGETED_DEVICE_FAMILY "1" "All")
else()
if(QT_IOS_VERBOSE)
message(STATUS "None of SUPPORT_IPHONE or SUPPORT_IPAD are set. Support both by default.")
endif()
qt_ios_set_xcode_property(${QT_IOS_TARGET} TARGETED_DEVICE_FAMILY "1,2" "All")
endif()
# Set AppIcon Catalog
if(QT_IOS_CATALOG_APPICON)
qt_ios_set_xcode_property (${QT_IOS_TARGET} ASSETCATALOG_COMPILER_APPICON_NAME ${QT_IOS_CATALOG_APPICON} "All")
endif()
# Set LaunchImage Catalog
if(QT_IOS_CATALOG_LAUNCHIMAGE)
qt_ios_set_xcode_property (${QT_IOS_TARGET} ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME ${QT_IOS_CATALOG_LAUNCHIMAGE} "All")
endif()
# Make sure a publish dialog is set in XCode.
# If INSTALL_PATH is empty it won't be possible to deploy to App Store
qt_ios_set_xcode_property(${QT_IOS_TARGET} INSTALL_PATH "/Applications" "All")
# Set CMake variables for plist
set(MACOSX_BUNDLE_EXECUTABLE_NAME ${QT_IOS_NAME} PARENT_SCOPE)
set(MACOSX_BUNDLE_INFO_STRING ${QT_IOS_NAME} PARENT_SCOPE)
set(MACOSX_BUNDLE_GUI_IDENTIFIER ${QT_IOS_BUNDLE_IDENTIFIER} PARENT_SCOPE)
set(MACOSX_BUNDLE_BUNDLE_NAME ${QT_IOS_NAME} PARENT_SCOPE)
qt_ios_set_xcode_property(${QT_IOS_TARGET} PRODUCT_BUNDLE_IDENTIFIER "${QT_IOS_BUNDLE_IDENTIFIER}" "All")
#set(MACOSX_BUNDLE_ICON_FILE "${PROJECT_SOURCE_DIR} PARENT_SCOPE/platform/ios/Assets.xcassets/AppIcon.appiconset")
set(MACOSX_BUNDLE_BUNDLE_VERSION ${QT_IOS_VERSION} PARENT_SCOPE)
set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${QT_IOS_SHORT_VERSION} PARENT_SCOPE)
set(MACOSX_BUNDLE_LONG_VERSION_STRING ${QT_IOS_LONG_VERSION} PARENT_SCOPE)
set(MACOSX_BUNDLE_COPYRIGHT ${QT_IOS_COPYRIGHT} PARENT_SCOPE)
# Set require full screen
if(QT_IOS_REQUIRES_FULL_SCREEN)
set(MACOSX_BUNDLE_REQUIRES_FULL_SCREEN "YES" PARENT_SCOPE)
if(QT_IOS_VERBOSE)
message(STATUS "Add UIRequiresFullScreen flag to Info.pList")
endif() # QT_IOS_VERBOSE
else() # QT_IOS_REQUIRES_FULL_SCREEN
set(MACOSX_BUNDLE_REQUIRES_FULL_SCREEN "NO" PARENT_SCOPE)
endif() # QT_IOS_REQUIRES_FULL_SCREEN
# Set hidden status bar
if(QT_IOS_HIDDEN_STATUS_BAR)
set(MACOSX_BUNDLE_HIDDEN_STATUS_BAR "true" PARENT_SCOPE)
if(QT_IOS_VERBOSE)
message(STATUS "Add UIStatusBarHidden flag to Info.pList")
endif() # QT_IOS_VERBOSE
else() # QT_IOS_HIDDEN_STATUS_BAR
set(MACOSX_BUNDLE_HIDDEN_STATUS_BAR "false" PARENT_SCOPE)
endif() # QT_IOS_HIDDEN_STATUS_BAR
# Add orientation flags
if(QT_IOS_ORIENTATION_PORTRAIT)
set(MACOSX_BUNDLE_PORTRAIT "UIInterfaceOrientationPortrait" PARENT_SCOPE)
if(QT_IOS_VERBOSE)
message(STATUS "Add UIInterfaceOrientationPortrait flag to Info.pList")
endif() # QT_IOS_VERBOSE
endif()
if(QT_IOS_ORIENTATION_PORTRAIT_UPDOWN)
set(MACOSX_BUNDLE_PORTRAITUPDOWN "UIInterfaceOrientationPortraitUpsideDown" PARENT_SCOPE)
if(QT_IOS_VERBOSE)
message(STATUS "Add UIInterfaceOrientationPortraitUpsideDown flag to Info.pList")
endif() # QT_IOS_VERBOSE
endif()
if(QT_IOS_ORIENTATION_LANDSCAPE_LEFT)
set(MACOSX_BUNDLE_LANDSCAPELEFT "UIInterfaceOrientationLandscapeLeft" PARENT_SCOPE)
if(QT_IOS_VERBOSE)
message(STATUS "Add UIInterfaceOrientationLandscapeLeft flag to Info.pList")
endif() # QT_IOS_VERBOSE
endif()
if(QT_IOS_ORIENTATION_LANDSCAPE_RIGHT)
set(MACOSX_BUNDLE_LANDSCAPERIGHT "UIInterfaceOrientationLandscapeRight" PARENT_SCOPE)
if(QT_IOS_VERBOSE)
message(STATUS "Add UIInterfaceOrientationLandscapeRight flag to Info.pList")
endif() # QT_IOS_VERBOSE
endif()
if(NOT QT_IOS_ORIENTATION_PORTRAIT AND
NOT QT_IOS_ORIENTATION_PORTRAIT_UPDOWN AND
NOT QT_IOS_ORIENTATION_LANDSCAPE_LEFT AND
NOT QT_IOS_ORIENTATION_LANDSCAPE_RIGHT)
set(MACOSX_BUNDLE_PORTRAIT "UIInterfaceOrientationPortrait" PARENT_SCOPE)
if(QT_IOS_VERBOSE)
message(STATUS "Add UIInterfaceOrientationPortrait as default to Info.pList becayse nothing was set by user in the list"
"{ORIENTATION_PORTRAIT, ORIENTATION_PORTRAIT_UPDOWN, ORIENTATION_LANDSCAPE_LEFT, ORIENTATION_LANDSCAPE_RIGHT}")
endif() # QT_IOS_VERBOSE
endif()
# Set Custom pList
set_target_properties(${QT_IOS_TARGET} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${QT_IOS_CUSTOM_PLIST})
# Add asset dir as ressource
if(QT_IOS_ASSET_DIR)
target_sources(${QT_IOS_TARGET} PRIVATE ${QT_IOS_ASSET_DIR})
set_source_files_properties(${QT_IOS_ASSET_DIR} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
else(QT_IOS_ASSET_DIR)
if(QT_IOS_VERBOSE)
message(STATUS "No Asset dir specified. This is the recommanded way to add Icons and LaunchImage")
endif() # QT_IOS_VERBOSE
endif() # QT_IOS_ASSET_DIR
foreach(_resource IN LISTS QT_IOS_RESOURCE_FILES)
if(QT_IOS_VERBOSE)
message(STATUS "Add resource: ${_resource}")
endif()
target_sources(${QT_IOS_TARGET} PRIVATE ${_resource})
set_source_files_properties(${_resource} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
endforeach()
# Add Launchscreen storyboard as ressource
if(QT_IOS_LAUNCHSCREEN_STORYBOARD)
target_sources(${QT_IOS_TARGET} PRIVATE ${QT_IOS_LAUNCHSCREEN_STORYBOARD})
set_source_files_properties(${QT_IOS_LAUNCHSCREEN_STORYBOARD} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
get_filename_component(STORYBOARD_FILE_NAME ${QT_IOS_LAUNCHSCREEN_STORYBOARD} NAME_WE)
if(QT_IOS_VERBOSE)
message(STATUS "Add UILaunchStoryboardName key with value ${STORYBOARD_FILE_NAME} in Info.pList")
endif() # QT_IOS_VERBOSE
set(MACOSX_BUNDLE_LAUNCHSCREEN_STORYBOARD ${STORYBOARD_FILE_NAME} PARENT_SCOPE)
else() # QT_IOS_LAUNCHSCREEN_STORYBOARD
if(QT_IOS_VERBOSE)
if(NOT QT_IOS_REQUIRES_FULL_SCREEN)
message(WARNING "LaunchScreen.storyboard isn't specified, it's is now recommanded to have one if you don't set REQUIRES_FULL_SCREEN")
endif() # NOT QT_IOS_REQUIRES_FULL_SCREEN
endif() # QT_IOS_VERBOSE
endif() # QT_IOS_LAUNCHSCREEN_STORYBOARD
# Add Main storyboard as ressource
if(QT_IOS_MAIN_STORYBOARD)
target_sources(${QT_IOS_TARGET} PRIVATE ${QT_IOS_MAIN_STORYBOARD})
set_source_files_properties(${QT_IOS_MAIN_STORYBOARD} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
# We just need to set the filename without extension
string(REGEX MATCH "([a-zA-Z0-9 \\-_]*)\\.storyboard" STORYBOARD_FILE_NAME ${QT_IOS_MAIN_STORYBOARD})
if(QT_IOS_VERBOSE)
message(STATUS "Add UIMainStoryboardFile key with value ${CMAKE_MATCH_1} in Info.pList")
endif() # QT_IOS_VERBOSE
set(MACOSX_BUNDLE_MAIN_STORYBOARD ${CMAKE_MATCH_1} PARENT_SCOPE)
endif(QT_IOS_MAIN_STORYBOARD)
if(${PLATFORM_INT} MATCHES ".*SIMULATOR.*" AND QT_IOS_IPA)
unset(QT_IOS_IPA)
message(WARNING "Ipa can't be enabled for simulator.")
endif()
if(QT_IOS_IPA)
set(QT_IOS_TARGET_ARCHIVE ${QT_IOS_TARGET}Archive)
set(QT_IOS_TARGET_IPA ${QT_IOS_TARGET}Ipa)
set(QT_IOS_TARGET_ARCHIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/${QT_IOS_TARGET}.xcarchive)
set(QT_IOS_TARGET_IPA_PATH ${CMAKE_CURRENT_BINARY_DIR}/${QT_IOS_TARGET_IPA})
# Generate archive
add_custom_target(${QT_IOS_TARGET_ARCHIVE}
ALL
DEPENDS ${QT_IOS_TARGET}
COMMAND xcodebuild
-project ${PROJECT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.xcodeproj
-scheme ${QT_IOS_TARGET}
-archivePath ${QT_IOS_TARGET_ARCHIVE_PATH}
${QT_IOS_ARCHIVE_XCODEBUILD_FLAGS}
archive
)
# Generate IPA
if(QT_IOS_PROVISIONING_PROFILE_SPECIFIER)
set(QT_IOS_EXPORT_SIGNING_TYPE "manual")
else()
set(QT_IOS_EXPORT_SIGNING_TYPE "automatic")
endif()
set(QT_IOS_PROVISIONING_PROFILES_KEY
"<key>provisioningProfiles</key>\n <dict>\n <key>${QT_IOS_BUNDLE_IDENTIFIER}</key>\n <string>${QT_IOS_PROVISIONING_PROFILE_SPECIFIER}</string>\n </dict>\n"
)
if(ENABLE_BITCODE)
set(QT_IOS_ENABLE_BITCODE TRUE)
endif()
if(QT_IOS_ENABLE_BITCODE)
set(QT_IOS_ENABLE_BITCODE_KEY "<key>compileBitcode</key><true/>")
else()
set(QT_IOS_ENABLE_BITCODE_KEY "")
endif()
if(QT_IOS_UPLOAD_SYMBOL)
set(QT_IOS_UPLOAD_SYMBOL_KEY "<key>uploadSymbols</key><true/>")
else()
set(QT_IOS_UPLOAD_SYMBOL_KEY "")
endif()
if(QT_IOS_PHOTO_LIBRARY_USAGE_DESCRIPTION)
set(MACOSX_BUNDLE_PHOTO_LIBRARY_USAGE_DESCRIPTION "<key>NSPhotoLibraryUsageDescription</key> <string>${QT_IOS_PHOTO_LIBRARY_USAGE_DESCRIPTION}</string>" PARENT_SCOPE)
endif()
set(QT_IOS_EXPORT_OPTIONS_FILE ${CMAKE_CURRENT_BINARY_DIR}/${QT_IOS_TARGET}ExportOptions.plist)
configure_file(${QT_IOS_SOURCE_DIR}/ExportOptions.plist.in ${QT_IOS_EXPORT_OPTIONS_FILE})
add_custom_target(${QT_IOS_TARGET_IPA}
ALL
DEPENDS ${QT_IOS_TARGET_ARCHIVE}
COMMAND xcodebuild -exportArchive
-archivePath ${QT_IOS_TARGET_ARCHIVE_PATH}
-exportOptionsPlist ${QT_IOS_EXPORT_OPTIONS_FILE}
-exportPath ${QT_IOS_TARGET_IPA_PATH}
${QT_IOS_EXPORT_ARCHIVE_XCODEBUILD_FLAGS}
)
endif()
endfunction()