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.

2338 lines
96KB

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