Explorar el Código

Add cmake option to disable user interface

Adds:
ENABLE_UI (on by default) which makes it so that the UI is required, and
will fail if a dependency is not found.  This is on by default because
most people are building it with the user interface, and we'll probably
get a lot of issue reports stating "why is there no executable?" if we
don't have this on by default.

DISABLE_UI which forces the UI off.

If neither are set, then the UI will only be built if the dependencies
for it are found, otherwise the UI will be be ignored.
jp9000 hace 11 años
padre
commit
b4052f81ef
Se han modificado 1 ficheros con 26 adiciones y 7 borrados
  1. 26 7
      obs/CMakeLists.txt

+ 26 - 7
obs/CMakeLists.txt

@@ -1,11 +1,13 @@
 project(obs)
 
-include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/libobs")
-
-if(CMAKE_SIZEOF_VOID_P EQUAL 8)
-	set(_lib_suffix 64)
+option(ENABLE_UI "Enables the OBS user interfaces" ON)
+if(DISABLE_UI)
+	message(STATUS "UI disabled")
+	return()
+elseif(ENABLE_UI)
+	set(FIND_MODE REQUIRED)
 else()
-	set(_lib_suffix 32)
+	set(FIND_MODE QUIET)
 endif()
 
 if(DEFINED ENV{QTDIR${_lib_suffix}})
@@ -17,8 +19,25 @@ endif()
 set(CMAKE_INCLUDE_CURRENT_DIR TRUE)
 set(CMAKE_AUTOMOC TRUE)
 
-find_package(Qt5Widgets REQUIRED)
-find_package(Qt5Network REQUIRED)
+if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+	set(_lib_suffix 64)
+else()
+	set(_lib_suffix 32)
+endif()
+
+find_package(Qt5Widgets ${FIND_MODE})
+find_package(Qt5Network ${FIND_MODE})
+
+if(NOT Qt5Widgets_FOUND OR NOT Qt5Network_FOUND)
+	if (ENABLE_UI)
+		message(FATAL_ERROR "Failed to find Qt5")
+	else()
+		message(STATUS "Qt5 not found - UI disabled")
+		return()
+	endif()
+endif()
+
+include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/libobs")
 
 if(WIN32)
 	set(obs_PLATFORM_SOURCES