瀏覽代碼

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
jp9000 7 年之前
父節點
當前提交
8b936a1575
共有 4 個文件被更改,包括 20 次插入9 次删除
  1. 1 1
      CMakeLists.txt
  2. 7 1
      UI/CMakeLists.txt
  3. 8 7
      UI/window-basic-main.cpp
  4. 4 0
      plugins/CMakeLists.txt

+ 1 - 1
CMakeLists.txt

@@ -142,8 +142,8 @@ if(NOT INSTALLER_RUN)
 
 
 	add_subdirectory(libobs-opengl)
 	add_subdirectory(libobs-opengl)
 	add_subdirectory(libobs)
 	add_subdirectory(libobs)
-	add_subdirectory(UI)
 	add_subdirectory(plugins)
 	add_subdirectory(plugins)
+	add_subdirectory(UI)
 	if (BUILD_TESTS)
 	if (BUILD_TESTS)
 		add_subdirectory(test)
 		add_subdirectory(test)
 	endif()
 	endif()

+ 7 - 1
UI/CMakeLists.txt

@@ -7,6 +7,10 @@ else()
 	set(FIND_MODE QUIET)
 	set(FIND_MODE QUIET)
 endif()
 endif()
 
 
+if(BROWSER_AVAILABLE_INTERNAL)
+	add_definitions(-DBROWSER_AVAILABLE)
+endif()
+
 add_subdirectory(obs-frontend-api)
 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}/libobs")
 include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/deps/libff")
 include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/deps/libff")
 include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/deps/json11")
 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)
 find_package(Libcurl REQUIRED)
 include_directories(${LIBCURL_INCLUDE_DIRS})
 include_directories(${LIBCURL_INCLUDE_DIRS})

+ 8 - 7
UI/window-basic-main.cpp

@@ -70,16 +70,13 @@
 #include <QScreen>
 #include <QScreen>
 #include <QWindow>
 #include <QWindow>
 
 
-#ifdef _WIN32
-#include <browser-panel.hpp>
-#endif
-
 #include <json11.hpp>
 #include <json11.hpp>
 
 
 using namespace json11;
 using namespace json11;
 using namespace std;
 using namespace std;
 
 
-#ifdef _WIN32
+#if defined(_WIN32) && defined(BROWSER_AVAILABLE)
+#include <browser-panel.hpp>
 static CREATE_BROWSER_WIDGET_PROC create_browser_widget = nullptr;
 static CREATE_BROWSER_WIDGET_PROC create_browser_widget = nullptr;
 #endif
 #endif
 
 
@@ -1507,7 +1504,7 @@ void OBSBasic::OBSInit()
 	blog(LOG_INFO, "---------------------------------");
 	blog(LOG_INFO, "---------------------------------");
 	obs_post_load_modules();
 	obs_post_load_modules();
 
 
-#ifdef _WIN32
+#if defined(_WIN32) && defined(BROWSER_AVAILABLE)
 	create_browser_widget = obs_browser_init_panel();
 	create_browser_widget = obs_browser_init_panel();
 #endif
 #endif
 
 
@@ -1738,7 +1735,7 @@ void OBSBasic::OnFirstLoad()
 	if (api)
 	if (api)
 		api->on_event(OBS_FRONTEND_EVENT_FINISHED_LOADING);
 		api->on_event(OBS_FRONTEND_EVENT_FINISHED_LOADING);
 
 
-#ifdef _WIN32
+#if defined(_WIN32) && defined(BROWSER_AVAILABLE)
 	/* Attempt to load init screen if available */
 	/* Attempt to load init screen if available */
 	if (create_browser_widget) {
 	if (create_browser_widget) {
 		WhatsNewInfoThread *wnit = new WhatsNewInfoThread();
 		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 */
 /* shows a "what's new" page on startup of new versions using CEF */
 void OBSBasic::ReceivedIntroJson(const QString &text)
 void OBSBasic::ReceivedIntroJson(const QString &text)
 {
 {
+#ifdef BROWSER_AVAILABLE
 #ifdef _WIN32
 #ifdef _WIN32
 	std::string err;
 	std::string err;
 	Json json = Json::parse(QT_TO_UTF8(text), err);
 	Json json = Json::parse(QT_TO_UTF8(text), err);
@@ -1875,6 +1873,9 @@ void OBSBasic::ReceivedIntroJson(const QString &text)
 #else
 #else
 	UNUSED_PARAMETER(text);
 	UNUSED_PARAMETER(text);
 #endif
 #endif
+#else
+	UNUSED_PARAMETER(text);
+#endif
 }
 }
 
 
 void OBSBasic::UpdateMultiviewProjectorMenu()
 void OBSBasic::UpdateMultiviewProjectorMenu()

+ 4 - 0
plugins/CMakeLists.txt

@@ -53,9 +53,13 @@ if(WIN32 OR APPLE)
 	if (BUILD_BROWSER)
 	if (BUILD_BROWSER)
 		if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/obs-browser/CMakeLists.txt")
 		if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/obs-browser/CMakeLists.txt")
 			add_subdirectory(obs-browser)
 			add_subdirectory(obs-browser)
+			set(BROWSER_AVAILABLE_INTERNAL ON CACHE BOOL "Interal global cmake variable" FORCE)
 		else()
 		else()
 			message(STATUS "obs-browser submodule not found!  Please fetch submodules.  obs-browser plugin disabled.")
 			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()
 		endif()
+	else()
+		set(BROWSER_AVAILABLE_INTERNAL OFF CACHE BOOL "Interal global cmake variable" FORCE)
 	endif()
 	endif()
 
 
 	if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/obs-vst/CMakeLists.txt")
 	if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/obs-vst/CMakeLists.txt")