helpers.cmake 19 KB

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