Prechádzať zdrojové kódy

cmake: Update main CMake script to make UI functionality optional

There have been concerns that making the template link Qt and the
frontend-api by default may lead to plugins that do not actually require
this functionality but would still be encumbered by it.

This change comments out the corresponding lines, allowing plugin
authors to add them back by uncommenting.

Also removes clutter that is handled by the updated plugin helper now.
PatTheMav 2 rokov pred
rodič
commit
b1b727af2b
1 zmenil súbory, kde vykonal 19 pridanie a 22 odobranie
  1. 19 22
      CMakeLists.txt

+ 19 - 22
CMakeLists.txt

@@ -20,31 +20,34 @@ set(LINUX_MAINTAINER_EMAIL "me@mymailhost.com")
 # e.g. in Xcode or Visual Studio
 target_sources(${CMAKE_PROJECT_NAME} PRIVATE src/plugin-main.c)
 
-# /!\ TAKE NOTE: No need to edit things past this point /!\
-
+# Import libobs as main plugin dependency
 find_package(libobs REQUIRED)
-find_package(obs-frontend-api REQUIRED)
 include(cmake/ObsPluginHelpers.cmake)
+
+# Uncomment these lines if you want to use the OBS Frontend API in your plugin
+#[[
+find_package(obs-frontend-api REQUIRED)
+target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE OBS::obs-frontend-api)
+#]]
+
+# Uncomment those lines if you want to use Qt in your plugin
+#[[
 find_qt(COMPONENTS Widgets Core)
+target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE Qt::Core Qt::Widgets)
+set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES AUTOMOC ON AUTOUIC ON AUTORCC ON)
+#]]
 
 configure_file(src/plugin-macros.h.in ${CMAKE_SOURCE_DIR}/src/plugin-macros.generated.h)
 
 target_sources(${CMAKE_PROJECT_NAME} PRIVATE src/plugin-macros.generated.h)
 
+# /!\ TAKE NOTE: No need to edit things past this point /!\
+
 # --- Platform-independent build settings ---
 
 target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src)
 
-target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE OBS::libobs OBS::obs-frontend-api Qt::Core
-                                                    Qt::Widgets)
-
-set_target_properties(
-  ${CMAKE_PROJECT_NAME}
-  PROPERTIES AUTOMOC ON
-             AUTOUIC ON
-             AUTORCC ON)
-
-target_compile_features(${CMAKE_PROJECT_NAME} PRIVATE cxx_std_17)
+target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE OBS::libobs)
 
 # --- End of section ---
 
@@ -54,7 +57,7 @@ if(OS_WINDOWS)
                  ${CMAKE_BINARY_DIR}/installer-Windows.generated.iss)
 
   if(MSVC)
-    target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE /MP /d2FH4-)
+    target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE /W4)
   endif()
   # --- End of section ---
 
@@ -67,18 +70,12 @@ elseif(OS_MACOS)
   set(MACOSX_PLUGIN_BUNDLE_VERSION "${CMAKE_PROJECT_VERSION}")
   set(MACOSX_PLUGIN_SHORT_VERSION_STRING "1")
 
-  target_compile_options(
-    ${CMAKE_PROJECT_NAME} PRIVATE -Wall -Wextra -Werror-implicit-function-declaration
-                                  -stdlib=libc++ -fvisibility=default)
-
-  set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES PREFIX "")
+  target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -Wall)
   # --- End of section ---
 
   # --- Linux-specific build settings and tasks ---
 else()
-  target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -Wall -Wextra)
-
-  set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES PREFIX "")
+  target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -Wall)
 endif()
 # --- End of section ---