CMakeLists.txt 3.1 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
  3. # (e.g.: 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
  7. # to see as the author of the plugin (in the plugin's metadata itself and in the
  8. # installers)
  9. set(PLUGIN_AUTHOR "Your Name Here")
  10. # Replace `com.example.obs-plugin-template` with a unique Bundle ID for macOS
  11. # releases (used both in the installer and when submitting the installer for
  12. # 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
  15. # Linux packages
  16. set(LINUX_MAINTAINER_EMAIL "me@mymailhost.com")
  17. # Add your custom source files here - header files are optional and only
  18. # required for visibility e.g. in Xcode or Visual Studio
  19. target_sources(${CMAKE_PROJECT_NAME} PRIVATE src/plugin-main.c)
  20. # /!\ TAKE NOTE: No need to edit things past this point /!\
  21. find_package(libobs REQUIRED)
  22. find_package(obs-frontend-api REQUIRED)
  23. include(cmake/ObsPluginHelpers.cmake)
  24. find_qt(COMPONENTS Widgets Core)
  25. configure_file(src/plugin-macros.h.in
  26. ${CMAKE_SOURCE_DIR}/src/plugin-macros.generated.h)
  27. target_sources(${CMAKE_PROJECT_NAME} PRIVATE src/plugin-macros.generated.h)
  28. # --- Platform-independent build settings ---
  29. target_include_directories(${CMAKE_PROJECT_NAME}
  30. PRIVATE ${CMAKE_SOURCE_DIR}/src)
  31. target_link_libraries(
  32. ${CMAKE_PROJECT_NAME} PRIVATE OBS::libobs OBS::obs-frontend-api Qt::Core
  33. Qt::Widgets)
  34. set_target_properties(
  35. ${CMAKE_PROJECT_NAME}
  36. PROPERTIES AUTOMOC ON
  37. AUTOUIC ON
  38. AUTORCC ON)
  39. target_compile_features(${CMAKE_PROJECT_NAME} PRIVATE cxx_std_17)
  40. # --- End of section ---
  41. # --- Windows-specific build settings and tasks ---
  42. if(OS_WINDOWS)
  43. configure_file(cmake/bundle/windows/installer-Windows.iss.in
  44. ${CMAKE_BINARY_DIR}/installer-Windows.generated.iss)
  45. if(MSVC)
  46. target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE /MP /d2FH4-)
  47. endif()
  48. # --- End of section ---
  49. # -- macOS specific build settings and tasks --
  50. elseif(OS_MACOS)
  51. configure_file(cmake/bundle/macos/installer-macOS.pkgproj.in
  52. ${CMAKE_BINARY_DIR}/installer-macOS.generated.pkgproj)
  53. set(MACOSX_PLUGIN_GUI_IDENTIFIER "${MACOS_BUNDLEID}")
  54. set(MACOSX_PLUGIN_BUNDLE_VERSION "${CMAKE_PROJECT_VERSION}")
  55. set(MACOSX_PLUGIN_SHORT_VERSION_STRING "1")
  56. target_compile_options(
  57. ${CMAKE_PROJECT_NAME}
  58. PRIVATE -Wall -Wextra -Werror-implicit-function-declaration -stdlib=libc++
  59. -fvisibility=default)
  60. set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES PREFIX "")
  61. # --- End of section ---
  62. # --- Linux-specific build settings and tasks ---
  63. else()
  64. target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -Wall -Wextra)
  65. set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES PREFIX "")
  66. endif()
  67. # --- End of section ---
  68. setup_plugin_target(${CMAKE_PROJECT_NAME})