mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-09-29 04:47:56 -05:00
Move plugins to separate folder (#400)
This commit is contained in:
@@ -626,20 +626,28 @@ static void OBSEvent(enum obs_frontend_event event, void *switcher)
|
||||
|
||||
void LoadPlugins()
|
||||
{
|
||||
QFileInfo fi(obs_get_module_binary_path(obs_current_module()));
|
||||
QDirIterator it(fi.absolutePath(), QStringList() << "*.so",
|
||||
QDir::Files);
|
||||
QFileInfo libPath(
|
||||
QString(obs_get_module_binary_path(obs_current_module())));
|
||||
QString pluginDir(libPath.absolutePath() + "/adv-ss-plugins");
|
||||
#ifdef _WIN32
|
||||
QString libPattern = "*.dll";
|
||||
SetDllDirectory(pluginDir.toStdWString().c_str());
|
||||
#else
|
||||
QString libPattern = "*.so";
|
||||
#endif
|
||||
QDirIterator it(pluginDir, QStringList() << libPattern, QDir::Files);
|
||||
while (it.hasNext()) {
|
||||
auto file = it.next();
|
||||
if (it.fileName() == "advanced-scene-switcher.so") {
|
||||
continue;
|
||||
}
|
||||
blog(LOG_INFO, "attempting to load \"%s\"",
|
||||
file.toStdString().c_str());
|
||||
auto lib = new QLibrary(file, nullptr);
|
||||
if (lib->load()) {
|
||||
blog(LOG_INFO, "successfully loaded \"%s\"",
|
||||
file.toStdString().c_str());
|
||||
} else {
|
||||
blog(LOG_WARNING, "failed to load \"%s\": %s",
|
||||
file.toStdString().c_str(),
|
||||
lib->errorString().toStdString().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -658,10 +666,7 @@ extern "C" void InitSceneSwitcher()
|
||||
}
|
||||
|
||||
PlatformInit();
|
||||
#if !defined(_WIN32)
|
||||
// Windows does not require the plugins to be loaded manually
|
||||
LoadPlugins();
|
||||
#endif
|
||||
SetupDock();
|
||||
|
||||
auto cb = []() {
|
||||
|
||||
@@ -1,3 +1,57 @@
|
||||
# Helper function to install plugins to correct location
|
||||
function(install_advss_plugin target)
|
||||
set(plugin_folder "adv-ss-plugins")
|
||||
if(APPLE)
|
||||
set(_bit_suffix "")
|
||||
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(_bit_suffix "64bit/")
|
||||
else()
|
||||
set(_bit_suffix "32bit/")
|
||||
endif()
|
||||
|
||||
set_target_properties(${target} PROPERTIES PREFIX "")
|
||||
|
||||
install(
|
||||
TARGETS ${target}
|
||||
LIBRARY DESTINATION "${OBS_PLUGIN_DESTINATION}/${plugin_folder}"
|
||||
RUNTIME DESTINATION "${OBS_PLUGIN_DESTINATION}/${plugin_folder}")
|
||||
add_custom_command(
|
||||
TARGET ${target}
|
||||
POST_BUILD
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}" -E copy "$<TARGET_FILE:${target}>"
|
||||
"${OBS_OUTPUT_DIR}/$<CONFIGURATION>/obs-plugins/${_bit_suffix}/${plugin_folder}/$<TARGET_FILE_NAME:${target}>"
|
||||
VERBATIM)
|
||||
|
||||
if(DEFINED ENV{obsInstallerTempDir})
|
||||
add_custom_command(
|
||||
TARGET ${target}
|
||||
POST_BUILD
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}" -E copy "$<TARGET_FILE:${target}>"
|
||||
"$ENV{obsInstallerTempDir}/${OBS_PLUGIN_DESTINATION}/${plugin_folder}/$<TARGET_FILE_NAME:${target}>"
|
||||
VERBATIM)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
obs_debug_copy_helper(
|
||||
${target}
|
||||
"${OBS_OUTPUT_DIR}/$<CONFIGURATION>/obs-plugins/${_bit_suffix}/${plugin_folder}"
|
||||
)
|
||||
|
||||
if(DEFINED ENV{obsInstallerTempDir})
|
||||
obs_debug_copy_helper(
|
||||
${target}
|
||||
"$ENV{obsInstallerTempDir}/${OBS_PLUGIN_DESTINATION}/${plugin_folder}")
|
||||
endif()
|
||||
|
||||
install(
|
||||
DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/pdbs/"
|
||||
DESTINATION "${OBS_PLUGIN_DESTINATION}/${plugin_folder}"
|
||||
CONFIGURATIONS Debug RelWithDebInfo)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Add macro conditions or actions which have dependencies to external libraries
|
||||
# or other components which might potentially not be fulfilled by the user and
|
||||
# thus cause issues.
|
||||
|
||||
@@ -34,8 +34,9 @@ if(BUILD_OUT_OF_TREE)
|
||||
set(LIB_OUT_DIR "/lib/obs-plugins")
|
||||
endif()
|
||||
set_target_properties(advanced-scene-switcher-opencv PROPERTIES PREFIX "")
|
||||
install(TARGETS advanced-scene-switcher-opencv
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/${LIB_OUT_DIR})
|
||||
install(
|
||||
TARGETS advanced-scene-switcher-opencv
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/${LIB_OUT_DIR}/adv-ss-plugins)
|
||||
endif()
|
||||
else()
|
||||
target_link_libraries(
|
||||
@@ -46,5 +47,5 @@ else()
|
||||
Qt5::Core
|
||||
Qt5::Widgets
|
||||
libobs)
|
||||
install_obs_plugin(advanced-scene-switcher-opencv)
|
||||
install_advss_plugin(advanced-scene-switcher-opencv)
|
||||
endif()
|
||||
|
||||
@@ -73,8 +73,9 @@ if(BUILD_OUT_OF_TREE)
|
||||
set(LIB_OUT_DIR "/lib/obs-plugins")
|
||||
endif()
|
||||
set_target_properties(advanced-scene-switcher-openvr PROPERTIES PREFIX "")
|
||||
install(TARGETS advanced-scene-switcher-openvr
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/${LIB_OUT_DIR})
|
||||
install(
|
||||
TARGETS advanced-scene-switcher-openvr
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/${LIB_OUT_DIR}/adv-ss-plugins)
|
||||
endif()
|
||||
else()
|
||||
target_link_libraries(
|
||||
@@ -85,5 +86,5 @@ else()
|
||||
Qt5::Core
|
||||
Qt5::Widgets
|
||||
libobs)
|
||||
install_obs_plugin(advanced-scene-switcher-openvr)
|
||||
install_advss_plugin(advanced-scene-switcher-openvr)
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user