Skip to content

Commit fbadd36

Browse files
committed
build: Restore the generated AUv2 Info.plist on every build
1 parent b5c8586 commit fbadd36

1 file changed

Lines changed: 30 additions & 5 deletions

File tree

‎cmake/wrap_auv2.cmake‎

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,36 @@ function(target_add_auv2_wrapper)
276276
MACOSX_BUNDLE_SHORT_VERSION_STRING ${AUV2_BUNDLE_VERSION}
277277
)
278278

279-
# This is "PRE_BUILD" because the target is created at cmake time and we want to beat xcode signing in order
280-
# it is *not* a MACOSX_BUNDLE_INFO_PLIST since that is a configure not build time concept so doesn't work
281-
# with compile time generated files
282-
add_custom_command(TARGET ${AUV2_TARGET} PRE_BUILD
283-
COMMAND ${CMAKE_COMMAND} -E copy ${bhtgoutdir}/auv2_Info.plist $<TARGET_FILE_DIR:${AUV2_TARGET}>/../Info.plist)
279+
# The real Info.plist is written by the build helper at build time, so it can't be a
280+
# MACOSX_BUNDLE_INFO_PLIST (a configure time concept). But a BUNDLE target without one
281+
# still gets CMake's default plist, which has no AudioComponents, so no host registers
282+
# the AU. Each generator writes that default at a different time, so each needs the
283+
# real plist to be a tracked build input rather than a one-off copy.
284+
if (${CMAKE_GENERATOR} STREQUAL "Xcode")
285+
# Xcode writes the default plist while building the target, after any PRE_BUILD
286+
# step and before signing. Hand it the build helper's plist to process instead.
287+
set_target_properties(${AUV2_TARGET} PROPERTIES XCODE_ATTRIBUTE_INFOPLIST_FILE "${bhtgoutdir}/auv2_Info.plist")
288+
else()
289+
# Ninja and Makefiles write the default plist into the bundle at generate time,
290+
# on every reconfigure, and nothing in the build graph notices. So copy the real
291+
# plist through a stamp that every configure deletes, and relink when the stamp
292+
# changes so POST_BUILD steps that patch or sign the bundle run again. The stamp
293+
# is a source of the AUv2 target itself: in a separate target, the bundle path
294+
# genex would depend back on the AUv2 target in projects older than CMP0112.
295+
set(plist_stamp_dir "${CMAKE_CURRENT_BINARY_DIR}/${AUV2_TARGET}-info-plist")
296+
set(plist_stamp "${plist_stamp_dir}/$<CONFIG>.stamp")
297+
file(REMOVE_RECURSE "${plist_stamp_dir}")
298+
add_custom_command(
299+
OUTPUT "${plist_stamp}"
300+
COMMAND ${CMAKE_COMMAND} -E make_directory "$<TARGET_BUNDLE_CONTENT_DIR:${AUV2_TARGET}>"
301+
COMMAND ${CMAKE_COMMAND} -E copy "${bhtgoutdir}/auv2_Info.plist" "$<TARGET_BUNDLE_CONTENT_DIR:${AUV2_TARGET}>/Info.plist"
302+
COMMAND ${CMAKE_COMMAND} -E touch "${plist_stamp}"
303+
DEPENDS "${bhtgoutdir}/auv2_Info.plist"
304+
COMMENT "clap-wrapper: restoring the generated Info.plist in ${AUV2_OUTPUT_NAME}.component"
305+
VERBATIM)
306+
target_sources(${AUV2_TARGET} PRIVATE "${plist_stamp}")
307+
set_property(TARGET ${AUV2_TARGET} APPEND PROPERTY LINK_DEPENDS "${plist_stamp}")
308+
endif()
284309

285310
# XCode needs a special extra flag
286311
set_target_properties(${AUV2_TARGET} PROPERTIES XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "${AUV2_BUNDLE_IDENTIFIER}.component")

0 commit comments

Comments
 (0)