From aaa70c18dbc3fe6c7f6277e92fb86fa48010a769 Mon Sep 17 00:00:00 2001 From: Jean Pierre Cimalando Date: Fri, 23 Oct 2020 21:32:12 -0700 Subject: [PATCH 1/4] Set default plugin paths for install rules --- cmake/LV2Config.cmake | 9 ++++++--- cmake/VSTConfig.cmake | 11 ++++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/cmake/LV2Config.cmake b/cmake/LV2Config.cmake index 6b9d9b76..0cfc911f 100644 --- a/cmake/LV2Config.cmake +++ b/cmake/LV2Config.cmake @@ -30,10 +30,13 @@ else() set(LV2_UI_TYPE "X11UI") endif() -if (MSVC) +if (APPLE) + set (LV2PLUGIN_INSTALL_DIR "$ENV{HOME}/Library/Audio/Plug-Ins/LV2" CACHE STRING + "Install destination for LV2 bundle [default: $ENV{HOME}/Library/Audio/Plug-Ins/LV2]") +elseif (MSVC) set (LV2PLUGIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lv2" CACHE STRING - "Install destination for LV2 bundle [default: ${CMAKE_INSTALL_PREFIX}/lv2}]") + "Install destination for LV2 bundle [default: ${CMAKE_INSTALL_PREFIX}/lv2]") else() set (LV2PLUGIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib/lv2" CACHE STRING - "Install destination for LV2 bundle [default: ${CMAKE_INSTALL_PREFIX}/lib/lv2}]") + "Install destination for LV2 bundle [default: ${CMAKE_INSTALL_PREFIX}/lib/lv2]") endif() diff --git a/cmake/VSTConfig.cmake b/cmake/VSTConfig.cmake index 6eea1a0a..c4c8f44a 100644 --- a/cmake/VSTConfig.cmake +++ b/cmake/VSTConfig.cmake @@ -3,12 +3,17 @@ set (VSTPLUGIN_VENDOR "Paul Ferrand") set (VSTPLUGIN_URL "http://sfztools.github.io/sfizz") set (VSTPLUGIN_EMAIL "paul@ferrand.cc") -if (MSVC) +if (APPLE) + set (VSTPLUGIN_INSTALL_DIR "$ENV{HOME}/Library/Audio/Plug-Ins/VST3" CACHE STRING + "Install destination for VST bundle [default: $ENV{HOME}/Library/Audio/Plug-Ins/VST3]") + set (AUPLUGIN_INSTALL_DIR "$ENV{HOME}/Library/Audio/Plug-Ins/Components" CACHE STRING + "Install destination for AudioUnit bundle [default: $ENV{HOME}/Library/Audio/Plug-Ins/Components]") +elseif (MSVC) set (VSTPLUGIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/vst3" CACHE STRING - "Install destination for VST bundle [default: ${CMAKE_INSTALL_PREFIX}/vst3}]") + "Install destination for VST bundle [default: ${CMAKE_INSTALL_PREFIX}/vst3]") else() set (VSTPLUGIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib/vst3" CACHE STRING - "Install destination for VST bundle [default: ${CMAKE_INSTALL_PREFIX}/lib/vst3}]") + "Install destination for VST bundle [default: ${CMAKE_INSTALL_PREFIX}/lib/vst3]") endif() if (NOT VST3_SYSTEM_PROCESSOR) From f452d7f895f116cd3b46d79845ea6fdbcfe8d90f Mon Sep 17 00:00:00 2001 From: Jean Pierre Cimalando Date: Fri, 23 Oct 2020 21:53:05 -0700 Subject: [PATCH 2/4] Copy the VST in AU at installation time --- vst/CMakeLists.txt | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/vst/CMakeLists.txt b/vst/CMakeLists.txt index 0903f8ef..ea7f391d 100644 --- a/vst/CMakeLists.txt +++ b/vst/CMakeLists.txt @@ -275,13 +275,6 @@ elseif(SFIZZ_AU) "${VST3SDK_BASEDIR}/public.sdk/source/vst/auwrapper/auresource.r") endif() - # Copy VST3 in the bundle - add_custom_command(TARGET ${VSTPLUGIN_PRJ_NAME} POST_BUILD COMMAND - "${CMAKE_COMMAND}" "-E" - "copy_directory" - "${PROJECT_BINARY_DIR}/${VSTPLUGIN_BUNDLE_NAME}" - "${PROJECT_BINARY_DIR}/${AUPLUGIN_BUNDLE_NAME}/Contents/Resources/plugin.vst3") - if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") target_compile_options(${AUPLUGIN_PRJ_NAME} PRIVATE "-Wno-extra" @@ -300,5 +293,8 @@ elseif(SFIZZ_AU) install(DIRECTORY "${PROJECT_BINARY_DIR}/${AUPLUGIN_BUNDLE_NAME}" DESTINATION "${AUPLUGIN_INSTALL_DIR}" COMPONENT "au") + install(DIRECTORY "${PROJECT_BINARY_DIR}/${VSTPLUGIN_BUNDLE_NAME}/" + DESTINATION "${AUPLUGIN_INSTALL_DIR}/${AUPLUGIN_BUNDLE_NAME}/Contents/Resources/plugin.vst3" + COMPONENT "au") endif() endif() From 5723cc1ef758a42456acee16cc888e77fafb234d Mon Sep 17 00:00:00 2001 From: Jean Pierre Cimalando Date: Fri, 23 Oct 2020 22:22:45 -0700 Subject: [PATCH 3/4] Avoid using the dylibbundler flag -od This would erase the library directory before copying the dependencies. In the case of LV2, which copies in two steps, this would prevent sndfile from getting packaged into the bundle. --- .travis/prepare_osx.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis/prepare_osx.sh b/.travis/prepare_osx.sh index 8de6d08e..f9b0c53a 100755 --- a/.travis/prepare_osx.sh +++ b/.travis/prepare_osx.sh @@ -15,18 +15,18 @@ buildenv make DESTDIR=${PWD}/${INSTALL_DIR} install # Bundle LV2 dependencies cd "${INSTALL_DIR}"/Library/Audio/Plug-Ins/LV2 -dylibbundler -od -b -x sfizz.lv2/Contents/Binary/sfizz.so -d sfizz.lv2/Contents/libs/ -p @loader_path/../libs/ -dylibbundler -od -b -x sfizz.lv2/Contents/Binary/sfizz_ui.so -d sfizz.lv2/Contents/libs/ -p @loader_path/../libs/ +dylibbundler -cd -of -b -x sfizz.lv2/Contents/Binary/sfizz.so -d sfizz.lv2/Contents/libs/ -p @loader_path/../libs/ +dylibbundler -cd -of -b -x sfizz.lv2/Contents/Binary/sfizz_ui.so -d sfizz.lv2/Contents/libs/ -p @loader_path/../libs/ cd "${TRAVIS_BUILD_DIR}/build" # Bundle VST3 dependencies cd "${INSTALL_DIR}"/Library/Audio/Plug-Ins/VST3 -dylibbundler -od -b -x sfizz.vst3/Contents/MacOS/sfizz -d sfizz.vst3/Contents/libs/ -p @loader_path/../libs/ +dylibbundler -cd -of -b -x sfizz.vst3/Contents/MacOS/sfizz -d sfizz.vst3/Contents/libs/ -p @loader_path/../libs/ cd "${TRAVIS_BUILD_DIR}/build" # Bundle AU dependencies cd "${INSTALL_DIR}"/Library/Audio/Plug-Ins/Components -dylibbundler -od -b -x sfizz.component/Contents/Resources/plugin.vst3/Contents/MacOS/sfizz -d sfizz.component/Contents/Resources/plugin.vst3/Contents/libs/ -p @loader_path/../libs/ +dylibbundler -cd -of -b -x sfizz.component/Contents/Resources/plugin.vst3/Contents/MacOS/sfizz -d sfizz.component/Contents/Resources/plugin.vst3/Contents/libs/ -p @loader_path/../libs/ cd "${TRAVIS_BUILD_DIR}/build" # From b71be82e2799d185552f9efcaab043eb14ddb844 Mon Sep 17 00:00:00 2001 From: Jean Pierre Cimalando Date: Fri, 23 Oct 2020 23:08:56 -0700 Subject: [PATCH 4/4] Put the dylibbundler steps into cmake and out of travis --- .travis.yml | 2 +- .travis/prepare_osx.sh | 40 ---------------------------------------- CMakeLists.txt | 3 +++ cmake/BundleDylibs.cmake | 32 ++++++++++++++++++++++++++++++++ lv2/CMakeLists.txt | 8 +++++++- vst/CMakeLists.txt | 11 ++++++++++- 6 files changed, 53 insertions(+), 43 deletions(-) delete mode 100755 .travis/prepare_osx.sh create mode 100644 cmake/BundleDylibs.cmake diff --git a/.travis.yml b/.travis.yml index ce79862c..47ae06a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -56,7 +56,7 @@ jobs: env: - INSTALL_DIR="sfizz-${TRAVIS_BRANCH}-${TRAVIS_OS_NAME}-${TRAVIS_CPU_ARCH}" script: .travis/script_osx.sh - after_success: .travis/prepare_osx.sh + after_success: .travis/prepare_tarball.sh - name: "MOD devices arm" env: diff --git a/.travis/prepare_osx.sh b/.travis/prepare_osx.sh deleted file mode 100755 index f9b0c53a..00000000 --- a/.travis/prepare_osx.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -set -ex - -test -z "$CONTAINER" - -if ! [ -z "$CONTAINER" ]; then - . .travis/docker_container.sh -else - . .travis/no_container.sh -fi - -cd build -buildenv make DESTDIR=${PWD}/${INSTALL_DIR} install - -# Bundle LV2 dependencies -cd "${INSTALL_DIR}"/Library/Audio/Plug-Ins/LV2 -dylibbundler -cd -of -b -x sfizz.lv2/Contents/Binary/sfizz.so -d sfizz.lv2/Contents/libs/ -p @loader_path/../libs/ -dylibbundler -cd -of -b -x sfizz.lv2/Contents/Binary/sfizz_ui.so -d sfizz.lv2/Contents/libs/ -p @loader_path/../libs/ -cd "${TRAVIS_BUILD_DIR}/build" - -# Bundle VST3 dependencies -cd "${INSTALL_DIR}"/Library/Audio/Plug-Ins/VST3 -dylibbundler -cd -of -b -x sfizz.vst3/Contents/MacOS/sfizz -d sfizz.vst3/Contents/libs/ -p @loader_path/../libs/ -cd "${TRAVIS_BUILD_DIR}/build" - -# Bundle AU dependencies -cd "${INSTALL_DIR}"/Library/Audio/Plug-Ins/Components -dylibbundler -cd -of -b -x sfizz.component/Contents/Resources/plugin.vst3/Contents/MacOS/sfizz -d sfizz.component/Contents/Resources/plugin.vst3/Contents/libs/ -p @loader_path/../libs/ -cd "${TRAVIS_BUILD_DIR}/build" - -# -tar -zcvf "${INSTALL_DIR}.tar.gz" ${INSTALL_DIR} - -# Only release a tarball if there is a tag -if [[ ${TRAVIS_TAG} != "" ]]; then - mv "${INSTALL_DIR}.tar.gz" ${TRAVIS_BUILD_DIR} -fi - -cd "${TRAVIS_BUILD_DIR}" diff --git a/CMakeLists.txt b/CMakeLists.txt index d0d3c7cb..3356da61 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,6 +38,9 @@ include (SfizzConfig) # Don't use IPO in non Release builds include (CheckIPO) +# Dylib bunder for macOS +include (BundleDylibs) + # Add Abseil add_subdirectory (external/abseil-cpp EXCLUDE_FROM_ALL) diff --git a/cmake/BundleDylibs.cmake b/cmake/BundleDylibs.cmake new file mode 100644 index 00000000..abee5c18 --- /dev/null +++ b/cmake/BundleDylibs.cmake @@ -0,0 +1,32 @@ +# Dylib bundler for macOS +# Requires the external program "dylibbundler" + +if(APPLE) + find_program(DYLIBBUNDLER_PROGRAM "dylibbundler") + if(NOT DYLIBBUNDLER_PROGRAM) + message(WARNING "The installation helper \"dylibbundler\" is not available.") + endif() +endif() + +function(bundle_dylibs NAME PATH) + if(NOT APPLE OR NOT DYLIBBUNDLER_PROGRAM) + return() + endif() + + set(_relative_libdir "../libs") + + get_filename_component(_dir "${PATH}" DIRECTORY) + set(_dir "${_dir}/${_relative_libdir}") + + set(_script "${CMAKE_CURRENT_BINARY_DIR}/_bundle-dylibs.${NAME}.cmake") + + file(WRITE "${_script}" +"execute_process(COMMAND \"${DYLIBBUNDLER_PROGRAM}\" + \"-cd\" \"-of\" \"-b\" + \"-x\" \"\$ENV{DESTDIR}${PATH}\" + \"-d\" \"\$ENV{DESTDIR}${_dir}\" + \"-p\" \"@loader_path/${_relative_libdir}/\") +") + + install(SCRIPT "${_script}" ${ARGN}) +endfunction() diff --git a/lv2/CMakeLists.txt b/lv2/CMakeLists.txt index a888ca81..743b26d2 100644 --- a/lv2/CMakeLists.txt +++ b/lv2/CMakeLists.txt @@ -105,6 +105,12 @@ endif() # Installation if (NOT MSVC) - install (DIRECTORY ${PROJECT_BINARY_DIR} DESTINATION ${LV2PLUGIN_INSTALL_DIR} + install(DIRECTORY ${PROJECT_BINARY_DIR} DESTINATION ${LV2PLUGIN_INSTALL_DIR} + COMPONENT "lv2") + bundle_dylibs(lv2 + "${LV2PLUGIN_INSTALL_DIR}/${PROJECT_NAME}.lv2/Contents/Binary/sfizz.so" + COMPONENT "lv2") + bundle_dylibs(lv2-ui + "${LV2PLUGIN_INSTALL_DIR}/${PROJECT_NAME}.lv2/Contents/Binary/sfizz_ui.so" COMPONENT "lv2") endif() diff --git a/vst/CMakeLists.txt b/vst/CMakeLists.txt index ea7f391d..b5db2495 100644 --- a/vst/CMakeLists.txt +++ b/vst/CMakeLists.txt @@ -118,9 +118,12 @@ endif() # Installation if (NOT MSVC) - install (DIRECTORY "${PROJECT_BINARY_DIR}/${VSTPLUGIN_BUNDLE_NAME}" + install(DIRECTORY "${PROJECT_BINARY_DIR}/${VSTPLUGIN_BUNDLE_NAME}" DESTINATION "${VSTPLUGIN_INSTALL_DIR}" COMPONENT "vst") + bundle_dylibs(vst + "${VSTPLUGIN_INSTALL_DIR}/${VSTPLUGIN_BUNDLE_NAME}/Contents/MacOS/sfizz" + COMPONENT "vst") endif() # --- Audio Unit wrapper --- # @@ -296,5 +299,11 @@ elseif(SFIZZ_AU) install(DIRECTORY "${PROJECT_BINARY_DIR}/${VSTPLUGIN_BUNDLE_NAME}/" DESTINATION "${AUPLUGIN_INSTALL_DIR}/${AUPLUGIN_BUNDLE_NAME}/Contents/Resources/plugin.vst3" COMPONENT "au") + bundle_dylibs(au + "${AUPLUGIN_INSTALL_DIR}/${AUPLUGIN_BUNDLE_NAME}/Contents/MacOS/sfizz" + COMPONENT "au") + bundle_dylibs(au-vst + "${AUPLUGIN_INSTALL_DIR}/${AUPLUGIN_BUNDLE_NAME}/Contents/Resources/plugin.vst3/Contents/MacOS/sfizz" + COMPONENT "au") endif() endif()