mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-31 07:59:27 +02:00
Merge pull request #964 from Paul-Licameli/some-cmake-changes
Cmake changes fix loading of modules on macOS
This commit is contained in:
commit
767463cd44
@ -301,6 +301,19 @@ function( export_symbol_define var module_name )
|
||||
set( "${var}" "${symbol}=${value}" PARENT_SCOPE )
|
||||
endfunction()
|
||||
|
||||
# shorten a target name for purposes of generating a dependency graph picture
|
||||
function( canonicalize_node_name var node )
|
||||
# strip generator expressions
|
||||
string( REGEX REPLACE ".*>.*:(.*)>" "\\1" node "${node}" )
|
||||
# omit the "-interface" for alias targets to modules
|
||||
string( REGEX REPLACE "-interface\$" "" node "${node}" )
|
||||
# shorten names of standard libraries or Apple frameworks
|
||||
string( REGEX REPLACE "^-(l|framework )" "" node "${node}" )
|
||||
# shorten paths
|
||||
get_filename_component( node "${node}" NAME_WE )
|
||||
set( "${var}" "${node}" PARENT_SCOPE )
|
||||
endfunction()
|
||||
|
||||
function( audacity_module_fn NAME SOURCES IMPORT_TARGETS
|
||||
ADDITIONAL_DEFINES ADDITIONAL_LIBRARIES LIBTYPE )
|
||||
|
||||
@ -346,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}/$<CONFIG>"
|
||||
-P ${AUDACITY_MODULE_PATH}/CopyLibs.cmake
|
||||
POST_BUILD )
|
||||
endif()
|
||||
else()
|
||||
set( ATTRIBUTES "shape=octagon" )
|
||||
set_target_property_all( ${TARGET} ${DIRECTORY_PROPERTY} "${_SHARED_PROXY_PATH}" )
|
||||
@ -454,7 +476,7 @@ function( audacity_module_fn NAME SOURCES IMPORT_TARGETS
|
||||
if(IMPORT IN_LIST ACCESS)
|
||||
continue()
|
||||
endif()
|
||||
string( REGEX REPLACE "-interface\$" "" IMPORT "${IMPORT}" )
|
||||
canonicalize_node_name(IMPORT "${IMPORT}")
|
||||
list( APPEND GRAPH_EDGES "\"${TARGET}\" -> \"${IMPORT}\"" )
|
||||
endforeach()
|
||||
set( GRAPH_EDGES "${GRAPH_EDGES}" PARENT_SCOPE )
|
||||
|
@ -39,9 +39,10 @@ function( execute )
|
||||
endfunction()
|
||||
|
||||
set( VISITED )
|
||||
set( postcmds )
|
||||
function( gather_libs src )
|
||||
list( APPEND VISITED "${src}" )
|
||||
if( CMAKE_HOST_SYSTEM_NAME MATCHES "Windows" )
|
||||
list( APPEND VISITED "${src}" )
|
||||
execute( output cmd /k dumpbin /dependents ${src} )
|
||||
|
||||
foreach( line ${output} )
|
||||
@ -61,7 +62,8 @@ function( gather_libs src )
|
||||
execute( output otool -L ${src} )
|
||||
|
||||
set( libname "${src}" )
|
||||
|
||||
|
||||
set( words )
|
||||
foreach( line ${output} )
|
||||
if( line MATCHES "^.*\\.dylib " )
|
||||
string( REGEX REPLACE "dylib .*" "dylib" line "${line}" )
|
||||
@ -71,9 +73,7 @@ function( gather_libs src )
|
||||
message(STATUS "Checking out ${line}")
|
||||
set( lib "${WXWIN}/${dylib_name}" )
|
||||
|
||||
if( NOT lib STREQUAL "${src}" AND NOT line MATCHES "@executable" AND EXISTS "${lib}"
|
||||
AND NOT "${src}///${lib}" IN_LIST VISITED )
|
||||
list( APPEND VISITED "${src}///${lib}" )
|
||||
if( NOT lib STREQUAL "${src}" AND NOT line MATCHES "@executable" AND EXISTS "${lib}" )
|
||||
message(STATUS "\tProcessing ${lib}...")
|
||||
|
||||
list( APPEND libs ${lib} )
|
||||
@ -82,14 +82,28 @@ function( gather_libs src )
|
||||
|
||||
message(STATUS "\t\tAdding ${refname} to ${src}")
|
||||
|
||||
list( APPEND postcmds "sh -c 'install_name_tool -change ${line} @executable_path/../Frameworks/${refname} ${src}'" )
|
||||
list( APPEND words "-change ${line} @executable_path/../Frameworks/${refname}" )
|
||||
|
||||
gather_libs( ${lib} )
|
||||
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()
|
||||
endif()
|
||||
endforeach()
|
||||
if( words )
|
||||
# There is at least one dependency to rename
|
||||
list( PREPEND words "install_name_tool" )
|
||||
list( APPEND words "${src}" )
|
||||
string( JOIN " " postcmd ${words} )
|
||||
list( APPEND postcmds "${postcmd}" )
|
||||
endif()
|
||||
elseif( CMAKE_HOST_SYSTEM_NAME MATCHES "Linux" )
|
||||
list( APPEND VISITED "${src}" )
|
||||
message(STATUS "Executing LD_LIBRARY_PATH='${WXWIN}' ldd ${src}")
|
||||
|
||||
execute( output sh -c "LD_LIBRARY_PATH='${WXWIN}' ldd ${src}" )
|
||||
@ -133,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()
|
||||
|
@ -1365,8 +1365,7 @@ endif()
|
||||
list( APPEND GRAPH_EDGES "Audacity [shape=house]" )
|
||||
foreach( LIBRARY ${LIBRARIES} )
|
||||
if (NOT LIBRARY MATCHES "PUBLIC|PRIVATE|INTERFACE")
|
||||
string( REGEX REPLACE ".*>.*:(.*)>" "\\1" LIBRARY "${LIBRARY}" )
|
||||
string( REGEX REPLACE "^-(l|framework )" "" LIBRARY "${LIBRARY}" )
|
||||
canonicalize_node_name(LIBRARY "${LIBRARY}")
|
||||
list( APPEND GRAPH_EDGES "\"${TARGET}\" -> \"${LIBRARY}\"" )
|
||||
endif()
|
||||
endforeach()
|
||||
|
Loading…
x
Reference in New Issue
Block a user