Skip to content

Commit 91555eb

Browse files
committed
Enable ARC
1 parent 0771f93 commit 91555eb

27 files changed

Lines changed: 272 additions & 181 deletions

AGENTS.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ For main module headers (e.g., `yup_graphics.h`), include this declaration block
6161
6262
dependencies: yup_graphics [other_dependencies]
6363
searchpaths: native
64-
enableARC: 1
6564
6665
END_YUP_MODULE_DECLARATION
6766

CLAUDE.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ For main module headers (e.g., `yup_graphics.h`), include this declaration block
6161
6262
dependencies: yup_graphics [other_dependencies]
6363
searchpaths: native
64-
enableARC: 1
6564
6665
END_YUP_MODULE_DECLARATION
6766

cmake/toolchains/ios.cmake

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
#
102102
# ENABLE_BITCODE: (ON|OFF) Enables or disables bitcode support. Default OFF
103103
#
104-
# ENABLE_ARC: (ON|OFF) Enables or disables ARC support. Default ON (ARC enabled by default)
104+
# ENABLE_ARC: ARC is always enabled for YUP Apple builds.
105105
#
106106
# ENABLE_VISIBILITY: (ON|OFF) Enables or disables symbol visibility support. Default OFF (visibility hidden by default)
107107
#
@@ -655,13 +655,9 @@ if(NOT DEFINED ENABLE_BITCODE)
655655
endif()
656656
set(ENABLE_BITCODE_INT ${ENABLE_BITCODE} CACHE BOOL
657657
"Whether or not to enable bitcode" FORCE)
658-
# Use ARC or not
659-
if(NOT DEFINED ENABLE_ARC)
660-
# Unless specified, enable ARC support by default
661-
set(ENABLE_ARC ON)
662-
message(STATUS "[DEFAULTS] Enabling ARC support by default. ENABLE_ARC not provided!")
663-
endif()
664-
set(ENABLE_ARC_INT ${ENABLE_ARC} CACHE BOOL "Whether or not to enable ARC" FORCE)
658+
# ARC is required by YUP's Apple implementation.
659+
set(ENABLE_ARC ON)
660+
set(ENABLE_ARC_INT ON CACHE BOOL "Whether or not to enable ARC" FORCE)
665661
# Use hidden visibility or not
666662
if(NOT DEFINED ENABLE_VISIBILITY)
667663
# Unless specified, disable symbols visibility by default
@@ -917,13 +913,8 @@ else()
917913
set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO")
918914
endif()
919915

920-
if(ENABLE_ARC_INT)
921-
set(FOBJC_ARC "-fobjc-arc")
922-
set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC "YES")
923-
else()
924-
set(FOBJC_ARC "-fno-objc-arc")
925-
set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC "NO")
926-
endif()
916+
set(FOBJC_ARC "-fobjc-arc")
917+
set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC "YES")
927918

928919
if(NAMED_LANGUAGE_SUPPORT_INT)
929920
set(OBJC_VARS "-fobjc-abi-version=2 -DOBJC_OLD_DISPATCH_PROTOTYPES=0")
@@ -1027,11 +1018,7 @@ else()
10271018
message(STATUS "Bitcode: Disabled")
10281019
endif()
10291020

1030-
if(ENABLE_ARC_INT)
1031-
message(STATUS "ARC: Enabled")
1032-
else()
1033-
message(STATUS "ARC: Disabled")
1034-
endif()
1021+
message(STATUS "ARC: Enabled")
10351022

10361023
if(ENABLE_VISIBILITY_INT)
10371024
message(STATUS "Hiding symbols: Disabled")

cmake/yup_audio_plugin.cmake

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function (yup_audio_plugin)
8383

8484
set_target_properties (${target_name}_shared PROPERTIES
8585
FOLDER "${YUP_ARG_TARGET_IDE_GROUP}"
86-
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC OFF
86+
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC ON
8787
XCODE_GENERATE_SCHEME ON)
8888

8989
# ==== Find dependencies
@@ -126,6 +126,14 @@ function (yup_audio_plugin)
126126
${additional_libraries}
127127
${YUP_ARG_MODULES})
128128

