-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathJUCEUtils.cmake
2471 lines (1953 loc) · 105 KB
/
JUCEUtils.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
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# ==============================================================================
#
# This file is part of the JUCE framework.
# Copyright (c) Raw Material Software Limited
#
# JUCE is an open source framework subject to commercial or open source
# licensing.
#
# By downloading, installing, or using the JUCE framework, or combining the
# JUCE framework with any other source code, object code, content or any other
# copyrightable work, you agree to the terms of the JUCE End User Licence
# Agreement, and all incorporated terms including the JUCE Privacy Policy and
# the JUCE Website Terms of Service, as applicable, which will bind you. If you
# do not agree to the terms of these agreements, we will not license the JUCE
# framework to you, and you must discontinue the installation or download
# process and cease use of the JUCE framework.
#
# JUCE End User Licence Agreement: https://juce.com/legal/juce-8-licence/
# JUCE Privacy Policy: https://juce.com/juce-privacy-policy
# JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
#
# Or:
#
# You may also use this code under the terms of the AGPLv3:
# https://www.gnu.org/licenses/agpl-3.0.en.html
#
# THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
# WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
#
# ==============================================================================
# ==================================================================================================
# JUCE Target Support Helper Functions
#
# In this file, functions intended for use by end-users have the prefix `juce_`.
# Functions beginning with an underscore should be considered private and susceptible to
# change, so don't call them directly.
#
# See the readme at `docs/CMake API.md` for more information about CMake usage,
# including documentation of the public functions in this file.
# ==================================================================================================
include_guard(GLOBAL)
cmake_minimum_required(VERSION 3.22)
define_property(TARGET PROPERTY JUCE_COMPANY_NAME INHERITED
BRIEF_DOCS "The company name for a particular target"
FULL_DOCS "This can be found in ProjectInfo::companyName in a generated JuceHeader.h")
set_property(GLOBAL PROPERTY JUCE_COMPANY_NAME "yourcompany")
define_property(TARGET PROPERTY JUCE_COMPANY_WEBSITE INHERITED
BRIEF_DOCS "The company website for a particular target"
FULL_DOCS "This will be placed in the Info.plist for the target")
set_property(GLOBAL PROPERTY JUCE_COMPANY_WEBSITE "")
define_property(TARGET PROPERTY JUCE_COMPANY_EMAIL INHERITED
BRIEF_DOCS "The company email address for a particular target"
FULL_DOCS "This will be placed in the Info.plist for the target")
set_property(GLOBAL PROPERTY JUCE_COMPANY_EMAIL "")
define_property(TARGET PROPERTY JUCE_COMPANY_COPYRIGHT INHERITED
BRIEF_DOCS "The company copyright for a particular target"
FULL_DOCS "This will be placed in the Info.plist for the target")
set_property(GLOBAL PROPERTY JUCE_COMPANY_COPYRIGHT "")
define_property(TARGET PROPERTY JUCE_VST_COPY_DIR INHERITED
BRIEF_DOCS "Install location for VST2 plugins"
FULL_DOCS "This is where the plugin will be copied if plugin copying is enabled")
define_property(TARGET PROPERTY JUCE_VST3_COPY_DIR INHERITED
BRIEF_DOCS "Install location for VST3 plugins"
FULL_DOCS "This is where the plugin will be copied if plugin copying is enabled")
define_property(TARGET PROPERTY JUCE_AU_COPY_DIR INHERITED
BRIEF_DOCS "Install location for AU plugins"
FULL_DOCS "This is where the plugin will be copied if plugin copying is enabled")
define_property(TARGET PROPERTY JUCE_AAX_COPY_DIR INHERITED
BRIEF_DOCS "Install location for AAX plugins"
FULL_DOCS "This is where the plugin will be copied if plugin copying is enabled")
define_property(TARGET PROPERTY JUCE_UNITY_COPY_DIR INHERITED
BRIEF_DOCS "Install location for Unity plugins"
FULL_DOCS "This is where the plugin will be copied if plugin copying is enabled")
define_property(TARGET PROPERTY JUCE_LV2_COPY_DIR INHERITED
BRIEF_DOCS "Install location for LV2 plugins"
FULL_DOCS "This is where the plugin will be copied if plugin copying is enabled")
define_property(TARGET PROPERTY JUCE_COPY_PLUGIN_AFTER_BUILD INHERITED
BRIEF_DOCS "Whether or not plugins should be copied after building"
FULL_DOCS "Whether or not plugins should be copied after building")
set_property(GLOBAL PROPERTY JUCE_COPY_PLUGIN_AFTER_BUILD FALSE)
function(_juce_available_pkgconfig_module_or_else out package alternative_package)
find_package(PkgConfig REQUIRED)
pkg_check_modules(package_to_be_found ${package} QUIET)
if(package_to_be_found_FOUND)
set(${out} ${package} PARENT_SCOPE)
else()
set(${out} ${alternative_package} PARENT_SCOPE)
endif()
endfunction()
if((CMAKE_SYSTEM_NAME STREQUAL "Linux") OR (CMAKE_SYSTEM_NAME MATCHES ".*BSD"))
_juce_create_pkgconfig_target(JUCE_CURL_LINUX_DEPS libcurl)
_juce_available_pkgconfig_module_or_else(webkit_package_name webkit2gtk-4.1 webkit2gtk-4.0)
# All browser related libs are loaded dynamically only if they are available during runtime
_juce_create_pkgconfig_target(JUCE_BROWSER_LINUX_DEPS NOLINK ${webkit_package_name} gtk+-x11-3.0)
endif()
# We set up default/fallback copy dirs here. If you need different copy dirs, use
# set_directory_properties or set_target_properties to adjust the values of `JUCE_*_COPY_DIR` at
# the appropriate scope.
function(_juce_set_default_properties)
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set_property(GLOBAL PROPERTY JUCE_LV2_COPY_DIR "$ENV{HOME}/Library/Audio/Plug-Ins/LV2")
set_property(GLOBAL PROPERTY JUCE_VST_COPY_DIR "$ENV{HOME}/Library/Audio/Plug-Ins/VST")
set_property(GLOBAL PROPERTY JUCE_VST3_COPY_DIR "$ENV{HOME}/Library/Audio/Plug-Ins/VST3")
set_property(GLOBAL PROPERTY JUCE_AU_COPY_DIR "$ENV{HOME}/Library/Audio/Plug-Ins/Components")
set_property(GLOBAL PROPERTY JUCE_UNITY_COPY_DIR "$ENV{HOME}/Library/Audio/Plug-Ins/Unity")
set_property(GLOBAL PROPERTY JUCE_AAX_COPY_DIR "/Library/Application Support/Avid/Audio/Plug-Ins")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set_property(GLOBAL PROPERTY JUCE_VST_COPY_DIR "$ENV{ProgramW6432}/Steinberg/Vstplugins")
set(prefix "$ENV{CommonProgramW6432}")
else()
set_property(GLOBAL PROPERTY JUCE_VST_COPY_DIR "$ENV{programfiles\(x86\)}/Steinberg/Vstplugins")
set(prefix "$ENV{CommonProgramFiles\(x86\)}")
endif()
set_property(GLOBAL PROPERTY JUCE_VST3_COPY_DIR "${prefix}/VST3")
set_property(GLOBAL PROPERTY JUCE_AAX_COPY_DIR "${prefix}/Avid/Audio/Plug-Ins")
set_property(GLOBAL PROPERTY JUCE_LV2_COPY_DIR "$ENV{APPDATA}/LV2")
set_property(GLOBAL PROPERTY JUCE_UNITY_COPY_DIR "$ENV{APPDATA}/Unity")
elseif((CMAKE_SYSTEM_NAME STREQUAL "Linux") OR (CMAKE_SYSTEM_NAME MATCHES ".*BSD"))
set_property(GLOBAL PROPERTY JUCE_LV2_COPY_DIR "$ENV{HOME}/.lv2")
set_property(GLOBAL PROPERTY JUCE_VST_COPY_DIR "$ENV{HOME}/.vst")
set_property(GLOBAL PROPERTY JUCE_VST3_COPY_DIR "$ENV{HOME}/.vst3")
set_property(GLOBAL PROPERTY JUCE_UNITY_COPY_DIR "$ENV{HOME}/.unity")
endif()
endfunction()
_juce_set_default_properties()
# ==================================================================================================
function(juce_add_bundle_resources_directory target folder)
_juce_make_absolute(folder)
if(NOT EXISTS "${folder}")
message(FATAL_ERROR "Could not find resource folder ${folder}")
endif()
get_filename_component(folder_parent_path "${folder}" DIRECTORY)
file(GLOB_RECURSE resources RELATIVE "${folder_parent_path}" "${folder}/*")
foreach(file IN LISTS resources)
target_sources(${target} PRIVATE "${folder_parent_path}/${file}")
get_filename_component(resource_parent_path "${file}" DIRECTORY)
set_source_files_properties("${folder_parent_path}/${file}" PROPERTIES
HEADER_FILE_ONLY TRUE
MACOSX_PACKAGE_LOCATION "Resources/${resource_parent_path}")
endforeach()
endfunction()
# ==================================================================================================
function(_juce_create_linux_subprocess_helper_target)
if(TARGET juce_linux_subprocess_helper)
return()
endif()
set(source "${JUCE_CMAKE_UTILS_DIR}/juce_LinuxSubprocessHelper.cpp")
add_executable(juce_linux_subprocess_helper ${source})
add_executable(juce::juce_linux_subprocess_helper ALIAS juce_linux_subprocess_helper)
target_compile_features(juce_linux_subprocess_helper PRIVATE cxx_std_17)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(juce_linux_subprocess_helper PRIVATE Threads::Threads ${CMAKE_DL_LIBS})
endfunction()
function(_juce_create_embedded_linux_subprocess_target output_target_name target)
# This library needs to be created in every directory where a target wants to link against it.
# Pre CMake 3.20 the GENERATED property is only visible in the directory of the current target,
# and even post 3.20, CMake will not know how to generate the sources outside this directory.
set(target_directory_key JUCE_EMBEDDED_LINUX_SUBPROCESS_TARGET)
get_directory_property(embedded_linux_subprocess_target ${target_directory_key})
if(embedded_linux_subprocess_target)
set(${output_target_name} juce::${embedded_linux_subprocess_target} PARENT_SCOPE)
return()
endif()
set(prefix "_juce_directory_prefix")
set(embedded_linux_subprocess_target ${prefix}_embedded_linux_subprocess)
while(TARGET ${embedded_linux_subprocess_target})
set(embedded_linux_subprocess_target ${prefix}_${embedded_linux_subprocess_target})
endwhile()
_juce_create_linux_subprocess_helper_target()
get_target_property(generated_sources_directory ${target} JUCE_GENERATED_SOURCES_DIRECTORY)
if(generated_sources_directory)
set(juce_linux_subprocess_helper_binary_dir "${generated_sources_directory}/$<CONFIG>/")
else()
set(juce_linux_subprocess_helper_binary_dir "${CMAKE_CURRENT_BINARY_DIR}/juce_LinuxSubprocessHelper/$<CONFIG>/")
endif()
set(binary_header_file "${juce_linux_subprocess_helper_binary_dir}/juce_LinuxSubprocessHelperBinaryData.h")
set(binary_source_file "${juce_linux_subprocess_helper_binary_dir}/juce_LinuxSubprocessHelperBinaryData.cpp")
set(juceaide_input_file "${juce_linux_subprocess_helper_binary_dir}/input_file_list")
file(GENERATE OUTPUT ${juceaide_input_file} CONTENT "$<TARGET_FILE:juce_linux_subprocess_helper>")
file(MAKE_DIRECTORY ${juce_linux_subprocess_helper_binary_dir})
add_custom_command(
OUTPUT
${binary_header_file}
${binary_source_file}
COMMAND juce::juceaide binarydata "LinuxSubprocessHelperBinaryData" "${binary_header_file}"
${juce_linux_subprocess_helper_binary_dir} "${juceaide_input_file}"
COMMAND
${CMAKE_COMMAND} -E rename "${juce_linux_subprocess_helper_binary_dir}/BinaryData1.cpp" "${binary_source_file}"
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
DEPENDS juce_linux_subprocess_helper
VERBATIM)
add_library(${embedded_linux_subprocess_target} INTERFACE)
target_sources(${embedded_linux_subprocess_target} INTERFACE ${binary_source_file})
target_include_directories(${embedded_linux_subprocess_target} INTERFACE ${juce_linux_subprocess_helper_binary_dir})
target_compile_definitions(${embedded_linux_subprocess_target} INTERFACE JUCE_USE_EXTERNAL_TEMPORARY_SUBPROCESS=1)
add_library(juce::${embedded_linux_subprocess_target} ALIAS ${embedded_linux_subprocess_target})
set_directory_properties(PROPERTIES ${target_directory_key} ${embedded_linux_subprocess_target})
set(${output_target_name} juce::${embedded_linux_subprocess_target} PARENT_SCOPE)
endfunction()
function(juce_link_with_embedded_linux_subprocess target)
_juce_create_embedded_linux_subprocess_target(embedded_linux_subprocess_target ${target})
target_link_libraries(${target} PRIVATE ${embedded_linux_subprocess_target})
endfunction()
# ==================================================================================================
# Ideally, we'd check the preprocessor defs on the target to see whether
# JUCE_USE_CURL, JUCE_WEB_BROWSER, or JUCE_IN_APP_PURCHASES have been explicitly turned off,
# and then link libraries as appropriate.
# Unfortunately, this doesn't work, because linking a new library (curl/webkit/StoreKit)
# updates the target's compile defs, which results in a recursion/circular-dependency.
# Instead, we ask the user to explicitly request curl/webkit/StoreKit linking if they
# know they need it. Otherwise, we won't link anything.
# See the NEEDS_CURL, NEEDS_WEB_BROWSER, and NEEDS_STORE_KIT options in the CMake/readme.md.
function(_juce_link_optional_libraries target)
if((CMAKE_SYSTEM_NAME STREQUAL "Linux") OR (CMAKE_SYSTEM_NAME MATCHES ".*BSD"))
get_target_property(needs_curl ${target} JUCE_NEEDS_CURL)
if(needs_curl)
target_link_libraries(${target} PRIVATE juce::pkgconfig_JUCE_CURL_LINUX_DEPS)
endif()
get_target_property(needs_browser ${target} JUCE_NEEDS_WEB_BROWSER)
if(needs_browser)
target_link_libraries(${target} PRIVATE juce::pkgconfig_JUCE_BROWSER_LINUX_DEPS)
get_target_property(is_plugin ${target} JUCE_IS_PLUGIN)
if(is_plugin)
juce_link_with_embedded_linux_subprocess(${target})
endif()
endif()
elseif(APPLE)
get_target_property(needs_storekit ${target} JUCE_NEEDS_STORE_KIT)
if(needs_storekit)
_juce_link_frameworks("${target}" PRIVATE StoreKit)
endif()
get_target_property(needs_camera ${target} JUCE_CAMERA_PERMISSION_ENABLED)
if(CMAKE_SYSTEM_NAME STREQUAL "iOS" AND needs_camera)
_juce_link_frameworks("${target}" PRIVATE ImageIO)
endif()
elseif(WIN32)
get_target_property(needs_webview2 ${target} JUCE_NEEDS_WEBVIEW2)
if (needs_webview2)
if(NOT ("${JUCE_CMAKE_UTILS_DIR}" IN_LIST CMAKE_MODULE_PATH))
list(APPEND CMAKE_MODULE_PATH "${JUCE_CMAKE_UTILS_DIR}")
endif()
find_package(WebView2 REQUIRED)
target_link_libraries(${target} PRIVATE juce::juce_webview2)
endif()
endif()
endfunction()
# ==================================================================================================
function(_juce_get_module_definitions target filter out_var)
set(compile_defs $<TARGET_GENEX_EVAL:${target},$<TARGET_PROPERTY:${target},COMPILE_DEFINITIONS>>)
if(filter)
set(${out_var} $<FILTER:${compile_defs},EXCLUDE,JucePlugin_Build_|JUCE_SHARED_CODE> PARENT_SCOPE)
else()
set(${out_var} ${compile_defs} PARENT_SCOPE)
endif()
endfunction()
function(_juce_append_record output key)
string(ASCII 30 RS)
string(ASCII 31 US)
set(prev)
if(DEFINED "${output}")
set(prev "${${output}}")
endif()
set(${output} "${prev}${key}${US}${ARGN}${RS}" PARENT_SCOPE)
endfunction()
function(_juce_append_target_property output key target property)
get_target_property(prop ${target} ${property})
if(prop STREQUAL "prop-NOTFOUND")
set(prop)
endif()
_juce_append_record(${output} ${key} ${prop})
set(${output} "${${output}}" PARENT_SCOPE)
endfunction()
# This is all info that should be known at configure time (i.e. no generator expressions here!)
# We use this info to generate plists and entitlements files, also at configure time.
function(_juce_write_configure_time_info target)
_juce_append_target_property(file_content EXECUTABLE_NAME ${target} JUCE_PRODUCT_NAME)
_juce_append_target_property(file_content VERSION ${target} JUCE_VERSION)
_juce_append_target_property(file_content BUILD_VERSION ${target} JUCE_BUILD_VERSION)
_juce_append_target_property(file_content PLIST_TO_MERGE ${target} JUCE_PLIST_TO_MERGE)
_juce_append_target_property(file_content BUNDLE_ID ${target} JUCE_BUNDLE_ID)
_juce_append_target_property(file_content XCODE_EXTRA_PLIST_ENTRIES ${target} JUCE_XCODE_EXTRA_PLIST_ENTRIES)
_juce_append_target_property(file_content MICROPHONE_PERMISSION_ENABLED ${target} JUCE_MICROPHONE_PERMISSION_ENABLED)
_juce_append_target_property(file_content MICROPHONE_PERMISSION_TEXT ${target} JUCE_MICROPHONE_PERMISSION_TEXT)
_juce_append_target_property(file_content CAMERA_PERMISSION_ENABLED ${target} JUCE_CAMERA_PERMISSION_ENABLED)
_juce_append_target_property(file_content CAMERA_PERMISSION_TEXT ${target} JUCE_CAMERA_PERMISSION_TEXT)
_juce_append_target_property(file_content BLUETOOTH_PERMISSION_ENABLED ${target} JUCE_BLUETOOTH_PERMISSION_ENABLED)
_juce_append_target_property(file_content BLUETOOTH_PERMISSION_TEXT ${target} JUCE_BLUETOOTH_PERMISSION_TEXT)
_juce_append_target_property(file_content SEND_APPLE_EVENTS_PERMISSION_ENABLED ${target} JUCE_SEND_APPLE_EVENTS_PERMISSION_ENABLED)
_juce_append_target_property(file_content SEND_APPLE_EVENTS_PERMISSION_TEXT ${target} JUCE_SEND_APPLE_EVENTS_PERMISSION_TEXT)
_juce_append_target_property(file_content SHOULD_ADD_STORYBOARD ${target} JUCE_SHOULD_ADD_STORYBOARD)
_juce_append_target_property(file_content LAUNCH_STORYBOARD_FILE ${target} JUCE_LAUNCH_STORYBOARD_FILE)
_juce_append_target_property(file_content ICON_FILE ${target} JUCE_ICON_FILE)
_juce_append_target_property(file_content PROJECT_NAME ${target} JUCE_PRODUCT_NAME)
_juce_append_target_property(file_content COMPANY_COPYRIGHT ${target} JUCE_COMPANY_COPYRIGHT)
_juce_append_target_property(file_content COMPANY_NAME ${target} JUCE_COMPANY_NAME)
_juce_append_target_property(file_content DOCUMENT_EXTENSIONS ${target} JUCE_DOCUMENT_EXTENSIONS)
_juce_append_target_property(file_content FILE_SHARING_ENABLED ${target} JUCE_FILE_SHARING_ENABLED)
_juce_append_target_property(file_content DOCUMENT_BROWSER_ENABLED ${target} JUCE_DOCUMENT_BROWSER_ENABLED)
_juce_append_target_property(file_content STATUS_BAR_HIDDEN ${target} JUCE_STATUS_BAR_HIDDEN)
_juce_append_target_property(file_content REQUIRES_FULL_SCREEN ${target} JUCE_REQUIRES_FULL_SCREEN)
_juce_append_target_property(file_content BACKGROUND_AUDIO_ENABLED ${target} JUCE_BACKGROUND_AUDIO_ENABLED)
_juce_append_target_property(file_content BACKGROUND_BLE_ENABLED ${target} JUCE_BACKGROUND_BLE_ENABLED)
_juce_append_target_property(file_content PUSH_NOTIFICATIONS_ENABLED ${target} JUCE_PUSH_NOTIFICATIONS_ENABLED)
_juce_append_target_property(file_content NETWORK_MULTICAST_ENABLED ${target} JUCE_NETWORK_MULTICAST_ENABLED)
_juce_append_target_property(file_content PLUGIN_MANUFACTURER_CODE ${target} JUCE_PLUGIN_MANUFACTURER_CODE)
_juce_append_target_property(file_content PLUGIN_CODE ${target} JUCE_PLUGIN_CODE)
_juce_append_target_property(file_content IPHONE_SCREEN_ORIENTATIONS ${target} JUCE_IPHONE_SCREEN_ORIENTATIONS)
_juce_append_target_property(file_content IPAD_SCREEN_ORIENTATIONS ${target} JUCE_IPAD_SCREEN_ORIENTATIONS)
_juce_append_target_property(file_content PLUGIN_NAME ${target} JUCE_PLUGIN_NAME)
_juce_append_target_property(file_content PLUGIN_MANUFACTURER ${target} JUCE_COMPANY_NAME)
_juce_append_target_property(file_content PLUGIN_DESCRIPTION ${target} JUCE_DESCRIPTION)
_juce_append_target_property(file_content PLUGIN_AU_EXPORT_PREFIX ${target} JUCE_AU_EXPORT_PREFIX)
_juce_append_target_property(file_content PLUGIN_AU_MAIN_TYPE ${target} JUCE_AU_MAIN_TYPE_CODE)
_juce_append_target_property(file_content IS_AU_SANDBOX_SAFE ${target} JUCE_AU_SANDBOX_SAFE)
_juce_append_target_property(file_content IS_PLUGIN_SYNTH ${target} JUCE_IS_SYNTH)
_juce_append_target_property(file_content IS_PLUGIN_ARA_EFFECT ${target} JUCE_IS_ARA_EFFECT)
_juce_append_target_property(file_content SUPPRESS_AU_PLIST_RESOURCE_USAGE ${target} JUCE_SUPPRESS_AU_PLIST_RESOURCE_USAGE)
_juce_append_target_property(file_content HARDENED_RUNTIME_ENABLED ${target} JUCE_HARDENED_RUNTIME_ENABLED)
_juce_append_target_property(file_content APP_SANDBOX_ENABLED ${target} JUCE_APP_SANDBOX_ENABLED)
_juce_append_target_property(file_content APP_SANDBOX_INHERIT ${target} JUCE_APP_SANDBOX_INHERIT)
_juce_append_target_property(file_content HARDENED_RUNTIME_OPTIONS ${target} JUCE_HARDENED_RUNTIME_OPTIONS)
_juce_append_target_property(file_content APP_SANDBOX_OPTIONS ${target} JUCE_APP_SANDBOX_OPTIONS)
_juce_append_target_property(file_content APP_SANDBOX_FILE_ACCESS_HOME_RO ${target} JUCE_APP_SANDBOX_FILE_ACCESS_HOME_RO)
_juce_append_target_property(file_content APP_SANDBOX_FILE_ACCESS_HOME_RW ${target} JUCE_APP_SANDBOX_FILE_ACCESS_HOME_RW)
_juce_append_target_property(file_content APP_SANDBOX_FILE_ACCESS_ABS_RO ${target} JUCE_APP_SANDBOX_FILE_ACCESS_ABS_RO)
_juce_append_target_property(file_content APP_SANDBOX_FILE_ACCESS_ABS_RW ${target} JUCE_APP_SANDBOX_FILE_ACCESS_ABS_RW)
_juce_append_target_property(file_content APP_SANDBOX_EXCEPTION_IOKIT ${target} JUCE_APP_SANDBOX_EXCEPTION_IOKIT)
_juce_append_target_property(file_content APP_GROUPS_ENABLED ${target} JUCE_APP_GROUPS_ENABLED)
_juce_append_target_property(file_content APP_GROUP_IDS ${target} JUCE_APP_GROUP_IDS)
_juce_append_target_property(file_content IS_PLUGIN ${target} JUCE_IS_PLUGIN)
_juce_append_target_property(file_content ICLOUD_PERMISSIONS_ENABLED ${target} JUCE_ICLOUD_PERMISSIONS_ENABLED)
_juce_append_target_property(file_content IS_AU_PLUGIN_HOST ${target} JUCE_PLUGINHOST_AU)
if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
_juce_append_record(file_content IS_IOS 1)
else()
_juce_append_record(file_content IS_IOS 0)
endif()
get_target_property(juce_library_code ${target} JUCE_GENERATED_SOURCES_DIRECTORY)
set(info_file "${juce_library_code}/Info.txt")
file(WRITE "${info_file}" "${file_content}")
set_target_properties(${target} PROPERTIES JUCE_INFO_FILE "${info_file}")
endfunction()
# In this file, we put things that CMake is only able to divine at generate time, like preprocessor definitions.
# We use the target preprocessor definitions to work out which JUCE modules should go in the JuceHeader.h.
function(_juce_write_generate_time_info target)
_juce_get_module_definitions(${target} OFF module_defs)
_juce_append_record(defs MODULE_DEFINITIONS ${module_defs})
_juce_append_target_property(defs EXECUTABLE_NAME ${target} JUCE_PRODUCT_NAME)
_juce_append_target_property(defs PROJECT_NAME ${target} JUCE_PRODUCT_NAME)
_juce_append_target_property(defs VERSION ${target} JUCE_VERSION)
_juce_append_target_property(defs COMPANY_NAME ${target} JUCE_COMPANY_NAME)
get_target_property(juce_library_code ${target} JUCE_GENERATED_SOURCES_DIRECTORY)
set(defs_file "${juce_library_code}/$<CONFIG>/Defs.txt")
file(GENERATE OUTPUT "${defs_file}" CONTENT "${defs}")
set_target_properties(${target} PROPERTIES JUCE_DEFS_FILE "${defs_file}")
endfunction()
# ==================================================================================================
function(juce_add_binary_data target)
set(one_value_args NAMESPACE HEADER_NAME)
set(multi_value_args SOURCES)
cmake_parse_arguments(JUCE_ARG "" "${one_value_args}" "${multi_value_args}" ${ARGN})
list(LENGTH JUCE_ARG_SOURCES num_binary_files)
if(${num_binary_files} LESS 1)
message(FATAL_ERROR "juce_add_binary_data must be passed at least one file to encode")
endif()
add_library(${target} STATIC)
set_target_properties(${target} PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
set(juce_binary_data_folder "${CMAKE_CURRENT_BINARY_DIR}/juce_binarydata_${target}/JuceLibraryCode")
set(binary_file_names)
foreach(index RANGE 1 ${num_binary_files})
list(APPEND binary_file_names "${juce_binary_data_folder}/BinaryData${index}.cpp")
endforeach()
file(MAKE_DIRECTORY ${juce_binary_data_folder})
if(NOT JUCE_ARG_NAMESPACE)
set(JUCE_ARG_NAMESPACE BinaryData)
endif()
if(NOT JUCE_ARG_HEADER_NAME)
set(JUCE_ARG_HEADER_NAME BinaryData.h)
endif()
list(APPEND binary_file_names "${juce_binary_data_folder}/${JUCE_ARG_HEADER_NAME}")
set(newline_delimited_input)
foreach(name IN LISTS JUCE_ARG_SOURCES)
_juce_make_absolute(name)
set(newline_delimited_input "${newline_delimited_input}${name}\n")
endforeach()
set(input_file_list "${juce_binary_data_folder}/input_file_list")
file(WRITE "${input_file_list}" "${newline_delimited_input}")
add_custom_command(OUTPUT ${binary_file_names}
COMMAND juce::juceaide binarydata "${JUCE_ARG_NAMESPACE}" "${JUCE_ARG_HEADER_NAME}"
${juce_binary_data_folder} "${input_file_list}"
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
DEPENDS "${input_file_list}" ${JUCE_ARG_SOURCES}
VERBATIM)
target_sources(${target} PRIVATE "${binary_file_names}")
target_include_directories(${target} INTERFACE ${juce_binary_data_folder})
target_compile_features(${target} PRIVATE cxx_std_17)
# This fixes an issue where Xcode is unable to find binary data during archive.
if(CMAKE_GENERATOR STREQUAL "Xcode")
set_target_properties(${target} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "./")
endif()
if(JUCE_ARG_HEADER_NAME STREQUAL "BinaryData.h")
target_compile_definitions(${target} INTERFACE JUCE_TARGET_HAS_BINARY_DATA=1)
endif()
endfunction()
# ==================================================================================================
function(_juce_version_code version_in out_var)
string(REGEX REPLACE "\\." ";" version_list ${version_in})
list(LENGTH version_list num_version_components)
set(version_major 0)
set(version_minor 0)
set(version_patch 0)
if(num_version_components GREATER 0)
list(GET version_list 0 version_major)
endif()
if(num_version_components GREATER 1)
list(GET version_list 1 version_minor)
endif()
if(num_version_components GREATER 2)
list(GET version_list 2 version_patch)
endif()
math(EXPR hex "(${version_major} << 16) + (${version_minor} << 8) + ${version_patch}"
OUTPUT_FORMAT HEXADECIMAL)
set(${out_var} "${hex}" PARENT_SCOPE)
endfunction()
function(_juce_to_char_literal str out_var help_text)
string(LENGTH "${str}" string_length)
if(NOT "${string_length}" EQUAL "4")
message(WARNING "The ${help_text} code must contain exactly four characters, but it was set to '${str}'")
endif()
# Round-tripping through a file is the simplest way to convert a string to hex...
string(SUBSTRING "${str}" 0 4 four_chars)
string(RANDOM LENGTH 16 random_string)
set(scratch_file "${CMAKE_CURRENT_BINARY_DIR}/${random_string}_ascii_conversion.txt")
file(WRITE "${scratch_file}" "${four_chars}")
file(READ "${scratch_file}" four_chars_hex HEX)
file(REMOVE "${scratch_file}")
string(SUBSTRING "${four_chars_hex}00000000" 0 8 four_chars_hex)
set(${out_var} "${four_chars_hex}" PARENT_SCOPE)
endfunction()
# ==================================================================================================
function(juce_generate_juce_header target)
get_target_property(juce_library_code ${target} JUCE_GENERATED_SOURCES_DIRECTORY)
if(NOT juce_library_code)
message(FATAL_ERROR "Target ${target} does not have a generated sources directory. Ensure it was created with a juce_add_* function")
endif()
set(juce_header ${juce_library_code}/JuceHeader.h)
target_sources(${target} PRIVATE ${juce_header})
set(defs_file $<GENEX_EVAL:$<TARGET_PROPERTY:${target},JUCE_DEFS_FILE>>)
set(extra_args)
add_custom_command(OUTPUT "${juce_header}"
COMMAND juce::juceaide header "${defs_file}" "${juce_header}" ${extra_args}
DEPENDS "${defs_file}"
VERBATIM)
endfunction()
# ==================================================================================================
function(_juce_execute_juceaide)
if(NOT TARGET juce::juceaide)
message(FATAL_ERROR "The juceaide target does not exist")
endif()
get_target_property(juceaide_location juce::juceaide IMPORTED_LOCATION)
if(NOT EXISTS "${juceaide_location}")
message(FATAL_ERROR "juceaide was imported, but it doesn't exist!")
endif()
execute_process(COMMAND "${juceaide_location}" ${ARGN}
RESULT_VARIABLE result_variable
OUTPUT_VARIABLE output
ERROR_VARIABLE output)
if(result_variable)
message(FATAL_ERROR "Running juceaide failed:\ncommand: ${juceaide_location} ${ARGN}\noutput: ${output}")
endif()
endfunction()
function(_juce_set_output_name target name)
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Android")
set_target_properties(${target} PROPERTIES
OUTPUT_NAME ${name}
XCODE_ATTRIBUTE_PRODUCT_NAME ${name})
endif()
endfunction()
function(_juce_check_icon_files_exist icon_files)
foreach(file IN LISTS icon_files)
if(NOT EXISTS "${file}")
message(FATAL_ERROR "Could not find icon file: ${file}")
endif()
endforeach()
endfunction()
function(_juce_generate_icon source_target dest_target)
get_target_property(juce_library_code ${source_target} JUCE_GENERATED_SOURCES_DIRECTORY)
get_target_property(juce_property_icon_big ${source_target} JUCE_ICON_BIG)
get_target_property(juce_property_icon_small ${source_target} JUCE_ICON_SMALL)
set(icon_args)
if(juce_property_icon_big)
list(APPEND icon_args "${juce_property_icon_big}")
endif()
if(juce_property_icon_small)
list(APPEND icon_args "${juce_property_icon_small}")
endif()
set(generated_icon)
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
if(NOT icon_args)
return()
endif()
_juce_check_icon_files_exist("${icon_args}")
set(generated_icon "${juce_library_code}/Icon.icns")
# To get compiled properly, we need the icon before the plist is generated!
_juce_execute_juceaide(macicon "${generated_icon}" ${icon_args})
set_source_files_properties(${generated_icon} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
if(NOT icon_args)
return()
endif()
_juce_check_icon_files_exist("${icon_args}")
set(generated_icon "${juce_library_code}/icon.ico")
_juce_execute_juceaide(winicon "${generated_icon}" ${icon_args})
elseif(CMAKE_SYSTEM_NAME STREQUAL "iOS")
get_target_property(generated_icon ${source_target} JUCE_CUSTOM_XCASSETS_FOLDER)
if(icon_args AND (NOT generated_icon))
_juce_check_icon_files_exist("${icon_args}")
set(out_path "${juce_library_code}/${dest_target}")
set(generated_icon "${out_path}/Images.xcassets")
# To get compiled properly, we need iOS assets at configure time!
_juce_execute_juceaide(iosassets "${out_path}" ${icon_args})
endif()
if(NOT generated_icon)
return()
endif()
set_target_properties(${dest_target} PROPERTIES
XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_APPICON_NAME "AppIcon")
get_target_property(add_storyboard ${source_target} JUCE_SHOULD_ADD_STORYBOARD)
if(NOT add_storyboard)
set_target_properties(${dest_target} PROPERTIES
XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME "LaunchImage")
endif()
endif()
if(generated_icon)
_juce_check_icon_files_exist("${generated_icon}")
target_sources(${dest_target} PRIVATE ${generated_icon})
set_target_properties(${source_target} ${dest_target} PROPERTIES
JUCE_ICON_FILE "${generated_icon}"
RESOURCE "${generated_icon}")
endif()
endfunction()
function(_juce_add_xcode_entitlements source_target dest_target)
if(NOT APPLE)
return()
endif()
get_target_property(juce_kind_string ${dest_target} JUCE_TARGET_KIND_STRING)
get_target_property(input_info_file ${source_target} JUCE_INFO_FILE)
get_target_property(juce_library_code ${source_target} JUCE_GENERATED_SOURCES_DIRECTORY)
set(entitlements_file "${juce_library_code}/${dest_target}.entitlements")
_juce_execute_juceaide(entitlements "${juce_kind_string}" "${input_info_file}" "${entitlements_file}")
set_target_properties(${dest_target} PROPERTIES
XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS
"${entitlements_file}"
XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME
"$<TARGET_PROPERTY:${source_target},JUCE_HARDENED_RUNTIME_ENABLED>")
endfunction()
function(_juce_configure_bundle source_target dest_target)
_juce_generate_icon(${source_target} ${dest_target})
_juce_write_configure_time_info(${source_target})
if(NOT APPLE)
return()
endif()
get_target_property(generated_icon ${source_target} JUCE_ICON_FILE)
set(icon_dependency)
if(generated_icon)
set(icon_dependency "${generated_icon}")
endif()
get_target_property(juce_library_code ${source_target} JUCE_GENERATED_SOURCES_DIRECTORY)
get_target_property(input_info_file ${source_target} JUCE_INFO_FILE)
set(this_output_info_dir "${juce_library_code}/${dest_target}")
set(this_output_pkginfo "${this_output_info_dir}/PkgInfo")
set(this_output_plist "${this_output_info_dir}/Info.plist")
get_target_property(juce_kind_string ${dest_target} JUCE_TARGET_KIND_STRING)
_juce_execute_juceaide(plist "${juce_kind_string}" "${input_info_file}" "${this_output_plist}")
set_target_properties(${dest_target} PROPERTIES
BUNDLE TRUE
MACOSX_BUNDLE_INFO_PLIST "${this_output_plist}")
add_custom_command(OUTPUT "${this_output_pkginfo}"
COMMAND juce::juceaide pkginfo "${juce_kind_string}" "${this_output_pkginfo}"
VERBATIM)
set(output_folder "$<TARGET_BUNDLE_CONTENT_DIR:${dest_target}>")
target_sources(${dest_target} PRIVATE "${this_output_pkginfo}")
set_source_files_properties("${this_output_pkginfo}" PROPERTIES
HEADER_FILE_ONLY TRUE
GENERATED TRUE)
add_custom_command(TARGET ${dest_target} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy "${this_output_pkginfo}" "${output_folder}"
VERBATIM)
_juce_add_xcode_entitlements(${source_target} ${dest_target})
if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
get_target_property(add_storyboard ${source_target} JUCE_SHOULD_ADD_STORYBOARD)
if(add_storyboard)
get_target_property(storyboard_file ${source_target} JUCE_LAUNCH_STORYBOARD_FILE)
if(NOT EXISTS "${storyboard_file}")
message(FATAL_ERROR "Could not find storyboard file: ${storyboard_file}")
endif()
target_sources(${dest_target} PRIVATE "${storyboard_file}")
set_property(TARGET ${dest_target} APPEND PROPERTY RESOURCE "${storyboard_file}")
endif()
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set_target_properties(${dest_target} PROPERTIES
XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS "--timestamp")
endif()
set_target_properties(${dest_target} PROPERTIES
XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY
"$<TARGET_PROPERTY:${source_target},JUCE_TARGETED_DEVICE_FAMILY>")
if(juce_kind_string STREQUAL "AUv3 AppExtension")
get_target_property(source_bundle_id ${source_target} JUCE_BUNDLE_ID)
if(source_bundle_id MATCHES "\\.([^.]+)$")
set_target_properties(${dest_target} PROPERTIES
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER
"${source_bundle_id}.${CMAKE_MATCH_1}AUv3")
else()
message(FATAL_ERROR "Bundle ID should contain at least one `.`!")
endif()
else()
set_target_properties(${dest_target} PROPERTIES
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER
$<TARGET_PROPERTY:${source_target},JUCE_BUNDLE_ID>)
endif()
if(CMAKE_GENERATOR STREQUAL "Xcode")
get_target_property(product_name ${source_target} JUCE_PRODUCT_NAME)
set(skip_install NO)
set(install_path "$(LOCAL_APPS_DIR)")
if(juce_kind_string STREQUAL "AUv3 AppExtension")
set(skip_install YES)
set(install_path "")
endif()
set_target_properties(${dest_target} PROPERTIES
XCODE_ATTRIBUTE_INSTALL_PATH "${install_path}"
XCODE_ATTRIBUTE_SKIP_INSTALL "${skip_install}")
endif()
endfunction()
function(_juce_add_resources_rc source_target dest_target)
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
return()
endif()
if(NOT TARGET ${source_target}_rc_lib)
get_target_property(juce_library_code ${source_target} JUCE_GENERATED_SOURCES_DIRECTORY)
get_target_property(input_info_file ${source_target} JUCE_INFO_FILE)
get_target_property(generated_icon ${source_target} JUCE_ICON_FILE)
set(dependency)
if(generated_icon)
set(dependency DEPENDS "${generated_icon}")
endif()
set(resource_rc_file "${juce_library_code}/${source_target}_resources.rc")
add_custom_command(OUTPUT "${resource_rc_file}"
COMMAND juce::juceaide rcfile "${input_info_file}" "${resource_rc_file}"
${dependency}
VERBATIM)
add_library(${source_target}_rc_lib OBJECT ${resource_rc_file})
set(compile_defs $<TARGET_GENEX_EVAL:${source_target},$<TARGET_PROPERTY:${source_target},COMPILE_DEFINITIONS>>)
set(include_dirs $<TARGET_GENEX_EVAL:${source_target},$<TARGET_PROPERTY:${source_target},INCLUDE_DIRECTORIES>>)
set(filtered $<FILTER:${compile_defs},INCLUDE,JUCE_USER_DEFINED_RC_FILE=>)
set(has_custom_rc_include $<BOOL:${filtered}>)
target_include_directories(${source_target}_rc_lib
PRIVATE $<${has_custom_rc_include}:${include_dirs}>)
set_source_files_properties(${resource_rc_file} PROPERTIES
COMPILE_DEFINITIONS $<${has_custom_rc_include}:${compile_defs}>)
endif()
target_link_libraries(${dest_target} PRIVATE ${source_target}_rc_lib)
endfunction()
function(_juce_configure_app_bundle source_target dest_target)
set_target_properties(${dest_target} PROPERTIES
JUCE_TARGET_KIND_STRING "App"
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE)
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(nib_path "${JUCE_CMAKE_UTILS_DIR}/RecentFilesMenuTemplate.nib")
target_sources("${dest_target}" PRIVATE "${nib_path}")
set_source_files_properties("${nib_path}" PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
endif()
endfunction()
# ==================================================================================================
function(_juce_create_windows_package source_target dest_target extension default_icon arch_string)
get_target_property(products_folder ${dest_target} LIBRARY_OUTPUT_DIRECTORY)
set(product_name $<TARGET_PROPERTY:${source_target},JUCE_PRODUCT_NAME>)
set(output_folder "${products_folder}/${product_name}.${extension}")
set_target_properties(${dest_target}
PROPERTIES
PDB_OUTPUT_DIRECTORY "${products_folder}"
LIBRARY_OUTPUT_DIRECTORY "${output_folder}/Contents/${arch_string}")
get_target_property(icon_file ${source_target} JUCE_ICON_FILE)
if(NOT icon_file)
set(icon_file "${default_icon}")
endif()
if(icon_file)
set(desktop_ini "${output_folder}/desktop.ini")
set(plugin_ico "${output_folder}/Plugin.ico")
target_sources(${dest_target} PRIVATE "${desktop_ini}" "${icon_file}")
file(GENERATE OUTPUT "${desktop_ini}"
CONTENT
"[.ShellClassInfo]\nIconResource=Plugin.ico,0\nIconFile=Plugin.ico\nIconIndex=0\n")
add_custom_command(TARGET ${dest_target} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy "${icon_file}" "${plugin_ico}"
COMMAND attrib +s "${desktop_ini}"
COMMAND attrib +s "${output_folder}"
VERBATIM)
endif()
endfunction()
# ==================================================================================================
function(_juce_add_unity_plugin_prefix_if_necessary name out_var)
string(TOLOWER "${name}" lower)
if(NOT lower MATCHES "^audioplugin")
set(${out_var} "audioplugin_${name}" PARENT_SCOPE)
else()
set(${out_var} "${name}" PARENT_SCOPE)
endif()
endfunction()
function(_juce_add_unity_script_file shared_target out_var)
set(script_in "${JUCE_CMAKE_UTILS_DIR}/UnityPluginGUIScript.cs.in")
get_target_property(plugin_name ${shared_target} JUCE_PLUGIN_NAME)
get_target_property(plugin_vendor ${shared_target} JUCE_COMPANY_NAME)
get_target_property(plugin_description ${shared_target} JUCE_DESCRIPTION)
string(REGEX REPLACE " +" "_" plugin_class_name "${plugin_name}")
get_target_property(juce_library_code ${shared_target} JUCE_GENERATED_SOURCES_DIRECTORY)
_juce_add_unity_plugin_prefix_if_necessary("${plugin_name}" script_prefix)
set(script_out "${juce_library_code}/${script_prefix}_UnityScript.cs")
configure_file(${script_in} ${script_out})
set(${out_var} "${script_out}" PARENT_SCOPE)
endfunction()
# ==================================================================================================
function(_juce_copy_dir target from to)
# This is a shim to make CMake copy a whole directory, rather than just
# the contents of a directory
add_custom_command(TARGET ${target} POST_BUILD
COMMAND "${CMAKE_COMMAND}"
"-Dsrc=${from}"
"-Ddest=${to}"
"-P" "${JUCE_CMAKE_UTILS_DIR}/copyDir.cmake"
VERBATIM)
endfunction()
function(_juce_set_copy_properties shared_code target from to_property)
get_target_property(destination "${shared_code}" "${to_property}")
if(destination)
set_target_properties("${target}" PROPERTIES JUCE_PLUGIN_COPY_DIR "${destination}")
endif()
set_target_properties("${target}" PROPERTIES JUCE_PLUGIN_ARTEFACT_FILE "${from}")
endfunction()
function(_juce_adhoc_sign target)
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
return()
endif()
get_target_property(bundle "${target}" BUNDLE)
set(src "$<TARGET_FILE:${target}>")
if(bundle)
set(src "$<TARGET_BUNDLE_DIR:${target}>")
endif()
add_custom_command(TARGET ${target} POST_BUILD
COMMAND "${CMAKE_COMMAND}"
"-Dsrc=${src}"
"-P" "${JUCE_CMAKE_UTILS_DIR}/checkBundleSigning.cmake"
VERBATIM)
endfunction()
function(juce_enable_copy_plugin_step shared_code_target)
get_target_property(step_added ${shared_code_target} _JUCE_PLUGIN_COPY_STEP_ADDED)
if(step_added)
message(WARNING "Plugin copy step requested multiple times for ${shared_code_target}")
return()
endif()
set_target_properties(${shared_code_target} PROPERTIES _JUCE_PLUGIN_COPY_STEP_ADDED TRUE)
get_target_property(active_targets "${shared_code_target}" JUCE_ACTIVE_PLUGIN_TARGETS)
foreach(target IN LISTS active_targets)
get_target_property(target_kind "${target}" JUCE_TARGET_KIND_STRING)
if(target_kind STREQUAL "App")
continue()
endif()
_juce_adhoc_sign("${target}")
get_target_property(source "${target}" JUCE_PLUGIN_ARTEFACT_FILE)
if(NOT source)
continue()
endif()
get_target_property(dest "${target}" JUCE_PLUGIN_COPY_DIR)
if(dest)
_juce_copy_dir("${target}" "${source}" "$<GENEX_EVAL:${dest}>")
else()
message(WARNING "Target '${target}' requested copy but no destination is set")
endif()
endforeach()
endfunction()