Fixup OSX Rpath for imported external libraries on install
This commit is contained in:
parent
19f0a30160
commit
074f9627b7
@ -14,6 +14,9 @@ endif()
|
||||
|
||||
option(INSTALLER_RUN "Build a multiarch installer, needs to run indenepdently after both archs have compiled" FALSE)
|
||||
option(UNIX_STRUCTURE "Build with standard unix filesystem structure" ${_struct_def})
|
||||
if(APPLE)
|
||||
option(BUILD_REDISTRIBUTABLE "Fix rpath of external libraries" FALSE)
|
||||
endif()
|
||||
|
||||
if(INSTALLER_RUN AND NOT DEFINED ENV{obsInstallerTempDir})
|
||||
message(FATAL_ERROR "Environment variable obsInstallerTempDir is needed for multiarch installer generation")
|
||||
@ -67,6 +70,31 @@ else()
|
||||
add_definitions(-DOBS_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}/")
|
||||
endif()
|
||||
|
||||
function(obs_fixup_install_target target type)
|
||||
if(NOT APPLE OR NOT BUILD_REDISTRIBUTABLE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
foreach(data ${ARGN})
|
||||
if(type STREQUAL "TARGET")
|
||||
get_property(fullpath TARGET "${data}" PROPERTY LOCATION)
|
||||
else()
|
||||
set(fullpath "${data}")
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND otool -D "${fullpath}" OUTPUT_VARIABLE otool_out)
|
||||
string(REGEX REPLACE "(\r?\n)+$" "" otool_out "${otool_out}")
|
||||
string(REGEX REPLACE ".*\n" "" otool_out "${otool_out}")
|
||||
|
||||
string(REGEX REPLACE ".*/" "@rpath/" newpath "${otool_out}")
|
||||
|
||||
add_custom_command(TARGET ${target} POST_BUILD
|
||||
COMMAND
|
||||
install_name_tool -change "${otool_out}" "${newpath}" "$<TARGET_FILE:${target}>"
|
||||
VERBATIM)
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
function(obs_generate_multiarch_installer)
|
||||
install(DIRECTORY "$ENV{obsInstallerTempDir}/"
|
||||
DESTINATION "."
|
||||
@ -143,9 +171,9 @@ macro(install_obs_core target)
|
||||
"${OBS_OUTPUT_DIR}/$<CONFIGURATION>/bin/${_bit_suffix}$<TARGET_FILE_NAME:${target}>"
|
||||
VERBATIM)
|
||||
|
||||
|
||||
if(DEFINED ENV{obsInstallerTempDir})
|
||||
get_property(target_type TARGET ${target} PROPERTY TYPE)
|
||||
|
||||
if("${target_type}" STREQUAL "EXECUTABLE")
|
||||
set(tmp_target_dir "${OBS_EXECUTABLE_DESTINATION}")
|
||||
else()
|
||||
|
@ -192,3 +192,5 @@ target_link_libraries(libobs
|
||||
|
||||
install_obs_core(libobs)
|
||||
install_obs_data(libobs ../build/data/libobs libobs)
|
||||
|
||||
obs_fixup_install_target(libobs PATH ${Libswresample_LIBRARIES} ${Libavutil_LIBRARIES})
|
||||
|
@ -93,3 +93,7 @@ target_link_libraries(obs
|
||||
|
||||
install_obs_core(obs)
|
||||
install_obs_data(obs ../build/data/obs-studio obs-studio)
|
||||
|
||||
obs_fixup_install_target(obs TARGET Qt5::Widgets)
|
||||
obs_fixup_install_target(obs TARGET Qt5::Gui)
|
||||
obs_fixup_install_target(obs TARGET Qt5::Core)
|
||||
|
@ -24,3 +24,6 @@ target_link_libraries(obs-ffmpeg
|
||||
${Libswresample_LIBRARIES})
|
||||
|
||||
install_obs_plugin(obs-ffmpeg)
|
||||
|
||||
obs_fixup_install_target(obs-ffmpeg PATH ${Libavformat_LIBRARIES})
|
||||
obs_fixup_install_target(obs-ffmpeg PATH ${Libswresample_LIBRARIES})
|
||||
|
@ -21,3 +21,5 @@ target_link_libraries(obs-outputs
|
||||
${Libx264_LIBRARIES})
|
||||
|
||||
install_obs_plugin(obs-outputs)
|
||||
|
||||
obs_fixup_install_target(obs-outputs PATH ${Libx264_LIBRARIES})
|
||||
|
Loading…
x
Reference in New Issue
Block a user