129+
_yup_module_apply_arc_to_target_sources (${target_name}_clap_plugin
130+
${target_name}_shared
131+
yup_audio_plugin_client
132+
clap
133+
${target_name}_clap
134+
${additional_libraries}
135+
${YUP_ARG_MODULES})
136+
129137
set_target_properties (${target_name}_clap_plugin PROPERTIES
130138
SUFFIX ".clap"
131139
FOLDER "${YUP_ARG_TARGET_IDE_GROUP}"
@@ -183,6 +191,14 @@ function (yup_audio_plugin)
183191
${additional_libraries}
184192
${YUP_ARG_MODULES})
185193

194+
_yup_module_apply_arc_to_target_sources (${target_name}_vst3_plugin
195+
${target_name}_shared
196+
yup_audio_plugin_client
197+
sdk
198+
${target_name}_vst3
199+
${additional_libraries}
200+
${YUP_ARG_MODULES})
201+
186202
if (YUP_PLATFORM_MAC)
187203
smtg_target_set_bundle (${target_name}_vst3_plugin
188204
BUNDLE_IDENTIFIER org.kunitoki.yup.${target_name}

cmake/yup_modules.cmake

Lines changed: 108 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,100 @@ endfunction()
333333

334334
#==============================================================================
335335

336+
function (_yup_module_collect_objc_sources output_variable)
337+
set (objc_sources "")
338+
foreach (source_file IN LISTS ARGN)
339+
if (source_file MATCHES "^.*\\.(m|mm)$")
340+
list (APPEND objc_sources "${source_file}")
341+
endif()
342+
endforeach()
343+
344+
set (${output_variable} "${objc_sources}" PARENT_SCOPE)
345+
endfunction()
346+
347+
#==============================================================================
348+
349+
function (_yup_module_apply_objc_arc_to_sources target_name)
350+
if (NOT YUP_PLATFORM_APPLE OR NOT TARGET "${target_name}")
351+
return()
352+
endif()
353+
354+
set (objc_sources ${ARGN})
355+
if (NOT objc_sources)
356+
return()
357+
endif()
358+
359+
set_property (SOURCE ${objc_sources}
360+
TARGET_DIRECTORY ${target_name}
361+
APPEND PROPERTY COMPILE_OPTIONS "-fobjc-arc")
362+
363+
set_property (SOURCE ${objc_sources}
364+
TARGET_DIRECTORY ${target_name}
365+
APPEND PROPERTY XCODE_FILE_ATTRIBUTES "RequiresObjCArc")
366+
endfunction()
367+
368+
#==============================================================================
369+
370+
function (_yup_module_collect_objc_sources_from_target target_name output_variable visited_variable)
371+
set (arc_sources "${${output_variable}}")
372+
set (visited_targets "${${visited_variable}}")
373+
374+
if (NOT TARGET "${target_name}")
375+
set (${output_variable} "${arc_sources}" PARENT_SCOPE)
376+
set (${visited_variable} "${visited_targets}" PARENT_SCOPE)
377+
return()
378+
endif()
379+
380+
get_target_property (aliased_target "${target_name}" ALIASED_TARGET)
381+
if (aliased_target)
382+
set (target_name "${aliased_target}")
383+
endif()
384+
385+
if ("${target_name}" IN_LIST visited_targets)
386+
set (${output_variable} "${arc_sources}" PARENT_SCOPE)
387+
set (${visited_variable} "${visited_targets}" PARENT_SCOPE)
388+
return()
389+
endif()
390+
391+
list (APPEND visited_targets "${target_name}")
392+
393+
get_target_property (target_arc_sources "${target_name}" YUP_MODULE_ARC_SOURCES)
394+
if (target_arc_sources)
395+
list (APPEND arc_sources ${target_arc_sources})
396+
endif()
397+
398+
foreach (link_property IN ITEMS INTERFACE_LINK_LIBRARIES LINK_LIBRARIES)
399+
get_target_property (target_libraries "${target_name}" ${link_property})
400+
foreach (target_library IN LISTS target_libraries)
401+
_yup_module_collect_objc_sources_from_target ("${target_library}" arc_sources visited_targets)
402+
endforeach()
403+
endforeach()
404+
405+
set (${output_variable} "${arc_sources}" PARENT_SCOPE)
406+
set (${visited_variable} "${visited_targets}" PARENT_SCOPE)
407+
endfunction()
408+
409+
#==============================================================================
410+
411+
function (_yup_module_apply_arc_to_target_sources target_name)
412+
if (NOT YUP_PLATFORM_APPLE)
413+
return()
414+
endif()
415+
416+
set (arc_sources "")
417+
set (visited_targets "")
418+
foreach (linked_target IN LISTS ARGN)
419+
_yup_module_collect_objc_sources_from_target ("${linked_target}" arc_sources visited_targets)
420+
endforeach()
421+
422+
if (arc_sources)
423+
list (REMOVE_DUPLICATES arc_sources)
424+
_yup_module_apply_objc_arc_to_sources ("${target_name}" ${arc_sources})
425+
endif()
426+
endfunction()
427+
428+
#==============================================================================
429+
336430
function (_yup_module_setup_target module_name
337431
module_path
338432
module_cpp_standard
@@ -344,15 +438,20 @@ function (_yup_module_setup_target module_name
344438
module_libs_paths
345439
module_link_options
346440
module_frameworks
347-
module_dependencies
348-
module_arc_enabled)
441+
module_dependencies)
349442
if (YUP_PLATFORM_MSFT)
350443
list (APPEND module_defines NOMINMAX=1 WIN32_LEAN_AND_MEAN=1)
351444
list (APPEND module_options /bigobj)
352445
endif()
353446

354447
target_sources (${module_name} INTERFACE ${module_sources})
355448

449+
set (module_objc_sources "")
450+
set (module_arc_sources "")
451+
_yup_module_collect_objc_sources (module_objc_sources ${module_sources})
452+
set (module_arc_sources "${module_objc_sources}")
453+
_yup_module_apply_objc_arc_to_sources ("${module_name}" ${module_arc_sources})
454+
356455
if (module_cpp_standard)
357456
target_compile_features (${module_name} INTERFACE cxx_std_${module_cpp_standard})
358457
else()
@@ -364,9 +463,12 @@ function (_yup_module_setup_target module_name
364463
CXX_VISIBILITY_PRESET hidden
365464
VISIBILITY_INLINES_HIDDEN ON)
366465

466+
set_target_properties (${module_name} PROPERTIES
467+
YUP_MODULE_ARC_SOURCES "${module_arc_sources}")
468+
367469
if (YUP_PLATFORM_APPLE)
368470
set_target_properties (${module_name} PROPERTIES
369-
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC ${module_arc_enabled}
471+
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC ON
370472
XCODE_GENERATE_SCHEME OFF)
371473
endif()
372474

@@ -438,7 +540,6 @@ function (_yup_module_setup_plugin_client target_name plugin_client_target folde
438540
get_target_property (module_link_options ${plugin_client_target} YUP_MODULE_LINK_OPTIONS)
439541
get_target_property (module_frameworks ${plugin_client_target} YUP_MODULE_FRAMEWORK)
440542
get_target_property (module_dependencies ${plugin_client_target} YUP_MODULE_DEPENDENCIES)
441-
get_target_property (module_arc_enabled ${plugin_client_target} YUP_MODULE_ARC_ENABLED)
442543

443544
list (APPEND module_defines ${plugin_define})
444545
list (APPEND module_defines YupPlugin_Id="${YUP_ARG_PLUGIN_ID}")
@@ -478,8 +579,7 @@ function (_yup_module_setup_plugin_client target_name plugin_client_target folde
478579
"${module_libs_paths}"
479580
"${module_link_options}"
480581
"${module_frameworks}"
481-
"${module_dependencies}"
482-
"${module_arc_enabled}")
582+
"${module_dependencies}")
483583

484584
_yup_glob_recurse ("${module_path}/${plugin_type}/*" all_module_files)
485585
target_sources (${custom_target_name} PRIVATE ${all_module_files})
@@ -532,8 +632,6 @@ function (yup_add_module module_path modules_definitions module_group)
532632
_yup_comma_or_space_separated_list ("${value}" module_${key})
533633
elseif (${key} MATCHES "^minimumCppStandard$")
534634
set (module_cpp_standard "${value}")
535-
elseif (${key} MATCHES "^enableARC$")
536-
_yup_boolean_property ("${value}" module_arc_enabled)
537635
elseif (${key} MATCHES "^needsPython$")
538636
_yup_boolean_property ("${value}" module_needs_python)
539637
elseif (${key} MATCHES "^upstream$")
@@ -550,7 +648,6 @@ function (yup_add_module module_path modules_definitions module_group)
550648
endforeach()
551649

552650
_yup_set_default (module_cpp_standard "20")
553-
_yup_set_default (module_arc_enabled OFF)
554651
_yup_set_default (module_needs_python OFF)
555652
_yup_set_default (module_submodules ON)
556653
_yup_resolve_variable_paths ("${module_searchpaths}" module_searchpaths)
@@ -769,8 +866,7 @@ function (yup_add_module module_path modules_definitions module_group)
769866
"${module_libs_paths}"
770867
"${module_link_options}"
771868
"${module_frameworks}"
772-
"${module_dependencies}"
773-
"${module_arc_enabled}")
869+
"${module_dependencies}")
774870

