From 8b936a1575bda91813f8746338319604195b99db Mon Sep 17 00:00:00 2001 From: jp9000 Date: Tue, 18 Sep 2018 08:54:30 -0700 Subject: [PATCH] cmake: Fix UI being dependent on browser plugin files The UI currently is dependent on browser source files being present, when in actuality the files may not have been fetched (i.e. not fetching submodules). This fixes that by using a macro to detect whether it's available or not. Closes obsproject/obs-studio#1490 --- CMakeLists.txt | 2 +- UI/CMakeLists.txt | 8 +++++++- UI/window-basic-main.cpp | 15 ++++++++------- plugins/CMakeLists.txt | 4 ++++ 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c136e00f5..d4119660c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -142,8 +142,8 @@ if(NOT INSTALLER_RUN) add_subdirectory(libobs-opengl) add_subdirectory(libobs) - add_subdirectory(UI) add_subdirectory(plugins) + add_subdirectory(UI) if (BUILD_TESTS) add_subdirectory(test) endif() diff --git a/UI/CMakeLists.txt b/UI/CMakeLists.txt index a11f2548a..8a7c8defd 100644 --- a/UI/CMakeLists.txt +++ b/UI/CMakeLists.txt @@ -7,6 +7,10 @@ else() set(FIND_MODE QUIET) endif() +if(BROWSER_AVAILABLE_INTERNAL) + add_definitions(-DBROWSER_AVAILABLE) +endif() + add_subdirectory(obs-frontend-api) # ---------------------------------------------------------------------------- @@ -56,7 +60,9 @@ include_directories(SYSTEM "obs-frontend-api") include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/libobs") include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/deps/libff") include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/deps/json11") -include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/plugins/obs-browser/panel") +if(BROWSER_AVAILABLE_INTERNAL) + include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/plugins/obs-browser/panel") +endif() find_package(Libcurl REQUIRED) include_directories(${LIBCURL_INCLUDE_DIRS}) diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index 2b1b7d13f..4f8c9773c 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -70,16 +70,13 @@ #include #include -#ifdef _WIN32 -#include -#endif - #include using namespace json11; using namespace std; -#ifdef _WIN32 +#if defined(_WIN32) && defined(BROWSER_AVAILABLE) +#include static CREATE_BROWSER_WIDGET_PROC create_browser_widget = nullptr; #endif @@ -1507,7 +1504,7 @@ void OBSBasic::OBSInit() blog(LOG_INFO, "---------------------------------"); obs_post_load_modules(); -#ifdef _WIN32 +#if defined(_WIN32) && defined(BROWSER_AVAILABLE) create_browser_widget = obs_browser_init_panel(); #endif @@ -1738,7 +1735,7 @@ void OBSBasic::OnFirstLoad() if (api) api->on_event(OBS_FRONTEND_EVENT_FINISHED_LOADING); -#ifdef _WIN32 +#if defined(_WIN32) && defined(BROWSER_AVAILABLE) /* Attempt to load init screen if available */ if (create_browser_widget) { WhatsNewInfoThread *wnit = new WhatsNewInfoThread(); @@ -1776,6 +1773,7 @@ void OBSBasic::DeferredLoad(const QString &file, int requeueCount) /* shows a "what's new" page on startup of new versions using CEF */ void OBSBasic::ReceivedIntroJson(const QString &text) { +#ifdef BROWSER_AVAILABLE #ifdef _WIN32 std::string err; Json json = Json::parse(QT_TO_UTF8(text), err); @@ -1875,6 +1873,9 @@ void OBSBasic::ReceivedIntroJson(const QString &text) #else UNUSED_PARAMETER(text); #endif +#else + UNUSED_PARAMETER(text); +#endif } void OBSBasic::UpdateMultiviewProjectorMenu() diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index e6fa3e530..537ed219e 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -53,9 +53,13 @@ if(WIN32 OR APPLE) if (BUILD_BROWSER) if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/obs-browser/CMakeLists.txt") add_subdirectory(obs-browser) + set(BROWSER_AVAILABLE_INTERNAL ON CACHE BOOL "Interal global cmake variable" FORCE) else() message(STATUS "obs-browser submodule not found! Please fetch submodules. obs-browser plugin disabled.") + set(BROWSER_AVAILABLE_INTERNAL OFF CACHE BOOL "Interal global cmake variable" FORCE) endif() + else() + set(BROWSER_AVAILABLE_INTERNAL OFF CACHE BOOL "Interal global cmake variable" FORCE) endif() if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/obs-vst/CMakeLists.txt") -- GitLab