helpers.cmake 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. # OBS CMake macOS helper functions module
  2. # cmake-format: off
  3. # cmake-lint: disable=C0301
  4. # cmake-lint: disable=C0307
  5. # cmake-lint: disable=E1126
  6. # cmake-lint: disable=R0912
  7. # cmake-lint: disable=R0915
  8. # cmake-format: on
  9. include_guard(GLOBAL)
  10. include(helpers_common)
  11. # set_target_xcode_properties: Sets Xcode-specific target attributes
  12. function(set_target_xcode_properties target)
  13. set(options "")
  14. set(oneValueArgs "")
  15. set(multiValueArgs PROPERTIES)
  16. cmake_parse_arguments(PARSE_ARGV 0 _STXP "${options}" "${oneValueArgs}" "${multiValueArgs}")
  17. message(DEBUG "Setting Xcode properties for target ${target}...")
  18. while(_STXP_PROPERTIES)
  19. list(POP_FRONT _STXP_PROPERTIES key value)
  20. set_property(TARGET ${target} PROPERTY XCODE_ATTRIBUTE_${key} "${value}")
  21. endwhile()
  22. endfunction()
  23. # set_target_properties_obs: Set target properties for use in obs-studio
  24. function(set_target_properties_obs target)
  25. set(options "")
  26. set(oneValueArgs "")
  27. set(multiValueArgs PROPERTIES)
  28. cmake_parse_arguments(PARSE_ARGV 0 _STPO "${options}" "${oneValueArgs}" "${multiValueArgs}")
  29. message(DEBUG "Setting additional properties for target ${target}...")
  30. while(_STPO_PROPERTIES)
  31. list(POP_FRONT _STPO_PROPERTIES key value)
  32. set_property(TARGET ${target} PROPERTY ${key} "${value}")
  33. endwhile()
  34. get_target_property(target_type ${target} TYPE)
  35. string(TIMESTAMP CURRENT_YEAR "%Y")
  36. # Target is a GUI or CLI application
  37. if(target_type STREQUAL EXECUTABLE)
  38. if(target STREQUAL obs-studio)
  39. set_target_properties(
  40. ${target}
  41. PROPERTIES OUTPUT_NAME OBS
  42. MACOSX_BUNDLE TRUE
  43. MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos/Info.plist.in"
  44. XCODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY YES
  45. XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY YES
  46. XCODE_EMBED_PLUGINS_REMOVE_HEADERS_ON_COPY YES
  47. XCODE_EMBED_PLUGINS_CODE_SIGN_ON_COPY YES)
  48. # cmake-format: off
  49. set_target_xcode_properties(
  50. ${target}
  51. PROPERTIES PRODUCT_BUNDLE_IDENTIFIER com.obsproject.obs-studio
  52. PRODUCT_NAME OBS
  53. ASSETCATALOG_COMPILER_APPICON_NAME AppIcon
  54. CURRENT_PROJECT_VERSION ${OBS_BUILD_NUMBER}
  55. MARKETING_VERSION ${OBS_VERSION_CANONICAL}
  56. GENERATE_INFOPLIST_FILE YES
  57. COPY_PHASE_STRIP NO
  58. CLANG_ENABLE_OBJC_ARC YES
  59. SKIP_INSTALL NO
  60. INSTALL_PATH "$(LOCAL_APPS_DIR)"
  61. INFOPLIST_KEY_CFBundleDisplayName "OBS Studio"
  62. INFOPLIST_KEY_NSHumanReadableCopyright "(c) 2012-${CURRENT_YEAR} Lain Bailey"
  63. INFOPLIST_KEY_NSCameraUsageDescription "OBS needs to access the camera to enable camera sources to work."
  64. INFOPLIST_KEY_NSMicrophoneUsageDescription "OBS needs to access the microphone to enable audio input.")
  65. # cmake-format: on
  66. get_property(obs_dependencies GLOBAL PROPERTY _OBS_DEPENDENCIES)
  67. add_dependencies(${target} ${obs_dependencies})
  68. if(NOT XCODE)
  69. return()
  70. endif()
  71. get_property(obs_frameworks GLOBAL PROPERTY _OBS_FRAMEWORKS)
  72. set_property(
  73. TARGET ${target}
  74. APPEND
  75. PROPERTY XCODE_EMBED_FRAMEWORKS ${obs_frameworks})
  76. if(SPARKLE_APPCAST_URL AND SPARKLE_PUBLIC_KEY)
  77. set_property(
  78. TARGET ${target}
  79. APPEND
  80. PROPERTY XCODE_EMBED_FRAMEWORKS ${SPARKLE})
  81. endif()
  82. if(TARGET mac-syphon)
  83. set_property(
  84. TARGET ${target}
  85. APPEND
  86. PROPERTY XCODE_EMBED_FRAMEWORKS ${SYPHON})
  87. endif()
  88. get_property(obs_executables GLOBAL PROPERTY _OBS_EXECUTABLES)
  89. add_dependencies(${target} ${obs_executables})
  90. foreach(executable IN LISTS obs_executables)
  91. set_target_xcode_properties(${executable} PROPERTIES INSTALL_PATH
  92. "$(LOCAL_APPS_DIR)/$<TARGET_BUNDLE_DIR_NAME:${target}>/Contents/MacOS")
  93. add_custom_command(
  94. TARGET ${target}
  95. POST_BUILD
  96. COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$<TARGET_FILE:${executable}>"
  97. "$<TARGET_BUNDLE_CONTENT_DIR:${target}>/MacOS/"
  98. COMMENT "Copy ${executable} to application bundle")
  99. endforeach()
  100. if(VIRTUALCAM_DEVICE_UUID
  101. AND VIRTUALCAM_SOURCE_UUID
  102. AND VIRTUALCAM_SINK_UUID)
  103. set(has_virtualcam_uuids TRUE)
  104. else()
  105. set(has_virtualcam_uuids FALSE)
  106. endif()
  107. if(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_STYLE STREQUAL Automatic)
  108. if(has_virtualcam_uuids)
  109. set(entitlements_file "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos/entitlements-extension.plist")
  110. else()
  111. set(entitlements_file "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos/entitlements.plist")
  112. endif()
  113. else()
  114. if(has_virtualcam_uuids AND OBS_PROVISIONING_PROFILE)
  115. set(entitlements_file "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos/entitlements-extension.plist")
  116. set_target_properties(${target} PROPERTIES XCODE_ATTRIBUTE_PROVISIONING_PROFILE_SPECIFIER
  117. "${OBS_PROVISIONING_PROFILE}")
  118. configure_file(cmake/macos/exportOptions-extension.plist.in ${CMAKE_BINARY_DIR}/exportOptions.plist)
  119. else()
  120. set(entitlements_file "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos/entitlements.plist")
  121. configure_file(cmake/macos/exportOptions.plist.in ${CMAKE_BINARY_DIR}/exportOptions.plist)
  122. endif()
  123. endif()
  124. if(NOT EXISTS "${entitlements_file}")
  125. message(FATAL_ERROR "Target ${target} is missing an entitlements file in its cmake directory.")
  126. endif()
  127. set_target_properties(${target} PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "${entitlements_file}")
  128. add_custom_command(
  129. TARGET ${target}
  130. POST_BUILD
  131. COMMAND
  132. /usr/bin/sed -i '' 's/font-size: 10pt\;/font-size: 12pt\;/'
  133. "$<TARGET_BUNDLE_CONTENT_DIR:${target}>/Resources/themes/Acri.qss"
  134. "$<TARGET_BUNDLE_CONTENT_DIR:${target}>/Resources/themes/Grey.qss"
  135. "$<TARGET_BUNDLE_CONTENT_DIR:${target}>/Resources/themes/Light.qss"
  136. "$<TARGET_BUNDLE_CONTENT_DIR:${target}>/Resources/themes/Rachni.qss"
  137. "$<TARGET_BUNDLE_CONTENT_DIR:${target}>/Resources/themes/Yami.qss"
  138. COMMENT "Patch Qt stylesheets to use larger default font size on macOS")
  139. add_custom_command(
  140. TARGET ${target}
  141. POST_BUILD
  142. COMMAND /bin/ln -fs obs-frontend-api.dylib libobs-frontend-api.1.dylib
  143. WORKING_DIRECTORY "$<TARGET_BUNDLE_CONTENT_DIR:${target}>/Frameworks"
  144. COMMENT "Create symlink for legacy obs-frontend-api")
  145. if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos/qt.conf")
  146. target_add_resource(${target} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos/qt.conf")
  147. endif()
  148. target_add_resource(${target} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos/Assets.xcassets")
  149. target_add_resource(${target} "${CMAKE_CURRENT_SOURCE_DIR}/../AUTHORS")
  150. if(TARGET obs-dal-plugin)
  151. add_custom_command(
  152. TARGET ${target}
  153. POST_BUILD
  154. COMMAND "${CMAKE_COMMAND}" -E copy_directory "$<TARGET_BUNDLE_DIR:obs-dal-plugin>"
  155. "$<TARGET_BUNDLE_CONTENT_DIR:${target}>/Resources/$<TARGET_BUNDLE_DIR_NAME:obs-dal-plugin>"
  156. COMMENT "Add OBS DAL plugin to application bundle")
  157. endif()
  158. if(TARGET obspython)
  159. add_custom_command(
  160. TARGET ${target}
  161. POST_BUILD
  162. COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$<TARGET_FILE_DIR:obspython>/obspython.py"
  163. "$<TARGET_BUNDLE_CONTENT_DIR:${target}>/Resources"
  164. COMMENT "Add OBS::python import module")
  165. endif()
  166. if(TARGET mac-camera-extension AND (CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_STYLE STREQUAL Automatic
  167. OR OBS_PROVISIONING_PROFILE))
  168. target_enable_feature(mac-camera-extension "macOS CMIO Camera Extension")
  169. add_custom_command(
  170. TARGET ${target}
  171. POST_BUILD
  172. COMMAND
  173. "${CMAKE_COMMAND}" -E copy_directory "$<TARGET_BUNDLE_DIR:mac-camera-extension>"
  174. "$<TARGET_BUNDLE_CONTENT_DIR:${target}>/Library/SystemExtensions/$<TARGET_BUNDLE_DIR_NAME:mac-camera-extension>"
  175. COMMENT "Add Camera Extension to application bundle")
  176. else()
  177. target_disable_feature(mac-camera-extension "macOS CMIO Camera Extension")
  178. endif()
  179. _bundle_dependencies(${target})
  180. install(TARGETS ${target} BUNDLE DESTINATION "." COMPONENT Application)
  181. elseif(${target} STREQUAL mac-camera-extension)
  182. set_target_properties(${target} PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)
  183. set_property(GLOBAL APPEND PROPERTY _OBS_DEPENDENCIES ${target})
  184. else()
  185. set_property(TARGET ${target} PROPERTY XCODE_ATTRIBUTE_SKIP_INSTALL NO)
  186. set_property(GLOBAL APPEND PROPERTY _OBS_EXECUTABLES ${target})
  187. set_property(GLOBAL APPEND PROPERTY _OBS_DEPENDENCIES ${target})
  188. _add_entitlements()
  189. endif()
  190. elseif(target_type STREQUAL SHARED_LIBRARY)
  191. set_target_properties(
  192. ${target}
  193. PROPERTIES NO_SONAME TRUE
  194. MACHO_COMPATIBILITY_VERSION 1.0
  195. MACHO_CURRENT_VERSION ${OBS_VERSION_MAJOR}
  196. SOVERSION 0
  197. VERSION 0)
  198. # cmake-format: off
  199. set_target_xcode_properties(
  200. ${target}
  201. PROPERTIES DYLIB_COMPATIBILITY_VERSION 1.0
  202. DYLIB_CURRENT_VERSION ${OBS_VERSION_MAJOR}
  203. PRODUCT_NAME ${target}
  204. PRODUCT_BUNDLE_IDENTIFIER com.obsproject.${target}
  205. SKIP_INSTALL YES)
  206. # cmake-format: on
  207. get_target_property(is_framework ${target} FRAMEWORK)
  208. if(is_framework)
  209. set_target_properties(${target} PROPERTIES FRAMEWORK_VERSION A MACOSX_FRAMEWORK_IDENTIFIER
  210. com.obsproject.${target})
  211. # cmake-format: off
  212. set_target_xcode_properties(
  213. ${target}
  214. PROPERTIES CODE_SIGN_IDENTITY ""
  215. DEVELOPMENT_TEAM ""
  216. SKIP_INSTALL YES
  217. PRODUCT_NAME ${target}
  218. PRODUCT_BUNDLE_IDENTIFIER com.obsproject.${target}
  219. CURRENT_PROJECT_VERSION ${OBS_BUILD_NUMBER}
  220. MARKETING_VERSION ${OBS_VERSION_CANONICAL}
  221. GENERATE_INFOPLIST_FILE YES
  222. INFOPLIST_FILE ""
  223. INFOPLIST_KEY_CFBundleDisplayName ${target}
  224. INFOPLIST_KEY_NSHumanReadableCopyright "(c) 2012-${CURRENT_YEAR} Lain Bailey")
  225. # cmake-format: on
  226. endif()
  227. set_property(GLOBAL APPEND PROPERTY _OBS_FRAMEWORKS ${target})
  228. set_property(GLOBAL APPEND PROPERTY _OBS_DEPENDENCIES ${target})
  229. elseif(target_type STREQUAL MODULE_LIBRARY)
  230. if(target STREQUAL obspython)
  231. # cmake-format: off
  232. set_target_xcode_properties(
  233. ${target}
  234. PROPERTIES PRODUCT_NAME ${target}
  235. PRODUCT_BUNDLE_IDENTIFIER com.obsproject.${target})
  236. # cmake-format: on
  237. elseif(target STREQUAL obslua)
  238. # cmake-format: off
  239. set_target_xcode_properties(
  240. ${target}
  241. PROPERTIES PRODUCT_NAME ${target}
  242. PRODUCT_BUNDLE_IDENTIFIER com.obsproject.${target})
  243. # cmake-format: on
  244. elseif(target STREQUAL obs-dal-plugin)
  245. set_target_properties(${target} PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)
  246. set_property(GLOBAL APPEND PROPERTY _OBS_DEPENDENCIES ${target})
  247. return()
  248. else()
  249. set_target_properties(${target} PROPERTIES BUNDLE TRUE BUNDLE_EXTENSION plugin)
  250. # cmake-format: off
  251. set_target_xcode_properties(
  252. ${target}
  253. PROPERTIES PRODUCT_NAME ${target}
  254. PRODUCT_BUNDLE_IDENTIFIER com.obsproject.${target}
  255. CURRENT_PROJECT_VERSION ${OBS_BUILD_NUMBER}
  256. MARKETING_VERSION ${OBS_VERSION_CANONICAL}
  257. GENERATE_INFOPLIST_FILE YES
  258. INFOPLIST_KEY_CFBundleDisplayName ${target}
  259. INFOPLIST_KEY_NSHumanReadableCopyright "(c) 2012-${CURRENT_YEAR} Lain Bailey")
  260. # cmake-format: on
  261. if(target STREQUAL obs-browser)
  262. # Good-enough for now as there are no other variants - in _theory_ we should only add the appropriate variant,
  263. # but that is only known at project generation and not build system configuration.
  264. get_target_property(imported_location CEF::Library IMPORTED_LOCATION_RELEASE)
  265. if(imported_location)
  266. list(APPEND cef_items "${imported_location}")
  267. endif()
  268. foreach(helper IN ITEMS _gpu _plugin _renderer "")
  269. if(TARGET OBS::browser-helper${helper})
  270. set_property(GLOBAL APPEND PROPERTY _OBS_DEPENDENCIES OBS::browser-helper${helper})
  271. list(APPEND cef_items OBS::browser-helper${helper})
  272. endif()
  273. endforeach()
  274. set_property(GLOBAL APPEND PROPERTY _OBS_FRAMEWORKS ${cef_items})
  275. endif()
  276. endif()
  277. set_property(GLOBAL APPEND PROPERTY OBS_MODULES_ENABLED ${target})
  278. set_property(GLOBAL APPEND PROPERTY _OBS_DEPENDENCIES ${target})
  279. endif()
  280. target_install_resources(${target})
  281. get_target_property(target_sources ${target} SOURCES)
  282. set(target_ui_files ${target_sources})
  283. list(FILTER target_ui_files INCLUDE REGEX ".+\\.(ui|qrc)")
  284. source_group(
  285. TREE "${CMAKE_CURRENT_SOURCE_DIR}"
  286. PREFIX "UI Files"
  287. FILES ${target_ui_files})
  288. if(${target} STREQUAL libobs)
  289. set(target_source_files ${target_sources})
  290. set(target_header_files ${target_sources})
  291. list(FILTER target_source_files INCLUDE REGEX ".+\\.(m|c[cp]?p?|swift)")
  292. list(FILTER target_header_files INCLUDE REGEX ".+\\.h(pp)?")
  293. source_group(
  294. TREE "${CMAKE_CURRENT_SOURCE_DIR}"
  295. PREFIX "Source Files"
  296. FILES ${target_source_files})
  297. source_group(
  298. TREE "${CMAKE_CURRENT_SOURCE_DIR}"
  299. PREFIX "Header Files"
  300. FILES ${target_header_files})
  301. endif()
  302. endfunction()
  303. # _check_entitlements: Macro to check if project ships with entitlements plist
  304. macro(_check_entitlements)
  305. if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos/entitlements.plist")
  306. message(FATAL_ERROR "Target ${target} is missing an entitlements.plist in its cmake directory.")
  307. endif()
  308. endmacro()
  309. # _add_entitlements: Macro to add entitlements shipped with project
  310. macro(_add_entitlements)
  311. if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos/entitlements.plist")
  312. # cmake-format: off
  313. set_target_xcode_properties(
  314. ${target}
  315. PROPERTIES CODE_SIGN_ENTITLEMENTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos/entitlements.plist")
  316. # cmake-format: on
  317. endif()
  318. endmacro()
  319. # target_export: Helper function to export target as CMake package
  320. function(target_export target)
  321. # Exclude CMake package from 'ALL' target
  322. set(exclude_variant EXCLUDE_FROM_ALL)
  323. _target_export(${target})
  324. endfunction()
  325. # target_install_resources: Helper function to add resources into bundle
  326. function(target_install_resources target)
  327. message(DEBUG "Installing resources for target ${target}...")
  328. if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/data")
  329. file(GLOB_RECURSE data_files "${CMAKE_CURRENT_SOURCE_DIR}/data/*")
  330. foreach(data_file IN LISTS data_files)
  331. cmake_path(RELATIVE_PATH data_file BASE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data/" OUTPUT_VARIABLE
  332. relative_path)
  333. cmake_path(GET relative_path PARENT_PATH relative_path)
  334. target_sources(${target} PRIVATE "${data_file}")
  335. set_property(SOURCE "${data_file}" PROPERTY MACOSX_PACKAGE_LOCATION "Resources/${relative_path}")
  336. source_group("Resources/${relative_path}" FILES "${data_file}")
  337. endforeach()
  338. endif()
  339. endfunction()
  340. # target_add_resource: Helper function to add a specific resource to a bundle
  341. function(target_add_resource target resource)
  342. message(DEBUG "Add resource ${resource} to target ${target} at destination ${destination}...")
  343. target_sources(${target} PRIVATE "${resource}")
  344. set_property(SOURCE "${resource}" PROPERTY MACOSX_PACKAGE_LOCATION Resources)
  345. source_group("Resources" FILES "${resource}")
  346. endfunction()
  347. # _bundle_dependencies: Resolve 3rd party dependencies and add them to macOS app bundle
  348. function(_bundle_dependencies target)
  349. message(DEBUG "Discover dependencies of target ${target}...")
  350. set(found_dependencies)
  351. find_dependencies(TARGET ${target} FOUND_VAR found_dependencies)
  352. get_property(obs_module_list GLOBAL PROPERTY OBS_MODULES_ENABLED)
  353. list(LENGTH obs_module_list num_modules)
  354. if(num_modules GREATER 0)
  355. add_dependencies(${target} ${obs_module_list})
  356. set_property(
  357. TARGET ${target}
  358. APPEND
  359. PROPERTY XCODE_EMBED_PLUGINS ${obs_module_list})
  360. foreach(module IN LISTS obs_module_list)
  361. find_dependencies(TARGET ${module} FOUND_VAR found_dependencies)
  362. endforeach()
  363. endif()
  364. list(REMOVE_DUPLICATES found_dependencies)
  365. set(library_paths)
  366. set(plugins_list)
  367. file(GLOB sdk_library_paths /Applications/Xcode*.app)
  368. set(system_library_path "/usr/lib/")
  369. foreach(library IN LISTS found_dependencies)
  370. get_target_property(library_type ${library} TYPE)
  371. get_target_property(is_framework ${library} FRAMEWORK)
  372. get_target_property(is_imported ${library} IMPORTED)
  373. if(is_imported)
  374. get_target_property(imported_location ${library} LOCATION)
  375. if(NOT imported_location)
  376. continue()
  377. endif()
  378. set(is_xcode_framework FALSE)
  379. set(is_system_framework FALSE)
  380. foreach(sdk_library_path IN LISTS sdk_library_paths)
  381. if(is_xcode_framework)
  382. break()
  383. endif()
  384. cmake_path(IS_PREFIX sdk_library_path "${imported_location}" is_xcode_framework)
  385. endforeach()
  386. cmake_path(IS_PREFIX system_library_path "${imported_location}" is_system_framework)
  387. if(is_system_framework OR is_xcode_framework)
  388. continue()
  389. elseif(is_framework)
  390. file(REAL_PATH "../../.." library_location BASE_DIRECTORY "${imported_location}")
  391. elseif(NOT library_type STREQUAL "STATIC_LIBRARY")
  392. if(NOT imported_location MATCHES ".+\\.a")
  393. set(library_location "${imported_location}")
  394. else()
  395. continue()
  396. endif()
  397. else()
  398. continue()
  399. endif()
  400. if(library MATCHES "Qt[56]?::.+")
  401. find_qt_plugins(COMPONENT ${library} TARGET ${target} FOUND_VAR plugins_list)
  402. endif()
  403. list(APPEND library_paths ${library_location})
  404. elseif(NOT is_imported AND library_type STREQUAL "SHARED_LIBRARY")
  405. list(APPEND library_paths ${library})
  406. endif()
  407. endforeach()
  408. list(REMOVE_DUPLICATES plugins_list)
  409. foreach(plugin IN LISTS plugins_list)
  410. cmake_path(GET plugin PARENT_PATH plugin_path)
  411. set(plugin_base_dir "${plugin_path}/../")
  412. cmake_path(SET plugin_stem_dir NORMALIZE "${plugin_base_dir}")
  413. cmake_path(RELATIVE_PATH plugin_path BASE_DIRECTORY "${plugin_stem_dir}" OUTPUT_VARIABLE plugin_file_name)
  414. target_sources(${target} PRIVATE "${plugin}")
  415. set_source_files_properties("${plugin}" PROPERTIES MACOSX_PACKAGE_LOCATION "plugins/${plugin_file_name}"
  416. XCODE_FILE_ATTRIBUTES "CodeSignOnCopy")
  417. source_group("Qt plugins" FILES "${plugin}")
  418. endforeach()
  419. list(REMOVE_DUPLICATES library_paths)
  420. set_property(
  421. TARGET ${target}
  422. APPEND
  423. PROPERTY XCODE_EMBED_FRAMEWORKS ${library_paths})
  424. endfunction()