Cmake strip plugin binaries

We are doing this to strip our plugin binaries. It works. But is there a better way - it seems a little fragile, certainly isn’t DRY and is the wrong side of the initial code signing. The linker flag seems to no longer work (-s apparently deprecated with no useful information on what replaces it from Apple!).

Any tips appreciated, I’m a CMAKE amateur :slight_smile:

    # release build only on the mac strip the binaries
    if(NOT MSVC AND ${CMAKE_BUILD_TYPE} STREQUAL "Release")
        add_custom_command(TARGET ${PROJECT_NAME}_VST3 POST_BUILD
            COMMAND strip -no_code_signature_warning -x $<TARGET_FILE:${PROJECT_NAME}_VST3>
        )
        add_custom_command(TARGET ${PROJECT_NAME}_AU POST_BUILD
            COMMAND strip -no_code_signature_warning -x $<TARGET_FILE:${PROJECT_NAME}_AU>
        )
        add_custom_command(TARGET ${PROJECT_NAME}_VST POST_BUILD
            COMMAND strip -no_code_signature_warning -x $<TARGET_FILE:${PROJECT_NAME}_VST>
        )
        add_custom_command(TARGET ${PROJECT_NAME}_AAX POST_BUILD
            COMMAND strip -no_code_signature_warning -x $<TARGET_FILE:${PROJECT_NAME}_AAX>
        )
    endif()

If you’re using the Xcode generator, then maybe XCODE_ATTRIBUTE_DEPLOYMENT_POSTPROCESSING and XCODE_ATTRIBUTE_STRIP_INSTALLED_PRODUCT are worth investigating. For Ninja/Make, CMake creates install/strip targets.

Oh right, we are in Ninja land. Let me check out the strip targets, didn’t spot those. Cmake is it’s own little set of multi-verses :slight_smile:

The install/strip target fails for me trying to do something weird:

-- Installing: /usr/local/include/JUCE-7.0.4/modules/juce_analytics
CMake Error at swag/juce/modules/cmake_install.cmake:41 (file):
  file INSTALL cannot make directory
  "/usr/local/include/JUCE-7.0.4/modules/juce_analytics": No such file or
  directory.
Call Stack (most recent call first):
  swag/juce/cmake_install.cmake:42 (include)
  cmake_install.cmake:42 (include)

I gave up trying to use cmake for the entire build & package, especially all the stripping and notarizing stuff…life’s too short. I ended up using a shell script for the overall build, and just use cmake to essentially replace Projucer.

If you’ve got a shell script working, it’s fairly straightforward to translate each command into a CMake post-build step. You could even have a post-build step that just executes your shell script

I’ve got it all figured in CMAKE now. The code above (Jan 15 post) was working but you have to delay the plugin copy step, which is documented in the cmake JUCE readme.

1 Like