CMakeLists.txt 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 'https://www.example.com` with a link to the website of your plugin or repository
  10. set(PLUGIN_WEBSITE "https://www.example.com")
  11. # Replace `com.example.obs-plugin-template` with a unique Bundle ID for macOS releases (used both in
  12. # the installer and when submitting the installer for notarization)
  13. set(MACOS_BUNDLEID "com.example.${CMAKE_PROJECT_NAME}")
  14. # Replace `me@contoso.com` with the maintainer email address you want to put in Linux packages
  15. set(LINUX_MAINTAINER_EMAIL "me@mymailhost.com")
  16. # Add your custom source files here - header files are optional and only required for visibility
  17. # e.g. in Xcode or Visual Studio
  18. target_sources(${CMAKE_PROJECT_NAME} PRIVATE src/plugin-main.c)
  19. # Import libobs as main plugin dependency
  20. find_package(libobs REQUIRED)
  21. include(cmake/ObsPluginHelpers.cmake)
  22. # Uncomment these lines if you want to use the OBS Frontend API in your plugin
  23. #[[
  24. find_package(obs-frontend-api REQUIRED)
  25. target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE OBS::obs-frontend-api)
  26. #]]
  27. # Uncomment those lines if you want to use Qt in your plugin
  28. #[[
  29. find_qt(COMPONENTS Widgets Core)
  30. target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE Qt::Core Qt::Widgets)
  31. set_target_properties(
  32. ${CMAKE_PROJECT_NAME}
  33. PROPERTIES AUTOMOC ON
  34. AUTOUIC ON
  35. AUTORCC ON)
  36. #]]
  37. configure_file(src/plugin-macros.h.in ${CMAKE_SOURCE_DIR}/src/plugin-macros.generated.h)
  38. target_sources(${CMAKE_PROJECT_NAME} PRIVATE src/plugin-macros.generated.h)
  39. # /!\ TAKE NOTE: No need to edit things past this point /!\
  40. # --- Platform-independent build settings ---
  41. target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src)
  42. target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE OBS::libobs)
  43. # --- End of section ---
  44. # --- Windows-specific build settings and tasks ---
  45. if(OS_WINDOWS)
  46. configure_file(cmake/bundle/windows/installer-Windows.iss.in
  47. ${CMAKE_BINARY_DIR}/installer-Windows.generated.iss)
  48. configure_file(cmake/bundle/windows/resource.rc.in ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}.rc)
  49. target_sources(${CMAKE_PROJECT_NAME} PRIVATE ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}.rc)
  50. if(MSVC)
  51. target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE /W4)
  52. endif()
  53. # --- End of section ---
  54. # -- macOS specific build settings and tasks --
  55. elseif(OS_MACOS)
  56. configure_file(cmake/bundle/macos/installer-macos.pkgproj.in
  57. ${CMAKE_BINARY_DIR}/installer-macos.generated.pkgproj)
  58. set(MACOSX_PLUGIN_GUI_IDENTIFIER "${MACOS_BUNDLEID}")
  59. set(MACOSX_PLUGIN_BUNDLE_VERSION "${CMAKE_PROJECT_VERSION}")
  60. set(MACOSX_PLUGIN_SHORT_VERSION_STRING "1")
  61. target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -Wall)
  62. # --- End of section ---
  63. # --- Linux-specific build settings and tasks ---
  64. else()
  65. target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -Wall)
  66. endif()
  67. # --- End of section ---
  68. setup_plugin_target(${CMAKE_PROJECT_NAME})