From d890b25726c023caef657b1314c49940861047f5 Mon Sep 17 00:00:00 2001 From: Syl Morrison Date: Sat, 27 Dec 2025 17:11:13 +0000 Subject: [PATCH 1/2] macOS symbol stripping --- cmake/mostly_harmless.cmake | 45 +++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/cmake/mostly_harmless.cmake b/cmake/mostly_harmless.cmake index 1e60dc4..af164f7 100644 --- a/cmake/mostly_harmless.cmake +++ b/cmake/mostly_harmless.cmake @@ -1,4 +1,32 @@ +function(mostly_harmless_enable_stripping_static_lib target location name) + if(APPLE) + target_compile_options(${target} PUBLIC $<$:-fvisibility=hidden>) + set(target_file ${location}/lib${name}_SharedCode.a) + add_custom_command( + TARGET ${target} + COMMAND "$<$:strip;-x;${target_file}>" + VERBATIM + POST_BUILD + COMMAND_EXPAND_LISTS + ) + endif() +endfunction() + +function(mostly_harmless_enable_stripping target name extension) + if(APPLE) + target_compile_options(${target} PUBLIC $<$:-fvisibility=hidden>) + set(target_file ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${name}.${extension}/Contents/MacOS/${name}) + add_custom_command( + TARGET ${target} + COMMAND "$<$:strip;-x;${target_file}>" + VERBATIM + POST_BUILD + COMMAND_EXPAND_LISTS + ) + endif() +endfunction() + function(mostly_harmless_add_binary_data pluginTarget) set(ARGS TARGET_NAME @@ -63,6 +91,7 @@ function(mostly_harmless_add_plugin targetName) SUBTYPE_CODE # REQUIRED IF AU AU_TYPE # REQUIRED IF AU + STRIP # OPTIONAL, DEFAULT FALSE - if true, will strip symbols in release builds SIGN_ID # OPTIONAL, if provided, will codesign ) @@ -141,6 +170,10 @@ function(mostly_harmless_add_plugin targetName) if (NOT DEFINED PLUGIN_FEATURES) message(FATAL_ERROR "At least one feature is required") endif () + if(NOT DEFINED PLUGIN_STRIP) + set(PLUGIN_STRIP FALSE) + endif() + configure_file( ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/mostlyharmless_Descriptor.cpp ${CMAKE_CURRENT_BINARY_DIR}/mostlyharmless_Descriptor.cpp @@ -149,6 +182,9 @@ function(mostly_harmless_add_plugin targetName) target_sources(${PLUGIN_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/mostlyharmless_Descriptor.cpp) target_link_libraries(${PLUGIN_NAME} PUBLIC MostlyHarmless) set_target_properties(${PLUGIN_NAME} PROPERTIES OUTPUT_NAME ${PLUGIN_NAME}_SharedCode) + if(${PLUGIN_STRIP}) + mostly_harmless_enable_stripping_static_lib(${PLUGIN_NAME} ${CMAKE_CURRENT_BINARY_DIR} ${PLUGIN_NAME}) + endif() list(FIND PLUGIN_FORMATS "CLAP" INDEX) if (${INDEX} GREATER -1) @@ -166,6 +202,9 @@ function(mostly_harmless_add_plugin targetName) MACOSX_BUNDLE_SHORT_VERSION_STRING ${PLUGIN_VERSION} MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/mostly_harmless.plist.in ) + if(${PLUGIN_STRIP}) + mostly_harmless_enable_stripping(${PLUGIN_NAME}_CLAP ${PLUGIN_NAME} "clap") + endif() if (NOT ${PLUGIN_SIGN_ID} STREQUAL "") mostly_harmless_sign_target(${PLUGIN_NAME}_CLAP ${PLUGIN_NAME} ${PLUGIN_SIGN_ID}) endif () @@ -199,6 +238,9 @@ function(mostly_harmless_add_plugin targetName) MACOSX_BUNDLE_SHORT_VERSION_STRING ${PLUGIN_VERSION} MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/mostly_harmless.plist.in ) + if(${PLUGIN_STRIP}) + mostly_harmless_enable_stripping(${PLUGIN_NAME}_VST3 ${PLUGIN_NAME} "vst3") + endif() if (NOT ${PLUGIN_SIGN_ID} STREQUAL "") mostly_harmless_sign_target(${PLUGIN_NAME}_VST3 ${PLUGIN_NAME} ${PLUGIN_SIGN_ID}) endif () @@ -244,6 +286,9 @@ function(mostly_harmless_add_plugin targetName) SUBTYPE_CODE ${PLUGIN_SUBTYPE_CODE} INSTRUMENT_TYPE ${PLUGIN_AU_TYPE} ) + if(${PLUGIN_STRIP}) + mostly_harmless_enable_stripping(${PLUGIN_NAME}_AU ${PLUGIN_NAME} "component") + endif() if (NOT ${PLUGIN_SIGN_ID} STREQUAL "") mostly_harmless_sign_target(${PLUGIN_NAME}_AU ${PLUGIN_NAME} ${PLUGIN_SIGN_ID}) endif () From e17a581eaa2b9ec33c7c97ec0d947717ce66ae14 Mon Sep 17 00:00:00 2001 From: Syl Morrison Date: Sat, 27 Dec 2025 19:23:53 +0000 Subject: [PATCH 2/2] Update docs --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 454b868..7b0c7d6 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,10 @@ you specify the AU format, a few more arguments become neccessary - the argument MANUFACTURER_CODE "Brat" # REQUIRED FOR AU, UNUSED OTHERWISE - Your unique 4 character manufacturer code. SUBTYPE_CODE "Bpi1" # REQUIRED FOR AU, UNUSED OTHERWISE - A 4 character identifier for your plugin. AU_TYPE "aufx" # REQUIRED FOR AU, UNUSED OTHERWISE - The AU plugin type for your plugin. [2] + + STRIP TRUE # OPTIONAL, DEFAULTS TO FALSE - On macOS, if provided, will add a post-build symbol strip step to your plugin + # targets, and compile with -fvisibility=hidden. Does nothing on Windows. + SIGN_ID "Developer ID Application: ...." # OPTIONAL - On macOS, if provided, will be used to sign plugin targets ) ```