Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include $ORIGIN in portable mode on unix #34

Merged
merged 3 commits into from
Jan 28, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ endif()

if(APPLE)
set(CMAKE_MACOSX_RPATH TRUE)
set(CMAKE_INSTALL_RPATH
"${CMAKE_INSTALL_RPATH};@loader_path/;@executable_path/")
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
list(APPEND CMAKE_INSTALL_RPATH "@loader_path/" "@executable_path/")
elseif(UNIX AND NOT UNIX_STRUCTURE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
list(APPEND CMAKE_INSTALL_RPATH "$ORIGIN")
endif()

if(NOT INSTALLER_RUN)
Expand Down
2 changes: 1 addition & 1 deletion cmake/Modules/FindLibavcodec.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ else()

find_library(AVCODEC_LIB
NAMES avcodec
HINTS ${_AVCODEC_LIBRARY_DIRS} ${FFMPEG_INCLUDE_DIR}/../lib ${FFMPEG_INCLUDE_DIR}/lib${_lib_suffix} /usr/lib /usr/local/lib /opt/local/lib /sw/lib)
HINTS ${FFMPEG_INCLUDE_DIR}/../lib ${FFMPEG_INCLUDE_DIR}/lib${_lib_suffix} ${_AVCODEC_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib)

set(Libavcodec_INCLUDE_DIR ${FFMPEG_INCLUDE_DIR} CACHE PATH "Libavcodec include dir")
set(Libavcodec_LIBRARIES ${AVCODEC_LIB} CACHE STRING "Libavcodec libraries")
Expand Down
2 changes: 1 addition & 1 deletion cmake/Modules/FindLibavformat.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ else()

find_library(AVFORMAT_LIB
NAMES avformat
HINTS ${_AVFORMAT_LIBRARY_DIRS} ${FFMPEG_INCLUDE_DIR}/../lib ${FFMPEG_INCLUDE_DIR}/lib${_lib_suffix} /usr/lib /usr/local/lib /opt/local/lib /sw/lib)
HINTS ${FFMPEG_INCLUDE_DIR}/../lib ${FFMPEG_INCLUDE_DIR}/lib${_lib_suffix} ${_AVFORMAT_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib)

set(Libavformat_INCLUDE_DIR ${FFMPEG_INCLUDE_DIR} CACHE PATH "Libavformat include dir")
set(Libavformat_LIBRARIES ${AVFORMAT_LIB} CACHE STRING "Libavformat libraries")
Expand Down
2 changes: 1 addition & 1 deletion cmake/Modules/FindLibavutil.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ else()

find_library(AVUTIL_LIB
NAMES avutil
HINTS ${_AVUTIL_LIBRARY_DIRS} ${FFMPEG_INCLUDE_DIR}/../lib ${FFMPEG_INCLUDE_DIR}/lib${_lib_suffix} /usr/lib /usr/local/lib /opt/local/lib /sw/lib)
HINTS ${FFMPEG_INCLUDE_DIR}/../lib ${FFMPEG_INCLUDE_DIR}/lib${_lib_suffix} ${_AVUTIL_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib)

set(Libavutil_INCLUDE_DIR ${FFMPEG_INCLUDE_DIR} CACHE PATH "Libavutil include dir")
set(Libavutil_LIBRARIES ${AVUTIL_LIB} CACHE STRING "Libavutil libraries")
Expand Down
2 changes: 1 addition & 1 deletion cmake/Modules/FindLibswresample.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ else()

find_library(SWRESAMPLE_LIB
NAMES swresample
HINTS ${_SWRESAMPLE_LIBRARY_DIRS} ${FFMPEG_INCLUDE_DIR}/../lib ${FFMPEG_INCLUDE_DIR}/lib${_lib_suffix} /usr/lib /usr/local/lib /opt/local/lib /sw/lib)
HINTS ${FFMPEG_INCLUDE_DIR}/../lib ${FFMPEG_INCLUDE_DIR}/lib${_lib_suffix} ${_SWRESAMPLE_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib)

set(Libswresample_INCLUDE_DIR ${FFMPEG_INCLUDE_DIR} CACHE PATH "Libswresample include dir")
set(Libswresample_LIBRARIES ${SWRESAMPLE_LIB} CACHE STRING "Libswresample libraries")
Expand Down
2 changes: 1 addition & 1 deletion cmake/Modules/FindLibx264.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ else()

find_library(X264_LIB
NAMES x264 libx264
HINTS ${_X264_LIBRARY_DIRS} ${X264_INCLUDE_DIR}/../lib ${X264_INCLUDE_DIR}/lib${_lib_suffix} /usr/lib /usr/local/lib /opt/local/lib /sw/lib)
HINTS ${X264_INCLUDE_DIR}/../lib ${X264_INCLUDE_DIR}/lib${_lib_suffix} ${_X264_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib)

set(Libx264_INCLUDE_DIR ${X264_INCLUDE_DIR} CACHE PATH "x264 include dir")
set(Libx264_LIBRARIES ${X264_LIB} CACHE STRING "x264 libraries")
Expand Down
30 changes: 29 additions & 1 deletion cmake/Modules/ObsHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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 "."
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions libobs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
4 changes: 4 additions & 0 deletions obs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 3 additions & 0 deletions plugins/obs-ffmpeg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
2 changes: 2 additions & 0 deletions plugins/obs-outputs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})