From f95fabc9de7b7ef3241680ea89d7b513906b1942 Mon Sep 17 00:00:00 2001 From: Rodrigo Diaz Date: Mon, 20 Mar 2023 14:05:18 +0100 Subject: [PATCH] add rpath to origin in linux --- CMakeLists.txt | 10 +++- NeuralResonatorVST/CMakeLists.txt | 80 +++++++++++++++++++------------ 2 files changed, 58 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 52b0e85..c0cfe59 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,9 +68,17 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin" set(CMAKE_MACOSX_RPATH TRUE) set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) # This is to use the use the local libraries in the rpath as well - set(CMAKE_INSTALL_RPATH "@loader_path") # This is the path to the folder containing the executable # set(CMAKE_SKIP_BUILD_RPATH FALSE) set(CMAKE_BUILD_RPATH_USE_ORIGIN TRUE) + + if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") + # This is the path to the folder containing the executable + set(CMAKE_INSTALL_RPATH "@loader_path") + elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(CMAKE_INSTALL_RPATH "$ORIGIN") + endif() + + endif() add_subdirectory(NeuralResonatorVST) diff --git a/NeuralResonatorVST/CMakeLists.txt b/NeuralResonatorVST/CMakeLists.txt index 73dda4c..0684b2e 100644 --- a/NeuralResonatorVST/CMakeLists.txt +++ b/NeuralResonatorVST/CMakeLists.txt @@ -110,27 +110,28 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Linux") # ) endif() -if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - set( - PRETRAINED_MODELS_PATH - ${CMAKE_SOURCE_DIR}/pretrained/encoder.pt - ${CMAKE_SOURCE_DIR}/pretrained/model_wrap.pt - CACHE INTERNAL "Path to the pretrained models" - ) +set( + PRETRAINED_MODELS_PATH + ${CMAKE_SOURCE_DIR}/pretrained/encoder.pt + ${CMAKE_SOURCE_DIR}/pretrained/model_wrap.pt + CACHE INTERNAL "Path to the pretrained models" +) - get_target_property(active_targets ${PLUGIN_NAME} JUCE_ACTIVE_PLUGIN_TARGETS) - foreach( sub_target IN LISTS active_targets ) - - message(STATUS "Adding libraries and models to ${sub_target}") +get_target_property(active_targets ${PLUGIN_NAME} JUCE_ACTIVE_PLUGIN_TARGETS) +foreach( sub_target IN LISTS active_targets ) + + message(STATUS "Adding libraries and models to ${sub_target}") - get_target_property( - BUNDLE_PATH - ${sub_target} - JUCE_PLUGIN_ARTEFACT_FILE - ) + get_target_property( + BUNDLE_PATH + ${sub_target} + JUCE_PLUGIN_ARTEFACT_FILE + ) + + copy_torch_libs(${sub_target}) - copy_torch_libs(${sub_target}) + if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") # Copy pretrained models to the plugin bundle target_sources(${sub_target} PRIVATE ${PRETRAINED_MODELS_PATH}) @@ -142,22 +143,39 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") # Copy the minified ui to the plugin bundle target_sources(${sub_target} PRIVATE ${MINIFIED_UI_PATH}) - set_source_files_properties( ${MINIFIED_UI_PATH} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources" ) - - # TODO Sign the plugin - # https://forum.juce.com/t/prepare-plugins-for-distribution-on-macos-notarization-code-signing-etc/53124/7 - # add_custom_command( - # TARGET ${sub_target} POST_BUILD - # COMMENT "Signing ${sub_target}" - # COMMAND "codesign" "--force" "--deep" "-s" "-" ${bundle_path} - # VERBATIM - # ) - endforeach() - - juce_enable_copy_plugin_step(${PLUGIN_NAME}) -endif() + elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") + # Copy pretrained models to the plugin bundle + add_custom_command( + TARGET ${sub_target} + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy ${PRETRAINED_MODELS_PATH} "$" + COMMENT "Copy models to ${sub_target}" + VERBATIM + ) + # Copy the minified ui to the plugin bundle + add_custom_command( + TARGET ${sub_target} + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy ${MINIFIED_UI_PATH} "$" + COMMENT "Copy minified ui to ${sub_target}" + VERBATIM + ) + endif() + # TODO Sign the plugin + # https://forum.juce.com/t/prepare-plugins-for-distribution-on-macos-notarization-code-signing-etc/53124/7 +# add_custom_command( +# TARGET ${sub_target} POST_BUILD +# COMMENT "Signing ${sub_target}" +# COMMAND "codesign" "--force" "--deep" "-s" "-" ${bundle_path} +# VERBATIM +# ) +endforeach() + +juce_enable_copy_plugin_step(${PLUGIN_NAME})