CMakeLists.txt 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. cmake_minimum_required(VERSION 3.16)
  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.5)
  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. configure_file(src/plugin-macros.h.in
  25. ${CMAKE_SOURCE_DIR}/src/plugin-macros.generated.h)
  26. target_sources(${CMAKE_PROJECT_NAME} PRIVATE src/plugin-macros.generated.h)
  27. # --- Platform-independent build settings ---
  28. target_include_directories(${CMAKE_PROJECT_NAME}
  29. PRIVATE ${CMAKE_SOURCE_DIR}/src)
  30. target_link_libraries(
  31. ${CMAKE_PROJECT_NAME} PRIVATE OBS::libobs OBS::obs-frontend-api Qt5::Core
  32. Qt5::Widgets)
  33. set_target_properties(
  34. ${CMAKE_PROJECT_NAME}
  35. PROPERTIES AUTOMOC ON
  36. AUTOUIC ON
  37. AUTORCC ON)
  38. target_compile_features(${CMAKE_PROJECT_NAME} PRIVATE cxx_std_17)
  39. # --- End of section ---
  40. # --- Windows-specific build settings and tasks ---
  41. if(OS_WINDOWS)
  42. configure_file(cmake/bundle/windows/installer-Windows.iss.in
  43. ${CMAKE_BINARY_DIR}/installer-Windows.generated.iss)
  44. if(MSVC)
  45. target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE /MP /d2FH4-)
  46. endif()
  47. # --- End of section ---
  48. # -- macOS specific build settings and tasks --
  49. elseif(OS_MACOS)
  50. configure_file(cmake/bundle/macos/installer-macOS.pkgproj.in
  51. ${CMAKE_BINARY_DIR}/installer-macOS.generated.pkgproj)
  52. set(MACOSX_PLUGIN_GUI_IDENTIFIER "${MACOS_BUNDLEID}")
  53. set(MACOSX_PLUGIN_BUNDLE_VERSION "${CMAKE_PROJECT_VERSION}")
  54. set(MACOSX_PLUGIN_SHORT_VERSION_STRING "1")
  55. target_compile_options(
  56. ${CMAKE_PROJECT_NAME}
  57. PRIVATE -Wall -Wextra -Werror-implicit-function-declaration -stdlib=libc++
  58. -fvisibility=default)
  59. set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES PREFIX "")
  60. # --- End of section ---
  61. # --- Linux-specific build settings and tasks ---
  62. else()
  63. target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -Wall -Wextra)
  64. set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES PREFIX "")
  65. endif()
  66. # --- End of section ---
  67. setup_plugin_target(${CMAKE_PROJECT_NAME})