The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2079 lines
85KB

  1. # ==============================================================================
  2. #
  3. # This file is part of the JUCE library.
  4. # Copyright (c) 2022 - Raw Material Software Limited
  5. #
  6. # JUCE is an open source library subject to commercial or open-source
  7. # licensing.
  8. #
  9. # By using JUCE, you agree to the terms of both the JUCE 7 End-User License
  10. # Agreement and JUCE Privacy Policy.
  11. #
  12. # End User License Agreement: www.juce.com/juce-7-licence
  13. # Privacy Policy: www.juce.com/juce-privacy-policy
  14. #
  15. # Or: You may also use this code under the terms of the GPL v3 (see
  16. # www.gnu.org/licenses).
  17. #
  18. # JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  19. # EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  20. # DISCLAIMED.
  21. #
  22. # ==============================================================================
  23. # ==================================================================================================
  24. # JUCE Target Support Helper Functions
  25. #
  26. # In this file, functions intended for use by end-users have the prefix `juce_`.
  27. # Functions beginning with an underscore should be considered private and susceptible to
  28. # change, so don't call them directly.
  29. #
  30. # See the readme at `docs/CMake API.md` for more information about CMake usage,
  31. # including documentation of the public functions in this file.
  32. # ==================================================================================================
  33. include_guard(GLOBAL)
  34. cmake_minimum_required(VERSION 3.15)
  35. define_property(TARGET PROPERTY JUCE_COMPANY_NAME INHERITED
  36. BRIEF_DOCS "The company name for a particular target"
  37. FULL_DOCS "This can be found in ProjectInfo::companyName in a generated JuceHeader.h")
  38. set_property(GLOBAL PROPERTY JUCE_COMPANY_NAME "yourcompany")
  39. define_property(TARGET PROPERTY JUCE_COMPANY_WEBSITE INHERITED
  40. BRIEF_DOCS "The company website for a particular target"
  41. FULL_DOCS "This will be placed in the Info.plist for the target")
  42. set_property(GLOBAL PROPERTY JUCE_COMPANY_WEBSITE "")
  43. define_property(TARGET PROPERTY JUCE_COMPANY_EMAIL INHERITED
  44. BRIEF_DOCS "The company email address for a particular target"
  45. FULL_DOCS "This will be placed in the Info.plist for the target")
  46. set_property(GLOBAL PROPERTY JUCE_COMPANY_EMAIL "")
  47. define_property(TARGET PROPERTY JUCE_COMPANY_COPYRIGHT INHERITED
  48. BRIEF_DOCS "The company copyright for a particular target"
  49. FULL_DOCS "This will be placed in the Info.plist for the target")
  50. set_property(GLOBAL PROPERTY JUCE_COMPANY_COPYRIGHT "")
  51. define_property(TARGET PROPERTY JUCE_VST_COPY_DIR INHERITED
  52. BRIEF_DOCS "Install location for VST2 plugins"
  53. FULL_DOCS "This is where the plugin will be copied if plugin copying is enabled")
  54. define_property(TARGET PROPERTY JUCE_VST3_COPY_DIR INHERITED
  55. BRIEF_DOCS "Install location for VST3 plugins"
  56. FULL_DOCS "This is where the plugin will be copied if plugin copying is enabled")
  57. define_property(TARGET PROPERTY JUCE_AU_COPY_DIR INHERITED
  58. BRIEF_DOCS "Install location for AU plugins"
  59. FULL_DOCS "This is where the plugin will be copied if plugin copying is enabled")
  60. define_property(TARGET PROPERTY JUCE_AAX_COPY_DIR INHERITED
  61. BRIEF_DOCS "Install location for AAX plugins"
  62. FULL_DOCS "This is where the plugin will be copied if plugin copying is enabled")
  63. define_property(TARGET PROPERTY JUCE_UNITY_COPY_DIR INHERITED
  64. BRIEF_DOCS "Install location for Unity plugins"
  65. FULL_DOCS "This is where the plugin will be copied if plugin copying is enabled")
  66. define_property(TARGET PROPERTY JUCE_LV2_COPY_DIR INHERITED
  67. BRIEF_DOCS "Install location for LV2 plugins"
  68. FULL_DOCS "This is where the plugin will be copied if plugin copying is enabled")
  69. define_property(TARGET PROPERTY JUCE_COPY_PLUGIN_AFTER_BUILD INHERITED
  70. BRIEF_DOCS "Whether or not plugins should be copied after building"
  71. FULL_DOCS "Whether or not plugins should be copied after building")
  72. set_property(GLOBAL PROPERTY JUCE_COPY_PLUGIN_AFTER_BUILD FALSE)
  73. if((CMAKE_SYSTEM_NAME STREQUAL "Linux") OR (CMAKE_SYSTEM_NAME MATCHES ".*BSD"))
  74. _juce_create_pkgconfig_target(JUCE_CURL_LINUX_DEPS libcurl)
  75. _juce_create_pkgconfig_target(JUCE_BROWSER_LINUX_DEPS webkit2gtk-4.0 gtk+-x11-3.0)
  76. endif()
  77. # We set up default/fallback copy dirs here. If you need different copy dirs, use
  78. # set_directory_properties or set_target_properties to adjust the values of `JUCE_*_COPY_DIR` at
  79. # the appropriate scope.
  80. function(_juce_set_default_properties)
  81. if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  82. set_property(GLOBAL PROPERTY JUCE_LV2_COPY_DIR "$ENV{HOME}/Library/Audio/Plug-Ins/LV2")
  83. set_property(GLOBAL PROPERTY JUCE_VST_COPY_DIR "$ENV{HOME}/Library/Audio/Plug-Ins/VST")
  84. set_property(GLOBAL PROPERTY JUCE_VST3_COPY_DIR "$ENV{HOME}/Library/Audio/Plug-Ins/VST3")
  85. set_property(GLOBAL PROPERTY JUCE_AU_COPY_DIR "$ENV{HOME}/Library/Audio/Plug-Ins/Components")
  86. set_property(GLOBAL PROPERTY JUCE_UNITY_COPY_DIR "$ENV{HOME}/Library/Audio/Plug-Ins/Unity")
  87. set_property(GLOBAL PROPERTY JUCE_AAX_COPY_DIR "/Library/Application Support/Avid/Audio/Plug-Ins")
  88. elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
  89. if(CMAKE_SIZEOF_VOID_P EQUAL 8)
  90. set_property(GLOBAL PROPERTY JUCE_VST_COPY_DIR "$ENV{ProgramW6432}/Steinberg/Vstplugins")
  91. set(prefix "$ENV{CommonProgramW6432}")
  92. else()
  93. set_property(GLOBAL PROPERTY JUCE_VST_COPY_DIR "$ENV{programfiles\(x86\)}/Steinberg/Vstplugins")
  94. set(prefix "$ENV{CommonProgramFiles\(x86\)}")
  95. endif()
  96. set_property(GLOBAL PROPERTY JUCE_VST3_COPY_DIR "${prefix}/VST3")
  97. set_property(GLOBAL PROPERTY JUCE_AAX_COPY_DIR "${prefix}/Avid/Audio/Plug-Ins")
  98. set_property(GLOBAL PROPERTY JUCE_LV2_COPY_DIR "$ENV{APPDATA}/LV2")
  99. set_property(GLOBAL PROPERTY JUCE_UNITY_COPY_DIR "$ENV{APPDATA}/Unity")
  100. elseif((CMAKE_SYSTEM_NAME STREQUAL "Linux") OR (CMAKE_SYSTEM_NAME MATCHES ".*BSD"))
  101. set_property(GLOBAL PROPERTY JUCE_LV2_COPY_DIR "$ENV{HOME}/.lv2")
  102. set_property(GLOBAL PROPERTY JUCE_VST_COPY_DIR "$ENV{HOME}/.vst")
  103. set_property(GLOBAL PROPERTY JUCE_VST3_COPY_DIR "$ENV{HOME}/.vst3")
  104. set_property(GLOBAL PROPERTY JUCE_UNITY_COPY_DIR "$ENV{HOME}/.unity")
  105. endif()
  106. endfunction()
  107. _juce_set_default_properties()
  108. # ==================================================================================================
  109. function(juce_add_bundle_resources_directory target folder)
  110. _juce_make_absolute(folder)
  111. if(NOT EXISTS "${folder}")
  112. message(FATAL_ERROR "Could not find resource folder ${folder}")
  113. endif()
  114. get_filename_component(folder_parent_path "${folder}" DIRECTORY)
  115. file(GLOB_RECURSE resources RELATIVE "${folder_parent_path}" "${folder}/*")
  116. foreach(file IN LISTS resources)
  117. target_sources(${target} PRIVATE "${folder_parent_path}/${file}")
  118. get_filename_component(resource_parent_path "${file}" DIRECTORY)
  119. set_source_files_properties("${folder_parent_path}/${file}" PROPERTIES
  120. HEADER_FILE_ONLY TRUE
  121. MACOSX_PACKAGE_LOCATION "Resources/${resource_parent_path}")
  122. endforeach()
  123. endfunction()
  124. # ==================================================================================================
  125. # Ideally, we'd check the preprocessor defs on the target to see whether
  126. # JUCE_USE_CURL, JUCE_WEB_BROWSER, or JUCE_IN_APP_PURCHASES have been explicitly turned off,
  127. # and then link libraries as appropriate.
  128. # Unfortunately, this doesn't work, because linking a new library (curl/webkit/StoreKit)
  129. # updates the target's compile defs, which results in a recursion/circular-dependency.
  130. # Instead, we ask the user to explicitly request curl/webkit/StoreKit linking if they
  131. # know they need it. Otherwise, we won't link anything.
  132. # See the NEEDS_CURL, NEEDS_WEB_BROWSER, and NEEDS_STORE_KIT options in the CMake/readme.md.
  133. function(_juce_link_optional_libraries target)
  134. if((CMAKE_SYSTEM_NAME STREQUAL "Linux") OR (CMAKE_SYSTEM_NAME MATCHES ".*BSD"))
  135. get_target_property(needs_curl ${target} JUCE_NEEDS_CURL)
  136. if(needs_curl)
  137. target_link_libraries(${target} PRIVATE juce::pkgconfig_JUCE_CURL_LINUX_DEPS)
  138. endif()
  139. get_target_property(needs_browser ${target} JUCE_NEEDS_WEB_BROWSER)
  140. if(needs_browser)
  141. target_link_libraries(${target} PRIVATE juce::pkgconfig_JUCE_BROWSER_LINUX_DEPS)
  142. endif()
  143. elseif(APPLE)
  144. get_target_property(needs_storekit ${target} JUCE_NEEDS_STORE_KIT)
  145. if(needs_storekit)
  146. _juce_link_frameworks("${target}" PRIVATE StoreKit)
  147. endif()
  148. get_target_property(needs_camera ${target} JUCE_CAMERA_PERMISSION_ENABLED)
  149. if(CMAKE_SYSTEM_NAME STREQUAL "iOS" AND needs_camera)
  150. _juce_link_frameworks("${target}" PRIVATE ImageIO)
  151. endif()
  152. endif()
  153. endfunction()
  154. # ==================================================================================================
  155. function(_juce_get_module_definitions target filter out_var)
  156. set(compile_defs $<TARGET_GENEX_EVAL:${target},$<TARGET_PROPERTY:${target},COMPILE_DEFINITIONS>>)
  157. if(filter)
  158. set(${out_var} $<FILTER:${compile_defs},EXCLUDE,JucePlugin_Build_|JUCE_SHARED_CODE> PARENT_SCOPE)
  159. else()
  160. set(${out_var} ${compile_defs} PARENT_SCOPE)
  161. endif()
  162. endfunction()
  163. function(_juce_append_record output key)
  164. string(ASCII 30 RS)
  165. string(ASCII 31 US)
  166. set(${output} "${${output}}${key}${US}${ARGN}${RS}" PARENT_SCOPE)
  167. endfunction()
  168. function(_juce_append_target_property output key target property)
  169. get_target_property(prop ${target} ${property})
  170. if(prop STREQUAL "prop-NOTFOUND")
  171. set(prop)
  172. endif()
  173. _juce_append_record(${output} ${key} ${prop})
  174. set(${output} "${${output}}" PARENT_SCOPE)
  175. endfunction()
  176. # This is all info that should be known at configure time (i.e. no generator expressions here!)
  177. # We use this info to generate plists and entitlements files, also at configure time.
  178. function(_juce_write_configure_time_info target)
  179. _juce_append_target_property(file_content EXECUTABLE_NAME ${target} JUCE_PRODUCT_NAME)
  180. _juce_append_target_property(file_content VERSION ${target} JUCE_VERSION)
  181. _juce_append_target_property(file_content BUILD_VERSION ${target} JUCE_BUILD_VERSION)
  182. _juce_append_target_property(file_content PLIST_TO_MERGE ${target} JUCE_PLIST_TO_MERGE)
  183. _juce_append_target_property(file_content BUNDLE_ID ${target} JUCE_BUNDLE_ID)
  184. _juce_append_target_property(file_content XCODE_EXTRA_PLIST_ENTRIES ${target} JUCE_XCODE_EXTRA_PLIST_ENTRIES)
  185. _juce_append_target_property(file_content MICROPHONE_PERMISSION_ENABLED ${target} JUCE_MICROPHONE_PERMISSION_ENABLED)
  186. _juce_append_target_property(file_content MICROPHONE_PERMISSION_TEXT ${target} JUCE_MICROPHONE_PERMISSION_TEXT)
  187. _juce_append_target_property(file_content CAMERA_PERMISSION_ENABLED ${target} JUCE_CAMERA_PERMISSION_ENABLED)
  188. _juce_append_target_property(file_content CAMERA_PERMISSION_TEXT ${target} JUCE_CAMERA_PERMISSION_TEXT)
  189. _juce_append_target_property(file_content BLUETOOTH_PERMISSION_ENABLED ${target} JUCE_BLUETOOTH_PERMISSION_ENABLED)
  190. _juce_append_target_property(file_content BLUETOOTH_PERMISSION_TEXT ${target} JUCE_BLUETOOTH_PERMISSION_TEXT)
  191. _juce_append_target_property(file_content SEND_APPLE_EVENTS_PERMISSION_ENABLED ${target} JUCE_SEND_APPLE_EVENTS_PERMISSION_ENABLED)
  192. _juce_append_target_property(file_content SEND_APPLE_EVENTS_PERMISSION_TEXT ${target} JUCE_SEND_APPLE_EVENTS_PERMISSION_TEXT)
  193. _juce_append_target_property(file_content SHOULD_ADD_STORYBOARD ${target} JUCE_SHOULD_ADD_STORYBOARD)
  194. _juce_append_target_property(file_content LAUNCH_STORYBOARD_FILE ${target} JUCE_LAUNCH_STORYBOARD_FILE)
  195. _juce_append_target_property(file_content ICON_FILE ${target} JUCE_ICON_FILE)
  196. _juce_append_target_property(file_content PROJECT_NAME ${target} JUCE_PRODUCT_NAME)
  197. _juce_append_target_property(file_content COMPANY_COPYRIGHT ${target} JUCE_COMPANY_COPYRIGHT)
  198. _juce_append_target_property(file_content COMPANY_NAME ${target} JUCE_COMPANY_NAME)
  199. _juce_append_target_property(file_content DOCUMENT_EXTENSIONS ${target} JUCE_DOCUMENT_EXTENSIONS)
  200. _juce_append_target_property(file_content FILE_SHARING_ENABLED ${target} JUCE_FILE_SHARING_ENABLED)
  201. _juce_append_target_property(file_content DOCUMENT_BROWSER_ENABLED ${target} JUCE_DOCUMENT_BROWSER_ENABLED)
  202. _juce_append_target_property(file_content STATUS_BAR_HIDDEN ${target} JUCE_STATUS_BAR_HIDDEN)
  203. _juce_append_target_property(file_content REQUIRES_FULL_SCREEN ${target} JUCE_REQUIRES_FULL_SCREEN)
  204. _juce_append_target_property(file_content BACKGROUND_AUDIO_ENABLED ${target} JUCE_BACKGROUND_AUDIO_ENABLED)
  205. _juce_append_target_property(file_content BACKGROUND_BLE_ENABLED ${target} JUCE_BACKGROUND_BLE_ENABLED)
  206. _juce_append_target_property(file_content PUSH_NOTIFICATIONS_ENABLED ${target} JUCE_PUSH_NOTIFICATIONS_ENABLED)
  207. _juce_append_target_property(file_content NETWORK_MULTICAST_ENABLED ${target} JUCE_NETWORK_MULTICAST_ENABLED)
  208. _juce_append_target_property(file_content PLUGIN_MANUFACTURER_CODE ${target} JUCE_PLUGIN_MANUFACTURER_CODE)
  209. _juce_append_target_property(file_content PLUGIN_CODE ${target} JUCE_PLUGIN_CODE)
  210. _juce_append_target_property(file_content IPHONE_SCREEN_ORIENTATIONS ${target} JUCE_IPHONE_SCREEN_ORIENTATIONS)
  211. _juce_append_target_property(file_content IPAD_SCREEN_ORIENTATIONS ${target} JUCE_IPAD_SCREEN_ORIENTATIONS)
  212. _juce_append_target_property(file_content PLUGIN_NAME ${target} JUCE_PLUGIN_NAME)
  213. _juce_append_target_property(file_content PLUGIN_MANUFACTURER ${target} JUCE_COMPANY_NAME)
  214. _juce_append_target_property(file_content PLUGIN_DESCRIPTION ${target} JUCE_DESCRIPTION)
  215. _juce_append_target_property(file_content PLUGIN_AU_EXPORT_PREFIX ${target} JUCE_AU_EXPORT_PREFIX)
  216. _juce_append_target_property(file_content PLUGIN_AU_MAIN_TYPE ${target} JUCE_AU_MAIN_TYPE_CODE)
  217. _juce_append_target_property(file_content IS_AU_SANDBOX_SAFE ${target} JUCE_AU_SANDBOX_SAFE)
  218. _juce_append_target_property(file_content IS_PLUGIN_SYNTH ${target} JUCE_IS_SYNTH)
  219. _juce_append_target_property(file_content IS_PLUGIN_ARA_EFFECT ${target} JUCE_IS_ARA_EFFECT)
  220. _juce_append_target_property(file_content SUPPRESS_AU_PLIST_RESOURCE_USAGE ${target} JUCE_SUPPRESS_AU_PLIST_RESOURCE_USAGE)
  221. _juce_append_target_property(file_content HARDENED_RUNTIME_ENABLED ${target} JUCE_HARDENED_RUNTIME_ENABLED)
  222. _juce_append_target_property(file_content APP_SANDBOX_ENABLED ${target} JUCE_APP_SANDBOX_ENABLED)
  223. _juce_append_target_property(file_content APP_SANDBOX_INHERIT ${target} JUCE_APP_SANDBOX_INHERIT)
  224. _juce_append_target_property(file_content HARDENED_RUNTIME_OPTIONS ${target} JUCE_HARDENED_RUNTIME_OPTIONS)
  225. _juce_append_target_property(file_content APP_SANDBOX_OPTIONS ${target} JUCE_APP_SANDBOX_OPTIONS)
  226. _juce_append_target_property(file_content APP_SANDBOX_FILE_ACCESS_HOME_RO ${target} JUCE_APP_SANDBOX_FILE_ACCESS_HOME_RO)
  227. _juce_append_target_property(file_content APP_SANDBOX_FILE_ACCESS_HOME_RW ${target} JUCE_APP_SANDBOX_FILE_ACCESS_HOME_RW)
  228. _juce_append_target_property(file_content APP_SANDBOX_FILE_ACCESS_ABS_RO ${target} JUCE_APP_SANDBOX_FILE_ACCESS_ABS_RO)
  229. _juce_append_target_property(file_content APP_SANDBOX_FILE_ACCESS_ABS_RW ${target} JUCE_APP_SANDBOX_FILE_ACCESS_ABS_RW)
  230. _juce_append_target_property(file_content APP_GROUPS_ENABLED ${target} JUCE_APP_GROUPS_ENABLED)
  231. _juce_append_target_property(file_content APP_GROUP_IDS ${target} JUCE_APP_GROUP_IDS)
  232. _juce_append_target_property(file_content IS_PLUGIN ${target} JUCE_IS_PLUGIN)
  233. _juce_append_target_property(file_content ICLOUD_PERMISSIONS_ENABLED ${target} JUCE_ICLOUD_PERMISSIONS_ENABLED)
  234. if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
  235. _juce_append_record(file_content IS_IOS 1)
  236. else()
  237. _juce_append_record(file_content IS_IOS 0)
  238. endif()
  239. get_target_property(juce_library_code ${target} JUCE_GENERATED_SOURCES_DIRECTORY)
  240. set(info_file "${juce_library_code}/Info.txt")
  241. file(WRITE "${info_file}" "${file_content}")
  242. set_target_properties(${target} PROPERTIES JUCE_INFO_FILE "${info_file}")
  243. endfunction()
  244. # In this file, we put things that CMake is only able to divine at generate time, like preprocessor definitions.
  245. # We use the target preprocessor definitions to work out which JUCE modules should go in the JuceHeader.h.
  246. function(_juce_write_generate_time_info target)
  247. _juce_get_module_definitions(${target} OFF module_defs)
  248. _juce_append_record(defs MODULE_DEFINITIONS ${module_defs})
  249. _juce_append_target_property(defs EXECUTABLE_NAME ${target} JUCE_PRODUCT_NAME)
  250. _juce_append_target_property(defs PROJECT_NAME ${target} JUCE_PRODUCT_NAME)
  251. _juce_append_target_property(defs VERSION ${target} JUCE_VERSION)
  252. _juce_append_target_property(defs COMPANY_NAME ${target} JUCE_COMPANY_NAME)
  253. get_target_property(juce_library_code ${target} JUCE_GENERATED_SOURCES_DIRECTORY)
  254. set(defs_file "${juce_library_code}/$<CONFIG>/Defs.txt")
  255. file(GENERATE OUTPUT "${defs_file}" CONTENT "${defs}")
  256. set_target_properties(${target} PROPERTIES JUCE_DEFS_FILE "${defs_file}")
  257. endfunction()
  258. # ==================================================================================================
  259. function(juce_add_binary_data target)
  260. set(one_value_args NAMESPACE HEADER_NAME)
  261. set(multi_value_args SOURCES)
  262. cmake_parse_arguments(JUCE_ARG "" "${one_value_args}" "${multi_value_args}" ${ARGN})
  263. list(LENGTH JUCE_ARG_SOURCES num_binary_files)
  264. if(${num_binary_files} LESS 1)
  265. message(FATAL_ERROR "juce_add_binary_data must be passed at least one file to encode")
  266. endif()
  267. add_library(${target} STATIC)
  268. set(juce_binary_data_folder "${CMAKE_CURRENT_BINARY_DIR}/juce_binarydata_${target}/JuceLibraryCode")
  269. set(binary_file_names)
  270. foreach(index RANGE 1 ${num_binary_files})
  271. list(APPEND binary_file_names "${juce_binary_data_folder}/BinaryData${index}.cpp")
  272. endforeach()
  273. file(MAKE_DIRECTORY ${juce_binary_data_folder})
  274. if(NOT JUCE_ARG_NAMESPACE)
  275. set(JUCE_ARG_NAMESPACE BinaryData)
  276. endif()
  277. if(NOT JUCE_ARG_HEADER_NAME)
  278. set(JUCE_ARG_HEADER_NAME BinaryData.h)
  279. endif()
  280. list(APPEND binary_file_names "${juce_binary_data_folder}/${JUCE_ARG_HEADER_NAME}")
  281. set(newline_delimited_input)
  282. foreach(name IN LISTS JUCE_ARG_SOURCES)
  283. _juce_make_absolute_and_check(name)
  284. set(newline_delimited_input "${newline_delimited_input}${name}\n")
  285. endforeach()
  286. set(input_file_list "${juce_binary_data_folder}/input_file_list")
  287. file(WRITE "${input_file_list}" "${newline_delimited_input}")
  288. add_custom_command(OUTPUT ${binary_file_names}
  289. COMMAND juce::juceaide binarydata "${JUCE_ARG_NAMESPACE}" "${JUCE_ARG_HEADER_NAME}"
  290. ${juce_binary_data_folder} "${input_file_list}"
  291. WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
  292. DEPENDS "${input_file_list}"
  293. VERBATIM)
  294. target_sources(${target} PRIVATE "${binary_file_names}")
  295. target_include_directories(${target} INTERFACE ${juce_binary_data_folder})
  296. target_compile_features(${target} PRIVATE cxx_std_17)
  297. # This fixes an issue where Xcode is unable to find binary data during archive.
  298. if(CMAKE_GENERATOR STREQUAL "Xcode")
  299. set_target_properties(${target} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "./")
  300. endif()
  301. if(JUCE_ARG_HEADER_NAME STREQUAL "BinaryData.h")
  302. target_compile_definitions(${target} INTERFACE JUCE_TARGET_HAS_BINARY_DATA=1)
  303. endif()
  304. endfunction()
  305. # ==================================================================================================
  306. function(_juce_version_code version_in out_var)
  307. string(REGEX REPLACE "\\." ";" version_list ${version_in})
  308. list(LENGTH version_list num_version_components)
  309. set(version_major 0)
  310. set(version_minor 0)
  311. set(version_patch 0)
  312. if(num_version_components GREATER 0)
  313. list(GET version_list 0 version_major)
  314. endif()
  315. if(num_version_components GREATER 1)
  316. list(GET version_list 1 version_minor)
  317. endif()
  318. if(num_version_components GREATER 2)
  319. list(GET version_list 2 version_patch)
  320. endif()
  321. math(EXPR hex "(${version_major} << 16) + (${version_minor} << 8) + ${version_patch}"
  322. OUTPUT_FORMAT HEXADECIMAL)
  323. set(${out_var} "${hex}" PARENT_SCOPE)
  324. endfunction()
  325. function(_juce_to_char_literal str out_var help_text)
  326. string(LENGTH "${str}" string_length)
  327. if(NOT "${string_length}" EQUAL "4")
  328. message(WARNING "The ${help_text} code must contain exactly four characters, but it was set to '${str}'")
  329. endif()
  330. # Round-tripping through a file is the simplest way to convert a string to hex...
  331. string(SUBSTRING "${str}" 0 4 four_chars)
  332. string(RANDOM LENGTH 16 random_string)
  333. set(scratch_file "${CMAKE_CURRENT_BINARY_DIR}/${random_string}_ascii_conversion.txt")
  334. file(WRITE "${scratch_file}" "${four_chars}")
  335. file(READ "${scratch_file}" four_chars_hex HEX)
  336. file(REMOVE "${scratch_file}")
  337. string(SUBSTRING "${four_chars_hex}00000000" 0 8 four_chars_hex)
  338. set(${out_var} "${four_chars_hex}" PARENT_SCOPE)
  339. endfunction()
  340. # ==================================================================================================
  341. function(juce_generate_juce_header target)
  342. get_target_property(juce_library_code ${target} JUCE_GENERATED_SOURCES_DIRECTORY)
  343. if(NOT juce_library_code)
  344. message(FATAL_ERROR "Target ${target} does not have a generated sources directory. Ensure it was created with a juce_add_* function")
  345. endif()
  346. set(juce_header ${juce_library_code}/JuceHeader.h)
  347. target_sources(${target} PRIVATE ${juce_header})
  348. set(defs_file $<GENEX_EVAL:$<TARGET_PROPERTY:${target},JUCE_DEFS_FILE>>)
  349. set(extra_args)
  350. add_custom_command(OUTPUT "${juce_header}"
  351. COMMAND juce::juceaide header "${defs_file}" "${juce_header}" ${extra_args}
  352. DEPENDS "${defs_file}"
  353. VERBATIM)
  354. endfunction()
  355. # ==================================================================================================
  356. function(_juce_execute_juceaide)
  357. if(NOT TARGET juce::juceaide)
  358. message(FATAL_ERROR "The juceaide target does not exist")
  359. endif()
  360. get_target_property(juceaide_location juce::juceaide IMPORTED_LOCATION)
  361. if(NOT EXISTS "${juceaide_location}")
  362. message(FATAL_ERROR "juceaide was imported, but it doesn't exist!")
  363. endif()
  364. execute_process(COMMAND "${juceaide_location}" ${ARGN}
  365. RESULT_VARIABLE result_variable
  366. OUTPUT_VARIABLE output
  367. ERROR_VARIABLE output)
  368. if(result_variable)
  369. message(FATAL_ERROR "Running juceaide failed:\n${output}")
  370. endif()
  371. endfunction()
  372. function(_juce_set_output_name target name)
  373. if(NOT CMAKE_SYSTEM_NAME STREQUAL "Android")
  374. set_target_properties(${target} PROPERTIES
  375. OUTPUT_NAME ${name}
  376. XCODE_ATTRIBUTE_PRODUCT_NAME ${name})
  377. endif()
  378. endfunction()
  379. function(_juce_check_icon_files_exist icon_files)
  380. foreach(file IN LISTS icon_files)
  381. if(NOT EXISTS "${file}")
  382. message(FATAL_ERROR "Could not find icon file: ${file}")
  383. endif()
  384. endforeach()
  385. endfunction()
  386. function(_juce_generate_icon source_target dest_target)
  387. get_target_property(juce_library_code ${source_target} JUCE_GENERATED_SOURCES_DIRECTORY)
  388. get_target_property(juce_property_icon_big ${source_target} JUCE_ICON_BIG)
  389. get_target_property(juce_property_icon_small ${source_target} JUCE_ICON_SMALL)
  390. set(icon_args)
  391. if(juce_property_icon_big)
  392. list(APPEND icon_args "${juce_property_icon_big}")
  393. endif()
  394. if(juce_property_icon_small)
  395. list(APPEND icon_args "${juce_property_icon_small}")
  396. endif()
  397. set(generated_icon)
  398. if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  399. if(NOT icon_args)
  400. return()
  401. endif()
  402. _juce_check_icon_files_exist("${icon_args}")
  403. set(generated_icon "${juce_library_code}/Icon.icns")
  404. # To get compiled properly, we need the icon before the plist is generated!
  405. _juce_execute_juceaide(macicon "${generated_icon}" ${icon_args})
  406. set_source_files_properties(${generated_icon} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
  407. elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
  408. if(NOT icon_args)
  409. return()
  410. endif()
  411. _juce_check_icon_files_exist("${icon_args}")
  412. set(generated_icon "${juce_library_code}/icon.ico")
  413. _juce_execute_juceaide(winicon "${generated_icon}" ${icon_args})
  414. elseif(CMAKE_SYSTEM_NAME STREQUAL "iOS")
  415. get_target_property(generated_icon ${source_target} JUCE_CUSTOM_XCASSETS_FOLDER)
  416. if(icon_args AND (NOT generated_icon))
  417. _juce_check_icon_files_exist("${icon_args}")
  418. set(out_path "${juce_library_code}/${dest_target}")
  419. set(generated_icon "${out_path}/Images.xcassets")
  420. # To get compiled properly, we need iOS assets at configure time!
  421. _juce_execute_juceaide(iosassets "${out_path}" ${icon_args})
  422. endif()
  423. if(NOT generated_icon)
  424. return()
  425. endif()
  426. set_target_properties(${dest_target} PROPERTIES
  427. XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_APPICON_NAME "AppIcon")
  428. get_target_property(add_storyboard ${source_target} JUCE_SHOULD_ADD_STORYBOARD)
  429. if(NOT add_storyboard)
  430. set_target_properties(${dest_target} PROPERTIES
  431. XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME "LaunchImage")
  432. endif()
  433. endif()
  434. if(generated_icon)
  435. _juce_check_icon_files_exist("${generated_icon}")
  436. target_sources(${dest_target} PRIVATE ${generated_icon})
  437. set_target_properties(${source_target} ${dest_target} PROPERTIES
  438. JUCE_ICON_FILE "${generated_icon}"
  439. RESOURCE "${generated_icon}")
  440. endif()
  441. endfunction()
  442. function(_juce_add_xcode_entitlements source_target dest_target)
  443. get_target_property(juce_kind_string ${dest_target} JUCE_TARGET_KIND_STRING)
  444. get_target_property(input_info_file ${source_target} JUCE_INFO_FILE)
  445. get_target_property(juce_library_code ${source_target} JUCE_GENERATED_SOURCES_DIRECTORY)
  446. set(entitlements_file "${juce_library_code}/${dest_target}.entitlements")
  447. _juce_execute_juceaide(entitlements "${juce_kind_string}" "${input_info_file}" "${entitlements_file}")
  448. set_target_properties(${dest_target} PROPERTIES
  449. XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "${entitlements_file}")
  450. endfunction()
  451. function(_juce_configure_bundle source_target dest_target)
  452. _juce_generate_icon(${source_target} ${dest_target})
  453. _juce_write_configure_time_info(${source_target})
  454. if(NOT APPLE)
  455. return()
  456. endif()
  457. get_target_property(generated_icon ${source_target} JUCE_ICON_FILE)
  458. set(icon_dependency)
  459. if(generated_icon)
  460. set(icon_dependency "${generated_icon}")
  461. endif()
  462. get_target_property(juce_library_code ${source_target} JUCE_GENERATED_SOURCES_DIRECTORY)
  463. get_target_property(input_info_file ${source_target} JUCE_INFO_FILE)
  464. set(this_output_info_dir "${juce_library_code}/${dest_target}")
  465. set(this_output_pkginfo "${this_output_info_dir}/PkgInfo")
  466. set(this_output_plist "${this_output_info_dir}/Info.plist")
  467. get_target_property(juce_kind_string ${dest_target} JUCE_TARGET_KIND_STRING)
  468. _juce_execute_juceaide(plist "${juce_kind_string}" "${input_info_file}" "${this_output_plist}")
  469. set_target_properties(${dest_target} PROPERTIES
  470. BUNDLE TRUE
  471. MACOSX_BUNDLE_INFO_PLIST "${this_output_plist}")
  472. add_custom_command(OUTPUT "${this_output_pkginfo}"
  473. COMMAND juce::juceaide pkginfo "${juce_kind_string}" "${this_output_pkginfo}"
  474. VERBATIM)
  475. set(output_folder "$<TARGET_BUNDLE_CONTENT_DIR:${dest_target}>")
  476. target_sources(${dest_target} PRIVATE "${this_output_pkginfo}")
  477. set_source_files_properties("${this_output_pkginfo}" PROPERTIES
  478. HEADER_FILE_ONLY TRUE
  479. GENERATED TRUE)
  480. add_custom_command(TARGET ${dest_target} POST_BUILD
  481. COMMAND "${CMAKE_COMMAND}" -E copy "${this_output_pkginfo}" "${output_folder}"
  482. DEPENDS "${this_output_pkginfo}"
  483. VERBATIM)
  484. _juce_add_xcode_entitlements(${source_target} ${dest_target})
  485. if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
  486. get_target_property(add_storyboard ${source_target} JUCE_SHOULD_ADD_STORYBOARD)
  487. if(add_storyboard)
  488. get_target_property(storyboard_file ${source_target} JUCE_LAUNCH_STORYBOARD_FILE)
  489. if(NOT EXISTS "${storyboard_file}")
  490. message(FATAL_ERROR "Could not find storyboard file: ${storyboard_file}")
  491. endif()
  492. target_sources(${dest_target} PRIVATE "${storyboard_file}")
  493. set_property(TARGET ${dest_target} APPEND PROPERTY RESOURCE "${storyboard_file}")
  494. endif()
  495. endif()
  496. set_target_properties(${dest_target} PROPERTIES
  497. XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME
  498. "$<TARGET_PROPERTY:${source_target},JUCE_HARDENED_RUNTIME_ENABLED>"
  499. XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY
  500. "$<TARGET_PROPERTY:${source_target},JUCE_TARGETED_DEVICE_FAMILY>")
  501. if(juce_kind_string STREQUAL "AUv3 AppExtension")
  502. get_target_property(source_bundle_id ${source_target} JUCE_BUNDLE_ID)
  503. if(source_bundle_id MATCHES "\\.([^.]+)$")
  504. set_target_properties(${dest_target} PROPERTIES
  505. XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER
  506. "${source_bundle_id}.${CMAKE_MATCH_1}AUv3")
  507. else()
  508. message(FATAL_ERROR "Bundle ID should contain at least one `.`!")
  509. endif()
  510. else()
  511. set_target_properties(${dest_target} PROPERTIES
  512. XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER
  513. $<TARGET_PROPERTY:${source_target},JUCE_BUNDLE_ID>)
  514. endif()
  515. if(CMAKE_GENERATOR STREQUAL "Xcode")
  516. get_target_property(product_name ${source_target} JUCE_PRODUCT_NAME)
  517. set(install_path "$(LOCAL_APPS_DIR)")
  518. if(juce_kind_string STREQUAL "AUv3 AppExtension")
  519. set(install_path "${install_path}/${product_name}.app")
  520. if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
  521. set(install_path "${install_path}/PlugIns")
  522. else()
  523. set(install_path "${install_path}/Contents/PlugIns")
  524. endif()
  525. endif()
  526. set_target_properties(${dest_target} PROPERTIES
  527. XCODE_ATTRIBUTE_INSTALL_PATH "${install_path}"
  528. XCODE_ATTRIBUTE_SKIP_INSTALL "NO")
  529. endif()
  530. endfunction()
  531. function(_juce_add_resources_rc source_target dest_target)
  532. if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
  533. return()
  534. endif()
  535. get_target_property(juce_library_code ${source_target} JUCE_GENERATED_SOURCES_DIRECTORY)
  536. set(input_info_file "$<TARGET_PROPERTY:${source_target},JUCE_INFO_FILE>")
  537. get_target_property(generated_icon ${source_target} JUCE_ICON_FILE)
  538. set(dependency)
  539. if(generated_icon)
  540. set(dependency DEPENDS "${generated_icon}")
  541. endif()
  542. set(resource_rc_file "${juce_library_code}/resources.rc")
  543. add_custom_command(OUTPUT "${resource_rc_file}"
  544. COMMAND juce::juceaide rcfile "${input_info_file}" "${resource_rc_file}"
  545. ${dependency}
  546. VERBATIM)
  547. target_sources(${dest_target} PRIVATE "${resource_rc_file}")
  548. endfunction()
  549. function(_juce_configure_app_bundle source_target dest_target)
  550. set_target_properties(${dest_target} PROPERTIES
  551. JUCE_TARGET_KIND_STRING "App"
  552. MACOSX_BUNDLE TRUE
  553. WIN32_EXECUTABLE TRUE)
  554. _juce_add_resources_rc(${source_target} ${dest_target})
  555. if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  556. set(nib_path "${JUCE_CMAKE_UTILS_DIR}/RecentFilesMenuTemplate.nib")
  557. target_sources("${dest_target}" PRIVATE "${nib_path}")
  558. set_source_files_properties("${nib_path}" PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
  559. endif()
  560. endfunction()
  561. # ==================================================================================================
  562. function(_juce_create_windows_package source_target dest_target extension default_icon x32folder x64folder)
  563. if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
  564. return()
  565. endif()
  566. get_target_property(products_folder ${dest_target} LIBRARY_OUTPUT_DIRECTORY)
  567. set(product_name $<TARGET_PROPERTY:${source_target},JUCE_PRODUCT_NAME>)
  568. set(output_folder "${products_folder}/${product_name}.${extension}")
  569. set(is_x64 $<EQUAL:${CMAKE_SIZEOF_VOID_P},8>)
  570. set(arch_string $<IF:${is_x64},${x64folder},${x32folder}>)
  571. set_target_properties(${dest_target}
  572. PROPERTIES
  573. PDB_OUTPUT_DIRECTORY "${products_folder}"
  574. LIBRARY_OUTPUT_DIRECTORY "${output_folder}/Contents/${arch_string}")
  575. get_target_property(icon_file ${source_target} JUCE_ICON_FILE)
  576. if(NOT icon_file)
  577. set(icon_file "${default_icon}")
  578. endif()
  579. if(icon_file)
  580. set(desktop_ini "${output_folder}/desktop.ini")
  581. set(plugin_ico "${output_folder}/Plugin.ico")
  582. file(GENERATE OUTPUT "${desktop_ini}"
  583. CONTENT
  584. "[.ShellClassInfo]\nIconResource=Plugin.ico,0\nIconFile=Plugin.ico\nIconIndex=0\n")
  585. add_custom_command(TARGET ${dest_target} POST_BUILD
  586. COMMAND "${CMAKE_COMMAND}" -E copy "${icon_file}" "${plugin_ico}"
  587. COMMAND attrib +s "${desktop_ini}"
  588. COMMAND attrib +s "${output_folder}"
  589. DEPENDS "${icon_file}" "${desktop_ini}"
  590. VERBATIM)
  591. endif()
  592. endfunction()
  593. # ==================================================================================================
  594. function(_juce_add_unity_plugin_prefix_if_necessary name out_var)
  595. string(TOLOWER "${name}" lower)
  596. if(NOT lower MATCHES "^audioplugin")
  597. set(${out_var} "audioplugin_${name}" PARENT_SCOPE)
  598. else()
  599. set(${out_var} "${name}" PARENT_SCOPE)
  600. endif()
  601. endfunction()
  602. function(_juce_add_unity_script_file shared_target out_var)
  603. set(script_in "${JUCE_CMAKE_UTILS_DIR}/UnityPluginGUIScript.cs.in")
  604. get_target_property(plugin_name ${shared_target} JUCE_PLUGIN_NAME)
  605. get_target_property(plugin_vendor ${shared_target} JUCE_COMPANY_NAME)
  606. get_target_property(plugin_description ${shared_target} JUCE_DESCRIPTION)
  607. string(REGEX REPLACE " +" "_" plugin_class_name "${plugin_name}")
  608. get_target_property(juce_library_code ${shared_target} JUCE_GENERATED_SOURCES_DIRECTORY)
  609. _juce_add_unity_plugin_prefix_if_necessary("${plugin_name}" script_prefix)
  610. set(script_out "${juce_library_code}/${script_prefix}_UnityScript.cs")
  611. configure_file(${script_in} ${script_out})
  612. set(${out_var} "${script_out}" PARENT_SCOPE)
  613. endfunction()
  614. # ==================================================================================================
  615. function(_juce_copy_dir target from to)
  616. # This is a shim to make CMake copy a whole directory, rather than just
  617. # the contents of a directory
  618. add_custom_command(TARGET ${target} POST_BUILD
  619. COMMAND "${CMAKE_COMMAND}"
  620. "-Dsrc=${from}"
  621. "-Ddest=${to}"
  622. "-P" "${JUCE_CMAKE_UTILS_DIR}/copyDir.cmake"
  623. VERBATIM)
  624. endfunction()
  625. function(_juce_set_copy_properties shared_code target from to_property)
  626. get_target_property(destination "${shared_code}" "${to_property}")
  627. if(destination)
  628. set_target_properties("${target}" PROPERTIES JUCE_PLUGIN_COPY_DIR "${destination}")
  629. endif()
  630. set_target_properties("${target}" PROPERTIES JUCE_PLUGIN_ARTEFACT_FILE "${from}")
  631. endfunction()
  632. function(juce_enable_copy_plugin_step shared_code_target)
  633. get_target_property(active_targets "${shared_code_target}" JUCE_ACTIVE_PLUGIN_TARGETS)
  634. foreach(target IN LISTS active_targets)
  635. get_target_property(target_kind "${target}" JUCE_TARGET_KIND_STRING)
  636. if(target_kind STREQUAL "App")
  637. continue()
  638. endif()
  639. get_target_property(source "${target}" JUCE_PLUGIN_ARTEFACT_FILE)
  640. if(source)
  641. if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  642. add_custom_command(TARGET ${target} POST_BUILD
  643. COMMAND "${CMAKE_COMMAND}"
  644. "-Dsrc=${source}"
  645. "-P" "${JUCE_CMAKE_UTILS_DIR}/checkBundleSigning.cmake"
  646. VERBATIM)
  647. endif()
  648. get_target_property(dest "${target}" JUCE_PLUGIN_COPY_DIR)
  649. if(dest)
  650. _juce_copy_dir("${target}" "${source}" "$<GENEX_EVAL:${dest}>")
  651. else()
  652. message(WARNING "Target '${target}' requested copy but no destination is set")
  653. endif()
  654. endif()
  655. endforeach()
  656. endfunction()
  657. # ==================================================================================================
  658. function(_juce_add_lv2_manifest_helper_target)
  659. if(TARGET juce_lv2_helper)
  660. return()
  661. endif()
  662. get_target_property(module_path juce::juce_audio_plugin_client INTERFACE_JUCE_MODULE_PATH)
  663. set(source "${module_path}/juce_audio_plugin_client/LV2/juce_LV2TurtleDumpProgram.cpp")
  664. add_executable(juce_lv2_helper "${source}")
  665. add_executable(juce::juce_lv2_helper ALIAS juce_lv2_helper)
  666. target_compile_features(juce_lv2_helper PRIVATE cxx_std_14)
  667. set_target_properties(juce_lv2_helper PROPERTIES BUILD_WITH_INSTALL_RPATH ON)
  668. target_link_libraries(juce_lv2_helper PRIVATE ${CMAKE_DL_LIBS})
  669. endfunction()
  670. # ==================================================================================================
  671. function(_juce_set_plugin_target_properties shared_code_target kind)
  672. set(target_name ${shared_code_target}_${kind})
  673. set_target_properties(${target_name} PROPERTIES
  674. ARCHIVE_OUTPUT_DIRECTORY "$<GENEX_EVAL:$<TARGET_PROPERTY:${shared_code_target},ARCHIVE_OUTPUT_DIRECTORY>>/${kind}"
  675. LIBRARY_OUTPUT_DIRECTORY "$<GENEX_EVAL:$<TARGET_PROPERTY:${shared_code_target},LIBRARY_OUTPUT_DIRECTORY>>/${kind}"
  676. RUNTIME_OUTPUT_DIRECTORY "$<GENEX_EVAL:$<TARGET_PROPERTY:${shared_code_target},RUNTIME_OUTPUT_DIRECTORY>>/${kind}")
  677. get_target_property(products_folder ${target_name} LIBRARY_OUTPUT_DIRECTORY)
  678. set(product_name $<TARGET_PROPERTY:${shared_code_target},JUCE_PRODUCT_NAME>)
  679. if(kind STREQUAL "Standalone")
  680. get_target_property(is_bundle "${target_name}" BUNDLE)
  681. if(is_bundle)
  682. set_target_properties("${target_name}" PROPERTIES JUCE_PLUGIN_ARTEFACT_FILE "$<TARGET_BUNDLE_DIR:${target_name}>")
  683. else()
  684. set_target_properties("${target_name}" PROPERTIES JUCE_PLUGIN_ARTEFACT_FILE "$<TARGET_FILE:${target_name}>")
  685. endif()
  686. elseif(kind STREQUAL "VST3")
  687. set_target_properties(${target_name} PROPERTIES
  688. BUNDLE_EXTENSION vst3
  689. PREFIX ""
  690. SUFFIX .vst3
  691. BUNDLE TRUE
  692. XCODE_ATTRIBUTE_WRAPPER_EXTENSION vst3
  693. XCODE_ATTRIBUTE_LIBRARY_STYLE Bundle
  694. XCODE_ATTRIBUTE_GENERATE_PKGINFO_FILE YES)
  695. _juce_create_windows_package(${shared_code_target} ${target_name} vst3 "" x86-win x86_64-win)
  696. set(output_path "${products_folder}/${product_name}.vst3")
  697. if((CMAKE_SYSTEM_NAME STREQUAL "Linux") OR (CMAKE_SYSTEM_NAME MATCHES ".*BSD"))
  698. set_target_properties(${target_name} PROPERTIES
  699. SUFFIX .so
  700. LIBRARY_OUTPUT_DIRECTORY "${output_path}/Contents/${JUCE_TARGET_ARCHITECTURE}-linux")
  701. endif()
  702. _juce_set_copy_properties(${shared_code_target} ${target_name} "${output_path}" JUCE_VST3_COPY_DIR)
  703. elseif(kind STREQUAL "VST")
  704. set_target_properties(${target_name} PROPERTIES
  705. BUNDLE_EXTENSION vst
  706. BUNDLE TRUE
  707. XCODE_ATTRIBUTE_WRAPPER_EXTENSION vst
  708. XCODE_ATTRIBUTE_LIBRARY_STYLE Bundle
  709. XCODE_ATTRIBUTE_GENERATE_PKGINFO_FILE YES)
  710. set(output_path "$<TARGET_FILE:${target_name}>")
  711. if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  712. set(output_path "$<TARGET_BUNDLE_DIR:${target_name}>")
  713. endif()
  714. _juce_set_copy_properties(${shared_code_target} ${target_name} "${output_path}" JUCE_VST_COPY_DIR)
  715. elseif(kind STREQUAL "AU")
  716. set_target_properties(${target_name} PROPERTIES
  717. BUNDLE_EXTENSION component
  718. XCODE_ATTRIBUTE_WRAPPER_EXTENSION component
  719. BUNDLE TRUE
  720. XCODE_ATTRIBUTE_LIBRARY_STYLE Bundle
  721. XCODE_ATTRIBUTE_GENERATE_PKGINFO_FILE YES)
  722. set(output_path "$<TARGET_BUNDLE_DIR:${target_name}>")
  723. _juce_set_copy_properties(${shared_code_target} ${target_name} "${output_path}" JUCE_AU_COPY_DIR)
  724. elseif(kind STREQUAL "AUv3")
  725. set_target_properties(${target_name} PROPERTIES
  726. XCODE_PRODUCT_TYPE "com.apple.product-type.app-extension"
  727. BUNDLE_EXTENSION appex
  728. XCODE_ATTRIBUTE_WRAPPER_EXTENSION appex
  729. XCODE_ATTRIBUTE_GENERATE_PKGINFO_FILE YES)
  730. elseif(kind STREQUAL "AAX")
  731. set_target_properties(${target_name} PROPERTIES
  732. BUNDLE_EXTENSION aaxplugin
  733. PREFIX ""
  734. SUFFIX .aaxplugin
  735. XCODE_ATTRIBUTE_WRAPPER_EXTENSION aaxplugin
  736. BUNDLE TRUE
  737. XCODE_ATTRIBUTE_LIBRARY_STYLE Bundle
  738. XCODE_ATTRIBUTE_GENERATE_PKGINFO_FILE YES)
  739. get_target_property(default_icon juce_aax_sdk INTERFACE_JUCE_AAX_DEFAULT_ICON)
  740. _juce_create_windows_package(${shared_code_target} ${target_name} aaxplugin "${default_icon}" Win32 x64)
  741. set(output_path "${products_folder}/${product_name}.aaxplugin")
  742. _juce_set_copy_properties(${shared_code_target} ${target_name} "${output_path}" JUCE_AAX_COPY_DIR)
  743. elseif(kind STREQUAL "Unity")
  744. set_target_properties(${target_name} PROPERTIES
  745. BUNDLE_EXTENSION bundle
  746. XCODE_ATTRIBUTE_WRAPPER_EXTENSION bundle
  747. BUNDLE TRUE
  748. XCODE_ATTRIBUTE_LIBRARY_STYLE Bundle
  749. XCODE_ATTRIBUTE_GENERATE_PKGINFO_FILE YES)
  750. _juce_add_unity_script_file(${shared_code_target} script_file)
  751. target_sources(${target_name} PRIVATE "${script_file}")
  752. set_source_files_properties("${script_file}" PROPERTIES
  753. GENERATED TRUE
  754. MACOSX_PACKAGE_LOCATION Resources)
  755. if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  756. set(output_path "$<TARGET_BUNDLE_DIR:${target_name}>")
  757. _juce_set_copy_properties(${shared_code_target} ${target_name} "${output_path}" JUCE_UNITY_COPY_DIR)
  758. else()
  759. # On windows and linux, the gui script needs to be copied next to the unity output
  760. add_custom_command(TARGET ${target_name} POST_BUILD
  761. COMMAND "${CMAKE_COMMAND}" -E copy "${script_file}" "${products_folder}"
  762. DEPENDS "${script_file}"
  763. VERBATIM)
  764. _juce_set_copy_properties(${shared_code_target}
  765. ${target_name}
  766. "$<TARGET_FILE:${target_name}>"
  767. JUCE_UNITY_COPY_DIR)
  768. _juce_set_copy_properties(${shared_code_target}
  769. ${target_name}
  770. "${script_file}"
  771. JUCE_UNITY_COPY_DIR)
  772. endif()
  773. elseif(kind STREQUAL "LV2")
  774. set_target_properties(${target_name} PROPERTIES BUNDLE FALSE)
  775. get_target_property(JUCE_LV2URI "${shared_code_target}" JUCE_LV2URI)
  776. if(NOT JUCE_LV2URI MATCHES "https?://.*")
  777. message(WARNING
  778. "LV2URI should be well-formed with an 'http' prefix. "
  779. "Check the LV2URI argument to juce_add_plugin.")
  780. endif()
  781. set(source_header "${JUCE_CMAKE_UTILS_DIR}/JuceLV2Defines.h.in")
  782. get_target_property(juce_library_code "${shared_code_target}" JUCE_GENERATED_SOURCES_DIRECTORY)
  783. configure_file("${source_header}" "${juce_library_code}/JuceLV2Defines.h")
  784. set(output_path "${products_folder}/${product_name}.lv2")
  785. set_target_properties(${target_name} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${output_path}")
  786. _juce_add_lv2_manifest_helper_target()
  787. add_custom_command(TARGET ${target_name} POST_BUILD
  788. COMMAND juce_lv2_helper "$<TARGET_FILE:${target_name}>"
  789. VERBATIM)
  790. _juce_set_copy_properties(${shared_code_target} ${target_name} "${output_path}" JUCE_LV2_COPY_DIR)
  791. endif()
  792. endfunction()
  793. # Place plugin wrapper targets alongside the shared code target in IDEs
  794. function(_juce_set_plugin_folder_property shared_target wrapper_target)
  795. get_target_property(folder_to_use "${shared_target}" FOLDER)
  796. if(folder_to_use STREQUAL "folder_to_use-NOTFOUND")
  797. set_target_properties("${shared_target}" PROPERTIES FOLDER "${shared_target}")
  798. elseif(NOT folder_to_use MATCHES ".*${shared_target}$")
  799. set_target_properties("${shared_target}" PROPERTIES FOLDER "${folder_to_use}/${shared_target}")
  800. endif()
  801. get_target_property(folder_to_use "${shared_target}" FOLDER)
  802. set_target_properties("${wrapper_target}" PROPERTIES FOLDER "${folder_to_use}")
  803. endfunction()
  804. # Convert the cmake plugin kind ids to strings understood by ProjectType::Target::typeFromName
  805. function(_juce_get_plugin_kind_name kind out_var)
  806. if(kind STREQUAL "AU")
  807. set(${out_var} "AU" PARENT_SCOPE)
  808. elseif(kind STREQUAL "AUv3")
  809. set(${out_var} "AUv3 AppExtension" PARENT_SCOPE)
  810. elseif(kind STREQUAL "AAX")
  811. set(${out_var} "AAX" PARENT_SCOPE)
  812. elseif(kind STREQUAL "LV2")
  813. set(${out_var} "LV2" PARENT_SCOPE)
  814. elseif(kind STREQUAL "Standalone")
  815. set(${out_var} "Standalone Plugin" PARENT_SCOPE)
  816. elseif(kind STREQUAL "Unity")
  817. set(${out_var} "Unity Plugin" PARENT_SCOPE)
  818. elseif(kind STREQUAL "VST")
  819. set(${out_var} "VST" PARENT_SCOPE)
  820. elseif(kind STREQUAL "VST3")
  821. set(${out_var} "VST3" PARENT_SCOPE)
  822. endif()
  823. endfunction()
  824. function(_juce_link_plugin_wrapper shared_code_target kind)
  825. set(target_name ${shared_code_target}_${kind})
  826. if(CMAKE_SYSTEM_NAME STREQUAL "Android")
  827. add_library(${target_name} SHARED)
  828. elseif((kind STREQUAL "Standalone") OR (kind STREQUAL "AUv3"))
  829. add_executable(${target_name} WIN32 MACOSX_BUNDLE)
  830. else()
  831. add_library(${target_name} MODULE)
  832. endif()
  833. if((CMAKE_SYSTEM_NAME STREQUAL "Linux") OR (CMAKE_SYSTEM_NAME MATCHES ".*BSD"))
  834. target_link_options(${target_name} PRIVATE "-Wl,--no-undefined")
  835. endif()
  836. # We re-export the shared code's private include dirs, because the wrapper targets need to
  837. # see the module headers. We don't just link publicly, because that would introduce
  838. # conflicting macro definitions.
  839. target_include_directories(${target_name} PRIVATE
  840. $<TARGET_PROPERTY:${shared_code_target},INCLUDE_DIRECTORIES>)
  841. target_link_libraries(${target_name} PRIVATE
  842. ${shared_code_target}
  843. juce::juce_audio_plugin_client_${kind})
  844. _juce_set_output_name(${target_name} $<TARGET_PROPERTY:${shared_code_target},JUCE_PRODUCT_NAME>)
  845. _juce_set_plugin_folder_property("${shared_code_target}" "${target_name}")
  846. _juce_get_plugin_kind_name(${kind} juce_kind_string)
  847. set_target_properties(${target_name} PROPERTIES
  848. XCODE_ATTRIBUTE_CLANG_LINK_OBJC_RUNTIME NO
  849. XCODE_ATTRIBUTE_COMBINE_HIDPI_IMAGES YES
  850. POSITION_INDEPENDENT_CODE TRUE
  851. VISIBILITY_INLINES_HIDDEN TRUE
  852. C_VISIBILITY_PRESET hidden
  853. CXX_VISIBILITY_PRESET hidden
  854. JUCE_TARGET_KIND_STRING "${juce_kind_string}")
  855. # Under the Xcode generator, POST_BUILD commands (including the plugin copy step) run before
  856. # signing, but M1 macs will only load signed binaries. Setting "adhoc_codesign" forces the
  857. # linker to sign bundles, so that they can be loaded even if they are copied before the "real"
  858. # signing step. See issue 21854 on the CMake Gitlab repo.
  859. if("${CMAKE_GENERATOR};${CMAKE_SYSTEM_NAME};${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Xcode;Darwin;arm64")
  860. target_link_options(${target_name} PRIVATE LINKER:-adhoc_codesign)
  861. endif()
  862. add_dependencies(${shared_code_target}_All ${target_name})
  863. if(NOT kind STREQUAL "LV2")
  864. _juce_configure_bundle(${shared_code_target} ${target_name})
  865. endif()
  866. _juce_set_plugin_target_properties(${shared_code_target} ${kind})
  867. endfunction()
  868. # ==================================================================================================
  869. function(_juce_get_vst3_category_string target out_var)
  870. get_target_property(vst3_categories ${target} JUCE_VST3_CATEGORIES)
  871. if((NOT Fx IN_LIST vst3_categories) AND (NOT Instrument IN_LIST vst3_categories))
  872. get_target_property(is_synth ${target} JUCE_IS_SYNTH)
  873. if(is_synth)
  874. set(first_type Instrument)
  875. else()
  876. set(first_type Fx)
  877. endif()
  878. list(INSERT vst3_categories 0 ${first_type})
  879. else()
  880. if(Instrument IN_LIST vst3_categories)
  881. list(REMOVE_ITEM vst3_categories Instrument)
  882. list(INSERT vst3_categories 0 Instrument)
  883. endif()
  884. if(Fx IN_LIST vst3_categories)
  885. list(REMOVE_ITEM vst3_categories Fx)
  886. list(INSERT vst3_categories 0 Fx)
  887. endif()
  888. endif()
  889. string(REGEX REPLACE ";" "|" result "${vst3_categories}")
  890. set(${out_var} ${result} PARENT_SCOPE)
  891. endfunction()
  892. function(_juce_configure_plugin_targets target)
  893. _juce_set_output_name(${target} $<TARGET_PROPERTY:${target},JUCE_PRODUCT_NAME>_SharedCode)
  894. target_link_libraries(${target} PRIVATE juce::juce_audio_plugin_client_utils)
  895. get_target_property(enabled_formats ${target} JUCE_FORMATS)
  896. set(active_formats)
  897. _juce_get_platform_plugin_kinds(plugin_kinds)
  898. foreach(kind IN LISTS plugin_kinds)
  899. if(kind IN_LIST enabled_formats)
  900. list(APPEND active_formats "${kind}")
  901. endif()
  902. endforeach()
  903. if((VST IN_LIST active_formats) AND (NOT TARGET juce_vst2_sdk))
  904. message(FATAL_ERROR "Use juce_set_vst2_sdk_path to set up the VST sdk before adding VST targets")
  905. elseif((AAX IN_LIST active_formats) AND (NOT TARGET juce_aax_sdk))
  906. message(FATAL_ERROR "Use juce_set_aax_sdk_path to set up the AAX sdk before adding AAX targets")
  907. endif()
  908. _juce_add_standard_defs(${target})
  909. _juce_add_plugin_definitions(${target} PRIVATE ${active_formats})
  910. # The plugin wrappers need to know what other modules are available, especially
  911. # juce_audio_utils and juce_gui_basics. We achieve this by searching for
  912. # JUCE_MODULE_AVAILABLE_ private compile definitions, and reexporting them in
  913. # the interface compile definitions.
  914. _juce_get_module_definitions(${target} ON enabled_modules)
  915. target_compile_definitions(${target} INTERFACE ${enabled_modules})
  916. target_compile_definitions(${target} PRIVATE JUCE_SHARED_CODE=1)
  917. get_target_property(project_version_string ${target} JUCE_VERSION)
  918. _juce_version_code(${project_version_string} project_version_hex)
  919. get_target_property(project_manufacturer_code ${target} JUCE_PLUGIN_MANUFACTURER_CODE)
  920. get_target_property(project_plugin_code ${target} JUCE_PLUGIN_CODE)
  921. get_target_property(use_legacy_compatibility_plugin_code ${target} JUCE_USE_LEGACY_COMPATIBILITY_PLUGIN_CODE)
  922. if(use_legacy_compatibility_plugin_code)
  923. set(project_manufacturer_code "proj")
  924. endif()
  925. _juce_to_char_literal(${project_manufacturer_code} project_manufacturer_code "plugin manufacturer")
  926. _juce_to_char_literal(${project_plugin_code} project_plugin_code "plugin")
  927. _juce_get_vst3_category_string(${target} vst3_category_string)
  928. target_compile_definitions(${target} PUBLIC
  929. JUCE_STANDALONE_APPLICATION=JucePlugin_Build_Standalone
  930. JucePlugin_IsSynth=$<BOOL:$<TARGET_PROPERTY:${target},JUCE_IS_SYNTH>>
  931. JucePlugin_ManufacturerCode=0x${project_manufacturer_code}
  932. JucePlugin_Manufacturer="$<TARGET_PROPERTY:${target},JUCE_COMPANY_NAME>"
  933. JucePlugin_ManufacturerWebsite="$<TARGET_PROPERTY:${target},JUCE_COMPANY_WEBSITE>"
  934. JucePlugin_ManufacturerEmail="$<TARGET_PROPERTY:${target},JUCE_COMPANY_EMAIL>"
  935. JucePlugin_PluginCode=0x${project_plugin_code}
  936. JucePlugin_ProducesMidiOutput=$<BOOL:$<TARGET_PROPERTY:${target},JUCE_NEEDS_MIDI_OUTPUT>>
  937. JucePlugin_IsMidiEffect=$<BOOL:$<TARGET_PROPERTY:${target},JUCE_IS_MIDI_EFFECT>>
  938. JucePlugin_WantsMidiInput=$<BOOL:$<TARGET_PROPERTY:${target},JUCE_NEEDS_MIDI_INPUT>>
  939. JucePlugin_EditorRequiresKeyboardFocus=$<BOOL:$<TARGET_PROPERTY:${target},JUCE_EDITOR_WANTS_KEYBOARD_FOCUS>>
  940. JucePlugin_Name="$<TARGET_PROPERTY:${target},JUCE_PLUGIN_NAME>"
  941. JucePlugin_Desc="$<TARGET_PROPERTY:${target},JUCE_DESCRIPTION>"
  942. JucePlugin_Version=${project_version_string}
  943. JucePlugin_VersionString="${project_version_string}"
  944. JucePlugin_VersionCode=${project_version_hex}
  945. JucePlugin_VSTUniqueID=JucePlugin_PluginCode
  946. JucePlugin_VSTCategory=$<TARGET_PROPERTY:${target},JUCE_VST2_CATEGORY>
  947. JucePlugin_Vst3Category="${vst3_category_string}"
  948. JucePlugin_AUMainType=$<TARGET_PROPERTY:${target},JUCE_AU_MAIN_TYPE_CODE>
  949. JucePlugin_AUSubType=JucePlugin_PluginCode
  950. JucePlugin_AUExportPrefix=$<TARGET_PROPERTY:${target},JUCE_AU_EXPORT_PREFIX>
  951. JucePlugin_AUExportPrefixQuoted="$<TARGET_PROPERTY:${target},JUCE_AU_EXPORT_PREFIX>"
  952. JucePlugin_AUManufacturerCode=JucePlugin_ManufacturerCode
  953. JucePlugin_CFBundleIdentifier=$<TARGET_PROPERTY:${target},JUCE_BUNDLE_ID>
  954. JucePlugin_AAXIdentifier=$<TARGET_PROPERTY:${target},JUCE_AAX_IDENTIFIER>
  955. JucePlugin_AAXManufacturerCode=JucePlugin_ManufacturerCode
  956. JucePlugin_AAXProductId=JucePlugin_PluginCode
  957. JucePlugin_AAXCategory=$<TARGET_PROPERTY:${target},JUCE_AAX_CATEGORY>
  958. JucePlugin_AAXDisableBypass=$<BOOL:$<TARGET_PROPERTY:${target},JUCE_DISABLE_AAX_BYPASS>>
  959. JucePlugin_AAXDisableMultiMono=$<BOOL:$<TARGET_PROPERTY:${target},JUCE_DISABLE_AAX_MULTI_MONO>>
  960. JucePlugin_VSTNumMidiInputs=$<TARGET_PROPERTY:${target},JUCE_VST_NUM_MIDI_INS>
  961. JucePlugin_VSTNumMidiOutputs=$<TARGET_PROPERTY:${target},JUCE_VST_NUM_MIDI_OUTS>
  962. JucePlugin_Enable_ARA=$<BOOL:$<TARGET_PROPERTY:${target},JUCE_IS_ARA_EFFECT>>
  963. JucePlugin_ARAFactoryID=$<TARGET_PROPERTY:${target},JUCE_ARA_FACTORY_ID>
  964. JucePlugin_ARADocumentArchiveID=$<TARGET_PROPERTY:${target},JUCE_ARA_DOCUMENT_ARCHIVE_ID>
  965. JucePlugin_ARACompatibleArchiveIDs=$<TARGET_PROPERTY:${target},JUCE_ARA_COMPATIBLE_ARCHIVE_IDS>
  966. JucePlugin_ARAContentTypes=$<TARGET_PROPERTY:${target},JUCE_ARA_ANALYSIS_TYPES>
  967. JucePlugin_ARATransformationFlags=$<TARGET_PROPERTY:${target},JUCE_ARA_TRANSFORMATION_FLAGS>)
  968. set_target_properties(${target} PROPERTIES
  969. POSITION_INDEPENDENT_CODE TRUE
  970. INTERFACE_POSITION_INDEPENDENT_CODE TRUE
  971. VISIBILITY_INLINES_HIDDEN TRUE
  972. C_VISIBILITY_PRESET hidden
  973. CXX_VISIBILITY_PRESET hidden)
  974. # A convenience target for building all plugin variations at once
  975. add_custom_target(${target}_All)
  976. _juce_set_plugin_folder_property("${target}" "${target}_All")
  977. foreach(kind IN LISTS active_formats)
  978. _juce_link_plugin_wrapper(${target} ${kind})
  979. if(TARGET ${target}_${kind})
  980. list(APPEND active_plugin_targets ${target}_${kind})
  981. endif()
  982. endforeach()
  983. set_target_properties(${target} PROPERTIES JUCE_ACTIVE_PLUGIN_TARGETS "${active_plugin_targets}")
  984. if(TARGET ${target}_Standalone)
  985. _juce_configure_app_bundle(${target} ${target}_Standalone)
  986. endif()
  987. if(TARGET ${target}_AAX)
  988. target_link_libraries(${target}_AAX PRIVATE juce_aax_sdk)
  989. endif()
  990. if((TARGET ${target}_AUv3) AND (TARGET ${target}_Standalone))
  991. add_dependencies(${target}_Standalone ${target}_AUv3)
  992. # Copy the AUv3 into the Standalone app bundle
  993. _juce_copy_dir(${target}_Standalone
  994. "$<TARGET_BUNDLE_DIR:${target}_AUv3>"
  995. "$<TARGET_BUNDLE_CONTENT_DIR:${target}_Standalone>/PlugIns")
  996. endif()
  997. get_target_property(wants_copy "${target}" JUCE_COPY_PLUGIN_AFTER_BUILD)
  998. if(wants_copy)
  999. juce_enable_copy_plugin_step("${target}")
  1000. endif()
  1001. endfunction()
  1002. # ==================================================================================================
  1003. function(_juce_set_generic_property_if_not_set target property)
  1004. list(LENGTH ARGN num_extra_args)
  1005. if(num_extra_args EQUAL 0)
  1006. return()
  1007. endif()
  1008. set(existing_property)
  1009. get_target_property(existing_property ${target} ${property})
  1010. if(existing_property STREQUAL "existing_property-NOTFOUND")
  1011. set_target_properties(${target} PROPERTIES ${property} "${ARGN}")
  1012. endif()
  1013. endfunction()
  1014. function(_juce_set_property_if_not_set target property)
  1015. _juce_set_generic_property_if_not_set(${target} JUCE_${property} ${ARGN})
  1016. endfunction()
  1017. function(_juce_make_valid_4cc out_var)
  1018. string(RANDOM LENGTH 1 ALPHABET "ABCDEFGHIJKLMNOPQRSTUVWXYZ" head)
  1019. string(RANDOM LENGTH 3 ALPHABET "abcdefghijklmnopqrstuvwxyz" tail)
  1020. set(${out_var} "${head}${tail}" PARENT_SCOPE)
  1021. endfunction()
  1022. # This function adds some default properties that plugin targets expect to be
  1023. # set, in order to generate the correct compile definitions.
  1024. function(_juce_set_fallback_properties target)
  1025. _juce_set_property_if_not_set(${target} PRODUCT_NAME ${target})
  1026. get_target_property(output_name ${target} JUCE_PRODUCT_NAME)
  1027. _juce_set_property_if_not_set(${target} DESCRIPTION "${output_name}")
  1028. _juce_set_property_if_not_set(${target} PLUGIN_NAME "${output_name}")
  1029. get_target_property(real_company_name ${target} JUCE_COMPANY_NAME)
  1030. _juce_set_property_if_not_set(${target} BUNDLE_ID "com.${real_company_name}.${target}")
  1031. _juce_set_property_if_not_set(${target} VERSION ${PROJECT_VERSION})
  1032. get_target_property(final_version ${target} JUCE_VERSION)
  1033. if(NOT final_version)
  1034. message(FATAL_ERROR "Target ${target} must have its VERSION argument set, or must be part of a project with a PROJECT_VERSION")
  1035. endif()
  1036. _juce_set_property_if_not_set(${target} BUILD_VERSION "${final_version}")
  1037. get_target_property(custom_xcassets ${target} JUCE_CUSTOM_XCASSETS_FOLDER)
  1038. get_target_property(custom_storyboard ${target} JUCE_LAUNCH_STORYBOARD_FILE)
  1039. set(needs_storyboard TRUE)
  1040. if((NOT custom_storyboard) AND custom_xcassets AND (EXISTS "${custom_xcassets}/LaunchImage.launchimage"))
  1041. set(needs_storyboard FALSE)
  1042. endif()
  1043. set_target_properties(${target} PROPERTIES JUCE_SHOULD_ADD_STORYBOARD ${needs_storyboard})
  1044. _juce_set_property_if_not_set(${target} IPHONE_SCREEN_ORIENTATIONS
  1045. UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft
  1046. UIInterfaceOrientationLandscapeRight)
  1047. _juce_set_property_if_not_set(${target} IPAD_SCREEN_ORIENTATIONS
  1048. UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft
  1049. UIInterfaceOrientationLandscapeRight)
  1050. _juce_set_property_if_not_set(${target}
  1051. LAUNCH_STORYBOARD_FILE "${JUCE_CMAKE_UTILS_DIR}/LaunchScreen.storyboard")
  1052. _juce_set_property_if_not_set(${target} PLUGIN_MANUFACTURER_CODE "Manu")
  1053. # The plugin code will change on each run, unless you specify one manually!
  1054. _juce_make_valid_4cc(random_code)
  1055. _juce_set_property_if_not_set(${target} PLUGIN_CODE ${random_code})
  1056. _juce_set_property_if_not_set(${target} IS_SYNTH FALSE)
  1057. _juce_set_property_if_not_set(${target} NEEDS_MIDI_INPUT FALSE)
  1058. _juce_set_property_if_not_set(${target} NEEDS_MIDI_OUTPUT FALSE)
  1059. _juce_set_property_if_not_set(${target} IS_MIDI_EFFECT FALSE)
  1060. _juce_set_property_if_not_set(${target} EDITOR_WANTS_KEYBOARD_FOCUS FALSE)
  1061. _juce_set_property_if_not_set(${target} DISABLE_AAX_BYPASS FALSE)
  1062. _juce_set_property_if_not_set(${target} DISABLE_AAX_MULTI_MONO FALSE)
  1063. _juce_set_property_if_not_set(${target} PLUGINHOST_AU FALSE)
  1064. get_target_property(bundle_id ${target} JUCE_BUNDLE_ID)
  1065. _juce_set_property_if_not_set(${target} AAX_IDENTIFIER ${bundle_id})
  1066. _juce_set_property_if_not_set(${target} VST_NUM_MIDI_INS 16)
  1067. _juce_set_property_if_not_set(${target} VST_NUM_MIDI_OUTS 16)
  1068. _juce_set_property_if_not_set(${target} AU_SANDBOX_SAFE FALSE)
  1069. _juce_set_property_if_not_set(${target} SUPPRESS_AU_PLIST_RESOURCE_USAGE FALSE)
  1070. _juce_set_property_if_not_set(${target} HARDENED_RUNTIME_ENABLED NO)
  1071. _juce_set_property_if_not_set(${target} APP_SANDBOX_ENABLED NO)
  1072. _juce_set_property_if_not_set(${target} APP_SANDBOX_INHERIT NO)
  1073. get_target_property(is_synth ${target} JUCE_IS_SYNTH)
  1074. # VST3_CATEGORIES
  1075. if(is_synth)
  1076. _juce_set_property_if_not_set(${target} VST3_CATEGORIES Instrument Synth)
  1077. else()
  1078. _juce_set_property_if_not_set(${target} VST3_CATEGORIES Fx)
  1079. endif()
  1080. # VST2_CATEGORY
  1081. if(is_synth)
  1082. _juce_set_property_if_not_set(${target} VST2_CATEGORY kPlugCategSynth)
  1083. else()
  1084. _juce_set_property_if_not_set(${target} VST2_CATEGORY kPlugCategEffect)
  1085. endif()
  1086. get_target_property(is_midi_effect ${target} JUCE_IS_MIDI_EFFECT)
  1087. get_target_property(needs_midi_input ${target} JUCE_NEEDS_MIDI_INPUT)
  1088. # AU MAIN TYPE
  1089. if(is_midi_effect)
  1090. _juce_set_property_if_not_set(${target} AU_MAIN_TYPE kAudioUnitType_MIDIProcessor)
  1091. elseif(is_synth)
  1092. _juce_set_property_if_not_set(${target} AU_MAIN_TYPE kAudioUnitType_MusicDevice)
  1093. elseif(needs_midi_input)
  1094. _juce_set_property_if_not_set(${target} AU_MAIN_TYPE kAudioUnitType_MusicEffect)
  1095. else()
  1096. _juce_set_property_if_not_set(${target} AU_MAIN_TYPE kAudioUnitType_Effect)
  1097. endif()
  1098. _juce_set_property_if_not_set(${target} TARGETED_DEVICE_FAMILY "1,2")
  1099. set(au_category_codes
  1100. 'aufx'
  1101. 'aufc'
  1102. 'augn'
  1103. 'aumi'
  1104. 'aumx'
  1105. 'aumu'
  1106. 'aumf'
  1107. 'auol'
  1108. 'auou'
  1109. 'aupn')
  1110. set(au_category_strings
  1111. kAudioUnitType_Effect
  1112. kAudioUnitType_FormatConverter
  1113. kAudioUnitType_Generator
  1114. kAudioUnitType_MIDIProcessor
  1115. kAudioUnitType_Mixer
  1116. kAudioUnitType_MusicDevice
  1117. kAudioUnitType_MusicEffect
  1118. kAudioUnitType_OfflineEffect
  1119. kAudioUnitType_Output
  1120. kAudioUnitType_Panner)
  1121. # AU export prefix
  1122. string(MAKE_C_IDENTIFIER ${output_name} au_prefix)
  1123. set(au_prefix "${au_prefix}AU")
  1124. _juce_set_property_if_not_set(${target} AU_EXPORT_PREFIX ${au_prefix})
  1125. # Find appropriate AU category code
  1126. get_target_property(actual_au_category ${target} JUCE_AU_MAIN_TYPE)
  1127. list(FIND au_category_strings ${actual_au_category} au_index)
  1128. if(au_index GREATER_EQUAL 0)
  1129. list(GET au_category_codes ${au_index} au_code_representation)
  1130. set_target_properties(${target} PROPERTIES JUCE_AU_MAIN_TYPE_CODE ${au_code_representation})
  1131. endif()
  1132. # AAX category
  1133. # The order of these strings is important, as the index of each string
  1134. # will be used to set an appropriate bit in the category bitfield.
  1135. set(aax_category_strings
  1136. ePlugInCategory_None
  1137. ePlugInCategory_EQ
  1138. ePlugInCategory_Dynamics
  1139. ePlugInCategory_PitchShift
  1140. ePlugInCategory_Reverb
  1141. ePlugInCategory_Delay
  1142. ePlugInCategory_Modulation
  1143. ePlugInCategory_Harmonic
  1144. ePlugInCategory_NoiseReduction
  1145. ePlugInCategory_Dither
  1146. ePlugInCategory_SoundField
  1147. ePlugInCategory_HWGenerators
  1148. ePlugInCategory_SWGenerators
  1149. ePlugInCategory_WrappedPlugin
  1150. ePlugInCategory_Effect)
  1151. if(is_synth)
  1152. set(default_aax_category ePlugInCategory_SWGenerators)
  1153. else()
  1154. set(default_aax_category ePlugInCategory_None)
  1155. endif()
  1156. _juce_set_property_if_not_set(${target} AAX_CATEGORY ${default_aax_category})
  1157. # Replace AAX category string with its integral representation
  1158. get_target_property(actual_aax_category ${target} JUCE_AAX_CATEGORY)
  1159. set(aax_category_int "")
  1160. foreach(category_string IN LISTS actual_aax_category)
  1161. list(FIND aax_category_strings ${category_string} aax_index)
  1162. if(aax_index GREATER_EQUAL 0)
  1163. if(aax_index EQUAL 0)
  1164. set(aax_category_bit 0)
  1165. else()
  1166. set(aax_category_bit "1 << (${aax_index} - 1)")
  1167. endif()
  1168. if(aax_category_int STREQUAL "")
  1169. set(aax_category_int 0)
  1170. endif()
  1171. math(EXPR aax_category_int "${aax_category_int} | (${aax_category_bit})")
  1172. endif()
  1173. endforeach()
  1174. if(NOT aax_category_int STREQUAL "")
  1175. set_target_properties(${target} PROPERTIES JUCE_AAX_CATEGORY ${aax_category_int})
  1176. endif()
  1177. # Ensure this matches the Projucer implementation
  1178. get_target_property(company_website ${target} JUCE_COMPANY_WEBSITE)
  1179. get_target_property(plugin_name ${target} JUCE_PLUGIN_NAME)
  1180. string(MAKE_C_IDENTIFIER "${plugin_name}" plugin_name_sanitised)
  1181. _juce_set_property_if_not_set(${target} LV2URI "${company_website}/plugins/${plugin_name_sanitised}")
  1182. # ARA configuration
  1183. # Analysis types
  1184. set(ara_analysis_type_strings
  1185. kARAContentTypeNotes
  1186. kARAContentTypeTempoEntries
  1187. kARAContentTypeBarSignatures
  1188. kARAContentTypeStaticTuning
  1189. kARAContentTypeKeySignatures
  1190. kARAContentTypeSheetChords)
  1191. get_target_property(actual_ara_analysis_types ${target} JUCE_ARA_ANALYSIS_TYPES)
  1192. set(ara_analysis_types_int "")
  1193. foreach(category_string IN LISTS actual_ara_analysis_types)
  1194. list(FIND ara_analysis_type_strings ${category_string} ara_index)
  1195. if(ara_index GREATER_EQUAL 0)
  1196. set(ara_analysis_types_bit "1 << ${ara_index}")
  1197. if(ara_analysis_types_int STREQUAL "")
  1198. set(ara_analysis_types_int 0)
  1199. endif()
  1200. math(EXPR ara_analysis_types_int "${ara_analysis_types_int} | (${ara_analysis_types_bit})")
  1201. endif()
  1202. endforeach()
  1203. if(NOT ara_analysis_types_int STREQUAL "")
  1204. set_target_properties(${target} PROPERTIES JUCE_ARA_ANALYSIS_TYPES ${ara_analysis_types_int})
  1205. endif()
  1206. _juce_set_property_if_not_set(${target} ARA_ANALYSIS_TYPES 0)
  1207. # Transformation flags
  1208. set(ara_transformation_flags_strings
  1209. kARAPlaybackTransformationNoChanges
  1210. kARAPlaybackTransformationTimestretch
  1211. kARAPlaybackTransformationTimestretchReflectingTempo
  1212. kARAPlaybackTransformationContentBasedFadeAtTail
  1213. kARAPlaybackTransformationContentBasedFadeAtHead)
  1214. set(default_ara_transformation_flags kARAPlaybackTransformationNoChanges)
  1215. _juce_set_property_if_not_set(${target} ARA_TRANSFORMATION_FLAGS ${default_ara_transformation_flags})
  1216. get_target_property(actual_ara_transformation_flags ${target} JUCE_ARA_TRANSFORMATION_FLAGS)
  1217. set(ara_transformation_flags_int "")
  1218. foreach(transformation_string IN LISTS actual_ara_transformation_flags)
  1219. list(FIND ara_transformation_flags_strings ${transformation_string} ara_transformation_index)
  1220. if(ara_transformation_index GREATER_EQUAL 0)
  1221. if(ara_transformation_index EQUAL 0)
  1222. set(ara_transformation_bit 0)
  1223. else()
  1224. set(ara_transformation_bit "1 << (${ara_transformation_index} - 1)")
  1225. endif()
  1226. if(ara_transformation_flags_int STREQUAL "")
  1227. set(ara_transformation_flags_int 0)
  1228. endif()
  1229. math(EXPR ara_transformation_flags_int "${ara_transformation_flags_int} | (${ara_transformation_bit})")
  1230. endif()
  1231. endforeach()
  1232. if(NOT ara_transformation_flags_int STREQUAL "")
  1233. set_target_properties(${target} PROPERTIES JUCE_ARA_TRANSFORMATION_FLAGS ${ara_transformation_flags_int})
  1234. endif()
  1235. _juce_set_property_if_not_set(${target} IS_ARA_EFFECT FALSE)
  1236. get_target_property(final_bundle_id ${target} JUCE_BUNDLE_ID)
  1237. _juce_set_property_if_not_set(${target} ARA_FACTORY_ID "\"${final_bundle_id}.arafactory.${final_version}\"")
  1238. _juce_set_property_if_not_set(${target} ARA_DOCUMENT_ARCHIVE_ID "\"${final_bundle_id}.aradocumentarchive.1\"")
  1239. _juce_set_property_if_not_set(${target} ARA_COMPATIBLE_ARCHIVE_IDS "\"\"")
  1240. endfunction()
  1241. # ==================================================================================================
  1242. function(_juce_initialise_target target)
  1243. set(one_value_args
  1244. VERSION
  1245. BUILD_VERSION
  1246. PRODUCT_NAME
  1247. PLIST_TO_MERGE
  1248. BUNDLE_ID
  1249. MICROPHONE_PERMISSION_ENABLED
  1250. MICROPHONE_PERMISSION_TEXT
  1251. CAMERA_PERMISSION_ENABLED
  1252. CAMERA_PERMISSION_TEXT
  1253. SEND_APPLE_EVENTS_PERMISSION_ENABLED
  1254. SEND_APPLE_EVENTS_PERMISSION_TEXT
  1255. BLUETOOTH_PERMISSION_ENABLED
  1256. BLUETOOTH_PERMISSION_TEXT
  1257. FILE_SHARING_ENABLED # iOS only
  1258. DOCUMENT_BROWSER_ENABLED # iOS only
  1259. LAUNCH_STORYBOARD_FILE # iOS only
  1260. APP_GROUPS_ENABLED # iOS only
  1261. ICLOUD_PERMISSIONS_ENABLED # iOS only
  1262. STATUS_BAR_HIDDEN # iOS only
  1263. BACKGROUND_AUDIO_ENABLED # iOS only
  1264. BACKGROUND_BLE_ENABLED # iOS only
  1265. CUSTOM_XCASSETS_FOLDER # iOS only
  1266. TARGETED_DEVICE_FAMILY # iOS only
  1267. REQUIRES_FULL_SCREEN # iOS only
  1268. ICON_BIG
  1269. ICON_SMALL
  1270. COMPANY_COPYRIGHT
  1271. COMPANY_NAME
  1272. COMPANY_WEBSITE
  1273. COMPANY_EMAIL
  1274. NEEDS_CURL # Set this true if you want to link curl on Linux
  1275. NEEDS_WEB_BROWSER # Set this true if you want to link webkit on Linux
  1276. NEEDS_STORE_KIT # Set this true if you want in-app-purchases on Mac
  1277. PUSH_NOTIFICATIONS_ENABLED
  1278. NETWORK_MULTICAST_ENABLED
  1279. HARDENED_RUNTIME_ENABLED
  1280. APP_SANDBOX_ENABLED
  1281. APP_SANDBOX_INHERIT
  1282. PLUGIN_NAME
  1283. PLUGIN_MANUFACTURER_CODE
  1284. PLUGIN_CODE
  1285. DESCRIPTION
  1286. IS_SYNTH
  1287. NEEDS_MIDI_INPUT
  1288. NEEDS_MIDI_OUTPUT
  1289. IS_MIDI_EFFECT
  1290. EDITOR_WANTS_KEYBOARD_FOCUS
  1291. DISABLE_AAX_BYPASS
  1292. DISABLE_AAX_MULTI_MONO
  1293. AAX_IDENTIFIER
  1294. VST_NUM_MIDI_INS
  1295. VST_NUM_MIDI_OUTS
  1296. VST2_CATEGORY
  1297. AU_MAIN_TYPE
  1298. AU_EXPORT_PREFIX
  1299. AU_SANDBOX_SAFE
  1300. SUPPRESS_AU_PLIST_RESOURCE_USAGE
  1301. PLUGINHOST_AU # Set this true if you want to host AU plugins
  1302. USE_LEGACY_COMPATIBILITY_PLUGIN_CODE
  1303. LV2URI
  1304. IS_ARA_EFFECT
  1305. ARA_FACTORY_ID
  1306. ARA_DOCUMENT_ARCHIVE_ID
  1307. VST_COPY_DIR
  1308. VST3_COPY_DIR
  1309. AAX_COPY_DIR
  1310. AU_COPY_DIR
  1311. UNITY_COPY_DIR
  1312. COPY_PLUGIN_AFTER_BUILD)
  1313. set(multi_value_args
  1314. FORMATS
  1315. VST3_CATEGORIES
  1316. HARDENED_RUNTIME_OPTIONS
  1317. APP_SANDBOX_OPTIONS
  1318. APP_SANDBOX_FILE_ACCESS_HOME_RO
  1319. APP_SANDBOX_FILE_ACCESS_HOME_RW
  1320. APP_SANDBOX_FILE_ACCESS_ABS_RO
  1321. APP_SANDBOX_FILE_ACCESS_ABS_RW
  1322. DOCUMENT_EXTENSIONS
  1323. AAX_CATEGORY
  1324. IPHONE_SCREEN_ORIENTATIONS # iOS only
  1325. IPAD_SCREEN_ORIENTATIONS # iOS only
  1326. APP_GROUP_IDS # iOS only
  1327. ARA_COMPATIBLE_ARCHIVE_IDS
  1328. ARA_ANALYSIS_TYPES
  1329. ARA_TRANSFORMATION_FLAGS)
  1330. cmake_parse_arguments(JUCE_ARG "" "${one_value_args}" "${multi_value_args}" ${ARGN})
  1331. set(base_folder "${CMAKE_CURRENT_BINARY_DIR}/${target}_artefacts")
  1332. set(products_folder "${base_folder}/$<CONFIG>")
  1333. set(juce_library_code "${base_folder}/JuceLibraryCode")
  1334. set_target_properties(${target} PROPERTIES JUCE_GENERATED_SOURCES_DIRECTORY "${juce_library_code}")
  1335. set_target_properties(${target} PROPERTIES
  1336. ARCHIVE_OUTPUT_DIRECTORY "${products_folder}"
  1337. LIBRARY_OUTPUT_DIRECTORY "${products_folder}"
  1338. RUNTIME_OUTPUT_DIRECTORY "${products_folder}")
  1339. if(JUCE_ARG_ICON_BIG)
  1340. _juce_make_absolute_and_check(JUCE_ARG_ICON_BIG)
  1341. endif()
  1342. if(JUCE_ARG_ICON_SMALL)
  1343. _juce_make_absolute_and_check(JUCE_ARG_ICON_SMALL)
  1344. endif()
  1345. set(inherited_properties
  1346. COMPANY_NAME
  1347. COMPANY_WEBSITE
  1348. COMPANY_EMAIL
  1349. COMPANY_COPYRIGHT
  1350. VST_COPY_DIR
  1351. VST3_COPY_DIR
  1352. AU_COPY_DIR
  1353. AAX_COPY_DIR
  1354. UNITY_COPY_DIR
  1355. COPY_PLUGIN_AFTER_BUILD)
  1356. # Overwrite any properties that might be inherited
  1357. foreach(prop_string IN LISTS inherited_properties)
  1358. if(NOT ${JUCE_ARG_${prop_string}} STREQUAL "")
  1359. set_target_properties(${target} PROPERTIES JUCE_${prop_string} "${JUCE_ARG_${prop_string}}")
  1360. endif()
  1361. endforeach()
  1362. # Add each of the function arguments as target properties, so that it's easier to
  1363. # extract them in other functions
  1364. foreach(arg_string IN LISTS one_value_args multi_value_args)
  1365. _juce_set_property_if_not_set(${target} ${arg_string} "${JUCE_ARG_${arg_string}}")
  1366. endforeach()
  1367. _juce_set_fallback_properties(${target})
  1368. target_include_directories(${target} PRIVATE
  1369. $<TARGET_PROPERTY:${target},JUCE_GENERATED_SOURCES_DIRECTORY>)
  1370. target_link_libraries(${target} PUBLIC $<$<TARGET_EXISTS:juce_vst2_sdk>:juce_vst2_sdk>)
  1371. get_target_property(is_pluginhost_au ${target} JUCE_PLUGINHOST_AU)
  1372. if(is_pluginhost_au)
  1373. target_compile_definitions(${target} PUBLIC JUCE_PLUGINHOST_AU=1)
  1374. if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR CMAKE_SYSTEM_NAME STREQUAL "iOS")
  1375. _juce_link_frameworks("${target}" PRIVATE CoreAudioKit)
  1376. endif()
  1377. if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  1378. _juce_link_frameworks("${target}" PRIVATE AudioUnit)
  1379. endif()
  1380. endif()
  1381. _juce_write_generate_time_info(${target})
  1382. _juce_link_optional_libraries(${target})
  1383. _juce_fixup_module_source_groups()
  1384. endfunction()
  1385. # ==================================================================================================
  1386. function(juce_add_console_app target)
  1387. add_executable(${target})
  1388. target_compile_definitions(${target} PRIVATE JUCE_STANDALONE_APPLICATION=1)
  1389. if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
  1390. target_compile_definitions(${target} PRIVATE _CONSOLE=1)
  1391. endif()
  1392. _juce_initialise_target(${target} ${ARGN})
  1393. endfunction()
  1394. function(juce_add_gui_app target)
  1395. if(CMAKE_SYSTEM_NAME STREQUAL "Android")
  1396. add_library(${target} SHARED)
  1397. else()
  1398. add_executable(${target})
  1399. endif()
  1400. target_compile_definitions(${target} PRIVATE JUCE_STANDALONE_APPLICATION=1)
  1401. _juce_initialise_target(${target} ${ARGN})
  1402. _juce_set_output_name(${target} $<TARGET_PROPERTY:${target},JUCE_PRODUCT_NAME>)
  1403. set_target_properties(${target} PROPERTIES JUCE_TARGET_KIND_STRING "App")
  1404. _juce_configure_bundle(${target} ${target})
  1405. _juce_configure_app_bundle(${target} ${target})
  1406. endfunction()
  1407. function(juce_add_plugin target)
  1408. add_library(${target} STATIC)
  1409. set_target_properties(${target} PROPERTIES JUCE_IS_PLUGIN TRUE)
  1410. _juce_initialise_target(${target} ${ARGN})
  1411. _juce_configure_plugin_targets(${target})
  1412. endfunction()
  1413. # ==================================================================================================
  1414. function(_juce_target_args_from_plugin_characteristics out_var)
  1415. set(pairs
  1416. "pluginIsSynth\;IS_SYNTH"
  1417. "pluginWantsMidiIn\;NEEDS_MIDI_INPUT"
  1418. "pluginProducesMidiOut\;NEEDS_MIDI_OUTPUT"
  1419. "pluginIsMidiEffectPlugin\;IS_MIDI_EFFECT"
  1420. "pluginEditorRequiresKeys\;EDITOR_WANTS_KEYBOARD_FOCUS")
  1421. set(result)
  1422. foreach(pair IN LISTS pairs)
  1423. list(GET pair 0 old_key)
  1424. if("${old_key}" IN_LIST ARGN)
  1425. list(GET pair 1 new_key)
  1426. list(APPEND result ${new_key} TRUE)
  1427. endif()
  1428. endforeach()
  1429. set(${out_var} ${result} PARENT_SCOPE)
  1430. endfunction()
  1431. # ==================================================================================================
  1432. function(_juce_get_pip_targets pip out_var)
  1433. set(test_targets "${pip}")
  1434. _juce_get_all_plugin_kinds(plugin_kinds)
  1435. foreach(plugin_kind IN LISTS plugin_kinds)
  1436. list(APPEND test_targets "${JUCE_PIP_NAME}_${plugin_kind}")
  1437. endforeach()
  1438. set(${out_var} ${test_targets} PARENT_SCOPE)
  1439. endfunction()
  1440. function(juce_add_pip header)
  1441. _juce_make_absolute(header)
  1442. _juce_extract_metadata_block(JUCE_PIP_METADATA "${header}" metadata_dict)
  1443. _juce_get_metadata("${metadata_dict}" name JUCE_PIP_NAME)
  1444. if(NOT JUCE_PIP_NAME)
  1445. message(FATAL_ERROR "Error in '${header}': PIP headers must declare a `name` field")
  1446. endif()
  1447. string(MAKE_C_IDENTIFIER "${JUCE_PIP_NAME}" pip_name_sanitised)
  1448. if(NOT JUCE_PIP_NAME STREQUAL pip_name_sanitised)
  1449. message(FATAL_ERROR "Error in '${header}': PIP `name` value '${JUCE_PIP_NAME}' must be a valid C identifier")
  1450. endif()
  1451. if(TARGET "${JUCE_PIP_NAME}")
  1452. # We already added a target with this name, let's try using the filename instead
  1453. get_filename_component(JUCE_PIP_NAME "${header}" NAME_WE)
  1454. endif()
  1455. if(TARGET "${JUCE_PIP_NAME}")
  1456. message(FATAL_ERROR "Error in '${header}': Could not create a unique target name for PIP ${header}")
  1457. endif()
  1458. _juce_get_metadata("${metadata_dict}" type pip_kind)
  1459. if(NOT pip_kind)
  1460. message(FATAL_ERROR "Error in '${header}': PIP headers must declare a `type` field")
  1461. endif()
  1462. _juce_get_metadata("${metadata_dict}" pluginCharacteristics pip_charateristics)
  1463. _juce_target_args_from_plugin_characteristics(extra_target_args ${pip_charateristics})
  1464. list(APPEND extra_target_args
  1465. NEEDS_CURL TRUE
  1466. NEEDS_WEB_BROWSER TRUE)
  1467. _juce_get_metadata("${metadata_dict}" moduleFlags pip_moduleflags)
  1468. if("JUCE_IN_APP_PURCHASES=1" IN_LIST pip_moduleflags)
  1469. list(APPEND extra_target_args
  1470. BUNDLE_ID "com.rmsl.juceInAppPurchaseSample"
  1471. NEEDS_STORE_KIT TRUE)
  1472. endif()
  1473. if("JUCE_PLUGINHOST_AU=1" IN_LIST pip_moduleflags)
  1474. list(APPEND extra_target_args PLUGINHOST_AU TRUE)
  1475. endif()
  1476. if(pip_kind STREQUAL "AudioProcessor")
  1477. _juce_get_metadata("${metadata_dict}" documentControllerClass JUCE_PIP_DOCUMENTCONTROLLER_CLASS)
  1478. if(JUCE_PIP_DOCUMENTCONTROLLER_CLASS)
  1479. if(NOT TARGET juce_ara_sdk)
  1480. message(WARNING
  1481. "${header} specifies a documentControllerClass, but the ARA SDK could not be located. "
  1482. "Use juce_set_ara_sdk_path to specify the ARA SDK location. "
  1483. "This PIP will not be configured.")
  1484. endif()
  1485. set(source_main "${JUCE_CMAKE_UTILS_DIR}/PIPAudioProcessorWithARA.cpp.in")
  1486. juce_add_plugin(${JUCE_PIP_NAME}
  1487. FORMATS AU VST3
  1488. IS_ARA_EFFECT TRUE
  1489. ${extra_target_args})
  1490. else()
  1491. set(source_main "${JUCE_CMAKE_UTILS_DIR}/PIPAudioProcessor.cpp.in")
  1492. # We add AAX/VST2 targets too, if the user has set up those SDKs
  1493. set(extra_formats)
  1494. if(TARGET juce_aax_sdk)
  1495. list(APPEND extra_formats AAX)
  1496. endif()
  1497. if(TARGET juce_vst2_sdk)
  1498. list(APPEND extra_formats VST)
  1499. endif()
  1500. # Standalone plugins might want to access the mic
  1501. list(APPEND extra_target_args MICROPHONE_PERMISSION_ENABLED TRUE)
  1502. juce_add_plugin(${JUCE_PIP_NAME}
  1503. FORMATS AU AUv3 LV2 Standalone Unity VST3 ${extra_formats}
  1504. ${extra_target_args})
  1505. endif()
  1506. elseif(pip_kind STREQUAL "Component")
  1507. set(source_main "${JUCE_CMAKE_UTILS_DIR}/PIPComponent.cpp.in")
  1508. juce_add_gui_app(${JUCE_PIP_NAME} ${extra_target_args})
  1509. elseif(pip_kind STREQUAL "Console")
  1510. set(source_main "${JUCE_CMAKE_UTILS_DIR}/PIPConsole.cpp.in")
  1511. juce_add_console_app(${JUCE_PIP_NAME} ${extra_target_args})
  1512. else()
  1513. message(FATAL_ERROR "Error in '${header}': PIP kind must be either AudioProcessor, Component, or Console")
  1514. endif()
  1515. if(NOT ARGV1 STREQUAL "")
  1516. set("${ARGV1}" "${JUCE_PIP_NAME}" PARENT_SCOPE)
  1517. endif()
  1518. # Generate Main.cpp
  1519. _juce_get_metadata("${metadata_dict}" mainClass JUCE_PIP_MAIN_CLASS)
  1520. get_target_property(juce_library_code ${JUCE_PIP_NAME} JUCE_GENERATED_SOURCES_DIRECTORY)
  1521. set(pip_main "${juce_library_code}/Main.cpp")
  1522. set(JUCE_PIP_HEADER "${header}")
  1523. configure_file(${source_main} ${pip_main})
  1524. target_sources(${JUCE_PIP_NAME} PRIVATE ${pip_main})
  1525. _juce_get_metadata("${metadata_dict}" dependencies pip_dependencies)
  1526. juce_generate_juce_header(${JUCE_PIP_NAME})
  1527. foreach(module IN LISTS pip_dependencies)
  1528. if(module STREQUAL "")
  1529. continue()
  1530. endif()
  1531. set(discovered_module)
  1532. if(TARGET "${module}")
  1533. set(discovered_module "${module}")
  1534. else()
  1535. message(FATAL_ERROR "Error in '${header}': No such module: ${module}")
  1536. endif()
  1537. target_link_libraries(${JUCE_PIP_NAME} PRIVATE ${discovered_module})
  1538. endforeach()
  1539. target_compile_definitions(${JUCE_PIP_NAME}
  1540. PRIVATE ${pip_moduleflags}
  1541. PUBLIC
  1542. JUCE_VST3_CAN_REPLACE_VST2=0)
  1543. _juce_get_pip_targets(${JUCE_PIP_NAME} pip_targets)
  1544. # This keeps the PIPs slightly better organised in the JUCE megaproject
  1545. if((DEFINED JUCE_SOURCE_DIR) AND (header MATCHES "^${JUCE_SOURCE_DIR}"))
  1546. file(RELATIVE_PATH folder "${JUCE_SOURCE_DIR}" "${header}")
  1547. get_filename_component(folder_parent "${folder}" DIRECTORY)
  1548. foreach(target_name IN ITEMS ${pip_targets} ${JUCE_PIP_NAME}_All)
  1549. if(TARGET "${target_name}")
  1550. set_target_properties("${target_name}" PROPERTIES
  1551. FOLDER "${folder_parent}/${JUCE_PIP_NAME}")
  1552. endif()
  1553. endforeach()
  1554. endif()
  1555. # We're building JUCE itself
  1556. if(DEFINED JUCE_SOURCE_DIR)
  1557. # PIPs need to know about the resources folder
  1558. target_compile_definitions(${JUCE_PIP_NAME} PRIVATE
  1559. PIP_JUCE_EXAMPLES_DIRECTORY_STRING="${JUCE_SOURCE_DIR}/examples")
  1560. get_filename_component(pip_parent_path "${header}" DIRECTORY)
  1561. target_include_directories(${JUCE_PIP_NAME} PRIVATE "${pip_parent_path}")
  1562. if((CMAKE_SYSTEM_NAME STREQUAL "iOS") AND (header MATCHES "^${JUCE_SOURCE_DIR}"))
  1563. foreach(target_name IN LISTS pip_targets)
  1564. if(TARGET "${target_name}")
  1565. juce_add_bundle_resources_directory("${target_name}" "${JUCE_SOURCE_DIR}/examples/Assets")
  1566. endif()
  1567. endforeach()
  1568. endif()
  1569. endif()
  1570. endfunction()
  1571. # ==================================================================================================
  1572. function(juce_set_aax_sdk_path path)
  1573. if(TARGET juce_aax_sdk)
  1574. message(FATAL_ERROR "juce_set_aax_sdk_path should only be called once")
  1575. endif()
  1576. _juce_make_absolute(path)
  1577. if((NOT EXISTS "${path}")
  1578. OR (NOT EXISTS "${path}/Interfaces")
  1579. OR (NOT EXISTS "${path}/Interfaces/ACF"))
  1580. message(FATAL_ERROR "Could not find AAX SDK at the specified path: ${path}")
  1581. endif()
  1582. if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  1583. add_library(juce_aax_sdk STATIC IMPORTED GLOBAL)
  1584. set_target_properties(juce_aax_sdk PROPERTIES
  1585. IMPORTED_LOCATION_DEBUG "${path}/Libs/Debug/libAAXLibrary_libcpp.a"
  1586. IMPORTED_LOCATION "${path}/Libs/Release/libAAXLibrary_libcpp.a")
  1587. elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
  1588. add_library(juce_aax_sdk INTERFACE IMPORTED GLOBAL)
  1589. else()
  1590. return()
  1591. endif()
  1592. target_include_directories(juce_aax_sdk INTERFACE
  1593. "${path}"
  1594. "${path}/Interfaces"
  1595. "${path}/Interfaces/ACF")
  1596. target_compile_definitions(juce_aax_sdk INTERFACE JucePlugin_AAXLibs_path="${path}/Libs")
  1597. set_target_properties(juce_aax_sdk PROPERTIES INTERFACE_JUCE_AAX_DEFAULT_ICON "${path}/Utilities/PlugIn.ico")
  1598. endfunction()
  1599. function(juce_set_vst2_sdk_path path)
  1600. if(TARGET juce_vst2_sdk)
  1601. message(FATAL_ERROR "juce_set_vst2_sdk_path should only be called once")
  1602. endif()
  1603. _juce_make_absolute(path)
  1604. if(NOT EXISTS "${path}")
  1605. message(FATAL_ERROR "Could not find VST2 SDK at the specified path: ${path}")
  1606. endif()
  1607. add_library(juce_vst2_sdk INTERFACE IMPORTED GLOBAL)
  1608. # This is a bit of a hack, but we really need the VST2 paths to always follow the VST3 paths.
  1609. target_include_directories(juce_vst2_sdk INTERFACE
  1610. $<TARGET_PROPERTY:juce::juce_vst3_headers,INTERFACE_INCLUDE_DIRECTORIES>
  1611. "${path}")
  1612. endfunction()
  1613. function(juce_set_vst3_sdk_path path)
  1614. if(TARGET juce_vst3_sdk)
  1615. message(FATAL_ERROR "juce_set_vst3_sdk_path should only be called once")
  1616. endif()
  1617. _juce_make_absolute(path)
  1618. if(NOT EXISTS "${path}")
  1619. message(FATAL_ERROR "Could not find VST3 SDK at the specified path: ${path}")
  1620. endif()
  1621. add_library(juce_vst3_sdk INTERFACE IMPORTED GLOBAL)
  1622. target_include_directories(juce_vst3_sdk INTERFACE "${path}")
  1623. endfunction()
  1624. function(juce_set_ara_sdk_path path)
  1625. if(TARGET juce_ara_sdk)
  1626. message(FATAL_ERROR "juce_set_ara_sdk_path should only be called once")
  1627. endif()
  1628. _juce_make_absolute(path)
  1629. if(NOT EXISTS "${path}")
  1630. message(FATAL_ERROR "Could not find ARA SDK at the specified path: ${path}")
  1631. endif()
  1632. add_library(juce_ara_sdk INTERFACE IMPORTED GLOBAL)
  1633. target_include_directories(juce_ara_sdk INTERFACE "${path}")
  1634. endfunction()
  1635. # ==================================================================================================
  1636. function(juce_disable_default_flags)
  1637. set(langs C CXX)
  1638. set(modes DEBUG RELEASE RELWITHDEBINFO MINSIZEREL)
  1639. foreach(lang IN LISTS langs)
  1640. foreach(mode IN LISTS modes)
  1641. list(FILTER CMAKE_${lang}_FLAGS_${mode} INCLUDE REGEX "[/-]M[TD]d?")
  1642. set(CMAKE_${lang}_FLAGS_${mode} "${CMAKE_${lang}_FLAGS_${mode}}" PARENT_SCOPE)
  1643. endforeach()
  1644. endforeach()
  1645. endfunction()