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.

1944 lines
80KB

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