775871
if (module_upstream_target)
776872
add_dependencies (${module_name} "${module_upstream_target}")
@@ -799,8 +895,7 @@ function (yup_add_module module_path modules_definitions module_group)
799895
YUP_MODULE_LIBS_PATHS "${module_libs_paths}"
800896
YUP_MODULE_LINK_OPTIONS "${module_link_options}"
801897
YUP_MODULE_FRAMEWORK "${module_frameworks}"
802-
YUP_MODULE_DEPENDENCIES "${module_dependencies}"
803-
YUP_MODULE_ARC_ENABLED "${module_arc_enabled}")
898+
YUP_MODULE_DEPENDENCIES "${module_dependencies}")
804899

805900
# ==== Add Java support for Android if available (after target properties are set)
806901
if (YUP_PLATFORM_ANDROID AND YUP_BUILD_JAVA_SUPPORT)

cmake/yup_standalone.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ function (yup_standalone_app)
156156
XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED OFF
157157
XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT dwarf
158158
XCODE_ATTRIBUTE_GCC_INLINES_ARE_PRIVATE_EXTERN ON
159-
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC OFF
159+
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC ON
160160
XCODE_ATTRIBUTE_CLANG_LINK_OBJC_RUNTIME OFF
161161
XCODE_GENERATE_SCHEME ON)
162162

