diff --git a/cmake-proxies/cmake-modules/AudacityFunctions.cmake b/cmake-proxies/cmake-modules/AudacityFunctions.cmake index 4a14db612..165101289 100644 --- a/cmake-proxies/cmake-modules/AudacityFunctions.cmake +++ b/cmake-proxies/cmake-modules/AudacityFunctions.cmake @@ -359,6 +359,15 @@ function( audacity_module_fn NAME SOURCES IMPORT_TARGETS PREFIX "" FOLDER "modules" # for IDE organization ) + if( CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin" ) + add_custom_command( + TARGET ${TARGET} + COMMAND ${CMAKE_COMMAND} + -D SRC="${_MODDIR}/${TARGET}.so" + -D WXWIN="${_SHARED_PROXY_BASE_PATH}/$" + -P ${AUDACITY_MODULE_PATH}/CopyLibs.cmake + POST_BUILD ) + endif() else() set( ATTRIBUTES "shape=octagon" ) set_target_property_all( ${TARGET} ${DIRECTORY_PROPERTY} "${_SHARED_PROXY_PATH}" ) diff --git a/cmake-proxies/cmake-modules/CopyLibs.cmake b/cmake-proxies/cmake-modules/CopyLibs.cmake index a79811e44..9050acc1c 100644 --- a/cmake-proxies/cmake-modules/CopyLibs.cmake +++ b/cmake-proxies/cmake-modules/CopyLibs.cmake @@ -84,7 +84,13 @@ function( gather_libs src ) list( APPEND words "-change ${line} @executable_path/../Frameworks/${refname}" ) - if( NOT "${lib}" IN_LIST VISITED ) + if( + # Don't do depth first search from modules: assume the fixup + # of .dylib libraries was already done when this function + # was visited for the executable + NOT src MATCHES "\\.so$" + AND NOT "${lib}" IN_LIST VISITED + ) gather_libs( ${lib} ) endif() endif() @@ -141,5 +147,9 @@ foreach( cmd ${postcmds} ) ) endforeach() -list( REMOVE_DUPLICATES libs ) -file( INSTALL ${libs} DESTINATION ${DST} FOLLOW_SYMLINK_CHAIN ) +# This .cmake file is invoked on Darwin for modules too. +# Do the INSTALL only for the executable. +if( NOT SRC MATCHES "\\.so$" ) + list( REMOVE_DUPLICATES libs ) + file( INSTALL ${libs} DESTINATION ${DST} FOLLOW_SYMLINK_CHAIN ) +endif()