CMakeLists.txt 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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.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 installers)
  8. set(PLUGIN_AUTHOR "Your Name Here")
  9. # Replace `com.example.obs-plugin-template` with a unique Bundle ID for macOS releases
  10. # (used both in the installer and when submitting the installer for notarization)
  11. set(MACOS_BUNDLEID "com.example.obs-plugintemplate")
  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}
  17. PRIVATE
  18. src/plugin-main.c)
  19. # /!\ TAKE NOTE: No need to edit things past this point /!\
  20. find_package(libobs REQUIRED)
  21. find_package(obs-frontend-api REQUIRED)
  22. include(external/ObsPluginHelpers.cmake)
  23. find_package(Qt5Core REQUIRED)
  24. find_package(Qt5Widgets REQUIRED)
  25. configure_file(
  26. src/plugin-macros.h.in
  27. ${CMAKE_SOURCE_DIR}/src/plugin-macros.generated.h)
  28. target_sources(${CMAKE_PROJECT_NAME}
  29. PRIVATE
  30. src/plugin-macros.generated.h)
  31. # --- Platform-independent build settings ---
  32. target_include_directories(${CMAKE_PROJECT_NAME}
  33. PRIVATE ${CMAKE_SOURCE_DIR}/src)
  34. target_link_libraries(${CMAKE_PROJECT_NAME}
  35. PRIVATE
  36. OBS::libobs
  37. OBS::obs-frontend-api
  38. Qt5::Core
  39. Qt5::Widgets)
  40. set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES
  41. AUTOMOC ON
  42. AUTOUIC ON
  43. AUTORCC ON)
  44. target_compile_features(${CMAKE_PROJECT_NAME}
  45. PRIVATE
  46. cxx_std_17)
  47. # --- End of section ---
  48. # --- Windows-specific build settings and tasks ---
  49. if(OS_WINDOWS)
  50. configure_file(
  51. installer/installer-Windows.iss.in
  52. ${CMAKE_SOURCE_DIR}/installer/installer-Windows.generated.iss)
  53. configure_file(
  54. CI/include/build_environment.ps1.in
  55. ${CMAKE_SOURCE_DIR}/CI/include/build_environment.ps1)
  56. if(MSVC)
  57. target_compile_options(${CMAKE_PROJECT_NAME}
  58. PRIVATE
  59. /MP
  60. /d2FH4-)
  61. endif()
  62. # --- End of section ---
  63. # -- macOS specific build settings and tasks --
  64. elseif(OS_MACOS)
  65. configure_file(
  66. bundle/installer-macOS.pkgproj.in
  67. ${CMAKE_SOURCE_DIR}/bundle/installer-macOS.generated.pkgproj)
  68. configure_file(
  69. CI/include/build_environment.sh.in
  70. ${CMAKE_SOURCE_DIR}/CI/include/build_environment.sh
  71. )
  72. set(MACOSX_PLUGIN_GUI_IDENTIFIER "${MACOS_BUNDLEID}")
  73. set(MACOSX_PLUGIN_BUNDLE_VERSION "${CMAKE_PROJECT_VERSION}")
  74. set(MACOSX_PLUGIN_SHORT_VERSION_STRING "1")
  75. target_compile_options(${CMAKE_PROJECT_NAME}
  76. PRIVATE
  77. -Wall
  78. -Wextra
  79. -Werror-implicit-function-declaration
  80. -stdlib=libc++
  81. -fvisibility=default)
  82. set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES PREFIX "")
  83. # --- End of section ---
  84. # --- Linux-specific build settings and tasks ---
  85. else()
  86. configure_file(
  87. CI/include/build_environment.sh.in
  88. ${CMAKE_SOURCE_DIR}/CI/include/build_environment.sh
  89. )
  90. target_compile_options(${CMAKE_PROJECT_NAME}
  91. PRIVATE
  92. -Wall
  93. -Wextra)
  94. set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES PREFIX "")
  95. endif()
  96. # --- End of section ---
  97. setup_plugin_target(${CMAKE_PROJECT_NAME})