CMakeLists.txt 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. cmake_minimum_required(VERSION 3.16...3.21)
  2. # Change obs-plugintemplate to your plugin's name in a machine-readable format (e.g.:
  3. # obs-myawesomeplugin) and set
  4. project(obs-plugintemplate VERSION 1.0.0)
  5. add_library(${CMAKE_PROJECT_NAME} MODULE)
  6. # Replace `Your Name Here` with the name (yours or your organization's) you want to see as the
  7. # author of the plugin (in the plugin's metadata itself and in the installers)
  8. set(PLUGIN_AUTHOR "Your Name Here")
  9. # Replace `com.example.obs-plugin-template` with a unique Bundle ID for macOS releases (used both in
  10. # the installer and when submitting the installer for notarization)
  11. set(MACOS_BUNDLEID "com.example.${CMAKE_PROJECT_NAME}")
  12. # Replace `me@contoso.com` with the maintainer email address you want to put in Linux packages
  13. set(LINUX_MAINTAINER_EMAIL "me@mymailhost.com")
  14. # Add your custom source files here - header files are optional and only required for visibility
  15. # e.g. in Xcode or Visual Studio
  16. target_sources(${CMAKE_PROJECT_NAME} PRIVATE src/plugin-main.c)
  17. # Import libobs as main plugin dependency
  18. find_package(libobs REQUIRED)
  19. include(cmake/ObsPluginHelpers.cmake)
  20. # Uncomment these lines if you want to use the OBS Frontend API in your plugin
  21. #[[
  22. find_package(obs-frontend-api REQUIRED)
  23. target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE OBS::obs-frontend-api)
  24. #]]
  25. # Uncomment those lines if you want to use Qt in your plugin
  26. #[[
  27. find_qt(COMPONENTS Widgets Core)
  28. target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE Qt::Core Qt::Widgets)
  29. set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES AUTOMOC ON AUTOUIC ON AUTORCC ON)
  30. #]]
  31. configure_file(src/plugin-macros.h.in ${CMAKE_SOURCE_DIR}/src/plugin-macros.generated.h)
  32. target_sources(${CMAKE_PROJECT_NAME} PRIVATE src/plugin-macros.generated.h)
  33. # /!\ TAKE NOTE: No need to edit things past this point /!\
  34. # --- Platform-independent build settings ---
  35. target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src)
  36. target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE OBS::libobs)
  37. # --- End of section ---
  38. # --- Windows-specific build settings and tasks ---
  39. if(OS_WINDOWS)
  40. configure_file(cmake/bundle/windows/installer-Windows.iss.in
  41. ${CMAKE_BINARY_DIR}/installer-Windows.generated.iss)
  42. if(MSVC)
  43. target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE /W4)
  44. endif()
  45. # --- End of section ---
  46. # -- macOS specific build settings and tasks --
  47. elseif(OS_MACOS)
  48. configure_file(cmake/bundle/macos/installer-macos.pkgproj.in
  49. ${CMAKE_BINARY_DIR}/installer-macos.generated.pkgproj)
  50. set(MACOSX_PLUGIN_GUI_IDENTIFIER "${MACOS_BUNDLEID}")
  51. set(MACOSX_PLUGIN_BUNDLE_VERSION "${CMAKE_PROJECT_VERSION}")
  52. set(MACOSX_PLUGIN_SHORT_VERSION_STRING "1")
  53. target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -Wall)
  54. # --- End of section ---
  55. # --- Linux-specific build settings and tasks ---
  56. else()
  57. target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -Wall)
  58. endif()
  59. # --- End of section ---
  60. setup_plugin_target(${CMAKE_PROJECT_NAME})