From 5b893ca5d6bf4d4c504a34dc820f20e90f2adc04 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Thu, 18 Feb 2021 20:44:54 +0100 Subject: [PATCH] cmake: Add otool post-build steps for MacOS --- CMakeLists.txt | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b6f930..61b5f5f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1515,6 +1515,39 @@ if(T_CHECK AND HAVE_CLANG) ) endif() +# Apple otool +if(D_PLATFORM_MAC) + # OBS + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD + COMMAND install_name_tool ARGS -change "@rpath/libobs.0.dylib" "@executable_path/../Frameworks/libobs.0.dylib" $ + ) + message(STATUS "${LOGPREFIX} Added post-build step for adjusting libobs linking path.") + + # OBS Front-End API + if(REQUIRE_OBSFE AND HAVE_OBS_FRONTEND) + 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" $ + ) + message(STATUS "${LOGPREFIX} Added post-build step for adjusting libobs-frontend-api linking path.") + endif() + + # Qt5 + if(REQUIRE_QT AND HAVE_QT) + string(LENGTH "${Qt5_DIR}" T_PATH_LEN) + math(EXPR T_PATH_LEN "${T_PATH_LEN} - 10") + string(SUBSTRING "${Qt5_DIR}" 0 ${T_PATH_LEN} T_PATH) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD + # - QtCore + COMMAND install_name_tool ARGS -change "${T_PATH}/QtCore.framework/Versions/5/QtCore" "@executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore" $ + # - QtGui + COMMAND install_name_tool ARGS -change "${T_PATH}/QtGui.framework/Versions/5/QtGui" "@executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui" $ + # - QtWidgets + COMMAND install_name_tool ARGS -change "${T_PATH}/QtWidgets.framework/Versions/5/QtWidgets" "@executable_path/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets" $ + ) + message(STATUS "${LOGPREFIX} Added post-build step for adjusting Qt5 linking path (Found: ${Qt5_DIR} resolved to ${T_PATH}).") + endif() +endif() + ################################################################################ # Installation ################################################################################