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.

2444 lines
97KB

  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/CMake Compatibility Module
  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.12)
  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. # ==================================================================================================
  71. function(_juce_add_interface_library target)
  72. add_library(${target} INTERFACE)
  73. target_sources(${target} INTERFACE ${ARGN})
  74. endfunction()
  75. # ==================================================================================================
  76. function(_juce_create_pkgconfig_target name)
  77. if(TARGET juce::pkgconfig_${name})
  78. return()
  79. endif()
  80. find_package(PkgConfig REQUIRED)
  81. pkg_check_modules(${name} ${ARGN})
  82. add_library(pkgconfig_${name} INTERFACE)
  83. add_library(juce::pkgconfig_${name} ALIAS pkgconfig_${name})
  84. install(TARGETS pkgconfig_${name} EXPORT JUCE)
  85. set(pairs
  86. "INCLUDE_DIRECTORIES\;INCLUDE_DIRS"
  87. "LINK_LIBRARIES\;LINK_LIBRARIES"
  88. "LINK_OPTIONS\;LDFLAGS_OTHER"
  89. "COMPILE_OPTIONS\;CFLAGS_OTHER")
  90. foreach(pair IN LISTS pairs)
  91. list(GET pair 0 key)
  92. list(GET pair 1 value)
  93. if(${name}_${value})
  94. set_target_properties(pkgconfig_${name} PROPERTIES INTERFACE_${key} "${${name}_${value}}")
  95. endif()
  96. endforeach()
  97. endfunction()
  98. # ==================================================================================================
  99. set(JUCE_CMAKE_UTILS_DIR ${CMAKE_CURRENT_LIST_DIR}
  100. CACHE INTERNAL "The path to the folder holding this file and other resources")
  101. include("${JUCE_CMAKE_UTILS_DIR}/JUCEHelperTargets.cmake")
  102. include("${JUCE_CMAKE_UTILS_DIR}/JUCECheckAtomic.cmake")
  103. _juce_create_atomic_target(juce_atomic_wrapper)
  104. # Tries to discover the target platform architecture, which is necessary for
  105. # naming VST3 bundle folders correctly.
  106. function(_juce_find_linux_target_architecture result)
  107. set(test_file "${JUCE_CMAKE_UTILS_DIR}/juce_runtime_arch_detection.cpp")
  108. try_compile(compile_result "${CMAKE_CURRENT_BINARY_DIR}" "${test_file}"
  109. OUTPUT_VARIABLE compile_output)
  110. string(REGEX REPLACE ".*JUCE_ARCH ([a-zA-Z0-9_-]*).*" "\\1" match_result "${compile_output}")
  111. set("${result}" "${match_result}" PARENT_SCOPE)
  112. endfunction()
  113. if((CMAKE_SYSTEM_NAME STREQUAL "Linux") OR (CMAKE_SYSTEM_NAME MATCHES ".*BSD"))
  114. _juce_create_pkgconfig_target(JUCE_CURL_LINUX_DEPS libcurl)
  115. _juce_create_pkgconfig_target(JUCE_BROWSER_LINUX_DEPS webkit2gtk-4.0 gtk+-x11-3.0)
  116. # If you really need to override the detected arch for some reason,
  117. # you can configure the build with -DJUCE_LINUX_TARGET_ARCHITECTURE=<custom arch>
  118. if(NOT DEFINED JUCE_LINUX_TARGET_ARCHITECTURE)
  119. _juce_find_linux_target_architecture(target_arch)
  120. set(JUCE_LINUX_TARGET_ARCHITECTURE "${target_arch}"
  121. CACHE INTERNAL "The target architecture, used to name internal folders in VST3 bundles")
  122. endif()
  123. elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  124. find_program(JUCE_XCRUN xcrun)
  125. if(NOT JUCE_XCRUN)
  126. message(WARNING "failed to find xcrun; older resource-based AU plug-ins may not work correctly")
  127. endif()
  128. endif()
  129. # We set up default/fallback copy dirs here. If you need different copy dirs, use
  130. # set_directory_properties or set_target_properties to adjust the values of `JUCE_*_COPY_DIR` at
  131. # the appropriate scope.
  132. function(_juce_set_default_properties)
  133. if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  134. set_property(GLOBAL PROPERTY JUCE_VST_COPY_DIR "$ENV{HOME}/Library/Audio/Plug-Ins/VST")
  135. set_property(GLOBAL PROPERTY JUCE_VST3_COPY_DIR "$ENV{HOME}/Library/Audio/Plug-Ins/VST3")
  136. set_property(GLOBAL PROPERTY JUCE_AU_COPY_DIR "$ENV{HOME}/Library/Audio/Plug-Ins/Components")
  137. set_property(GLOBAL PROPERTY JUCE_AAX_COPY_DIR "/Library/Application Support/Avid/Audio/Plug-Ins")
  138. elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
  139. if(CMAKE_SIZEOF_VOID_P EQUAL 8)
  140. set_property(GLOBAL PROPERTY JUCE_VST_COPY_DIR "$ENV{ProgramW6432}/Steinberg/Vstplugins")
  141. set(prefix "$ENV{CommonProgramW6432}")
  142. else()
  143. set_property(GLOBAL PROPERTY JUCE_VST_COPY_DIR "$ENV{programfiles\(x86\)}/Steinberg/Vstplugins")
  144. set(prefix "$ENV{CommonProgramFiles\(x86\)}")
  145. endif()
  146. set_property(GLOBAL PROPERTY JUCE_VST3_COPY_DIR "${prefix}/VST3")
  147. set_property(GLOBAL PROPERTY JUCE_AAX_COPY_DIR "${prefix}/Avid/Audio/Plug-Ins")
  148. elseif((CMAKE_SYSTEM_NAME STREQUAL "Linux") OR (CMAKE_SYSTEM_NAME MATCHES ".*BSD"))
  149. set_property(GLOBAL PROPERTY JUCE_VST_COPY_DIR "$ENV{HOME}/.vst")
  150. set_property(GLOBAL PROPERTY JUCE_VST3_COPY_DIR "$ENV{HOME}/.vst3")
  151. endif()
  152. endfunction()
  153. _juce_set_default_properties()
  154. # ==================================================================================================
  155. function(_juce_add_standard_defs juce_target)
  156. target_compile_definitions(${juce_target} INTERFACE
  157. JUCE_GLOBAL_MODULE_SETTINGS_INCLUDED=1
  158. $<IF:$<CONFIG:DEBUG>,DEBUG=1 _DEBUG=1,NDEBUG=1 _NDEBUG=1>
  159. $<$<PLATFORM_ID:Android>:JUCE_ANDROID=1>)
  160. endfunction()
  161. # ==================================================================================================
  162. macro(_juce_make_absolute path)
  163. if(NOT IS_ABSOLUTE "${${path}}")
  164. get_filename_component("${path}" "${${path}}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_LIST_DIR}")
  165. endif()
  166. endmacro()
  167. macro(_juce_make_absolute_and_check path)
  168. _juce_make_absolute("${path}")
  169. if(NOT EXISTS "${${path}}")
  170. message(FATAL_ERROR "No file at path ${${path}}")
  171. endif()
  172. endmacro()
  173. # ==================================================================================================
  174. function(juce_add_bundle_resources_directory target folder)
  175. _juce_make_absolute(folder)
  176. if(NOT EXISTS "${folder}")
  177. message(FATAL_ERROR "Could not find resource folder ${folder}")
  178. endif()
  179. get_filename_component(folder_parent_path "${folder}" DIRECTORY)
  180. file(GLOB_RECURSE resources RELATIVE "${folder_parent_path}" "${folder}/*")
  181. foreach(file IN LISTS resources)
  182. target_sources(${target} PRIVATE "${folder_parent_path}/${file}")
  183. get_filename_component(resource_parent_path "${file}" DIRECTORY)
  184. set_source_files_properties("${folder_parent_path}/${file}" PROPERTIES
  185. HEADER_FILE_ONLY TRUE
  186. MACOSX_PACKAGE_LOCATION "Resources/${resource_parent_path}")
  187. endforeach()
  188. endfunction()
  189. # ==================================================================================================
  190. # This creates an imported interface library with a random name, and then adds
  191. # the fields from a JUCE module header to the target as INTERFACE_ properties.
  192. # We can extract properties later using `_juce_get_metadata`.
  193. # This way, the interface library ends up behaving a bit like a dictionary,
  194. # and we don't have to parse the module header from scratch every time we
  195. # want to find a specific key.
  196. function(_juce_extract_metadata_block delim_str file_with_block out_dict)
  197. string(RANDOM LENGTH 16 random_string)
  198. set(target_name "${random_string}_dict")
  199. set(${out_dict} "${target_name}" PARENT_SCOPE)
  200. add_library(${target_name} INTERFACE IMPORTED)
  201. if(NOT EXISTS ${file_with_block})
  202. message(FATAL_ERROR "Unable to find file ${file_with_block}")
  203. endif()
  204. file(STRINGS ${file_with_block} module_header_contents)
  205. set(last_written_key)
  206. set(append NO)
  207. foreach(line IN LISTS module_header_contents)
  208. if(NOT append)
  209. if(line MATCHES " *BEGIN_${delim_str} *")
  210. set(append YES)
  211. endif()
  212. continue()
  213. endif()
  214. if(append AND (line MATCHES " *END_${delim_str} *"))
  215. break()
  216. endif()
  217. if(line MATCHES "^ *([a-zA-Z]+):")
  218. set(last_written_key "${CMAKE_MATCH_1}")
  219. endif()
  220. string(REGEX REPLACE "^ *${last_written_key}: *" "" line "${line}")
  221. string(REGEX REPLACE "[ ,]+" ";" line "${line}")
  222. set_property(TARGET ${target_name} APPEND PROPERTY
  223. "INTERFACE_JUCE_${last_written_key}" "${line}")
  224. endforeach()
  225. endfunction()
  226. # Fetches properties attached to a metadata target.
  227. function(_juce_get_metadata target key out_var)
  228. get_target_property(content "${target}" "INTERFACE_JUCE_${key}")
  229. if(NOT "${content}" STREQUAL "content-NOTFOUND")
  230. set(${out_var} "${content}" PARENT_SCOPE)
  231. endif()
  232. endfunction()
  233. # ==================================================================================================
  234. function(_juce_should_build_module_source filename output_var)
  235. get_filename_component(trimmed_name "${filename}" NAME_WE)
  236. set(result TRUE)
  237. set(pairs
  238. "OSX\;Darwin"
  239. "Windows\;Windows"
  240. "Linux\;Linux"
  241. "Android\;Android"
  242. "iOS\;iOS")
  243. foreach(pair IN LISTS pairs)
  244. list(GET pair 0 suffix)
  245. list(GET pair 1 system_name)
  246. if((trimmed_name MATCHES "_${suffix}$") AND NOT (CMAKE_SYSTEM_NAME STREQUAL "${system_name}"))
  247. set(result FALSE)
  248. endif()
  249. endforeach()
  250. set("${output_var}" "${result}" PARENT_SCOPE)
  251. endfunction()
  252. function(_juce_module_sources module_path output_path built_sources other_sources)
  253. get_filename_component(module_parent_path ${module_path} DIRECTORY)
  254. get_filename_component(module_glob ${module_path} NAME)
  255. file(GLOB_RECURSE all_module_files
  256. CONFIGURE_DEPENDS LIST_DIRECTORIES FALSE
  257. RELATIVE "${module_parent_path}"
  258. "${module_path}/*")
  259. set(base_path "${module_glob}/${module_glob}")
  260. set(module_cpp ${all_module_files})
  261. list(FILTER module_cpp INCLUDE REGEX "^${base_path}[^/]*\\.(c|cc|cpp|cxx|s|asm)$")
  262. if(APPLE)
  263. set(module_mm ${all_module_files})
  264. list(FILTER module_mm INCLUDE REGEX "^${base_path}[^/]*\\.mm$")
  265. if(module_mm)
  266. set(module_mm_replaced ${module_mm})
  267. list(TRANSFORM module_mm_replaced REPLACE "\\.mm$" ".cpp")
  268. list(REMOVE_ITEM module_cpp ${module_mm_replaced})
  269. endif()
  270. set(module_apple_files ${all_module_files})
  271. list(FILTER module_apple_files INCLUDE REGEX "${base_path}[^/]*\\.(m|mm|metal|r|swift)$")
  272. list(APPEND module_cpp ${module_apple_files})
  273. endif()
  274. set(headers ${all_module_files})
  275. set(module_files_to_build)
  276. foreach(filename IN LISTS module_cpp)
  277. _juce_should_build_module_source("${filename}" should_build_file)
  278. if(should_build_file)
  279. list(APPEND module_files_to_build "${filename}")
  280. endif()
  281. endforeach()
  282. if(NOT "${module_files_to_build}" STREQUAL "")
  283. list(REMOVE_ITEM headers ${module_files_to_build})
  284. endif()
  285. foreach(source_list IN ITEMS module_files_to_build headers)
  286. list(TRANSFORM ${source_list} PREPEND "${output_path}/")
  287. endforeach()
  288. set(${built_sources} ${module_files_to_build} PARENT_SCOPE)
  289. set(${other_sources} ${headers} PARENT_SCOPE)
  290. endfunction()
  291. # ==================================================================================================
  292. function(_juce_get_all_plugin_kinds out)
  293. set(${out} AU AUv3 AAX Standalone Unity VST VST3 PARENT_SCOPE)
  294. endfunction()
  295. function(_juce_get_platform_plugin_kinds out)
  296. set(result Standalone)
  297. if(APPLE AND (CMAKE_GENERATOR STREQUAL "Xcode"))
  298. list(APPEND result AUv3)
  299. endif()
  300. if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  301. list(APPEND result AU)
  302. endif()
  303. if(NOT CMAKE_SYSTEM_NAME STREQUAL "iOS" AND NOT CMAKE_SYSTEM_NAME STREQUAL "Android")
  304. list(APPEND result AAX Unity VST)
  305. if(NOT MINGW AND NOT MSYS)
  306. list(APPEND result VST3)
  307. endif()
  308. endif()
  309. set(${out} ${result} PARENT_SCOPE)
  310. endfunction()
  311. function(_juce_add_plugin_definitions target visibility)
  312. _juce_get_all_plugin_kinds(options)
  313. cmake_parse_arguments(JUCE_ARG "${options}" "" "" ${ARGN})
  314. foreach(opt IN LISTS options)
  315. set(flag_value 0)
  316. if(JUCE_ARG_${opt})
  317. set(flag_value 1)
  318. endif()
  319. target_compile_definitions(${target} ${visibility} "JucePlugin_Build_${opt}=${flag_value}")
  320. endforeach()
  321. endfunction()
  322. # ==================================================================================================
  323. function(_juce_add_au_resource_fork shared_code_target au_target)
  324. if(NOT JUCE_XCRUN)
  325. return()
  326. endif()
  327. get_target_property(product_name ${shared_code_target} JUCE_PRODUCT_NAME)
  328. get_target_property(module_sources juce::juce_audio_plugin_client_AU INTERFACE_SOURCES)
  329. list(FILTER module_sources INCLUDE REGEX "/juce_audio_plugin_client_AU.r$")
  330. if(NOT module_sources)
  331. message(FATAL_ERROR "Failed to find AU resource file input")
  332. endif()
  333. list(GET module_sources 0 au_rez_sources)
  334. get_target_property(juce_library_code ${shared_code_target} JUCE_GENERATED_SOURCES_DIRECTORY)
  335. # We don't want our AU AppConfig.h to end up on peoples' include paths if we can help it
  336. set(secret_au_resource_dir "${juce_library_code}/${au_target}/secret")
  337. set(secret_au_plugindefines "${secret_au_resource_dir}/JucePluginDefines.h")
  338. set(au_rez_output "${secret_au_resource_dir}/${product_name}.rsrc")
  339. target_sources(${au_target} PRIVATE "${au_rez_output}")
  340. set_source_files_properties("${au_rez_output}" PROPERTIES
  341. GENERATED TRUE
  342. MACOSX_PACKAGE_LOCATION Resources)
  343. set(defs_file $<GENEX_EVAL:$<TARGET_PROPERTY:${shared_code_target},JUCE_DEFS_FILE>>)
  344. # Passing all our compile definitions using generator expressions is really painful
  345. # because some of the definitions have pipes and quotes and dollars and goodness-knows
  346. # what else that the shell would very much like to claim for itself, thank you very much.
  347. # CMake definitely knows how to escape all these things, because it's perfectly happy to pass
  348. # them to compiler invocations, but I have no idea how to get it to escape them
  349. # in a custom command.
  350. # In the end, it's simplest to generate a special single-purpose appconfig just for the
  351. # resource compiler.
  352. add_custom_command(OUTPUT "${secret_au_plugindefines}"
  353. COMMAND juce::juceaide auplugindefines "${defs_file}" "${secret_au_plugindefines}"
  354. DEPENDS "${defs_file}"
  355. VERBATIM)
  356. add_custom_command(OUTPUT "${au_rez_output}"
  357. COMMAND "${JUCE_XCRUN}" Rez
  358. -d "ppc_$ppc" -d "i386_$i386" -d "ppc64_$ppc64" -d "x86_64_$x86_64"
  359. -I "${secret_au_resource_dir}"
  360. -I "/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Versions/A/Headers"
  361. -I "${CMAKE_OSX_SYSROOT}/System/Library/Frameworks/AudioUnit.framework/Headers"
  362. -isysroot "${CMAKE_OSX_SYSROOT}"
  363. "${au_rez_sources}"
  364. -useDF
  365. -o "${au_rez_output}"
  366. DEPENDS "${secret_au_plugindefines}"
  367. VERBATIM)
  368. set(au_resource_directory "$<TARGET_BUNDLE_DIR:${au_target}>/Contents/Resources")
  369. endfunction()
  370. # ==================================================================================================
  371. # Takes a target, a link visibility, and a variable-length list of framework
  372. # names. On macOS, finds the requested frameworks using `find_library` and
  373. # links them. On iOS, links directly with `-framework Name`.
  374. function(_juce_link_frameworks target visibility)
  375. foreach(framework IN LISTS ARGN)
  376. if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  377. find_library("juce_found_${framework}" "${framework}" REQUIRED)
  378. target_link_libraries("${target}" "${visibility}" "${juce_found_${framework}}")
  379. elseif(CMAKE_SYSTEM_NAME STREQUAL "iOS")
  380. # CoreServices is only available on iOS 12+, we must link it weakly on earlier platforms
  381. if((framework STREQUAL "CoreServices") AND (CMAKE_OSX_DEPLOYMENT_TARGET LESS 12.0))
  382. set(framework_flags "-weak_framework ${framework}")
  383. else()
  384. set(framework_flags "-framework ${framework}")
  385. endif()
  386. target_link_libraries("${target}" "${visibility}" "${framework_flags}")
  387. endif()
  388. endforeach()
  389. endfunction()
  390. # ==================================================================================================
  391. function(_juce_add_plugin_wrapper_target format path out_path)
  392. _juce_module_sources("${path}" "${out_path}" out_var headers)
  393. list(FILTER out_var EXCLUDE REGEX "/juce_audio_plugin_client_utils.cpp$")
  394. set(target_name juce_audio_plugin_client_${format})
  395. _juce_add_interface_library("${target_name}" ${out_var})
  396. _juce_add_plugin_definitions("${target_name}" INTERFACE ${format})
  397. _juce_add_standard_defs("${target_name}")
  398. target_compile_features("${target_name}" INTERFACE cxx_std_11)
  399. add_library("juce::${target_name}" ALIAS "${target_name}")
  400. if(format STREQUAL "AUv3")
  401. _juce_link_frameworks("${target_name}" INTERFACE AVFoundation)
  402. if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  403. _juce_link_frameworks("${target_name}" INTERFACE AudioUnit)
  404. endif()
  405. elseif(format STREQUAL "AU")
  406. _juce_link_frameworks("${target_name}" INTERFACE AudioUnit CoreAudioKit)
  407. endif()
  408. endfunction()
  409. # ==================================================================================================
  410. function(_juce_link_libs_from_metadata module_name dict key)
  411. _juce_get_metadata("${dict}" "${key}" libs)
  412. if(libs)
  413. target_link_libraries(${module_name} INTERFACE ${libs})
  414. endif()
  415. endfunction()
  416. # ==================================================================================================
  417. function(juce_add_module module_path)
  418. set(one_value_args INSTALL_PATH ALIAS_NAMESPACE)
  419. cmake_parse_arguments(JUCE_ARG "" "${one_value_args}" "" ${ARGN})
  420. _juce_make_absolute(module_path)
  421. get_filename_component(module_name ${module_path} NAME)
  422. get_filename_component(module_parent_path ${module_path} DIRECTORY)
  423. set(module_header_name "${module_name}.h")
  424. if(NOT EXISTS "${module_path}/${module_header_name}")
  425. set(module_header_name "${module_header_name}pp")
  426. endif()
  427. if(NOT EXISTS "${module_path}/${module_header_name}")
  428. message(FATAL_ERROR "Could not locate module header for module '${module_path}'")
  429. endif()
  430. set(base_path "${module_parent_path}")
  431. _juce_module_sources("${module_path}" "${base_path}" globbed_sources headers)
  432. if(${module_name} STREQUAL "juce_audio_plugin_client")
  433. _juce_get_platform_plugin_kinds(plugin_kinds)
  434. foreach(kind IN LISTS plugin_kinds)
  435. _juce_add_plugin_wrapper_target(${kind} "${module_path}" "${base_path}")
  436. endforeach()
  437. set(utils_source
  438. "${base_path}/${module_name}/juce_audio_plugin_client_utils.cpp")
  439. add_library(juce_audio_plugin_client_utils INTERFACE)
  440. target_sources(juce_audio_plugin_client_utils INTERFACE "${utils_source}")
  441. if(JUCE_ARG_ALIAS_NAMESPACE)
  442. add_library(${JUCE_ARG_ALIAS_NAMESPACE}::juce_audio_plugin_client_utils
  443. ALIAS juce_audio_plugin_client_utils)
  444. endif()
  445. file(GLOB_RECURSE all_module_files
  446. CONFIGURE_DEPENDS LIST_DIRECTORIES FALSE
  447. RELATIVE "${module_parent_path}"
  448. "${module_path}/*")
  449. else()
  450. list(APPEND all_module_sources ${globbed_sources})
  451. endif()
  452. _juce_add_interface_library(${module_name} ${all_module_sources})
  453. set_property(GLOBAL APPEND PROPERTY _juce_module_names ${module_name})
  454. set_target_properties(${module_name} PROPERTIES
  455. INTERFACE_JUCE_MODULE_SOURCES "${globbed_sources}"
  456. INTERFACE_JUCE_MODULE_HEADERS "${headers}"
  457. INTERFACE_JUCE_MODULE_PATH "${base_path}")
  458. if(JUCE_ENABLE_MODULE_SOURCE_GROUPS)
  459. target_sources(${module_name} INTERFACE ${headers})
  460. endif()
  461. if(${module_name} STREQUAL "juce_core")
  462. _juce_add_standard_defs(${module_name})
  463. target_link_libraries(juce_core INTERFACE juce::juce_atomic_wrapper)
  464. if(CMAKE_SYSTEM_NAME MATCHES ".*BSD")
  465. target_link_libraries(juce_core INTERFACE execinfo)
  466. elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
  467. target_sources(juce_core INTERFACE "${ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c")
  468. target_include_directories(juce_core INTERFACE "${ANDROID_NDK}/sources/android/cpufeatures")
  469. target_link_libraries(juce_core INTERFACE android log)
  470. endif()
  471. endif()
  472. if(${module_name} STREQUAL "juce_audio_processors")
  473. add_library(juce_vst3_headers INTERFACE)
  474. target_compile_definitions(juce_vst3_headers INTERFACE "$<$<TARGET_EXISTS:juce_vst3_sdk>:JUCE_CUSTOM_VST3_SDK=1>")
  475. target_include_directories(juce_vst3_headers INTERFACE
  476. "$<$<TARGET_EXISTS:juce_vst3_sdk>:$<TARGET_PROPERTY:juce_vst3_sdk,INTERFACE_INCLUDE_DIRECTORIES>>"
  477. "$<$<NOT:$<TARGET_EXISTS:juce_vst3_sdk>>:${base_path}/juce_audio_processors/format_types/VST3_SDK>")
  478. target_link_libraries(juce_audio_processors INTERFACE juce_vst3_headers)
  479. if(JUCE_ARG_ALIAS_NAMESPACE)
  480. add_library(${JUCE_ARG_ALIAS_NAMESPACE}::juce_vst3_headers ALIAS juce_vst3_headers)
  481. endif()
  482. endif()
  483. target_include_directories(${module_name} INTERFACE ${base_path})
  484. target_compile_definitions(${module_name} INTERFACE JUCE_MODULE_AVAILABLE_${module_name}=1)
  485. if((CMAKE_SYSTEM_NAME STREQUAL "Linux") OR (CMAKE_SYSTEM_NAME MATCHES ".*BSD"))
  486. target_compile_definitions(${module_name} INTERFACE LINUX=1)
  487. endif()
  488. _juce_extract_metadata_block(JUCE_MODULE_DECLARATION "${module_path}/${module_header_name}" metadata_dict)
  489. _juce_get_metadata("${metadata_dict}" minimumCppStandard module_cpp_standard)
  490. if(module_cpp_standard)
  491. target_compile_features(${module_name} INTERFACE cxx_std_${module_cpp_standard})
  492. else()
  493. target_compile_features(${module_name} INTERFACE cxx_std_11)
  494. endif()
  495. if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  496. _juce_get_metadata("${metadata_dict}" OSXFrameworks module_osxframeworks)
  497. foreach(module_framework IN LISTS module_osxframeworks)
  498. if(module_framework STREQUAL "")
  499. continue()
  500. endif()
  501. _juce_link_frameworks("${module_name}" INTERFACE "${module_framework}")
  502. endforeach()
  503. _juce_link_libs_from_metadata("${module_name}" "${metadata_dict}" OSXLibs)
  504. elseif(CMAKE_SYSTEM_NAME STREQUAL "iOS")
  505. _juce_get_metadata("${metadata_dict}" iOSFrameworks module_iosframeworks)
  506. foreach(module_framework IN LISTS module_iosframeworks)
  507. if(module_framework STREQUAL "")
  508. continue()
  509. endif()
  510. _juce_link_frameworks("${module_name}" INTERFACE "${module_framework}")
  511. endforeach()
  512. _juce_link_libs_from_metadata("${module_name}" "${metadata_dict}" iOSLibs)
  513. elseif((CMAKE_SYSTEM_NAME STREQUAL "Linux") OR (CMAKE_SYSTEM_NAME MATCHES ".*BSD"))
  514. _juce_get_metadata("${metadata_dict}" linuxPackages module_linuxpackages)
  515. if(module_linuxpackages)
  516. _juce_create_pkgconfig_target(${module_name}_LINUX_DEPS ${module_linuxpackages})
  517. target_link_libraries(${module_name} INTERFACE juce::pkgconfig_${module_name}_LINUX_DEPS)
  518. endif()
  519. _juce_link_libs_from_metadata("${module_name}" "${metadata_dict}" linuxLibs)
  520. elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
  521. if((CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") OR (CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC"))
  522. if(module_name STREQUAL "juce_gui_basics")
  523. target_compile_options(${module_name} INTERFACE /bigobj)
  524. endif()
  525. _juce_link_libs_from_metadata("${module_name}" "${metadata_dict}" windowsLibs)
  526. elseif(MSYS OR MINGW)
  527. if(module_name STREQUAL "juce_gui_basics")
  528. target_compile_options(${module_name} INTERFACE "-Wa,-mbig-obj")
  529. endif()
  530. _juce_link_libs_from_metadata("${module_name}" "${metadata_dict}" mingwLibs)
  531. endif()
  532. endif()
  533. _juce_get_metadata("${metadata_dict}" dependencies module_dependencies)
  534. target_link_libraries(${module_name} INTERFACE ${module_dependencies})
  535. _juce_get_metadata("${metadata_dict}" searchpaths module_searchpaths)
  536. if(NOT module_searchpaths STREQUAL "")
  537. foreach(module_searchpath IN LISTS module_searchpaths)
  538. target_include_directories(${module_name}
  539. INTERFACE "${module_path}/${module_searchpath}")
  540. endforeach()
  541. endif()
  542. if(JUCE_ARG_INSTALL_PATH)
  543. install(DIRECTORY "${module_path}" DESTINATION "${JUCE_ARG_INSTALL_PATH}")
  544. endif()
  545. if(JUCE_ARG_ALIAS_NAMESPACE)
  546. add_library(${JUCE_ARG_ALIAS_NAMESPACE}::${module_name} ALIAS ${module_name})
  547. endif()
  548. endfunction()
  549. function(juce_add_modules)
  550. set(one_value_args INSTALL_PATH ALIAS_NAMESPACE)
  551. cmake_parse_arguments(JUCE_ARG "" "${one_value_args}" "" ${ARGN})
  552. foreach(path IN LISTS JUCE_ARG_UNPARSED_ARGUMENTS)
  553. juce_add_module(${path}
  554. INSTALL_PATH "${JUCE_ARG_INSTALL_PATH}"
  555. ALIAS_NAMESPACE "${JUCE_ARG_ALIAS_NAMESPACE}")
  556. endforeach()
  557. endfunction()
  558. # ==================================================================================================
  559. # Ideally, we'd check the preprocessor defs on the target to see whether
  560. # JUCE_USE_CURL, JUCE_WEB_BROWSER, or JUCE_IN_APP_PURCHASES have been explicitly turned off,
  561. # and then link libraries as appropriate.
  562. # Unfortunately, this doesn't work, because linking a new library (curl/webkit/StoreKit)
  563. # updates the target's compile defs, which results in a recursion/circular-dependency.
  564. # Instead, we ask the user to explicitly request curl/webkit/StoreKit linking if they
  565. # know they need it. Otherwise, we won't link anything.
  566. # See the NEEDS_CURL, NEEDS_WEB_BROWSER, and NEEDS_STORE_KIT options in the CMake/readme.md.
  567. function(_juce_link_optional_libraries target)
  568. if((CMAKE_SYSTEM_NAME STREQUAL "Linux") OR (CMAKE_SYSTEM_NAME MATCHES ".*BSD"))
  569. get_target_property(needs_curl ${target} JUCE_NEEDS_CURL)
  570. if(needs_curl)
  571. target_link_libraries(${target} PRIVATE juce::pkgconfig_JUCE_CURL_LINUX_DEPS)
  572. endif()
  573. get_target_property(needs_browser ${target} JUCE_NEEDS_WEB_BROWSER)
  574. if(needs_browser)
  575. target_link_libraries(${target} PRIVATE juce::pkgconfig_JUCE_BROWSER_LINUX_DEPS)
  576. endif()
  577. elseif(APPLE)
  578. get_target_property(needs_storekit ${target} JUCE_NEEDS_STORE_KIT)
  579. if(needs_storekit)
  580. _juce_link_frameworks("${target}" PRIVATE StoreKit)
  581. endif()
  582. get_target_property(needs_camera ${target} JUCE_CAMERA_PERMISSION_ENABLED)
  583. if(CMAKE_SYSTEM_NAME STREQUAL "iOS" AND needs_camera)
  584. _juce_link_frameworks("${target}" PRIVATE ImageIO)
  585. endif()
  586. endif()
  587. endfunction()
  588. # ==================================================================================================
  589. function(_juce_get_module_definitions target filter out_var)
  590. set(compile_defs $<TARGET_GENEX_EVAL:${target},$<TARGET_PROPERTY:${target},COMPILE_DEFINITIONS>>)
  591. if(filter)
  592. set(${out_var} $<FILTER:${compile_defs},EXCLUDE,JucePlugin_Build_|JUCE_SHARED_CODE> PARENT_SCOPE)
  593. else()
  594. set(${out_var} ${compile_defs} PARENT_SCOPE)
  595. endif()
  596. endfunction()
  597. function(_juce_append_record output key)
  598. string(ASCII 30 RS)
  599. string(ASCII 31 US)
  600. set(${output} "${${output}}${key}${US}${ARGN}${RS}" PARENT_SCOPE)
  601. endfunction()
  602. function(_juce_append_target_property output key target property)
  603. get_target_property(prop ${target} ${property})
  604. if(prop STREQUAL "prop-NOTFOUND")
  605. set(prop)
  606. endif()
  607. _juce_append_record(${output} ${key} ${prop})
  608. set(${output} "${${output}}" PARENT_SCOPE)
  609. endfunction()
  610. # This is all info that should be known at configure time (i.e. no generator expressions here!)
  611. # We use this info to generate plists and entitlements files, also at configure time.
  612. function(_juce_write_configure_time_info target)
  613. _juce_append_target_property(file_content EXECUTABLE_NAME ${target} JUCE_PRODUCT_NAME)
  614. _juce_append_target_property(file_content VERSION ${target} JUCE_VERSION)
  615. _juce_append_target_property(file_content BUILD_VERSION ${target} JUCE_BUILD_VERSION)
  616. _juce_append_target_property(file_content PLIST_TO_MERGE ${target} JUCE_PLIST_TO_MERGE)
  617. _juce_append_target_property(file_content BUNDLE_ID ${target} JUCE_BUNDLE_ID)
  618. _juce_append_target_property(file_content XCODE_EXTRA_PLIST_ENTRIES ${target} JUCE_XCODE_EXTRA_PLIST_ENTRIES)
  619. _juce_append_target_property(file_content MICROPHONE_PERMISSION_ENABLED ${target} JUCE_MICROPHONE_PERMISSION_ENABLED)
  620. _juce_append_target_property(file_content MICROPHONE_PERMISSION_TEXT ${target} JUCE_MICROPHONE_PERMISSION_TEXT)
  621. _juce_append_target_property(file_content CAMERA_PERMISSION_ENABLED ${target} JUCE_CAMERA_PERMISSION_ENABLED)
  622. _juce_append_target_property(file_content CAMERA_PERMISSION_TEXT ${target} JUCE_CAMERA_PERMISSION_TEXT)
  623. _juce_append_target_property(file_content BLUETOOTH_PERMISSION_ENABLED ${target} JUCE_BLUETOOTH_PERMISSION_ENABLED)
  624. _juce_append_target_property(file_content BLUETOOTH_PERMISSION_TEXT ${target} JUCE_BLUETOOTH_PERMISSION_TEXT)
  625. _juce_append_target_property(file_content SEND_APPLE_EVENTS_PERMISSION_ENABLED ${target} JUCE_SEND_APPLE_EVENTS_PERMISSION_ENABLED)
  626. _juce_append_target_property(file_content SEND_APPLE_EVENTS_PERMISSION_TEXT ${target} JUCE_SEND_APPLE_EVENTS_PERMISSION_TEXT)
  627. _juce_append_target_property(file_content SHOULD_ADD_STORYBOARD ${target} JUCE_SHOULD_ADD_STORYBOARD)
  628. _juce_append_target_property(file_content LAUNCH_STORYBOARD_FILE ${target} JUCE_LAUNCH_STORYBOARD_FILE)
  629. _juce_append_target_property(file_content ICON_FILE ${target} JUCE_ICON_FILE)
  630. _juce_append_target_property(file_content PROJECT_NAME ${target} JUCE_PRODUCT_NAME)
  631. _juce_append_target_property(file_content COMPANY_COPYRIGHT ${target} JUCE_COMPANY_COPYRIGHT)
  632. _juce_append_target_property(file_content COMPANY_NAME ${target} JUCE_COMPANY_NAME)
  633. _juce_append_target_property(file_content DOCUMENT_EXTENSIONS ${target} JUCE_DOCUMENT_EXTENSIONS)
  634. _juce_append_target_property(file_content FILE_SHARING_ENABLED ${target} JUCE_FILE_SHARING_ENABLED)
  635. _juce_append_target_property(file_content DOCUMENT_BROWSER_ENABLED ${target} JUCE_DOCUMENT_BROWSER_ENABLED)
  636. _juce_append_target_property(file_content STATUS_BAR_HIDDEN ${target} JUCE_STATUS_BAR_HIDDEN)
  637. _juce_append_target_property(file_content REQUIRES_FULL_SCREEN ${target} JUCE_REQUIRES_FULL_SCREEN)
  638. _juce_append_target_property(file_content BACKGROUND_AUDIO_ENABLED ${target} JUCE_BACKGROUND_AUDIO_ENABLED)
  639. _juce_append_target_property(file_content BACKGROUND_BLE_ENABLED ${target} JUCE_BACKGROUND_BLE_ENABLED)
  640. _juce_append_target_property(file_content PUSH_NOTIFICATIONS_ENABLED ${target} JUCE_PUSH_NOTIFICATIONS_ENABLED)
  641. _juce_append_target_property(file_content PLUGIN_MANUFACTURER_CODE ${target} JUCE_PLUGIN_MANUFACTURER_CODE)
  642. _juce_append_target_property(file_content PLUGIN_CODE ${target} JUCE_PLUGIN_CODE)
  643. _juce_append_target_property(file_content IPHONE_SCREEN_ORIENTATIONS ${target} JUCE_IPHONE_SCREEN_ORIENTATIONS)
  644. _juce_append_target_property(file_content IPAD_SCREEN_ORIENTATIONS ${target} JUCE_IPAD_SCREEN_ORIENTATIONS)
  645. _juce_append_target_property(file_content PLUGIN_NAME ${target} JUCE_PLUGIN_NAME)
  646. _juce_append_target_property(file_content PLUGIN_MANUFACTURER ${target} JUCE_COMPANY_NAME)
  647. _juce_append_target_property(file_content PLUGIN_DESCRIPTION ${target} JUCE_DESCRIPTION)
  648. _juce_append_target_property(file_content PLUGIN_AU_EXPORT_PREFIX ${target} JUCE_AU_EXPORT_PREFIX)
  649. _juce_append_target_property(file_content PLUGIN_AU_MAIN_TYPE ${target} JUCE_AU_MAIN_TYPE_CODE)
  650. _juce_append_target_property(file_content IS_AU_SANDBOX_SAFE ${target} JUCE_AU_SANDBOX_SAFE)
  651. _juce_append_target_property(file_content IS_PLUGIN_SYNTH ${target} JUCE_IS_SYNTH)
  652. _juce_append_target_property(file_content SUPPRESS_AU_PLIST_RESOURCE_USAGE ${target} JUCE_SUPPRESS_AU_PLIST_RESOURCE_USAGE)
  653. _juce_append_target_property(file_content HARDENED_RUNTIME_ENABLED ${target} JUCE_HARDENED_RUNTIME_ENABLED)
  654. _juce_append_target_property(file_content APP_SANDBOX_ENABLED ${target} JUCE_APP_SANDBOX_ENABLED)
  655. _juce_append_target_property(file_content APP_SANDBOX_INHERIT ${target} JUCE_APP_SANDBOX_INHERIT)
  656. _juce_append_target_property(file_content HARDENED_RUNTIME_OPTIONS ${target} JUCE_HARDENED_RUNTIME_OPTIONS)
  657. _juce_append_target_property(file_content APP_SANDBOX_OPTIONS ${target} JUCE_APP_SANDBOX_OPTIONS)
  658. _juce_append_target_property(file_content APP_GROUPS_ENABLED ${target} JUCE_APP_GROUPS_ENABLED)
  659. _juce_append_target_property(file_content APP_GROUP_IDS ${target} JUCE_APP_GROUP_IDS)
  660. _juce_append_target_property(file_content IS_PLUGIN ${target} JUCE_IS_PLUGIN)
  661. _juce_append_target_property(file_content ICLOUD_PERMISSIONS_ENABLED ${target} JUCE_ICLOUD_PERMISSIONS_ENABLED)
  662. if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
  663. _juce_append_record(file_content IS_IOS 1)
  664. else()
  665. _juce_append_record(file_content IS_IOS 0)
  666. endif()
  667. get_target_property(juce_library_code ${target} JUCE_GENERATED_SOURCES_DIRECTORY)
  668. set(info_file "${juce_library_code}/Info.txt")
  669. file(WRITE "${info_file}" "${file_content}")
  670. set_target_properties(${target} PROPERTIES JUCE_INFO_FILE "${info_file}")
  671. endfunction()
  672. # In this file, we put things that CMake is only able to divine at generate time, like preprocessor definitions.
  673. # We use the target preprocessor definitions to work out which JUCE modules should go in the JuceHeader.h.
  674. function(_juce_write_generate_time_info target)
  675. _juce_get_module_definitions(${target} OFF module_defs)
  676. _juce_append_record(defs MODULE_DEFINITIONS ${module_defs})
  677. _juce_append_target_property(defs EXECUTABLE_NAME ${target} JUCE_PRODUCT_NAME)
  678. _juce_append_target_property(defs PROJECT_NAME ${target} JUCE_PRODUCT_NAME)
  679. _juce_append_target_property(defs VERSION ${target} JUCE_VERSION)
  680. _juce_append_target_property(defs COMPANY_NAME ${target} JUCE_COMPANY_NAME)
  681. get_target_property(juce_library_code ${target} JUCE_GENERATED_SOURCES_DIRECTORY)
  682. set(defs_file "${juce_library_code}/$<CONFIG>/Defs.txt")
  683. file(GENERATE OUTPUT "${defs_file}" CONTENT "${defs}")
  684. set_target_properties(${target} PROPERTIES JUCE_DEFS_FILE "${defs_file}")
  685. endfunction()
  686. # ==================================================================================================
  687. function(juce_add_binary_data target)
  688. set(one_value_args NAMESPACE HEADER_NAME)
  689. set(multi_value_args SOURCES)
  690. cmake_parse_arguments(JUCE_ARG "" "${one_value_args}" "${multi_value_args}" ${ARGN})
  691. list(LENGTH JUCE_ARG_SOURCES num_binary_files)
  692. if(${num_binary_files} LESS 1)
  693. message(FATAL_ERROR "juce_add_binary_data must be passed at least one file to encode")
  694. endif()
  695. add_library(${target} STATIC)
  696. set(juce_binary_data_folder "${CMAKE_CURRENT_BINARY_DIR}/juce_binarydata_${target}/JuceLibraryCode")
  697. set(binary_file_names)
  698. foreach(index RANGE 1 ${num_binary_files})
  699. list(APPEND binary_file_names "${juce_binary_data_folder}/BinaryData${index}.cpp")
  700. endforeach()
  701. file(MAKE_DIRECTORY ${juce_binary_data_folder})
  702. if(NOT JUCE_ARG_NAMESPACE)
  703. set(JUCE_ARG_NAMESPACE BinaryData)
  704. endif()
  705. if(NOT JUCE_ARG_HEADER_NAME)
  706. set(JUCE_ARG_HEADER_NAME BinaryData.h)
  707. endif()
  708. list(APPEND binary_file_names "${juce_binary_data_folder}/${JUCE_ARG_HEADER_NAME}")
  709. set(newline_delimited_input)
  710. foreach(name IN LISTS JUCE_ARG_SOURCES)
  711. _juce_make_absolute_and_check(name)
  712. set(newline_delimited_input "${newline_delimited_input}${name}\n")
  713. endforeach()
  714. set(input_file_list "${juce_binary_data_folder}/input_file_list")
  715. file(WRITE "${input_file_list}" "${newline_delimited_input}")
  716. add_custom_command(OUTPUT ${binary_file_names}
  717. COMMAND juce::juceaide binarydata "${JUCE_ARG_NAMESPACE}" "${JUCE_ARG_HEADER_NAME}"
  718. ${juce_binary_data_folder} "${input_file_list}"
  719. WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
  720. DEPENDS "${input_file_list}"
  721. VERBATIM)
  722. target_sources(${target} PRIVATE "${binary_file_names}")
  723. target_include_directories(${target} INTERFACE ${juce_binary_data_folder})
  724. target_compile_features(${target} PRIVATE cxx_std_11)
  725. # This fixes an issue where Xcode is unable to find binary data during archive.
  726. if(CMAKE_GENERATOR STREQUAL "Xcode")
  727. set_target_properties(${target} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "./")
  728. endif()
  729. if(JUCE_ARG_HEADER_NAME STREQUAL "BinaryData.h")
  730. target_compile_definitions(${target} INTERFACE JUCE_TARGET_HAS_BINARY_DATA=1)
  731. endif()
  732. endfunction()
  733. # ==================================================================================================
  734. # math(EXPR ... OUTPUT_FORMAT HEXADECIMAL) wasn't added until 3.13, but we need 3.12 for vcpkg
  735. # compatibility
  736. function(_juce_dec_to_hex num out_var)
  737. while(num)
  738. math(EXPR digit "${num} % 16")
  739. math(EXPR num "${num} / 16")
  740. if(digit GREATER_EQUAL 10)
  741. math(EXPR ascii_code "${digit} + 55")
  742. string(ASCII "${ascii_code}" digit)
  743. endif()
  744. set(result "${digit}${result}")
  745. endwhile()
  746. set(${out_var} "${result}" PARENT_SCOPE)
  747. endfunction()
  748. function(_juce_version_code version_in out_var)
  749. string(REGEX REPLACE "\\." ";" version_list ${version_in})
  750. list(LENGTH version_list num_version_components)
  751. set(version_major 0)
  752. set(version_minor 0)
  753. set(version_patch 0)
  754. if(num_version_components GREATER 0)
  755. list(GET version_list 0 version_major)
  756. endif()
  757. if(num_version_components GREATER 1)
  758. list(GET version_list 1 version_minor)
  759. endif()
  760. if(num_version_components GREATER 2)
  761. list(GET version_list 2 version_patch)
  762. endif()
  763. math(EXPR decimal "(${version_major} << 16) + (${version_minor} << 8) + ${version_patch}")
  764. _juce_dec_to_hex(${decimal} hex)
  765. set(${out_var} "${hex}" PARENT_SCOPE)
  766. endfunction()
  767. function(_juce_to_char_literal str out_var)
  768. string(APPEND str " ") # Make sure there are at least 4 characters in the string.
  769. # Round-tripping through a file is the simplest way to convert a string to hex...
  770. string(SUBSTRING "${str}" 0 4 four_chars)
  771. string(RANDOM LENGTH 16 random_string)
  772. set(scratch_file "${CMAKE_CURRENT_BINARY_DIR}/${random_string}_ascii_conversion.txt")
  773. file(WRITE "${scratch_file}" "${four_chars}")
  774. file(READ "${scratch_file}" four_chars_hex HEX)
  775. file(REMOVE "${scratch_file}")
  776. set(${out_var} ${four_chars_hex} PARENT_SCOPE)
  777. endfunction()
  778. # ==================================================================================================
  779. function(juce_generate_juce_header target)
  780. get_target_property(juce_library_code ${target} JUCE_GENERATED_SOURCES_DIRECTORY)
  781. if(NOT juce_library_code)
  782. message(FATAL_ERROR "Target ${target} does not have a generated sources directory. Ensure it was created with a juce_add_* function")
  783. endif()
  784. set(juce_header ${juce_library_code}/JuceHeader.h)
  785. target_sources(${target} PRIVATE ${juce_header})
  786. set(defs_file $<GENEX_EVAL:$<TARGET_PROPERTY:${target},JUCE_DEFS_FILE>>)
  787. set(extra_args)
  788. add_custom_command(OUTPUT "${juce_header}"
  789. COMMAND juce::juceaide header "${defs_file}" "${juce_header}" ${extra_args}
  790. DEPENDS "${defs_file}"
  791. VERBATIM)
  792. endfunction()
  793. # ==================================================================================================
  794. function(_juce_execute_juceaide)
  795. if(NOT TARGET juce::juceaide)
  796. message(FATAL_ERROR "The juceaide target does not exist")
  797. endif()
  798. get_target_property(juceaide_location juce::juceaide IMPORTED_LOCATION)
  799. if(NOT EXISTS "${juceaide_location}")
  800. message(FATAL_ERROR "juceaide was imported, but it doesn't exist!")
  801. endif()
  802. execute_process(COMMAND "${juceaide_location}" ${ARGN} RESULT_VARIABLE result_variable)
  803. if(result_variable)
  804. message(FATAL_ERROR "Running juceaide failed")
  805. endif()
  806. endfunction()
  807. function(_juce_set_output_name target name)
  808. if(NOT CMAKE_SYSTEM_NAME STREQUAL "Android")
  809. set_target_properties(${target} PROPERTIES
  810. OUTPUT_NAME ${name}
  811. XCODE_ATTRIBUTE_PRODUCT_NAME ${name})
  812. endif()
  813. endfunction()
  814. function(_juce_generate_icon source_target dest_target)
  815. get_target_property(juce_library_code ${source_target} JUCE_GENERATED_SOURCES_DIRECTORY)
  816. get_target_property(juce_property_icon_big ${source_target} JUCE_ICON_BIG)
  817. get_target_property(juce_property_icon_small ${source_target} JUCE_ICON_SMALL)
  818. set(icon_args)
  819. if(juce_property_icon_big)
  820. list(APPEND icon_args "${juce_property_icon_big}")
  821. endif()
  822. if(juce_property_icon_small)
  823. list(APPEND icon_args "${juce_property_icon_small}")
  824. endif()
  825. set(generated_icon)
  826. if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  827. if(NOT icon_args)
  828. return()
  829. endif()
  830. set(generated_icon "${juce_library_code}/Icon.icns")
  831. # To get compiled properly, we need the icon before the plist is generated!
  832. _juce_execute_juceaide(macicon "${generated_icon}" ${icon_args})
  833. set_source_files_properties(${generated_icon} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
  834. elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
  835. if(NOT icon_args)
  836. return()
  837. endif()
  838. set(generated_icon "${juce_library_code}/icon.ico")
  839. _juce_execute_juceaide(winicon "${generated_icon}" ${icon_args})
  840. elseif(CMAKE_SYSTEM_NAME STREQUAL "iOS")
  841. get_target_property(generated_icon ${source_target} JUCE_CUSTOM_XCASSETS_FOLDER)
  842. if(icon_args AND (NOT generated_icon))
  843. set(out_path "${juce_library_code}/${dest_target}")
  844. set(generated_icon "${out_path}/Images.xcassets")
  845. # To get compiled properly, we need iOS assets at configure time!
  846. _juce_execute_juceaide(iosassets "${out_path}" ${icon_args})
  847. endif()
  848. if(NOT generated_icon)
  849. return()
  850. endif()
  851. set_target_properties(${dest_target} PROPERTIES
  852. XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_APPICON_NAME "AppIcon")
  853. get_target_property(add_storyboard ${source_target} JUCE_SHOULD_ADD_STORYBOARD)
  854. if(NOT add_storyboard)
  855. set_target_properties(${dest_target} PROPERTIES
  856. XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME "LaunchImage")
  857. endif()
  858. endif()
  859. if(generated_icon)
  860. target_sources(${dest_target} PRIVATE ${generated_icon})
  861. set_target_properties(${source_target} ${dest_target} PROPERTIES
  862. JUCE_ICON_FILE "${generated_icon}"
  863. RESOURCE "${generated_icon}")
  864. endif()
  865. endfunction()
  866. function(_juce_add_xcode_entitlements source_target dest_target)
  867. get_target_property(juce_kind_string ${dest_target} JUCE_TARGET_KIND_STRING)
  868. get_target_property(input_info_file ${source_target} JUCE_INFO_FILE)
  869. get_target_property(juce_library_code ${source_target} JUCE_GENERATED_SOURCES_DIRECTORY)
  870. set(entitlements_file "${juce_library_code}/${dest_target}.entitlements")
  871. _juce_execute_juceaide(entitlements "${juce_kind_string}" "${input_info_file}" "${entitlements_file}")
  872. set_target_properties(${dest_target} PROPERTIES
  873. XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "${entitlements_file}")
  874. endfunction()
  875. function(_juce_configure_bundle source_target dest_target)
  876. _juce_generate_icon(${source_target} ${dest_target})
  877. _juce_write_configure_time_info(${source_target})
  878. if(NOT APPLE)
  879. return()
  880. endif()
  881. get_target_property(generated_icon ${source_target} JUCE_ICON_FILE)
  882. set(icon_dependency)
  883. if(generated_icon)
  884. set(icon_dependency "${generated_icon}")
  885. endif()
  886. get_target_property(juce_library_code ${source_target} JUCE_GENERATED_SOURCES_DIRECTORY)
  887. get_target_property(input_info_file ${source_target} JUCE_INFO_FILE)
  888. set(this_output_info_dir "${juce_library_code}/${dest_target}")
  889. set(this_output_pkginfo "${this_output_info_dir}/PkgInfo")
  890. set(this_output_plist "${this_output_info_dir}/Info.plist")
  891. get_target_property(juce_kind_string ${dest_target} JUCE_TARGET_KIND_STRING)
  892. _juce_execute_juceaide(plist "${juce_kind_string}" "${input_info_file}" "${this_output_plist}")
  893. set_target_properties(${dest_target} PROPERTIES
  894. BUNDLE TRUE
  895. MACOSX_BUNDLE_INFO_PLIST "${this_output_plist}")
  896. add_custom_command(OUTPUT "${this_output_pkginfo}"
  897. COMMAND juce::juceaide pkginfo "${juce_kind_string}" "${this_output_pkginfo}"
  898. VERBATIM)
  899. set(output_folder "$<TARGET_BUNDLE_CONTENT_DIR:${dest_target}>")
  900. target_sources(${dest_target} PRIVATE "${this_output_pkginfo}")
  901. set_source_files_properties("${this_output_pkginfo}" PROPERTIES
  902. HEADER_FILE_ONLY TRUE
  903. GENERATED TRUE)
  904. add_custom_command(TARGET ${dest_target} POST_BUILD
  905. COMMAND "${CMAKE_COMMAND}" -E copy "${this_output_pkginfo}" "${output_folder}"
  906. DEPENDS "${this_output_pkginfo}"
  907. VERBATIM)
  908. _juce_add_xcode_entitlements(${source_target} ${dest_target})
  909. if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
  910. get_target_property(add_storyboard ${source_target} JUCE_SHOULD_ADD_STORYBOARD)
  911. if(add_storyboard)
  912. get_target_property(storyboard_file ${source_target} JUCE_LAUNCH_STORYBOARD_FILE)
  913. if(NOT EXISTS "${storyboard_file}")
  914. message(FATAL_ERROR "Could not find storyboard file: ${storyboard_file}")
  915. endif()
  916. target_sources(${dest_target} PRIVATE "${storyboard_file}")
  917. set_property(TARGET ${dest_target} APPEND PROPERTY RESOURCE "${storyboard_file}")
  918. endif()
  919. endif()
  920. set_target_properties(${dest_target} PROPERTIES
  921. XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME
  922. "$<TARGET_PROPERTY:${source_target},JUCE_HARDENED_RUNTIME_ENABLED>"
  923. XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY
  924. "$<TARGET_PROPERTY:${source_target},JUCE_TARGETED_DEVICE_FAMILY>")
  925. if(juce_kind_string STREQUAL "AUv3 AppExtension")
  926. get_target_property(source_bundle_id ${source_target} JUCE_BUNDLE_ID)
  927. if(source_bundle_id MATCHES "\\.([^.]+)$")
  928. set_target_properties(${dest_target} PROPERTIES
  929. XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER
  930. "${source_bundle_id}.${CMAKE_MATCH_1}AUv3")
  931. else()
  932. message(FATAL_ERROR "Bundle ID should contain at least one `.`!")
  933. endif()
  934. else()
  935. set_target_properties(${dest_target} PROPERTIES
  936. XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER
  937. $<TARGET_PROPERTY:${source_target},JUCE_BUNDLE_ID>)
  938. endif()
  939. if(CMAKE_GENERATOR STREQUAL "Xcode")
  940. get_target_property(product_name ${source_target} JUCE_PRODUCT_NAME)
  941. set(install_path "$(LOCAL_APPS_DIR)")
  942. if(juce_kind_string STREQUAL "AUv3 AppExtension")
  943. set(install_path "${install_path}/${product_name}.app")
  944. if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
  945. set(install_path "${install_path}/PlugIns")
  946. else()
  947. set(install_path "${install_path}/Contents/PlugIns")
  948. endif()
  949. endif()
  950. set_target_properties(${dest_target} PROPERTIES
  951. XCODE_ATTRIBUTE_INSTALL_PATH "${install_path}"
  952. XCODE_ATTRIBUTE_SKIP_INSTALL "NO")
  953. endif()
  954. endfunction()
  955. function(_juce_add_resources_rc source_target dest_target)
  956. if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
  957. return()
  958. endif()
  959. get_target_property(juce_library_code ${source_target} JUCE_GENERATED_SOURCES_DIRECTORY)
  960. set(input_info_file "$<TARGET_PROPERTY:${source_target},JUCE_INFO_FILE>")
  961. get_target_property(generated_icon ${source_target} JUCE_ICON_FILE)
  962. set(dependency)
  963. if(generated_icon)
  964. set(dependency DEPENDS "${generated_icon}")
  965. endif()
  966. set(resource_rc_file "${juce_library_code}/resources.rc")
  967. add_custom_command(OUTPUT "${resource_rc_file}"
  968. COMMAND juce::juceaide rcfile "${input_info_file}" "${resource_rc_file}"
  969. ${dependency}
  970. VERBATIM)
  971. target_sources(${dest_target} PRIVATE "${resource_rc_file}")
  972. endfunction()
  973. function(_juce_configure_app_bundle source_target dest_target)
  974. set_target_properties(${dest_target} PROPERTIES
  975. JUCE_TARGET_KIND_STRING "App"
  976. MACOSX_BUNDLE TRUE
  977. WIN32_EXECUTABLE TRUE)
  978. _juce_add_resources_rc(${source_target} ${dest_target})
  979. if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  980. set(nib_path "${JUCE_CMAKE_UTILS_DIR}/RecentFilesMenuTemplate.nib")
  981. target_sources("${dest_target}" PRIVATE "${nib_path}")
  982. set_source_files_properties("${nib_path}" PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
  983. endif()
  984. endfunction()
  985. # ==================================================================================================
  986. function(_juce_create_windows_package source_target dest_target extension default_icon x32folder x64folder)
  987. if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
  988. return()
  989. endif()
  990. get_target_property(products_folder ${dest_target} LIBRARY_OUTPUT_DIRECTORY)
  991. set(product_name $<TARGET_PROPERTY:${source_target},JUCE_PRODUCT_NAME>)
  992. set(output_folder "${products_folder}/${product_name}.${extension}")
  993. set(is_x64 $<EQUAL:${CMAKE_SIZEOF_VOID_P},8>)
  994. set(arch_string $<IF:${is_x64},${x64folder},${x32folder}>)
  995. set_target_properties(${dest_target}
  996. PROPERTIES
  997. LIBRARY_OUTPUT_DIRECTORY "${output_folder}/Contents/${arch_string}")
  998. get_target_property(icon_file ${source_target} JUCE_ICON_FILE)
  999. if(NOT icon_file)
  1000. set(icon_file "${default_icon}")
  1001. endif()
  1002. if(icon_file)
  1003. set(desktop_ini "${output_folder}/desktop.ini")
  1004. set(plugin_ico "${output_folder}/Plugin.ico")
  1005. file(GENERATE OUTPUT "${desktop_ini}"
  1006. CONTENT
  1007. "[.ShellClassInfo]\nIconResource=Plugin.ico,0\nIconFile=Plugin.ico\nIconIndex=0\n")
  1008. add_custom_command(TARGET ${dest_target} POST_BUILD
  1009. COMMAND "${CMAKE_COMMAND}" -E copy "${icon_file}" "${plugin_ico}"
  1010. COMMAND attrib +s "${desktop_ini}"
  1011. COMMAND attrib +s "${output_folder}"
  1012. DEPENDS "${icon_file}" "${desktop_ini}"
  1013. VERBATIM)
  1014. endif()
  1015. endfunction()
  1016. # ==================================================================================================
  1017. function(_juce_add_unity_plugin_prefix_if_necessary name out_var)
  1018. string(TOLOWER "${name}" lower)
  1019. if(NOT lower MATCHES "^audioplugin")
  1020. set(${out_var} "audioplugin_${name}" PARENT_SCOPE)
  1021. else()
  1022. set(${out_var} "${name}" PARENT_SCOPE)
  1023. endif()
  1024. endfunction()
  1025. function(_juce_add_unity_script_file shared_target out_var)
  1026. set(script_in "${JUCE_CMAKE_UTILS_DIR}/UnityPluginGUIScript.cs.in")
  1027. get_target_property(plugin_name ${shared_target} JUCE_PLUGIN_NAME)
  1028. get_target_property(plugin_vendor ${shared_target} JUCE_COMPANY_NAME)
  1029. get_target_property(plugin_description ${shared_target} JUCE_DESCRIPTION)
  1030. string(REGEX REPLACE " +" "_" plugin_class_name "${plugin_name}")
  1031. get_target_property(juce_library_code ${shared_target} JUCE_GENERATED_SOURCES_DIRECTORY)
  1032. _juce_add_unity_plugin_prefix_if_necessary("${plugin_name}" script_prefix)
  1033. set(script_out "${juce_library_code}/${script_prefix}_UnityScript.cs")
  1034. configure_file(${script_in} ${script_out})
  1035. set(${out_var} "${script_out}" PARENT_SCOPE)
  1036. endfunction()
  1037. # ==================================================================================================
  1038. function(_juce_copy_dir target from to)
  1039. # This is a shim to make CMake copy a whole directory, rather than just
  1040. # the contents of a directory
  1041. add_custom_command(TARGET ${target} POST_BUILD
  1042. COMMAND "${CMAKE_COMMAND}"
  1043. "-Dsrc=${from}"
  1044. "-Ddest=${to}"
  1045. "-P" "${JUCE_CMAKE_UTILS_DIR}/copyDir.cmake"
  1046. VERBATIM)
  1047. endfunction()
  1048. function(_juce_set_copy_properties shared_code target from to_property)
  1049. get_target_property(destination "${shared_code}" "${to_property}")
  1050. if(destination)
  1051. set_target_properties("${target}" PROPERTIES JUCE_PLUGIN_COPY_DIR "${destination}")
  1052. endif()
  1053. set_target_properties("${target}" PROPERTIES JUCE_PLUGIN_ARTEFACT_FILE "${from}")
  1054. endfunction()
  1055. function(juce_enable_copy_plugin_step shared_code_target)
  1056. get_target_property(active_targets "${shared_code_target}" JUCE_ACTIVE_PLUGIN_TARGETS)
  1057. foreach(target IN LISTS active_targets)
  1058. get_target_property(source "${target}" JUCE_PLUGIN_ARTEFACT_FILE)
  1059. if(source)
  1060. get_target_property(dest "${target}" JUCE_PLUGIN_COPY_DIR)
  1061. if(dest)
  1062. _juce_copy_dir("${target}" "${source}" "$<GENEX_EVAL:${dest}>")
  1063. else()
  1064. message(WARNING "Target '${target}' requested copy but no destination is set")
  1065. endif()
  1066. endif()
  1067. endforeach()
  1068. endfunction()
  1069. # ==================================================================================================
  1070. function(_juce_set_plugin_target_properties shared_code_target kind)
  1071. set(target_name ${shared_code_target}_${kind})
  1072. set_target_properties(${target_name} PROPERTIES
  1073. ARCHIVE_OUTPUT_DIRECTORY "$<GENEX_EVAL:$<TARGET_PROPERTY:${shared_code_target},ARCHIVE_OUTPUT_DIRECTORY>>/${kind}"
  1074. LIBRARY_OUTPUT_DIRECTORY "$<GENEX_EVAL:$<TARGET_PROPERTY:${shared_code_target},LIBRARY_OUTPUT_DIRECTORY>>/${kind}"
  1075. RUNTIME_OUTPUT_DIRECTORY "$<GENEX_EVAL:$<TARGET_PROPERTY:${shared_code_target},RUNTIME_OUTPUT_DIRECTORY>>/${kind}")
  1076. get_target_property(products_folder ${target_name} LIBRARY_OUTPUT_DIRECTORY)
  1077. set(product_name $<TARGET_PROPERTY:${shared_code_target},JUCE_PRODUCT_NAME>)
  1078. if(kind STREQUAL "VST3")
  1079. set_target_properties(${target_name} PROPERTIES
  1080. BUNDLE_EXTENSION vst3
  1081. PREFIX ""
  1082. SUFFIX .vst3
  1083. BUNDLE TRUE
  1084. XCODE_ATTRIBUTE_WRAPPER_EXTENSION vst3
  1085. XCODE_ATTRIBUTE_LIBRARY_STYLE Bundle
  1086. XCODE_ATTRIBUTE_GENERATE_PKGINFO_FILE YES)
  1087. _juce_create_windows_package(${shared_code_target} ${target_name} vst3 "" x86-win x86_64-win)
  1088. set(output_path "${products_folder}/${product_name}.vst3")
  1089. if((CMAKE_SYSTEM_NAME STREQUAL "Linux") OR (CMAKE_SYSTEM_NAME MATCHES ".*BSD"))
  1090. set_target_properties(${target_name} PROPERTIES
  1091. SUFFIX .so
  1092. LIBRARY_OUTPUT_DIRECTORY "${output_path}/Contents/${JUCE_LINUX_TARGET_ARCHITECTURE}-linux")
  1093. endif()
  1094. _juce_set_copy_properties(${shared_code_target} ${target_name} "${output_path}" JUCE_VST3_COPY_DIR)
  1095. elseif(kind STREQUAL "VST")
  1096. set_target_properties(${target_name} PROPERTIES
  1097. BUNDLE_EXTENSION vst
  1098. BUNDLE TRUE
  1099. XCODE_ATTRIBUTE_WRAPPER_EXTENSION vst
  1100. XCODE_ATTRIBUTE_LIBRARY_STYLE Bundle
  1101. XCODE_ATTRIBUTE_GENERATE_PKGINFO_FILE YES)
  1102. set(output_path "$<TARGET_FILE:${target_name}>")
  1103. if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  1104. set(output_path "$<TARGET_BUNDLE_DIR:${target_name}>")
  1105. endif()
  1106. _juce_set_copy_properties(${shared_code_target} ${target_name} "${output_path}" JUCE_VST_COPY_DIR)
  1107. elseif(kind STREQUAL "AU")
  1108. set_target_properties(${target_name} PROPERTIES
  1109. BUNDLE_EXTENSION component
  1110. XCODE_ATTRIBUTE_WRAPPER_EXTENSION component
  1111. BUNDLE TRUE
  1112. XCODE_ATTRIBUTE_LIBRARY_STYLE Bundle
  1113. XCODE_ATTRIBUTE_GENERATE_PKGINFO_FILE YES)
  1114. set(output_path "$<TARGET_BUNDLE_DIR:${target_name}>")
  1115. _juce_set_copy_properties(${shared_code_target} ${target_name} "${output_path}" JUCE_AU_COPY_DIR)
  1116. elseif(kind STREQUAL "AUv3")
  1117. set_target_properties(${target_name} PROPERTIES
  1118. XCODE_PRODUCT_TYPE "com.apple.product-type.app-extension"
  1119. BUNDLE_EXTENSION appex
  1120. XCODE_ATTRIBUTE_WRAPPER_EXTENSION appex
  1121. XCODE_ATTRIBUTE_GENERATE_PKGINFO_FILE YES)
  1122. elseif(kind STREQUAL "AAX")
  1123. set_target_properties(${target_name} PROPERTIES
  1124. BUNDLE_EXTENSION aaxplugin
  1125. PREFIX ""
  1126. SUFFIX .aaxplugin
  1127. XCODE_ATTRIBUTE_WRAPPER_EXTENSION aaxplugin
  1128. BUNDLE TRUE
  1129. XCODE_ATTRIBUTE_LIBRARY_STYLE Bundle
  1130. XCODE_ATTRIBUTE_GENERATE_PKGINFO_FILE YES)
  1131. get_target_property(default_icon juce_aax_sdk INTERFACE_JUCE_AAX_DEFAULT_ICON)
  1132. _juce_create_windows_package(${shared_code_target} ${target_name} aaxplugin "${default_icon}" Win32 x64)
  1133. set(output_path "${products_folder}/${product_name}.aaxplugin")
  1134. _juce_set_copy_properties(${shared_code_target} ${target_name} "${output_path}" JUCE_AAX_COPY_DIR)
  1135. elseif(kind STREQUAL "Unity")
  1136. set_target_properties(${target_name} PROPERTIES
  1137. BUNDLE_EXTENSION bundle
  1138. XCODE_ATTRIBUTE_WRAPPER_EXTENSION bundle
  1139. BUNDLE TRUE
  1140. XCODE_ATTRIBUTE_LIBRARY_STYLE Bundle
  1141. XCODE_ATTRIBUTE_GENERATE_PKGINFO_FILE YES)
  1142. _juce_add_unity_script_file(${shared_code_target} script_file)
  1143. target_sources(${target_name} PRIVATE "${script_file}")
  1144. set_source_files_properties("${script_file}" PROPERTIES
  1145. GENERATED TRUE
  1146. MACOSX_PACKAGE_LOCATION Resources)
  1147. if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  1148. set(output_path "$<TARGET_BUNDLE_DIR:${target_name}>")
  1149. _juce_set_copy_properties(${shared_code_target} ${target_name} "${output_path}" JUCE_UNITY_COPY_DIR)
  1150. else()
  1151. # On windows and linux, the gui script needs to be copied next to the unity output
  1152. add_custom_command(TARGET ${target_name} POST_BUILD
  1153. COMMAND "${CMAKE_COMMAND}" -E copy "${script_file}" "${products_folder}"
  1154. DEPENDS "${script_file}"
  1155. VERBATIM)
  1156. _juce_set_copy_properties(${shared_code_target}
  1157. ${target_name}
  1158. "$<TARGET_FILE:${target_name}>"
  1159. JUCE_UNITY_COPY_DIR)
  1160. _juce_set_copy_properties(${shared_code_target}
  1161. ${target_name}
  1162. "${script_file}"
  1163. JUCE_UNITY_COPY_DIR)
  1164. endif()
  1165. endif()
  1166. endfunction()
  1167. # Place plugin wrapper targets alongside the shared code target in IDEs
  1168. function(_juce_set_plugin_folder_property shared_target wrapper_target)
  1169. get_target_property(folder_to_use "${shared_target}" FOLDER)
  1170. if(folder_to_use STREQUAL "folder_to_use-NOTFOUND")
  1171. set_target_properties("${shared_target}" PROPERTIES FOLDER "${shared_target}")
  1172. elseif(NOT folder_to_use MATCHES ".*${shared_target}$")
  1173. set_target_properties("${shared_target}" PROPERTIES FOLDER "${folder_to_use}/${shared_target}")
  1174. endif()
  1175. get_target_property(folder_to_use "${shared_target}" FOLDER)
  1176. set_target_properties("${wrapper_target}" PROPERTIES FOLDER "${folder_to_use}")
  1177. endfunction()
  1178. # Convert the cmake plugin kind ids to strings understood by ProjectType::Target::typeFromName
  1179. function(_juce_get_plugin_kind_name kind out_var)
  1180. if(kind STREQUAL "AU")
  1181. set(${out_var} "AU" PARENT_SCOPE)
  1182. elseif(kind STREQUAL "AUv3")
  1183. set(${out_var} "AUv3 AppExtension" PARENT_SCOPE)
  1184. elseif(kind STREQUAL "AAX")
  1185. set(${out_var} "AAX" PARENT_SCOPE)
  1186. elseif(kind STREQUAL "Standalone")
  1187. set(${out_var} "Standalone Plugin" PARENT_SCOPE)
  1188. elseif(kind STREQUAL "Unity")
  1189. set(${out_var} "Unity Plugin" PARENT_SCOPE)
  1190. elseif(kind STREQUAL "VST")
  1191. set(${out_var} "VST" PARENT_SCOPE)
  1192. elseif(kind STREQUAL "VST3")
  1193. set(${out_var} "VST3" PARENT_SCOPE)
  1194. endif()
  1195. endfunction()
  1196. function(_juce_link_plugin_wrapper shared_code_target kind)
  1197. set(target_name ${shared_code_target}_${kind})
  1198. if(CMAKE_SYSTEM_NAME STREQUAL "Android")
  1199. add_library(${target_name} SHARED)
  1200. elseif((kind STREQUAL "Standalone") OR (kind STREQUAL "AUv3"))
  1201. add_executable(${target_name} WIN32 MACOSX_BUNDLE)
  1202. else()
  1203. add_library(${target_name} MODULE)
  1204. endif()
  1205. if((CMAKE_SYSTEM_NAME STREQUAL "Linux") OR (CMAKE_SYSTEM_NAME MATCHES ".*BSD"))
  1206. target_link_libraries(${target_name} PRIVATE "-Wl,--no-undefined")
  1207. endif()
  1208. # We re-export the shared code's private include dirs, because the wrapper targets need to
  1209. # see the module headers. We don't just link publicly, because that would introduce
  1210. # conflicting macro definitions.
  1211. target_include_directories(${target_name} PRIVATE
  1212. $<TARGET_PROPERTY:${shared_code_target},INCLUDE_DIRECTORIES>)
  1213. target_link_libraries(${target_name} PRIVATE
  1214. ${shared_code_target}
  1215. juce::juce_audio_plugin_client_${kind})
  1216. _juce_set_output_name(${target_name} $<TARGET_PROPERTY:${shared_code_target},JUCE_PRODUCT_NAME>)
  1217. _juce_set_plugin_folder_property("${shared_code_target}" "${target_name}")
  1218. _juce_get_plugin_kind_name(${kind} juce_kind_string)
  1219. set_target_properties(${target_name} PROPERTIES
  1220. XCODE_ATTRIBUTE_CLANG_LINK_OBJC_RUNTIME NO
  1221. XCODE_ATTRIBUTE_COMBINE_HIDPI_IMAGES YES
  1222. POSITION_INDEPENDENT_CODE TRUE
  1223. VISIBILITY_INLINES_HIDDEN TRUE
  1224. C_VISIBILITY_PRESET hidden
  1225. CXX_VISIBILITY_PRESET hidden
  1226. JUCE_TARGET_KIND_STRING "${juce_kind_string}")
  1227. add_dependencies(${shared_code_target}_All ${target_name})
  1228. _juce_configure_bundle(${shared_code_target} ${target_name})
  1229. _juce_set_plugin_target_properties(${shared_code_target} ${kind})
  1230. endfunction()
  1231. # ==================================================================================================
  1232. function(_juce_get_vst3_category_string target out_var)
  1233. get_target_property(vst3_categories ${target} JUCE_VST3_CATEGORIES)
  1234. if((NOT Fx IN_LIST vst3_categories) AND (NOT Instrument IN_LIST vst3_categories))
  1235. get_target_property(is_synth ${target} JUCE_IS_SYNTH)
  1236. if(is_synth)
  1237. set(first_type Instrument)
  1238. else()
  1239. set(first_type Fx)
  1240. endif()
  1241. list(INSERT vst3_categories 0 ${first_type})
  1242. else()
  1243. if(Instrument IN_LIST vst3_categories)
  1244. list(REMOVE_ITEM vst3_categories Instrument)
  1245. list(INSERT vst3_categories 0 Instrument)
  1246. endif()
  1247. if(Fx IN_LIST vst3_categories)
  1248. list(REMOVE_ITEM vst3_categories Fx)
  1249. list(INSERT vst3_categories 0 Fx)
  1250. endif()
  1251. endif()
  1252. string(REGEX REPLACE ";" "|" result "${vst3_categories}")
  1253. set(${out_var} ${result} PARENT_SCOPE)
  1254. endfunction()
  1255. function(_juce_configure_plugin_targets target)
  1256. if(CMAKE_VERSION VERSION_LESS "3.15.0")
  1257. message(FATAL_ERROR "Plugin targets require CMake 3.15 or higher")
  1258. endif()
  1259. _juce_set_output_name(${target} $<TARGET_PROPERTY:${target},JUCE_PRODUCT_NAME>_SharedCode)
  1260. target_link_libraries(${target} PRIVATE juce::juce_audio_plugin_client_utils)
  1261. get_target_property(enabled_formats ${target} JUCE_FORMATS)
  1262. set(active_formats)
  1263. _juce_get_platform_plugin_kinds(plugin_kinds)
  1264. foreach(kind IN LISTS plugin_kinds)
  1265. if(kind IN_LIST enabled_formats)
  1266. list(APPEND active_formats "${kind}")
  1267. endif()
  1268. endforeach()
  1269. if((VST IN_LIST active_formats) AND (NOT TARGET juce_vst2_sdk))
  1270. message(FATAL_ERROR "Use juce_set_vst2_sdk_path to set up the VST sdk before adding VST targets")
  1271. elseif((AAX IN_LIST active_formats) AND (NOT TARGET juce_aax_sdk))
  1272. message(FATAL_ERROR "Use juce_set_aax_sdk_path to set up the AAX sdk before adding AAX targets")
  1273. endif()
  1274. _juce_add_standard_defs(${target})
  1275. _juce_add_plugin_definitions(${target} PRIVATE ${active_formats})
  1276. # The plugin wrappers need to know what other modules are available, especially
  1277. # juce_audio_utils and juce_gui_basics. We achieve this by searching for
  1278. # JUCE_MODULE_AVAILABLE_ private compile definitions, and reexporting them in
  1279. # the interface compile definitions.
  1280. # Unfortunately this requires CMake 3.15.
  1281. _juce_get_module_definitions(${target} ON enabled_modules)
  1282. target_compile_definitions(${target} INTERFACE ${enabled_modules})
  1283. target_compile_definitions(${target} PRIVATE JUCE_SHARED_CODE=1)
  1284. get_target_property(project_version_string ${target} JUCE_VERSION)
  1285. _juce_version_code(${project_version_string} project_version_hex)
  1286. get_target_property(project_manufacturer_code ${target} JUCE_PLUGIN_MANUFACTURER_CODE)
  1287. get_target_property(project_plugin_code ${target} JUCE_PLUGIN_CODE)
  1288. get_target_property(use_legacy_compatibility_plugin_code ${target} JUCE_USE_LEGACY_COMPATIBILITY_PLUGIN_CODE)
  1289. if(use_legacy_compatibility_plugin_code)
  1290. set(project_manufacturer_code "project_manufacturer_code-NOTFOUND")
  1291. endif()
  1292. _juce_to_char_literal(${project_manufacturer_code} project_manufacturer_code)
  1293. _juce_to_char_literal(${project_plugin_code} project_plugin_code)
  1294. _juce_get_vst3_category_string(${target} vst3_category_string)
  1295. target_compile_definitions(${target} PUBLIC
  1296. JUCE_STANDALONE_APPLICATION=JucePlugin_Build_Standalone
  1297. JucePlugin_IsSynth=$<BOOL:$<TARGET_PROPERTY:${target},JUCE_IS_SYNTH>>
  1298. JucePlugin_ManufacturerCode=0x${project_manufacturer_code}
  1299. JucePlugin_Manufacturer="$<TARGET_PROPERTY:${target},JUCE_COMPANY_NAME>"
  1300. JucePlugin_ManufacturerWebsite="$<TARGET_PROPERTY:${target},JUCE_COMPANY_WEBSITE>"
  1301. JucePlugin_ManufacturerEmail="$<TARGET_PROPERTY:${target},JUCE_COMPANY_EMAIL>"
  1302. JucePlugin_PluginCode=0x${project_plugin_code}
  1303. JucePlugin_ProducesMidiOutput=$<BOOL:$<TARGET_PROPERTY:${target},JUCE_NEEDS_MIDI_OUTPUT>>
  1304. JucePlugin_IsMidiEffect=$<BOOL:$<TARGET_PROPERTY:${target},JUCE_IS_MIDI_EFFECT>>
  1305. JucePlugin_WantsMidiInput=$<BOOL:$<TARGET_PROPERTY:${target},JUCE_NEEDS_MIDI_INPUT>>
  1306. JucePlugin_EditorRequiresKeyboardFocus=$<BOOL:$<TARGET_PROPERTY:${target},JUCE_EDITOR_WANTS_KEYBOARD_FOCUS>>
  1307. JucePlugin_Name="$<TARGET_PROPERTY:${target},JUCE_PLUGIN_NAME>"
  1308. JucePlugin_Desc="$<TARGET_PROPERTY:${target},JUCE_DESCRIPTION>"
  1309. JucePlugin_Version=${project_version_string}
  1310. JucePlugin_VersionString="${project_version_string}"
  1311. JucePlugin_VersionCode=0x${project_version_hex}
  1312. JucePlugin_VSTUniqueID=JucePlugin_PluginCode
  1313. JucePlugin_VSTCategory=$<TARGET_PROPERTY:${target},JUCE_VST2_CATEGORY>
  1314. JucePlugin_Vst3Category="${vst3_category_string}"
  1315. JucePlugin_AUMainType=$<TARGET_PROPERTY:${target},JUCE_AU_MAIN_TYPE_CODE>
  1316. JucePlugin_AUSubType=JucePlugin_PluginCode
  1317. JucePlugin_AUExportPrefix=$<TARGET_PROPERTY:${target},JUCE_AU_EXPORT_PREFIX>
  1318. JucePlugin_AUExportPrefixQuoted="$<TARGET_PROPERTY:${target},JUCE_AU_EXPORT_PREFIX>"
  1319. JucePlugin_AUManufacturerCode=JucePlugin_ManufacturerCode
  1320. JucePlugin_CFBundleIdentifier=$<TARGET_PROPERTY:${target},JUCE_BUNDLE_ID>
  1321. JucePlugin_AAXIdentifier=$<TARGET_PROPERTY:${target},JUCE_AAX_IDENTIFIER>
  1322. JucePlugin_AAXManufacturerCode=JucePlugin_ManufacturerCode
  1323. JucePlugin_AAXProductId=JucePlugin_PluginCode
  1324. JucePlugin_AAXCategory=$<TARGET_PROPERTY:${target},JUCE_AAX_CATEGORY>
  1325. JucePlugin_AAXDisableBypass=$<BOOL:$<TARGET_PROPERTY:${target},JUCE_DISABLE_AAX_BYPASS>>
  1326. JucePlugin_AAXDisableMultiMono=$<BOOL:$<TARGET_PROPERTY:${target},JUCE_DISABLE_AAX_MULTI_MONO>>
  1327. JucePlugin_VSTNumMidiInputs=$<TARGET_PROPERTY:${target},JUCE_VST_NUM_MIDI_INS>
  1328. JucePlugin_VSTNumMidiOutputs=$<TARGET_PROPERTY:${target},JUCE_VST_NUM_MIDI_OUTS>)
  1329. set_target_properties(${target} PROPERTIES
  1330. POSITION_INDEPENDENT_CODE TRUE
  1331. INTERFACE_POSITION_INDEPENDENT_CODE TRUE
  1332. VISIBILITY_INLINES_HIDDEN TRUE
  1333. C_VISIBILITY_PRESET hidden
  1334. CXX_VISIBILITY_PRESET hidden)
  1335. # A convenience target for building all plugin variations at once
  1336. add_custom_target(${target}_All)
  1337. _juce_set_plugin_folder_property("${target}" "${target}_All")
  1338. foreach(kind IN LISTS active_formats)
  1339. _juce_link_plugin_wrapper(${target} ${kind})
  1340. if(TARGET ${target}_${kind})
  1341. list(APPEND active_plugin_targets ${target}_${kind})
  1342. endif()
  1343. endforeach()
  1344. set_target_properties(${target} PROPERTIES JUCE_ACTIVE_PLUGIN_TARGETS "${active_plugin_targets}")
  1345. if(TARGET ${target}_Standalone)
  1346. _juce_configure_app_bundle(${target} ${target}_Standalone)
  1347. endif()
  1348. if(TARGET ${target}_AU)
  1349. _juce_add_au_resource_fork(${target} ${target}_AU)
  1350. endif()
  1351. if(TARGET ${target}_AAX)
  1352. target_link_libraries(${target}_AAX PRIVATE juce_aax_sdk)
  1353. endif()
  1354. if((TARGET ${target}_AUv3) AND (TARGET ${target}_Standalone))
  1355. add_dependencies(${target}_Standalone ${target}_AUv3)
  1356. # Copy the AUv3 into the Standalone app bundle
  1357. _juce_copy_dir(${target}_Standalone
  1358. "$<TARGET_BUNDLE_DIR:${target}_AUv3>"
  1359. "$<TARGET_BUNDLE_CONTENT_DIR:${target}_Standalone>/PlugIns")
  1360. endif()
  1361. get_target_property(wants_copy "${target}" JUCE_COPY_PLUGIN_AFTER_BUILD)
  1362. if(wants_copy)
  1363. juce_enable_copy_plugin_step("${target}")
  1364. endif()
  1365. endfunction()
  1366. # ==================================================================================================
  1367. function(_juce_set_generic_property_if_not_set target property)
  1368. list(LENGTH ARGN num_extra_args)
  1369. if(num_extra_args EQUAL 0)
  1370. return()
  1371. endif()
  1372. set(existing_property)
  1373. get_target_property(existing_property ${target} ${property})
  1374. if(existing_property STREQUAL "existing_property-NOTFOUND")
  1375. set_target_properties(${target} PROPERTIES ${property} "${ARGN}")
  1376. endif()
  1377. endfunction()
  1378. function(_juce_set_property_if_not_set target property)
  1379. _juce_set_generic_property_if_not_set(${target} JUCE_${property} ${ARGN})
  1380. endfunction()
  1381. function(_juce_make_valid_4cc out_var)
  1382. string(RANDOM LENGTH 1 ALPHABET "ABCDEFGHIJKLMNOPQRSTUVWXYZ" head)
  1383. string(RANDOM LENGTH 3 ALPHABET "abcdefghijklmnopqrstuvwxyz" tail)
  1384. set(${out_var} "${head}${tail}" PARENT_SCOPE)
  1385. endfunction()
  1386. # This function adds some default properties that plugin targets expect to be
  1387. # set, in order to generate the correct compile definitions.
  1388. function(_juce_set_fallback_properties target)
  1389. _juce_set_property_if_not_set(${target} PRODUCT_NAME ${target})
  1390. get_target_property(output_name ${target} JUCE_PRODUCT_NAME)
  1391. _juce_set_property_if_not_set(${target} DESCRIPTION "${output_name}")
  1392. _juce_set_property_if_not_set(${target} PLUGIN_NAME "${output_name}")
  1393. get_target_property(real_company_name ${target} JUCE_COMPANY_NAME)
  1394. _juce_set_property_if_not_set(${target} BUNDLE_ID "com.${real_company_name}.${target}")
  1395. _juce_set_property_if_not_set(${target} VERSION ${PROJECT_VERSION})
  1396. get_target_property(final_version ${target} JUCE_VERSION)
  1397. if(NOT final_version)
  1398. message(FATAL_ERROR "Target ${target} must have its VERSION argument set, or must be part of a project with a PROJECT_VERSION")
  1399. endif()
  1400. _juce_set_property_if_not_set(${target} BUILD_VERSION "${final_version}")
  1401. get_target_property(custom_xcassets ${target} JUCE_CUSTOM_XCASSETS_FOLDER)
  1402. set(needs_storyboard TRUE)
  1403. if(custom_xcassets)
  1404. set(needs_storyboard FALSE)
  1405. endif()
  1406. set_target_properties(${target} PROPERTIES JUCE_SHOULD_ADD_STORYBOARD ${needs_storyboard})
  1407. _juce_set_property_if_not_set(${target} IPHONE_SCREEN_ORIENTATIONS
  1408. UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft
  1409. UIInterfaceOrientationLandscapeRight)
  1410. _juce_set_property_if_not_set(${target} IPAD_SCREEN_ORIENTATIONS
  1411. UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft
  1412. UIInterfaceOrientationLandscapeRight)
  1413. _juce_set_property_if_not_set(${target}
  1414. LAUNCH_STORYBOARD_FILE "${JUCE_CMAKE_UTILS_DIR}/LaunchScreen.storyboard")
  1415. _juce_set_property_if_not_set(${target} PLUGIN_MANUFACTURER_CODE "Manu")
  1416. # The plugin code will change on each run, unless you specify one manually!
  1417. _juce_make_valid_4cc(random_code)
  1418. _juce_set_property_if_not_set(${target} PLUGIN_CODE ${random_code})
  1419. _juce_set_property_if_not_set(${target} IS_SYNTH FALSE)
  1420. _juce_set_property_if_not_set(${target} NEEDS_MIDI_INPUT FALSE)
  1421. _juce_set_property_if_not_set(${target} NEEDS_MIDI_OUTPUT FALSE)
  1422. _juce_set_property_if_not_set(${target} IS_MIDI_EFFECT FALSE)
  1423. _juce_set_property_if_not_set(${target} EDITOR_WANTS_KEYBOARD_FOCUS FALSE)
  1424. _juce_set_property_if_not_set(${target} DISABLE_AAX_BYPASS FALSE)
  1425. _juce_set_property_if_not_set(${target} DISABLE_AAX_MULTI_MONO FALSE)
  1426. _juce_set_property_if_not_set(${target} PLUGINHOST_AU FALSE)
  1427. get_target_property(bundle_id ${target} JUCE_BUNDLE_ID)
  1428. _juce_set_property_if_not_set(${target} AAX_IDENTIFIER ${bundle_id})
  1429. _juce_set_property_if_not_set(${target} VST_NUM_MIDI_INS 16)
  1430. _juce_set_property_if_not_set(${target} VST_NUM_MIDI_OUTS 16)
  1431. _juce_set_property_if_not_set(${target} AU_SANDBOX_SAFE FALSE)
  1432. _juce_set_property_if_not_set(${target} SUPPRESS_AU_PLIST_RESOURCE_USAGE FALSE)
  1433. _juce_set_property_if_not_set(${target} HARDENED_RUNTIME_ENABLED NO)
  1434. _juce_set_property_if_not_set(${target} APP_SANDBOX_ENABLED NO)
  1435. _juce_set_property_if_not_set(${target} APP_SANDBOX_INHERIT NO)
  1436. get_target_property(is_synth ${target} JUCE_IS_SYNTH)
  1437. # VST3_CATEGORIES
  1438. if(is_synth)
  1439. _juce_set_property_if_not_set(${target} VST3_CATEGORIES Instrument Synth)
  1440. else()
  1441. _juce_set_property_if_not_set(${target} VST3_CATEGORIES Fx)
  1442. endif()
  1443. # VST2_CATEGORY
  1444. if(is_synth)
  1445. _juce_set_property_if_not_set(${target} VST2_CATEGORY kPlugCategSynth)
  1446. else()
  1447. _juce_set_property_if_not_set(${target} VST2_CATEGORY kPlugCategEffect)
  1448. endif()
  1449. get_target_property(is_midi_effect ${target} JUCE_IS_MIDI_EFFECT)
  1450. get_target_property(needs_midi_input ${target} JUCE_NEEDS_MIDI_INPUT)
  1451. # AU MAIN TYPE
  1452. if(is_midi_effect)
  1453. _juce_set_property_if_not_set(${target} AU_MAIN_TYPE kAudioUnitType_MIDIProcessor)
  1454. elseif(is_synth)
  1455. _juce_set_property_if_not_set(${target} AU_MAIN_TYPE kAudioUnitType_MusicDevice)
  1456. elseif(needs_midi_input)
  1457. _juce_set_property_if_not_set(${target} AU_MAIN_TYPE kAudioUnitType_MusicEffect)
  1458. else()
  1459. _juce_set_property_if_not_set(${target} AU_MAIN_TYPE kAudioUnitType_Effect)
  1460. endif()
  1461. _juce_set_property_if_not_set(${target} TARGETED_DEVICE_FAMILY "1,2")
  1462. set(au_category_codes
  1463. 'aufx'
  1464. 'aufc'
  1465. 'augn'
  1466. 'aumi'
  1467. 'aumx'
  1468. 'aumu'
  1469. 'aumf'
  1470. 'auol'
  1471. 'auou'
  1472. 'aupn')
  1473. set(au_category_strings
  1474. kAudioUnitType_Effect
  1475. kAudioUnitType_FormatConverter
  1476. kAudioUnitType_Generator
  1477. kAudioUnitType_MIDIProcessor
  1478. kAudioUnitType_Mixer
  1479. kAudioUnitType_MusicDevice
  1480. kAudioUnitType_MusicEffect
  1481. kAudioUnitType_OfflineEffect
  1482. kAudioUnitType_Output
  1483. kAudioUnitType_Panner)
  1484. # AU export prefix
  1485. string(MAKE_C_IDENTIFIER ${output_name} au_prefix)
  1486. set(au_prefix "${au_prefix}AU")
  1487. _juce_set_property_if_not_set(${target} AU_EXPORT_PREFIX ${au_prefix})
  1488. # Find appropriate AU category code
  1489. get_target_property(actual_au_category ${target} JUCE_AU_MAIN_TYPE)
  1490. list(FIND au_category_strings ${actual_au_category} au_index)
  1491. if(au_index GREATER_EQUAL 0)
  1492. list(GET au_category_codes ${au_index} au_code_representation)
  1493. set_target_properties(${target} PROPERTIES JUCE_AU_MAIN_TYPE_CODE ${au_code_representation})
  1494. endif()
  1495. # AAX category
  1496. # The order of these strings is important, as the index of each string
  1497. # will be used to set an appropriate bit in the category bitfield.
  1498. set(aax_category_strings
  1499. ePlugInCategory_None
  1500. ePlugInCategory_EQ
  1501. ePlugInCategory_Dynamics
  1502. ePlugInCategory_PitchShift
  1503. ePlugInCategory_Reverb
  1504. ePlugInCategory_Delay
  1505. ePlugInCategory_Modulation
  1506. ePlugInCategory_Harmonic
  1507. ePlugInCategory_NoiseReduction
  1508. ePlugInCategory_Dither
  1509. ePlugInCategory_SoundField
  1510. ePlugInCategory_HWGenerators
  1511. ePlugInCategory_SWGenerators
  1512. ePlugInCategory_WrappedPlugin
  1513. ePlugInCategory_Effect)
  1514. if(is_synth)
  1515. set(default_aax_category ePlugInCategory_SWGenerators)
  1516. else()
  1517. set(default_aax_category ePlugInCategory_None)
  1518. endif()
  1519. _juce_set_property_if_not_set(${target} AAX_CATEGORY ${default_aax_category})
  1520. # Replace AAX category string with its integral representation
  1521. get_target_property(actual_aax_category ${target} JUCE_AAX_CATEGORY)
  1522. set(aax_category_int "")
  1523. foreach(category_string IN LISTS actual_aax_category)
  1524. list(FIND aax_category_strings ${category_string} aax_index)
  1525. if(aax_index GREATER_EQUAL 0)
  1526. if(aax_index EQUAL 0)
  1527. set(aax_category_bit 0)
  1528. else()
  1529. set(aax_category_bit "1 << (${aax_index} - 1)")
  1530. endif()
  1531. if(aax_category_int STREQUAL "")
  1532. set(aax_category_int 0)
  1533. endif()
  1534. math(EXPR aax_category_int "${aax_category_int} | (${aax_category_bit})")
  1535. endif()
  1536. endforeach()
  1537. if(NOT aax_category_int STREQUAL "")
  1538. set_target_properties(${target} PROPERTIES JUCE_AAX_CATEGORY ${aax_category_int})
  1539. endif()
  1540. endfunction()
  1541. # ==================================================================================================
  1542. function(_juce_initialise_target target)
  1543. set(one_value_args
  1544. VERSION
  1545. BUILD_VERSION
  1546. PRODUCT_NAME
  1547. PLIST_TO_MERGE
  1548. BUNDLE_ID
  1549. MICROPHONE_PERMISSION_ENABLED
  1550. MICROPHONE_PERMISSION_TEXT
  1551. CAMERA_PERMISSION_ENABLED
  1552. CAMERA_PERMISSION_TEXT
  1553. SEND_APPLE_EVENTS_PERMISSION_ENABLED
  1554. SEND_APPLE_EVENTS_PERMISSION_TEXT
  1555. BLUETOOTH_PERMISSION_ENABLED
  1556. BLUETOOTH_PERMISSION_TEXT
  1557. FILE_SHARING_ENABLED # iOS only
  1558. DOCUMENT_BROWSER_ENABLED # iOS only
  1559. LAUNCH_STORYBOARD_FILE # iOS only
  1560. APP_GROUPS_ENABLED # iOS only
  1561. ICLOUD_PERMISSIONS_ENABLED # iOS only
  1562. STATUS_BAR_HIDDEN # iOS only
  1563. BACKGROUND_AUDIO_ENABLED # iOS only
  1564. BACKGROUND_BLE_ENABLED # iOS only
  1565. CUSTOM_XCASSETS_FOLDER # iOS only
  1566. TARGETED_DEVICE_FAMILY # iOS only
  1567. REQUIRES_FULL_SCREEN # iOS only
  1568. ICON_BIG
  1569. ICON_SMALL
  1570. COMPANY_COPYRIGHT
  1571. COMPANY_NAME
  1572. COMPANY_WEBSITE
  1573. COMPANY_EMAIL
  1574. NEEDS_CURL # Set this true if you want to link curl on Linux
  1575. NEEDS_WEB_BROWSER # Set this true if you want to link webkit on Linux
  1576. NEEDS_STORE_KIT # Set this true if you want in-app-purchases on Mac
  1577. PUSH_NOTIFICATIONS_ENABLED
  1578. HARDENED_RUNTIME_ENABLED
  1579. APP_SANDBOX_ENABLED
  1580. APP_SANDBOX_INHERIT
  1581. PLUGIN_NAME
  1582. PLUGIN_MANUFACTURER_CODE
  1583. PLUGIN_CODE
  1584. DESCRIPTION
  1585. IS_SYNTH
  1586. NEEDS_MIDI_INPUT
  1587. NEEDS_MIDI_OUTPUT
  1588. IS_MIDI_EFFECT
  1589. EDITOR_WANTS_KEYBOARD_FOCUS
  1590. DISABLE_AAX_BYPASS
  1591. DISABLE_AAX_MULTI_MONO
  1592. AAX_IDENTIFIER
  1593. VST_NUM_MIDI_INS
  1594. VST_NUM_MIDI_OUTS
  1595. VST2_CATEGORY
  1596. AU_MAIN_TYPE
  1597. AU_EXPORT_PREFIX
  1598. AU_SANDBOX_SAFE
  1599. SUPPRESS_AU_PLIST_RESOURCE_USAGE
  1600. PLUGINHOST_AU # Set this true if you want to host AU plugins
  1601. USE_LEGACY_COMPATIBILITY_PLUGIN_CODE
  1602. VST_COPY_DIR
  1603. VST3_COPY_DIR
  1604. AAX_COPY_DIR
  1605. AU_COPY_DIR
  1606. UNITY_COPY_DIR
  1607. COPY_PLUGIN_AFTER_BUILD)
  1608. set(multi_value_args
  1609. FORMATS
  1610. VST3_CATEGORIES
  1611. HARDENED_RUNTIME_OPTIONS
  1612. APP_SANDBOX_OPTIONS
  1613. DOCUMENT_EXTENSIONS
  1614. AAX_CATEGORY
  1615. IPHONE_SCREEN_ORIENTATIONS # iOS only
  1616. IPAD_SCREEN_ORIENTATIONS # iOS only
  1617. APP_GROUP_IDS) # iOS only
  1618. cmake_parse_arguments(JUCE_ARG "" "${one_value_args}" "${multi_value_args}" ${ARGN})
  1619. set(base_folder "${CMAKE_CURRENT_BINARY_DIR}/${target}_artefacts")
  1620. set(products_folder "${base_folder}/$<CONFIG>")
  1621. set(juce_library_code "${base_folder}/JuceLibraryCode")
  1622. set_target_properties(${target} PROPERTIES JUCE_GENERATED_SOURCES_DIRECTORY "${juce_library_code}")
  1623. set_target_properties(${target} PROPERTIES
  1624. ARCHIVE_OUTPUT_DIRECTORY "${products_folder}"
  1625. LIBRARY_OUTPUT_DIRECTORY "${products_folder}"
  1626. RUNTIME_OUTPUT_DIRECTORY "${products_folder}")
  1627. if(JUCE_ARG_ICON_BIG)
  1628. _juce_make_absolute_and_check(JUCE_ARG_ICON_BIG)
  1629. endif()
  1630. if(JUCE_ARG_ICON_SMALL)
  1631. _juce_make_absolute_and_check(JUCE_ARG_ICON_SMALL)
  1632. endif()
  1633. set(inherited_properties
  1634. COMPANY_NAME
  1635. COMPANY_WEBSITE
  1636. COMPANY_EMAIL
  1637. COMPANY_COPYRIGHT
  1638. VST_COPY_DIR
  1639. VST3_COPY_DIR
  1640. AU_COPY_DIR
  1641. AAX_COPY_DIR
  1642. UNITY_COPY_DIR
  1643. COPY_PLUGIN_AFTER_BUILD)
  1644. # Overwrite any properties that might be inherited
  1645. foreach(prop_string IN LISTS inherited_properties)
  1646. if(NOT ${JUCE_ARG_${prop_string}} STREQUAL "")
  1647. set_target_properties(${target} PROPERTIES JUCE_${prop_string} "${JUCE_ARG_${prop_string}}")
  1648. endif()
  1649. endforeach()
  1650. # Add each of the function arguments as target properties, so that it's easier to
  1651. # extract them in other functions
  1652. foreach(arg_string IN LISTS one_value_args multi_value_args)
  1653. _juce_set_property_if_not_set(${target} ${arg_string} "${JUCE_ARG_${arg_string}}")
  1654. endforeach()
  1655. _juce_set_fallback_properties(${target})
  1656. target_include_directories(${target} PRIVATE
  1657. $<TARGET_PROPERTY:${target},JUCE_GENERATED_SOURCES_DIRECTORY>)
  1658. target_link_libraries(${target} PUBLIC $<$<TARGET_EXISTS:juce_vst2_sdk>:juce_vst2_sdk>)
  1659. get_target_property(is_pluginhost_au ${target} JUCE_PLUGINHOST_AU)
  1660. if(is_pluginhost_au)
  1661. target_compile_definitions(${target} PUBLIC JUCE_PLUGINHOST_AU=1)
  1662. if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR CMAKE_SYSTEM_NAME STREQUAL "iOS")
  1663. _juce_link_frameworks("${target}" PRIVATE CoreAudioKit)
  1664. endif()
  1665. if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  1666. _juce_link_frameworks("${target}" PRIVATE AudioUnit)
  1667. endif()
  1668. endif()
  1669. _juce_write_generate_time_info(${target})
  1670. _juce_link_optional_libraries(${target})
  1671. if(JUCE_ENABLE_MODULE_SOURCE_GROUPS)
  1672. get_property(all_modules GLOBAL PROPERTY _juce_module_names)
  1673. foreach(module_name IN LISTS all_modules)
  1674. get_target_property(path ${module_name} INTERFACE_JUCE_MODULE_PATH)
  1675. get_target_property(header_files ${module_name} INTERFACE_JUCE_MODULE_HEADERS)
  1676. get_target_property(source_files ${module_name} INTERFACE_JUCE_MODULE_SOURCES)
  1677. source_group(TREE ${path} PREFIX "JUCE Modules" FILES ${header_files} ${source_files})
  1678. set_source_files_properties(${header_files} PROPERTIES HEADER_FILE_ONLY TRUE)
  1679. endforeach()
  1680. endif()
  1681. endfunction()
  1682. # ==================================================================================================
  1683. function(juce_add_console_app target)
  1684. add_executable(${target})
  1685. target_compile_definitions(${target} PRIVATE JUCE_STANDALONE_APPLICATION=1)
  1686. if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
  1687. target_compile_definitions(${target} PRIVATE _CONSOLE=1)
  1688. endif()
  1689. _juce_initialise_target(${target} ${ARGN})
  1690. endfunction()
  1691. function(juce_add_gui_app target)
  1692. if(CMAKE_SYSTEM_NAME STREQUAL "Android")
  1693. add_library(${target} SHARED)
  1694. else()
  1695. add_executable(${target})
  1696. endif()
  1697. target_compile_definitions(${target} PRIVATE JUCE_STANDALONE_APPLICATION=1)
  1698. _juce_initialise_target(${target} ${ARGN})
  1699. _juce_set_output_name(${target} $<TARGET_PROPERTY:${target},JUCE_PRODUCT_NAME>)
  1700. set_target_properties(${target} PROPERTIES JUCE_TARGET_KIND_STRING "App")
  1701. _juce_configure_bundle(${target} ${target})
  1702. _juce_configure_app_bundle(${target} ${target})
  1703. endfunction()
  1704. function(juce_add_plugin target)
  1705. add_library(${target} STATIC)
  1706. set_target_properties(${target} PROPERTIES JUCE_IS_PLUGIN TRUE)
  1707. _juce_initialise_target(${target} ${ARGN})
  1708. _juce_configure_plugin_targets(${target})
  1709. endfunction()
  1710. # ==================================================================================================
  1711. function(_juce_target_args_from_plugin_characteristics out_var)
  1712. set(pairs
  1713. "pluginIsSynth\;IS_SYNTH"
  1714. "pluginWantsMidiIn\;NEEDS_MIDI_INPUT"
  1715. "pluginProducesMidiOut\;NEEDS_MIDI_OUTPUT"
  1716. "pluginIsMidiEffectPlugin\;IS_MIDI_EFFECT"
  1717. "pluginEditorRequiresKeys\;EDITOR_WANTS_KEYBOARD_FOCUS")
  1718. set(result)
  1719. foreach(pair IN LISTS pairs)
  1720. list(GET pair 0 old_key)
  1721. if("${old_key}" IN_LIST ARGN)
  1722. list(GET pair 1 new_key)
  1723. list(APPEND result ${new_key} TRUE)
  1724. endif()
  1725. endforeach()
  1726. set(${out_var} ${result} PARENT_SCOPE)
  1727. endfunction()
  1728. # ==================================================================================================
  1729. function(_juce_get_pip_targets pip out_var)
  1730. set(test_targets "${pip}")
  1731. _juce_get_all_plugin_kinds(plugin_kinds)
  1732. foreach(plugin_kind IN LISTS plugin_kinds)
  1733. list(APPEND test_targets "${JUCE_PIP_NAME}_${plugin_kind}")
  1734. endforeach()
  1735. set(${out_var} ${test_targets} PARENT_SCOPE)
  1736. endfunction()
  1737. function(juce_add_pip header)
  1738. _juce_make_absolute(header)
  1739. _juce_extract_metadata_block(JUCE_PIP_METADATA "${header}" metadata_dict)
  1740. _juce_get_metadata("${metadata_dict}" name JUCE_PIP_NAME)
  1741. if(NOT JUCE_PIP_NAME)
  1742. message(FATAL_ERROR "PIP headers must declare a `name` field")
  1743. endif()
  1744. string(MAKE_C_IDENTIFIER "${JUCE_PIP_NAME}" pip_name_sanitised)
  1745. if(NOT JUCE_PIP_NAME STREQUAL pip_name_sanitised)
  1746. message(FATAL_ERROR "PIP `name` value '${JUCE_PIP_NAME}' must be a valid C identifier")
  1747. endif()
  1748. if(TARGET "${JUCE_PIP_NAME}")
  1749. # We already added a target with this name, let's try using the filename instead
  1750. get_filename_component(JUCE_PIP_NAME "${header}" NAME_WE)
  1751. endif()
  1752. if(TARGET "${JUCE_PIP_NAME}")
  1753. message(FATAL_ERROR "Could not create a unique target name for PIP ${header}")
  1754. endif()
  1755. _juce_get_metadata("${metadata_dict}" type pip_kind)
  1756. if(NOT pip_kind)
  1757. message(FATAL_ERROR "PIP headers must declare a `type` field")
  1758. endif()
  1759. _juce_get_metadata("${metadata_dict}" pluginCharacteristics pip_charateristics)
  1760. _juce_target_args_from_plugin_characteristics(extra_target_args ${pip_charateristics})
  1761. list(APPEND extra_target_args
  1762. NEEDS_CURL TRUE
  1763. NEEDS_WEB_BROWSER TRUE)
  1764. _juce_get_metadata("${metadata_dict}" moduleFlags pip_moduleflags)
  1765. if("JUCE_IN_APP_PURCHASES=1" IN_LIST pip_moduleflags)
  1766. list(APPEND extra_target_args
  1767. BUNDLE_ID "com.rmsl.juceInAppPurchaseSample"
  1768. NEEDS_STORE_KIT TRUE)
  1769. endif()
  1770. if(pip_kind STREQUAL "AudioProcessor")
  1771. set(source_main "${JUCE_CMAKE_UTILS_DIR}/PIPAudioProcessor.cpp.in")
  1772. # We add AAX/VST2 targets too, if the user has set up those SDKs
  1773. set(extra_formats)
  1774. if(TARGET juce_aax_sdk)
  1775. list(APPEND extra_formats AAX)
  1776. endif()
  1777. if(TARGET juce_vst2_sdk)
  1778. list(APPEND extra_formats VST)
  1779. endif()
  1780. # Standalone plugins might want to access the mic
  1781. list(APPEND extra_target_args MICROPHONE_PERMISSION_ENABLED TRUE)
  1782. juce_add_plugin(${JUCE_PIP_NAME}
  1783. FORMATS AU AUv3 VST3 Unity Standalone ${extra_formats}
  1784. ${extra_target_args})
  1785. elseif(pip_kind STREQUAL "Component")
  1786. set(source_main "${JUCE_CMAKE_UTILS_DIR}/PIPComponent.cpp.in")
  1787. juce_add_gui_app(${JUCE_PIP_NAME} ${extra_target_args})
  1788. elseif(pip_kind STREQUAL "Console")
  1789. set(source_main "${JUCE_CMAKE_UTILS_DIR}/PIPConsole.cpp.in")
  1790. juce_add_console_app(${JUCE_PIP_NAME} ${extra_target_args})
  1791. else()
  1792. message(FATAL_ERROR "PIP kind must be either AudioProcessor, Component, or Console")
  1793. endif()
  1794. if(NOT ARGV1 STREQUAL "")
  1795. set("${ARGV1}" "${JUCE_PIP_NAME}" PARENT_SCOPE)
  1796. endif()
  1797. # Generate Main.cpp
  1798. _juce_get_metadata("${metadata_dict}" mainClass JUCE_PIP_MAIN_CLASS)
  1799. get_target_property(juce_library_code ${JUCE_PIP_NAME} JUCE_GENERATED_SOURCES_DIRECTORY)
  1800. set(pip_main "${juce_library_code}/Main.cpp")
  1801. set(JUCE_PIP_HEADER "${header}")
  1802. configure_file(${source_main} ${pip_main})
  1803. target_sources(${JUCE_PIP_NAME} PRIVATE ${pip_main})
  1804. _juce_get_metadata("${metadata_dict}" dependencies pip_dependencies)
  1805. juce_generate_juce_header(${JUCE_PIP_NAME})
  1806. foreach(module IN LISTS pip_dependencies)
  1807. if(module STREQUAL "")
  1808. continue()
  1809. endif()
  1810. set(discovered_module)
  1811. if(TARGET "${module}")
  1812. set(discovered_module "${module}")
  1813. else()
  1814. message(FATAL_ERROR "No such module: ${module}")
  1815. endif()
  1816. target_link_libraries(${JUCE_PIP_NAME} PRIVATE ${discovered_module})
  1817. endforeach()
  1818. target_compile_definitions(${JUCE_PIP_NAME}
  1819. PRIVATE ${pip_moduleflags}
  1820. PUBLIC
  1821. JUCE_VST3_CAN_REPLACE_VST2=0)
  1822. _juce_get_pip_targets(${JUCE_PIP_NAME} pip_targets)
  1823. # This keeps the PIPs slightly better organised in the JUCE megaproject
  1824. if((DEFINED JUCE_SOURCE_DIR) AND (header MATCHES "^${JUCE_SOURCE_DIR}"))
  1825. file(RELATIVE_PATH folder "${JUCE_SOURCE_DIR}" "${header}")
  1826. get_filename_component(folder_parent "${folder}" DIRECTORY)
  1827. foreach(target_name IN ITEMS ${pip_targets} ${JUCE_PIP_NAME}_All)
  1828. if(TARGET "${target_name}")
  1829. set_target_properties("${target_name}" PROPERTIES
  1830. FOLDER "${folder_parent}/${JUCE_PIP_NAME}")
  1831. endif()
  1832. endforeach()
  1833. endif()
  1834. # We're building JUCE itself
  1835. if(DEFINED JUCE_SOURCE_DIR)
  1836. # PIPs need to know about the resources folder
  1837. target_compile_definitions(${JUCE_PIP_NAME} PRIVATE
  1838. PIP_JUCE_EXAMPLES_DIRECTORY_STRING="${JUCE_SOURCE_DIR}/examples")
  1839. get_filename_component(pip_parent_path "${header}" DIRECTORY)
  1840. target_include_directories(${JUCE_PIP_NAME} PRIVATE "${pip_parent_path}")
  1841. if((CMAKE_SYSTEM_NAME STREQUAL "iOS") AND (header MATCHES "^${JUCE_SOURCE_DIR}"))
  1842. foreach(target_name IN LISTS pip_targets)
  1843. if(TARGET "${target_name}")
  1844. juce_add_bundle_resources_directory("${target_name}" "${JUCE_SOURCE_DIR}/examples/Assets")
  1845. endif()
  1846. endforeach()
  1847. endif()
  1848. endif()
  1849. endfunction()
  1850. # ==================================================================================================
  1851. function(juce_set_aax_sdk_path path)
  1852. if(TARGET juce_aax_sdk)
  1853. message(FATAL_ERROR "juce_set_aax_sdk_path should only be called once")
  1854. endif()
  1855. _juce_make_absolute(path)
  1856. if((NOT EXISTS "${path}")
  1857. OR (NOT EXISTS "${path}/Interfaces")
  1858. OR (NOT EXISTS "${path}/Interfaces/ACF"))
  1859. message(FATAL_ERROR "Could not find AAX SDK at the specified path: ${path}")
  1860. endif()
  1861. if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  1862. add_library(juce_aax_sdk STATIC IMPORTED GLOBAL)
  1863. set_target_properties(juce_aax_sdk PROPERTIES
  1864. IMPORTED_LOCATION_DEBUG "${path}/Libs/Debug/libAAXLibrary_libcpp.a"
  1865. IMPORTED_LOCATION "${path}/Libs/Release/libAAXLibrary_libcpp.a")
  1866. elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
  1867. add_library(juce_aax_sdk INTERFACE IMPORTED GLOBAL)
  1868. else()
  1869. return()
  1870. endif()
  1871. target_include_directories(juce_aax_sdk INTERFACE
  1872. "${path}"
  1873. "${path}/Interfaces"
  1874. "${path}/Interfaces/ACF")
  1875. target_compile_definitions(juce_aax_sdk INTERFACE JucePlugin_AAXLibs_path="${path}/Libs")
  1876. set_target_properties(juce_aax_sdk PROPERTIES INTERFACE_JUCE_AAX_DEFAULT_ICON "${path}/Utilities/PlugIn.ico")
  1877. endfunction()
  1878. function(juce_set_vst2_sdk_path path)
  1879. if(TARGET juce_vst2_sdk)
  1880. message(FATAL_ERROR "juce_set_vst2_sdk_path should only be called once")
  1881. endif()
  1882. _juce_make_absolute(path)
  1883. if(NOT EXISTS "${path}")
  1884. message(FATAL_ERROR "Could not find VST2 SDK at the specified path: ${path}")
  1885. endif()
  1886. add_library(juce_vst2_sdk INTERFACE IMPORTED GLOBAL)
  1887. # This is a bit of a hack, but we really need the VST2 paths to always follow the VST3 paths.
  1888. target_include_directories(juce_vst2_sdk INTERFACE
  1889. $<TARGET_PROPERTY:juce::juce_vst3_headers,INTERFACE_INCLUDE_DIRECTORIES>
  1890. "${path}")
  1891. endfunction()
  1892. function(juce_set_vst3_sdk_path path)
  1893. if(TARGET juce_vst3_sdk)
  1894. message(FATAL_ERROR "juce_set_vst3_sdk_path should only be called once")
  1895. endif()
  1896. _juce_make_absolute(path)
  1897. if(NOT EXISTS "${path}")
  1898. message(FATAL_ERROR "Could not find VST3 SDK at the specified path: ${path}")
  1899. endif()
  1900. add_library(juce_vst3_sdk INTERFACE IMPORTED GLOBAL)
  1901. target_include_directories(juce_vst3_sdk INTERFACE "${path}")
  1902. endfunction()
  1903. # ==================================================================================================
  1904. function(juce_disable_default_flags)
  1905. set(langs C CXX)
  1906. set(modes DEBUG RELEASE RELWITHDEBINFO MINSIZEREL)
  1907. foreach(lang IN LISTS langs)
  1908. foreach(mode IN LISTS modes)
  1909. list(FILTER CMAKE_${lang}_FLAGS_${mode} INCLUDE REGEX "[/-]M[TD]d?")
  1910. set(CMAKE_${lang}_FLAGS_${mode} "${CMAKE_${lang}_FLAGS_${mode}}" PARENT_SCOPE)
  1911. endforeach()
  1912. endforeach()
  1913. endfunction()