Skip to content

Commit

Permalink
add rpath to origin in linux
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigodzf committed Mar 20, 2023
1 parent 41b7282 commit f95fabc
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 32 deletions.
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
80 changes: 49 additions & 31 deletions NeuralResonatorVST/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -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} "$<TARGET_FILE_DIR:${sub_target}>"
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} "$<TARGET_FILE_DIR:${sub_target}>"
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})

0 comments on commit f95fabc

Please sign in to comment.