@@ -243,6 +243,10 @@ function (yup_standalone_app)
243243
${additional_libraries}
244244
${YUP_ARG_MODULES})
245245

246+
_yup_module_apply_arc_to_target_sources (${target_name}
247+
${additional_libraries}
248+
${YUP_ARG_MODULES})
249+
246250
if (YUP_ARG_SOURCES AND NOT YUP_TARGET_ANDROID)
247251
target_sources (${target_name} PRIVATE ${YUP_ARG_SOURCES})
248252
endif()

modules/yup_audio_basics/utilities/yup_AudioWorkgroup.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,10 @@ class AudioWorkgroup::WorkgroupProvider
147147
ScopedWorkgroupRetainer (os_workgroup_t wg)
148148
: handle { wg }
149149
{
150-
if (handle != nullptr)
151-
os_retain (handle);
152150
}
153151

154152
~ScopedWorkgroupRetainer()
155153
{
156-
if (handle != nullptr)
157-
os_release (handle);
158154
}
159155

160156
ScopedWorkgroupRetainer (const ScopedWorkgroupRetainer& other)

modules/yup_audio_devices/native/yup_Audio_ios.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1541,7 +1541,7 @@ void iOSAudioIODeviceType::handleAsyncUpdate()
15411541
//==============================================================================
15421542
AudioSessionHolder::AudioSessionHolder() { nativeSession = [[iOSAudioSessionNative alloc] init:this]; }
15431543

1544-
AudioSessionHolder::~AudioSessionHolder() { [nativeSession release]; }
1544+
AudioSessionHolder::~AudioSessionHolder() = default;
15451545

15461546
void AudioSessionHolder::handleStatusChange (bool enabled, const char* reason) const
15471547
{

0 commit comments

Comments
 (0)