diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..33c9e3c0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,98 @@ +# Prerequisites # +################# +*.d + +# Object files # +################ +*.o +*.ko +*.obj +*.elf +*.slo +*.lo +*.obj + +# Linker output # +################# +*.ilk +*.map +*.exp + +# Precompiled Headers # +####################### +*.gch +*.pch + +# Libraries # +############# +*.lib +*.a +*.la +*.lo +*.lai + +# Shared objects (inc. Windows DLLs) # +###################################### +*.dll +*.so +*.so.* +*.dylib + +# Executables # +############### +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files # +############### +*.dSYM/ +*.su +*.idb +*.pdb + +# CMake temp files # +#################### +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake_install + +# OS generated files # +###################### +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db +*.directory + +# backup text files generated by an editor # +############################################ +**/*~ + +# Various IDE Files # +##################### +.classpath +.project +.settings +.idea +.metadata +*.iml +*.ipr +*.sublime* + +# Directories # +############### +build/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 17386077..e998df4d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,78 +1,142 @@ -project(advanced-scene-switcher) - -if(APPLE) - find_library(COCOA Cocoa) - include_directories(${COCOA}) -endif() - -if(UNIX) - find_package(X11 REQUIRED) - link_libraries(${X11_LIBRARIES}) - include_directories(${X11_INCLUDE_DIR}) -endif() - -set(advanced-scene-switcher_HEADERS - ${advanced-scene-switcher_HEADERS} - advanced-scene-switcher.hpp - switcher-data-structs.hpp - utility.hpp - ) -set(advanced-scene-switcher_SOURCES - ${advanced-scene-switcher_SOURCES} - advanced-scene-switcher.cpp - advanced-scene-switcher-module.c - scene-transitions.cpp - screen-region-switch.cpp - priority.cpp - executable-switch.cpp - idle-switch.cpp - scene-round-trip.cpp - file-switch.cpp - window-title-switch.cpp - hotkey.cpp - general.cpp - pause-switch.cpp - random.cpp - ) -set(advanced-scene-switcher_UI - ${advanced-scene-switcher_UI} - forms/advanced-scene-switcher.ui - ) - -if(WIN32) - set(advanced-scene-switcher_PLATFORM_SOURCES - advanced-scene-switcher-win.cpp) - -elseif(APPLE) - set(advanced-scene-switcher_PLATFORM_SOURCES - advanced-scene-switcher-osx.mm) - set_source_files_properties(advanced-scene-switcher-osx.mm - PROPERTIES COMPILE_FLAGS "-fobjc-arc") - - set(advanced-scene-switcher_PLATFORM_LIBS - ${COCOA}) -else() - set(advanced-scene-switcher_PLATFORM_SOURCES - advanced-scene-switcher-nix.cpp) - set(advanced-scene-switcher_PLATFORM_LIBS - Xss) -endif() - -qt5_wrap_ui(advanced-scene-switcher_UI_HEADERS - ${advanced-scene-switcher_UI} - ${advanced-scene-switcher_PLATFORM_UI}) - -add_library(advanced-scene-switcher MODULE - ${advanced-scene-switcher_HEADERS} - ${advanced-scene-switcher_SOURCES} - ${advanced-scene-switcher_UI_HEADERS} - ${advanced-scene-switcher_PLATFORM_SOURCES} - ${advanced-scene-switcher_PLATFORM_HEADERS} - ) -target_link_libraries(advanced-scene-switcher - ${advanced-scene-switcher_PLATFORM_LIBS} - obs-frontend-api - Qt5::Widgets - libobs) - -install_obs_plugin(advanced-scene-switcher data) +cmake_minimum_required(VERSION 3.5) + +project(advanced-scene-switcher) + +set(CMAKE_PREFIX_PATH "${QTDIR}") +set(CMAKE_INCLUDE_CURRENT_DIR ON) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/external") +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTOUIC ON) + + +include(external/FindLibObs.cmake) +find_package(LibObs REQUIRED) +find_package(Qt5Core REQUIRED) +find_package(Qt5Widgets REQUIRED) +find_path(LIBOBS_FRONTEND_INCLUDE_DIR HINTS ${LIBOBS_INCLUDE_DIRS}) +find_file(LIBOBS_FRONTEND_API_LIB NAMES libobs-frontend-api.* HINTS ${LIBOBS_LIB} ) + +if(APPLE) + find_library(COCOA Cocoa) + find_package(Qt5MacExtras REQUIRED) + include_directories(${COCOA}) + add_link_options("-v") +endif() + +if(UNIX) + find_package(X11 REQUIRED) + link_libraries(${X11_LIBRARIES}) + include_directories(${X11_INCLUDE_DIR}) +endif() + +set(advanced-scene-switcher_HEADERS + ${advanced-scene-switcher_HEADERS} + src/headers/advanced-scene-switcher.hpp + src/headers/switcher-data-structs.hpp + src/headers/utility.hpp + ) + +set(advanced-scene-switcher_SOURCES + ${advanced-scene-switcher_SOURCES} + src/advanced-scene-switcher.cpp + src/advanced-scene-switcher-module.c + src/scene-transitions.cpp + src/screen-region-switch.cpp + src/priority.cpp + src/executable-switch.cpp + src/idle-switch.cpp + src/scene-round-trip.cpp + src/file-switch.cpp + src/window-title-switch.cpp + src/hotkey.cpp + src/general.cpp + src/pause-switch.cpp + src/random.cpp + ) + +set(advanced-scene-switcher_UI + ${advanced-scene-switcher_UI} + forms/advanced-scene-switcher.ui + ) + +if(WIN32) + set(advanced-scene-switcher_PLATFORM_SOURCES + src/win/advanced-scene-switcher-win.cpp) + +elseif(APPLE) + set(advanced-scene-switcher_PLATFORM_SOURCES + src/osx/advanced-scene-switcher-osx.mm) + set_source_files_properties(advanced-scene-switcher-osx.mm + PROPERTIES COMPILE_FLAGS "-fobjc-arc") + set(advanced-scene-switcher_PLATFORM_LIBS + ${COCOA}) + +elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") + set(advanced-scene-switcher_PLATFORM_SOURCES + src/linux/advanced-scene-switcher-nix.cpp) + set(advanced-scene-switcher_PLATFORM_LIBS + Xss) +endif() + +add_library(advanced-scene-switcher MODULE + ${advanced-scene-switcher_HEADERS} + ${advanced-scene-switcher_SOURCES} + ${advanced-scene-switcher_UI_HEADERS} + ${advanced-scene-switcher_PLATFORM_SOURCES} + ${advanced-scene-switcher_PLATFORM_HEADERS} + ) + +include_directories( + "${LIBOBS_INCLUDE_DIRS}" + "${LIBOBS_FRONTEND_INCLUDE_DIR}" + ${Qt5Core_INCLUDES} + ${Qt5Widgets_INCLUDES}) + +target_link_libraries(advanced-scene-switcher + ${advanced-scene-switcher_PLATFORM_LIBS} + ${LIBOBS_LIB} + ${LIBOBS_FRONTEND_API_LIB} + Qt5::Core + Qt5::Widgets) + +# Additional commands to install the module in the correct place. +# Find all the translation files so we can copy them to the correct +# place later on. +file(GLOB ASS_TRANSLATION_FILES + "data/locale/*.ini" + ) + +# Windows +if(WIN32) + string(REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") + message("${CMAKE_CXX_FLAGS_RELEASE}") + + find_package(w32-pthreads REQUIRED) + + target_link_libraries(advanced-scene-switcher + w32-pthreads) +endif() + +# OSX +if(APPLE) + set_target_properties(advanced-scene-switcher PROPERTIES PREFIX "") + +endif() + +# Linux +if(UNIX AND NOT APPLE) + set(CMAKE_C_FLAGS "-Wall -Wextra -Wvla -Wno-unused-function -Werror-implicit-function-declaration -Wno-missing-braces -Wno-missing-field-initializers ${CMAKE_C_FLAGS} -std=c99 -fno-strict-aliasing") + + if(ARCH EQUAL 64) + set(ARCH_NAME "x86_64") + else() + set(ARCH_NAME "i686") + endif() + + set_target_properties(advanced-scene-switcher PROPERTIES PREFIX "") + + install(TARGETS advanced-scene-switcher + LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/obs-plugins) + install(FILES ${ASS_TRANSLATION_FILES} + DESTINATION "${CMAKE_INSTALL_PREFIX}/share/obs/obs-plugins/advanced-scene-switcher/locale") +endif() diff --git a/README.md b/README.md index 82d08c18..a7f55385 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,94 @@ An automated scene switcher for OBS Studio More information can be found on https://obsproject.com/forum/resources/automatic-scene-switching.395/ -To build it yourself follow these steps (changes / suggestions welcome): -1. Download the OBS Studio sources. -2. Move the sources of this plugin to the the frontend-plugins folder in the OBS sources ("obs-studio/UI/frontend-plugins/SceneSwitcher" for example). -3. Edit the CMakeLists.txt in the frontend-plugins folder to include the SceneSwitcher sources directory by appending the line "add_subdirectory(SceneSwitcher)". -4. Build OBS Studio and the plugin library will be located in the respective subdirectory of the rundir inside your build folder. (for example ~/obs-studio/build/rundir/RelWithDebInfo/obs-plugins/64bit/advanced-scene-switcher.so) +## Compiling +### Prerequisites +You'll need CMake and a working development environment for OBS Studio installed +on your computer. Once you've done that, do the following: +``` +git clone https://github.com/WarmUpTill/SceneSwitcher.git +cd SceneSwitcher +mkdir build && cd build +``` +### Windows +In cmake-gui, you'll have to set these CMake variables : +- **LIBOBS_INCLUDE_DIR** (path) : location of the libobs subfolder in the source +code of OBS Studio, located at [source_directory]/libobs/. +- **LIBOBS_LIB** (filepath) : location of the obs.dll file (usually set to +C:\Program Files\obs-studio\bin\64bit\obs.dll) -NOTE: The linux version of this plugin is dependent on libXScrnSaver. +Assuming that you installed Qt via the regular Qt App way: +- **Qt5Core_DIR** (path) : C:/Qt/5.10.1/msvc2017_64/lib/cmake/Qt5Core +- **Qt5Gui_DIR** (path): C:/Qt/5.10.1/msvc2017_64/lib/cmake/Qt5Gui +- **Qt5Widgets_DIR** (path) : C:/Qt/5.10.1/msvc2017_64/lib/cmake/Qt5Widgets + +- **LIBOBS_FRONTEND_API_LIB** (filepath) : location of the libobs-frontend-api.dll +file, usually C:/Program Files/obs-studio/bin/64bit/obs-frontend-api.dll +(usually in the same place as LIBOBS_LIB) +- **LIBOBS_FRONTEND_INCLUDE_DIR** (path) : location of the obs-frontend-api +subfolder in the source code of OBS Studio, located at [source_directory]/UI/obs-frontend-api. + +Just keep hitting configure until all the vars are filled out. Then hit generate. + +### Linux +Most versions of Linux you can use cmake-gui or the command line. + +**For the command line:** +``` +cmake -DLIBOBS_INCLUDE_DIR="" +-DLIBOBS_FRONTEND_INCLUDE_DIR="" +-DLIBOBS_FRONTEND_API_LIB="< path to the libobs-frontend-api.so file (usually in the same place as LIBOBS_LIB)>" +-DCMAKE_INSTALL_PREFIX=/usr .. +make -j4 +sudo make install +``` + +For cmake-gui you'll have to set the following variables: +- **LIBOBS_INCLUDE_DIR** (path) : location of the libobs subfolder in the source +code of OBS Studio, located at [source_directory]/libobs/. +- **LIBOBS_LIB** (filepath) : location of the libobs.so file (usually CMake finds +this, but if not it'll usually be in /usr/lib/libobs.so) + +Assuming that you installed Qt via your system package manager, it should be +found automatically. If not, then usually you'll find it in something like: +- **Qt5Core_DIR** (path) : /usr/lib64/cmake/Qt5Core +- **Qt5Gui_DIR** (path): /usr/lib64/cmake/Qt5Gui +- **Qt5Widgets_DIR** (path) : /usr/lib64/cmake/Qt5Widgets + +- **LIBOBS_FRONTEND_API_LIB** (filepath) : location of the libobs-frontend-api.so +file (usually in the same place as LIBOBS_LIB) +- **LIBOBS_FRONTEND_INCLUDE_DIR** (path) : location of the obs-frontend-api +subfolder in the source code of OBS Studio, located at +[source_directory]/UI/obs-frontend-api. + +Just keep hitting configure until all the vars are filled out. Then hit generate. + +Then open a terminal in the build folder and type: +``` +make -j4 +sudo make install +``` +NOTE: The Linux version of this plugin is dependent on libXScrnSaver. + +### OS X +In cmake-gui, you'll have to set these CMake variables : +- **LIBOBS_INCLUDE_DIR** (path) : location of the libobs subfolder in the source +code of OBS Studio, located at [source_directory]/libobs/. +- **LIBOBS_LIB** (filepath) : location of the libobs.0.dylib file (usually +in /Applications/OBS.app/Contents/Resources/bin/libobs.0.dylib) + +Assuming that you installed Qt via the regular Qt App way: +- **Qt5Core_DIR** (path) : Usually /Applications/Qt/5.10.1/clang_64/lib/cmake/Qt5Core +- **Qt5Widgets_DIR** (path) : Usually /Applications/Qt/5.10.1/clang_64/lib/cmake/Qt5Widgets +- **Qt5MacExtras_DIR** (path) : Usually /Applications/Qt/5.10.1/clang_64/lib/cmake/Qt5MacExtras + +- **LIBOBS_FRONTEND_API_LIB** (filepath) : location of the libobs-frontend-api.0.dylib +file (usually in usually in /Applications/OBS.app/Contents/Resources/bin/libobs-frontend-api.0.dylib) +- **LIBOBS_FRONTEND_INCLUDE_DIR** (path) : location of the obs-frontend-api subfolder +in the source code of OBS Studio, located at [source_directory]/UI/obs-frontend-api. + +Just keep hitting configure until all the vars are filled out. Then hit generate. + +Open xcode (or a terminal, depending on the build type you chose), build and copy +the advanced-scene-switcher.so file to /Applications/OBS.app/Contents/Resources/obs-plugins/ diff --git a/external/FindLibObs.cmake b/external/FindLibObs.cmake new file mode 100644 index 00000000..ab0a3dea --- /dev/null +++ b/external/FindLibObs.cmake @@ -0,0 +1,107 @@ +# This module can be copied and used by external plugins for OBS +# +# Once done these will be defined: +# +# LIBOBS_FOUND +# LIBOBS_INCLUDE_DIRS +# LIBOBS_LIBRARIES + +find_package(PkgConfig QUIET) +if (PKG_CONFIG_FOUND) + pkg_check_modules(_OBS QUIET obs libobs) +endif() + +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(_lib_suffix 64) +else() + set(_lib_suffix 32) +endif() + +if(DEFINED CMAKE_BUILD_TYPE) + if(CMAKE_BUILD_TYPE STREQUAL "Debug") + set(_build_type_base "debug") + else() + set(_build_type_base "release") + endif() +endif() + +find_path(LIBOBS_INCLUDE_DIR + NAMES obs.h + HINTS + ENV obsPath${_lib_suffix} + ENV obsPath + ${obsPath} + PATHS + /usr/include /usr/local/include /opt/local/include /sw/include + PATH_SUFFIXES + libobs + ) + +function(find_obs_lib base_name repo_build_path lib_name) + string(TOUPPER "${base_name}" base_name_u) + + if(DEFINED _build_type_base) + set(_build_type_${repo_build_path} "${_build_type_base}/${repo_build_path}") + set(_build_type_${repo_build_path}${_lib_suffix} "${_build_type_base}${_lib_suffix}/${repo_build_path}") + endif() + + find_library(${base_name_u}_LIB + NAMES ${_${base_name_u}_LIBRARIES} ${lib_name} lib${lib_name} + HINTS + ENV obsPath${_lib_suffix} + ENV obsPath + ${obsPath} + ${_${base_name_u}_LIBRARY_DIRS} + PATHS + /usr/lib /usr/local/lib /opt/local/lib /sw/lib + PATH_SUFFIXES + lib${_lib_suffix} lib + libs${_lib_suffix} libs + bin${_lib_suffix} bin + ../lib${_lib_suffix} ../lib + ../libs${_lib_suffix} ../libs + ../bin${_lib_suffix} ../bin + # base repo non-msvc-specific search paths + ${_build_type_${repo_build_path}} + ${_build_type_${repo_build_path}${_lib_suffix}} + build/${repo_build_path} + build${_lib_suffix}/${repo_build_path} + # base repo msvc-specific search paths on windows + build${_lib_suffix}/${repo_build_path}/Debug + build${_lib_suffix}/${repo_build_path}/RelWithDebInfo + build/${repo_build_path}/Debug + build/${repo_build_path}/RelWithDebInfo + ) +endfunction() + +find_obs_lib(LIBOBS libobs obs) + +if(MSVC) + find_obs_lib(W32_PTHREADS deps/w32-pthreads w32-pthreads) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Libobs DEFAULT_MSG LIBOBS_LIB LIBOBS_INCLUDE_DIR) +mark_as_advanced(LIBOBS_INCLUDE_DIR LIBOBS_LIB) + +if(LIBOBS_FOUND) + if(MSVC) + if (NOT DEFINED W32_PTHREADS_LIB) + message(FATAL_ERROR "Could not find the w32-pthreads library" ) + endif() + + set(W32_PTHREADS_INCLUDE_DIR ${LIBOBS_INCLUDE_DIR}/../deps/w32-pthreads) + endif() + + set(LIBOBS_INCLUDE_DIRS ${LIBOBS_INCLUDE_DIR} ${W32_PTHREADS_INCLUDE_DIR}) + set(LIBOBS_LIBRARIES ${LIBOBS_LIB} ${W32_PTHREADS_LIB}) + include(${LIBOBS_INCLUDE_DIR}/../cmake/external/ObsPluginHelpers.cmake) + + # allows external plugins to easily use/share common dependencies that are often included with libobs (such as FFmpeg) + if(NOT DEFINED INCLUDED_LIBOBS_CMAKE_MODULES) + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${LIBOBS_INCLUDE_DIR}/../cmake/Modules/") + set(INCLUDED_LIBOBS_CMAKE_MODULES true) + endif() +else() + message(FATAL_ERROR "Could not find the libobs library" ) +endif() diff --git a/external/ObsPluginHelpers.cmake b/external/ObsPluginHelpers.cmake new file mode 100644 index 00000000..b0651dc3 --- /dev/null +++ b/external/ObsPluginHelpers.cmake @@ -0,0 +1,163 @@ +# Functions for generating external plugins + +set(EXTERNAL_PLUGIN_OUTPUT_DIR "${CMAKE_BINARY_DIR}/rundir") + +# Fix XCode includes to ignore warnings on system includes +function(target_include_directories_system _target) + if(XCODE) + foreach(_arg ${ARGN}) + if("${_arg}" STREQUAL "PRIVATE" OR "${_arg}" STREQUAL "PUBLIC" OR "${_arg}" STREQUAL "INTERFACE") + set(_scope ${_arg}) + else() + target_compile_options(${_target} ${_scope} -isystem${_arg}) + endif() + endforeach() + else() + target_include_directories(${_target} SYSTEM ${_scope} ${ARGN}) + endif() +endfunction() + +function(install_external_plugin_data_internal target source_dir target_dir) + install(DIRECTORY ${source_dir}/ + DESTINATION "${target}/${target_dir}" + USE_SOURCE_PERMISSIONS) + add_custom_command(TARGET ${target} POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E copy_directory + "${CMAKE_CURRENT_SOURCE_DIR}/${source_dir}" "${EXTERNAL_PLUGIN_OUTPUT_DIR}/$/${target}/${target_dir}" + VERBATIM) +endfunction() + +# Installs data +# 'target' is the destination target project being installed to +# 'data_loc' specifies the directory of the data +function(install_external_plugin_data target data_loc) + install_external_plugin_data_internal(${target} ${data_loc} "data") +endfunction() + +# Installs data in an architecture-specific data directory on windows/linux (data/32bit or data/64bit). Does not apply for mac. +# 'target' is the destination target project being installed to +# 'data_loc' specifies the directory of the data being installed +function(install_external_plugin_arch_data target data_loc) + if(APPLE) + set(_bit_suffix "") + elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(_bit_suffix "/64bit") + else() + set(_bit_suffix "/32bit") + endif() + + install_external_plugin_data_internal(${target} ${data_loc} "data${_bit_suffix}") +endfunction() + +# Installs data in the target's bin directory +# 'target' is the destination target project being installed to +# 'data_loc' specifies the directory of the data being installed +function(install_external_plugin_data_to_bin target data_loc) + if(APPLE) + set(_bit_suffix "") + elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(_bit_suffix "/64bit") + else() + set(_bit_suffix "/32bit") + endif() + + install_external_plugin_data_internal(${target} ${data_loc} "bin${_bit_suffix}") +endfunction() + +# Installs an additional binary to a target +# 'target' is the destination target project being installed to +# 'additional_target' specifies the additional binary +function(install_external_plugin_additional target additional_target) + 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(${additional_target} PROPERTIES + PREFIX "") + + install(TARGETS ${additional_target} + LIBRARY DESTINATION "bin" + RUNTIME DESTINATION "bin") + add_custom_command(TARGET ${additional_target} POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E copy + "$" + "${EXTERNAL_PLUGIN_OUTPUT_DIR}/$/${target}/bin/${_bit_suffix}$" + VERBATIM) +endfunction() + +# Installs the binary of the target +# 'target' is the target project being installed +function(install_external_plugin target) + install_external_plugin_additional(${target} ${target}) +endfunction() + +# Installs the binary and data of the target +# 'target' is the destination target project being installed to +function(install_external_plugin_with_data target data_loc) + install_external_plugin(${target}) + install_external_plugin_data(${target} ${data_loc}) +endfunction() + +# Installs an additional binary to the data of a target +# 'target' is the destination target project being installed to +# 'additional_target' specifies the additional binary +function(install_external_plugin_bin_to_data target additional_target) + install(TARGETS ${additional_target} + LIBRARY DESTINATION "data" + RUNTIME DESTINATION "data") + add_custom_command(TARGET ${additional_target} POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E copy + "$" + "${EXTERNAL_PLUGIN_OUTPUT_DIR}/$/${target}/data/$" + VERBATIM) +endfunction() + +# Installs an additional binary in an architecture-specific data directory on windows/linux (data/32bit or data/64bit). Does not apply for mac. +# 'target' is the destination target project being installed to +# 'additional_target' specifies the additional binary +function(install_external_plugin_bin_to_arch_data target additional_target) + if(APPLE) + set(_bit_suffix "") + elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(_bit_suffix "/64bit") + else() + set(_bit_suffix "/32bit") + endif() + + install(TARGETS ${additional_target} + LIBRARY DESTINATION "data${_bit_suffix}" + RUNTIME DESTINATION "data${_bit_suffix}") + add_custom_command(TARGET ${additional_target} POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E copy + "$" + "${EXTERNAL_PLUGIN_OUTPUT_DIR}/$/${target}/data${_bit_suffix}/$" + VERBATIM) +endfunction() + +# Installs an additional file in an architecture-specific data directory on windows/linux (data/32bit or data/64bit). Does not apply for mac. +# 'target' is the destination target project being installed to +# 'additional_target' specifies the additional binary +function(install_external_plugin_data_file_to_arch_data target additional_target file_target) + if(APPLE) + set(_bit_suffix "") + elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(_bit_suffix "/64bit") + else() + set(_bit_suffix "/32bit") + endif() + + get_filename_component(file_target_name ${file_target} NAME) + + install(TARGETS ${additional_target} + LIBRARY DESTINATION "data${_bit_suffix}" + RUNTIME DESTINATION "data${_bit_suffix}") + add_custom_command(TARGET ${additional_target} POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E copy + "${file_target}" + "${EXTERNAL_PLUGIN_OUTPUT_DIR}/$/${target}/data${_bit_suffix}/${file_target_name}" + VERBATIM) +endfunction() diff --git a/advanced-scene-switcher-module.c b/src/advanced-scene-switcher-module.c similarity index 100% rename from advanced-scene-switcher-module.c rename to src/advanced-scene-switcher-module.c diff --git a/advanced-scene-switcher.cpp b/src/advanced-scene-switcher.cpp similarity index 99% rename from advanced-scene-switcher.cpp rename to src/advanced-scene-switcher.cpp index 8bc520e2..5bb7c5c8 100644 --- a/advanced-scene-switcher.cpp +++ b/src/advanced-scene-switcher.cpp @@ -20,9 +20,9 @@ #include #include -#include "switcher-data-structs.hpp" -#include "utility.hpp" -#include "advanced-scene-switcher.hpp" +#include "headers/switcher-data-structs.hpp" +#include "headers/utility.hpp" +#include "headers/advanced-scene-switcher.hpp" SwitcherData* switcher = nullptr; diff --git a/executable-switch.cpp b/src/executable-switch.cpp similarity index 98% rename from executable-switch.cpp rename to src/executable-switch.cpp index efe5f292..009a41d4 100644 --- a/executable-switch.cpp +++ b/src/executable-switch.cpp @@ -1,4 +1,4 @@ -#include "advanced-scene-switcher.hpp" +#include "headers/advanced-scene-switcher.hpp" int SceneSwitcher::executableFindByData(const QString& exe) { diff --git a/file-switch.cpp b/src/file-switch.cpp similarity index 99% rename from file-switch.cpp rename to src/file-switch.cpp index a315d380..909452ca 100644 --- a/file-switch.cpp +++ b/src/file-switch.cpp @@ -2,7 +2,7 @@ #include #include #include -#include "advanced-scene-switcher.hpp" +#include "headers/advanced-scene-switcher.hpp" diff --git a/general.cpp b/src/general.cpp similarity index 97% rename from general.cpp rename to src/general.cpp index 73aa2f17..3fe65e72 100644 --- a/general.cpp +++ b/src/general.cpp @@ -1,4 +1,4 @@ -#include "advanced-scene-switcher.hpp" +#include "headers/advanced-scene-switcher.hpp" #include void SceneSwitcher::on_close_clicked() diff --git a/advanced-scene-switcher.hpp b/src/headers/advanced-scene-switcher.hpp similarity index 99% rename from advanced-scene-switcher.hpp rename to src/headers/advanced-scene-switcher.hpp index 185fd38d..4a9dd760 100644 --- a/advanced-scene-switcher.hpp +++ b/src/headers/advanced-scene-switcher.hpp @@ -4,7 +4,7 @@ #include #include #include -#include "ui_advanced-scene-switcher.h" +#include "../../forms/ui_advanced-scene-switcher.h" #include "switcher-data-structs.hpp" class QCloseEvent; diff --git a/switcher-data-structs.hpp b/src/headers/switcher-data-structs.hpp similarity index 100% rename from switcher-data-structs.hpp rename to src/headers/switcher-data-structs.hpp diff --git a/utility.hpp b/src/headers/utility.hpp similarity index 100% rename from utility.hpp rename to src/headers/utility.hpp diff --git a/hotkey.cpp b/src/hotkey.cpp similarity index 97% rename from hotkey.cpp rename to src/hotkey.cpp index dd998c26..03c47e36 100644 --- a/hotkey.cpp +++ b/src/hotkey.cpp @@ -1,5 +1,5 @@ #include -#include "advanced-scene-switcher.hpp" +#include "headers/advanced-scene-switcher.hpp" void startStopHotkeyFunc(void* data, obs_hotkey_id id, obs_hotkey_t* hotkey, bool pressed) { diff --git a/idle-switch.cpp b/src/idle-switch.cpp similarity index 98% rename from idle-switch.cpp rename to src/idle-switch.cpp index 99a12918..371d2a23 100644 --- a/idle-switch.cpp +++ b/src/idle-switch.cpp @@ -1,4 +1,4 @@ -#include "advanced-scene-switcher.hpp" +#include "headers/advanced-scene-switcher.hpp" void SwitcherData::checkIdleSwitch(bool& match, OBSWeakSource& scene, OBSWeakSource& transition) { diff --git a/advanced-scene-switcher-nix.cpp b/src/linux/advanced-scene-switcher-nix.cpp similarity index 93% rename from advanced-scene-switcher-nix.cpp rename to src/linux/advanced-scene-switcher-nix.cpp index d6e653d2..66961225 100644 --- a/advanced-scene-switcher-nix.cpp +++ b/src/linux/advanced-scene-switcher-nix.cpp @@ -14,7 +14,7 @@ #undef Status #undef Unsorted #include -#include "advanced-scene-switcher.hpp" +#include "../headers/advanced-scene-switcher.hpp" using namespace std; diff --git a/advanced-scene-switcher-osx.mm b/src/osx/advanced-scene-switcher-osx.mm similarity index 98% rename from advanced-scene-switcher-osx.mm rename to src/osx/advanced-scene-switcher-osx.mm index 4a14ce33..31a13010 100644 --- a/advanced-scene-switcher-osx.mm +++ b/src/osx/advanced-scene-switcher-osx.mm @@ -4,7 +4,7 @@ #import #include #include -#include "advanced-scene-switcher.hpp" +#include "../headers/advanced-scene-switcher.hpp" void GetWindowList(vector &windows) diff --git a/pause-switch.cpp b/src/pause-switch.cpp similarity index 99% rename from pause-switch.cpp rename to src/pause-switch.cpp index 719a15e9..f6b30c53 100644 --- a/pause-switch.cpp +++ b/src/pause-switch.cpp @@ -1,4 +1,4 @@ -#include "advanced-scene-switcher.hpp" +#include "headers/advanced-scene-switcher.hpp" void SceneSwitcher::on_pauseScenesAdd_clicked() { diff --git a/priority.cpp b/src/priority.cpp similarity index 96% rename from priority.cpp rename to src/priority.cpp index 791b3e06..a6734edb 100644 --- a/priority.cpp +++ b/src/priority.cpp @@ -1,5 +1,5 @@ #include -#include "advanced-scene-switcher.hpp" +#include "headers/advanced-scene-switcher.hpp" void SceneSwitcher::on_priorityUp_clicked() { diff --git a/random.cpp b/src/random.cpp similarity index 98% rename from random.cpp rename to src/random.cpp index d940ba6c..6da40df5 100644 --- a/random.cpp +++ b/src/random.cpp @@ -1,4 +1,4 @@ -#include "advanced-scene-switcher.hpp" +#include "headers/advanced-scene-switcher.hpp" void SceneSwitcher::on_randomScenesList_currentRowChanged(int idx) { diff --git a/scene-round-trip.cpp b/src/scene-round-trip.cpp similarity index 99% rename from scene-round-trip.cpp rename to src/scene-round-trip.cpp index 95c6ca05..aaae6f26 100644 --- a/scene-round-trip.cpp +++ b/src/scene-round-trip.cpp @@ -2,7 +2,7 @@ #include #include -#include "advanced-scene-switcher.hpp" +#include "headers/advanced-scene-switcher.hpp" void SceneSwitcher::on_sceneRoundTripAdd_clicked() { diff --git a/scene-transitions.cpp b/src/scene-transitions.cpp similarity index 99% rename from scene-transitions.cpp rename to src/scene-transitions.cpp index b9dd4016..578e473e 100644 --- a/scene-transitions.cpp +++ b/src/scene-transitions.cpp @@ -1,4 +1,4 @@ -#include "advanced-scene-switcher.hpp" +#include "headers/advanced-scene-switcher.hpp" void SceneSwitcher::on_transitionsAdd_clicked() { diff --git a/screen-region-switch.cpp b/src/screen-region-switch.cpp similarity index 98% rename from screen-region-switch.cpp rename to src/screen-region-switch.cpp index 45d17765..bd42ab85 100644 --- a/screen-region-switch.cpp +++ b/src/screen-region-switch.cpp @@ -1,4 +1,4 @@ -#include "advanced-scene-switcher.hpp" +#include "headers/advanced-scene-switcher.hpp" void SwitcherData::checkScreenRegionSwitch(bool& match, OBSWeakSource& scene, OBSWeakSource& transition) { diff --git a/advanced-scene-switcher-win.cpp b/src/win/advanced-scene-switcher-win.cpp similarity index 98% rename from advanced-scene-switcher-win.cpp rename to src/win/advanced-scene-switcher-win.cpp index 576b54ee..d20bb9e5 100644 --- a/advanced-scene-switcher-win.cpp +++ b/src/win/advanced-scene-switcher-win.cpp @@ -1,6 +1,6 @@ #include #include -#include "advanced-scene-switcher.hpp" +#include "../headers/advanced-scene-switcher.hpp" #include #include diff --git a/window-title-switch.cpp b/src/window-title-switch.cpp similarity index 99% rename from window-title-switch.cpp rename to src/window-title-switch.cpp index 9dd37746..ce24f448 100644 --- a/window-title-switch.cpp +++ b/src/window-title-switch.cpp @@ -1,5 +1,5 @@ #include -#include "advanced-scene-switcher.hpp" +#include "headers/advanced-scene-switcher.hpp" void SceneSwitcher::on_add_clicked() {