mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-14 07:45:06 +00:00
cmake: (MacOS) Fix linker path for libraries
This commit is contained in:
parent
eef6d2d445
commit
d8bb1cecc5
2 changed files with 81 additions and 35 deletions
|
@ -273,13 +273,9 @@ endif()
|
||||||
if(STANDALONE)
|
if(STANDALONE)
|
||||||
message(STATUS "${LOGPREFIX} This is a standalone build, please make sure you've followed the instructions.")
|
message(STATUS "${LOGPREFIX} This is a standalone build, please make sure you've followed the instructions.")
|
||||||
set(${PREFIX}OBS_NATIVE OFF)
|
set(${PREFIX}OBS_NATIVE OFF)
|
||||||
if (TARGET obs-frontend-api)
|
|
||||||
set(HAVE_OBS_FRONTEND ON)
|
|
||||||
endif()
|
|
||||||
else()
|
else()
|
||||||
message(STATUS "${LOGPREFIX} This is a combined build.")
|
message(STATUS "${LOGPREFIX} This is a combined build.")
|
||||||
set(${PREFIX}OBS_NATIVE ON)
|
set(${PREFIX}OBS_NATIVE ON)
|
||||||
set(HAVE_OBS_FRONTEND ON)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -647,6 +643,7 @@ feature_frontend(OFF)
|
||||||
feature_updater(OFF)
|
feature_updater(OFF)
|
||||||
|
|
||||||
# Fulfill Requirements
|
# Fulfill Requirements
|
||||||
|
#- CURL
|
||||||
set(HAVE_CURL OFF)
|
set(HAVE_CURL OFF)
|
||||||
if(REQUIRE_CURL)
|
if(REQUIRE_CURL)
|
||||||
if(D_PLATFORM_WINDOWS)
|
if(D_PLATFORM_WINDOWS)
|
||||||
|
@ -668,6 +665,7 @@ if(REQUIRE_CURL)
|
||||||
set(HAVE_CURL ${CURL_FOUND})
|
set(HAVE_CURL ${CURL_FOUND})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
#- FFmpeg
|
||||||
set(HAVE_FFMPEG OFF)
|
set(HAVE_FFMPEG OFF)
|
||||||
if(REQUIRE_FFMPEG)
|
if(REQUIRE_FFMPEG)
|
||||||
if(D_PLATFORM_WINDOWS AND NOT ${PREFIX}OBS_NATIVE)
|
if(D_PLATFORM_WINDOWS AND NOT ${PREFIX}OBS_NATIVE)
|
||||||
|
@ -701,6 +699,7 @@ if(REQUIRE_FFMPEG)
|
||||||
set(HAVE_FFMPEG ${FFmpeg_FOUND})
|
set(HAVE_FFMPEG ${FFmpeg_FOUND})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
#- JSON
|
||||||
set(HAVE_JSON OFF)
|
set(HAVE_JSON OFF)
|
||||||
if(REQUIRE_JSON)
|
if(REQUIRE_JSON)
|
||||||
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/third-party/nlohmann-json/single_include")
|
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/third-party/nlohmann-json/single_include")
|
||||||
|
@ -712,7 +711,7 @@ if(REQUIRE_JSON)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# NVIDIA Augmented Reality SDK (Windows)
|
#- NVIDIA Augmented Reality SDK (Windows)
|
||||||
set(HAVE_NVIDIA_ARSDK OFF)
|
set(HAVE_NVIDIA_ARSDK OFF)
|
||||||
if(REQUIRE_NVIDIA_ARSDK AND D_PLATFORM_WINDOWS)
|
if(REQUIRE_NVIDIA_ARSDK AND D_PLATFORM_WINDOWS)
|
||||||
if(EXISTS "${PROJECT_SOURCE_DIR}/third-party/nvidia-arsdk/version.h")
|
if(EXISTS "${PROJECT_SOURCE_DIR}/third-party/nvidia-arsdk/version.h")
|
||||||
|
@ -724,12 +723,13 @@ if(REQUIRE_NVIDIA_ARSDK AND D_PLATFORM_WINDOWS)
|
||||||
set(HAVE_NVIDIA_ARSDK ${NVAR_FOUND})
|
set(HAVE_NVIDIA_ARSDK ${NVAR_FOUND})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# NVIDIA CUDA (Windows)
|
#- NVIDIA CUDA (Windows)
|
||||||
set(HAVE_NVIDIA_CUDA OFF)
|
set(HAVE_NVIDIA_CUDA OFF)
|
||||||
if(REQUIRE_NVIDIA_CUDA AND D_PLATFORM_WINDOWS)
|
if(REQUIRE_NVIDIA_CUDA AND D_PLATFORM_WINDOWS)
|
||||||
set(HAVE_NVIDIA_CUDA ON)
|
set(HAVE_NVIDIA_CUDA ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
#- OBS Front-End API
|
||||||
set(HAVE_OBSFE OFF)
|
set(HAVE_OBSFE OFF)
|
||||||
if(REQUIRE_OBSFE)
|
if(REQUIRE_OBSFE)
|
||||||
if(${PREFIX}OBS_NATIVE)
|
if(${PREFIX}OBS_NATIVE)
|
||||||
|
@ -744,6 +744,7 @@ if(REQUIRE_OBSFE)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
#- Qt5
|
||||||
set(HAVE_QT OFF)
|
set(HAVE_QT OFF)
|
||||||
if(REQUIRE_QT)
|
if(REQUIRE_QT)
|
||||||
find_package(Qt5
|
find_package(Qt5
|
||||||
|
@ -1526,33 +1527,43 @@ endif()
|
||||||
# Apple otool
|
# Apple otool
|
||||||
if(D_PLATFORM_MAC)
|
if(D_PLATFORM_MAC)
|
||||||
# OBS
|
# OBS
|
||||||
|
mac_get_linker_id(TARGET libobs OUTPUT T_OBS_LINK)
|
||||||
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
|
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
|
||||||
COMMAND install_name_tool ARGS -change "@rpath/libobs.0.dylib" "@executable_path/../Frameworks/libobs.0.dylib" $<TARGET_FILE:${PROJECT_NAME}>
|
COMMAND install_name_tool ARGS -change "${T_OBS_LINK}" "@executable_path/../Frameworks/libobs.0.dylib" $<TARGET_FILE:${PROJECT_NAME}>
|
||||||
)
|
)
|
||||||
message(STATUS "${LOGPREFIX} Added post-build step for adjusting libobs linking path.")
|
message(STATUS "${LOGPREFIX} Added post-build step for adjusting libobs linking path.")
|
||||||
|
|
||||||
# OBS Front-End API
|
# OBS Front-End API
|
||||||
if(REQUIRE_OBSFE AND HAVE_OBS_FRONTEND)
|
if(REQUIRE_OBSFE AND HAVE_OBSFE)
|
||||||
|
mac_get_linker_id(TARGET obs-frontend-api OUTPUT T_OBSFE_LINK)
|
||||||
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
|
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
|
||||||
COMMAND install_name_tool ARGS -change "@rpath/libobs-frontend-api.dylib" "@executable_path/../Frameworks/libobs-frontend-api.dylib" $<TARGET_FILE:${PROJECT_NAME}>
|
COMMAND install_name_tool ARGS -change "${T_OBSFE_LINK}" "@executable_path/../Frameworks/libobs-frontend-api.dylib" $<TARGET_FILE:${PROJECT_NAME}>
|
||||||
)
|
)
|
||||||
message(STATUS "${LOGPREFIX} Added post-build step for adjusting libobs-frontend-api linking path.")
|
message(STATUS "${LOGPREFIX} Added post-build step for adjusting libobs-frontend-api linking path.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Qt5
|
# Qt5
|
||||||
if(REQUIRE_QT AND HAVE_QT)
|
if(REQUIRE_QT AND HAVE_QT)
|
||||||
string(LENGTH "${Qt5_DIR}" T_PATH_LEN)
|
# Figure out the linker location for Qt5::Core
|
||||||
math(EXPR T_PATH_LEN "${T_PATH_LEN} - 10")
|
mac_get_linker_id(TARGET Qt5::Core OUTPUT T_QT5CORE_LINK)
|
||||||
string(SUBSTRING "${Qt5_DIR}" 0 ${T_PATH_LEN} T_PATH)
|
|
||||||
|
# Figure out the linker location for Qt5::Gui
|
||||||
|
mac_get_linker_id(TARGET Qt5::Gui OUTPUT T_QT5GUI_LINK)
|
||||||
|
|
||||||
|
# Figure out the linker location for Qt5::Widsgets
|
||||||
|
mac_get_linker_id(TARGET Qt5::Widgets OUTPUT T_QT5WIDGETS_LINK)
|
||||||
|
|
||||||
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
|
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
|
||||||
# - QtCore
|
# - QtCore
|
||||||
COMMAND install_name_tool ARGS -change "${T_PATH}/QtCore.framework/Versions/5/QtCore" "@executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore" $<TARGET_FILE:${PROJECT_NAME}>
|
COMMAND install_name_tool ARGS -change "${T_QT5CORE_LINK}" "@executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore" $<TARGET_FILE:${PROJECT_NAME}>
|
||||||
# - QtGui
|
# - QtGui
|
||||||
COMMAND install_name_tool ARGS -change "${T_PATH}/QtGui.framework/Versions/5/QtGui" "@executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui" $<TARGET_FILE:${PROJECT_NAME}>
|
COMMAND install_name_tool ARGS -change "${T_QT5GUI_LINK}" "@executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui" $<TARGET_FILE:${PROJECT_NAME}>
|
||||||
# - QtWidgets
|
# - QtWidgets
|
||||||
COMMAND install_name_tool ARGS -change "${T_PATH}/QtWidgets.framework/Versions/5/QtWidgets" "@executable_path/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets" $<TARGET_FILE:${PROJECT_NAME}>
|
COMMAND install_name_tool ARGS -change "${T_QT5WIDGETS_LINK}" "@executable_path/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets" $<TARGET_FILE:${PROJECT_NAME}>
|
||||||
)
|
)
|
||||||
message(STATUS "${LOGPREFIX} Added post-build step for adjusting Qt5 linking path (Found: ${Qt5_DIR} resolved to ${T_PATH}).")
|
message(STATUS "${LOGPREFIX} Added post-build step for adjusting Qt5::Core linking path (Found: ${Qt5_DIR} resolved to ${T_QT5CORE_LINK}).")
|
||||||
|
message(STATUS "${LOGPREFIX} Added post-build step for adjusting Qt5::Gui linking path (Found: ${Qt5_DIR} resolved to ${T_QT5GUI_LINK}).")
|
||||||
|
message(STATUS "${LOGPREFIX} Added post-build step for adjusting Qt5::Widgets linking path (Found: ${Qt5_DIR} resolved to ${T_QT5WIDGETS_LINK}).")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
include(CMakeParseArguments)
|
||||||
|
|
||||||
Function(CacheSet Name Value)
|
Function(CacheSet Name Value)
|
||||||
GET_PROPERTY(V_ADVANCED CACHE "${Name}" PROPERTY ADVANCED)
|
GET_PROPERTY(V_ADVANCED CACHE "${Name}" PROPERTY ADVANCED)
|
||||||
GET_PROPERTY(V_TYPE CACHE "${Name}" PROPERTY TYPE)
|
GET_PROPERTY(V_TYPE CACHE "${Name}" PROPERTY TYPE)
|
||||||
|
@ -17,3 +19,36 @@ Function(CacheClear Name)
|
||||||
Mark_As_Advanced(FORCE ${Name})
|
Mark_As_Advanced(FORCE ${Name})
|
||||||
EndIf()
|
EndIf()
|
||||||
EndFunction()
|
EndFunction()
|
||||||
|
|
||||||
|
function(mac_get_linker_id)
|
||||||
|
cmake_parse_arguments(
|
||||||
|
_MGLI "" "TARGET;OUTPUT" "" ${ARGN}
|
||||||
|
)
|
||||||
|
|
||||||
|
get_target_property(_MGLI_TARGET_LOC ${_MGLI_TARGET} IMPORTED_LOCATION)
|
||||||
|
if(NOT _MGLI_TARGET_LOC)
|
||||||
|
get_target_property(_MGLI_TARGET_LOC ${_MGLI_TARGET} IMPORTED_LOCATION_MINSIZEREL)
|
||||||
|
endif()
|
||||||
|
if(NOT _MGLI_TARGET_LOC)
|
||||||
|
get_target_property(_MGLI_TARGET_LOC ${_MGLI_TARGET} IMPORTED_LOCATION_RELEASE)
|
||||||
|
endif()
|
||||||
|
if(NOT _MGLI_TARGET_LOC)
|
||||||
|
get_target_property(_MGLI_TARGET_LOC ${_MGLI_TARGET} IMPORTED_LOCATION_RELWITHDEBINFO)
|
||||||
|
endif()
|
||||||
|
if(NOT _MGLI_TARGET_LOC)
|
||||||
|
get_target_property(_MGLI_TARGET_LOC ${_MGLI_TARGET} IMPORTED_LOCATION_DEBUG)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND otool -D ${_MGLI_TARGET_LOC}
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
||||||
|
RESULT_VARIABLE _MGLI_RES
|
||||||
|
OUTPUT_VARIABLE _MGLI_LINK OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
ERROR_VARIABLE _MGLI_ERR ERROR_STRIP_TRAILING_WHITESPACE ERROR_QUIET
|
||||||
|
)
|
||||||
|
STRING(REGEX REPLACE ";" "\\\\;" _MGLI_LINK "${_MGLI_LINK}")
|
||||||
|
STRING(REGEX REPLACE "\n" ";" _MGLI_LINK "${_MGLI_LINK}")
|
||||||
|
list(POP_FRONT _MGLI_LINK)
|
||||||
|
|
||||||
|
set(${_MGLI_OUTPUT} "${_MGLI_LINK}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
Loading…
Reference in a new issue