1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

CMake: Improve Windows Arm architecture detection

This commit is contained in:
Tom Poole 2024-10-18 16:54:07 +01:00
parent cba00cc71f
commit 9e193862c1
6 changed files with 103 additions and 56 deletions

View file

@ -799,8 +799,8 @@ CMakeLists in the `modules` directory.
This function parses the PIP metadata block in the provided header, and adds appropriate build This function parses the PIP metadata block in the provided header, and adds appropriate build
targets for a console app, GUI app, or audio plugin. For audio plugin targets, it builds as many targets for a console app, GUI app, or audio plugin. For audio plugin targets, it builds as many
plugin formats as possible. To build AAX or VST2 targets, call `juce_set_aax_sdk_path` and/or plugin formats as possible. To build VST2 targets, call `juce_set_vst2_sdk_path` *before* calling
`juce_set_vst2_sdk_path` *before* calling `juce_add_pip`. `juce_add_pip`.
This is mainly provided to build the built-in example projects in the JUCE repo, and for building This is mainly provided to build the built-in example projects in the JUCE repo, and for building
quick proof-of-concept demo apps with minimal set-up. For any use-case more complex than a quick proof-of-concept demo apps with minimal set-up. For any use-case more complex than a

View file

@ -62,7 +62,11 @@ function(_juce_find_target_architecture result)
set("${result}" "${match_result}" PARENT_SCOPE) set("${result}" "${match_result}" PARENT_SCOPE)
endfunction() endfunction()
if((CMAKE_SYSTEM_NAME STREQUAL "Linux") OR (CMAKE_SYSTEM_NAME MATCHES ".*BSD") OR MSYS OR MINGW) if((CMAKE_SYSTEM_NAME STREQUAL "Windows")
OR (CMAKE_SYSTEM_NAME STREQUAL "Linux")
OR (CMAKE_SYSTEM_NAME MATCHES ".*BSD")
OR MSYS
OR MINGW)
# If you really need to override the detected arch for some reason, # If you really need to override the detected arch for some reason,
# you can configure the build with -DJUCE_TARGET_ARCHITECTURE=<custom arch> # you can configure the build with -DJUCE_TARGET_ARCHITECTURE=<custom arch>
if(NOT DEFINED JUCE_TARGET_ARCHITECTURE) if(NOT DEFINED JUCE_TARGET_ARCHITECTURE)
@ -70,6 +74,17 @@ if((CMAKE_SYSTEM_NAME STREQUAL "Linux") OR (CMAKE_SYSTEM_NAME MATCHES ".*BSD") O
set(JUCE_TARGET_ARCHITECTURE "${target_arch}" set(JUCE_TARGET_ARCHITECTURE "${target_arch}"
CACHE INTERNAL "The target architecture, used to name internal folders in VST3 bundles, and to locate bundled libraries in modules") CACHE INTERNAL "The target architecture, used to name internal folders in VST3 bundles, and to locate bundled libraries in modules")
endif() endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
if ((CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "X86" AND NOT JUCE_TARGET_ARCHITECTURE STREQUAL "i386")
OR (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "AMD64"
AND NOT (JUCE_TARGET_ARCHITECTURE STREQUAL "i386"
OR JUCE_TARGET_ARCHITECTURE STREQUAL "x86_64")))
set(JUCE_WINDOWS_HELPERS_CAN_RUN FALSE)
else()
set(JUCE_WINDOWS_HELPERS_CAN_RUN TRUE)
endif()
endif()
endif() endif()
# ================================================================================================== # ==================================================================================================
@ -270,7 +285,9 @@ function(_juce_get_platform_plugin_kinds out)
endif() endif()
endif() endif()
if((CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR CMAKE_SYSTEM_NAME STREQUAL "Windows") AND NOT (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")) if(NOT (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
AND (CMAKE_SYSTEM_NAME STREQUAL "Darwin"
OR (CMAKE_SYSTEM_NAME STREQUAL "Windows" AND JUCE_TARGET_ARCHITECTURE STREQUAL "x86_64")))
list(APPEND result AAX) list(APPEND result AAX)
endif() endif()

View file

@ -851,19 +851,12 @@ endfunction()
# ================================================================================================== # ==================================================================================================
function(_juce_create_windows_package source_target dest_target extension default_icon x32folder x64folder) function(_juce_create_windows_package source_target dest_target extension default_icon arch_string)
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
return()
endif()
get_target_property(products_folder ${dest_target} LIBRARY_OUTPUT_DIRECTORY) get_target_property(products_folder ${dest_target} LIBRARY_OUTPUT_DIRECTORY)
set(product_name $<TARGET_PROPERTY:${source_target},JUCE_PRODUCT_NAME>) set(product_name $<TARGET_PROPERTY:${source_target},JUCE_PRODUCT_NAME>)
set(output_folder "${products_folder}/${product_name}.${extension}") set(output_folder "${products_folder}/${product_name}.${extension}")
set(is_x64 $<EQUAL:${CMAKE_SIZEOF_VOID_P},8>)
set(arch_string $<IF:${is_x64},${x64folder},${x32folder}>)
set_target_properties(${dest_target} set_target_properties(${dest_target}
PROPERTIES PROPERTIES
PDB_OUTPUT_DIRECTORY "${products_folder}" PDB_OUTPUT_DIRECTORY "${products_folder}"
@ -1090,6 +1083,13 @@ function(juce_enable_vst3_manifest_step shared_code_target)
return() return()
endif() endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Windows" AND NOT JUCE_WINDOWS_HELPERS_CAN_RUN)
message(WARNING "VST3 manifest generation is disabled for ${shared_code_target} because a "
"${JUCE_TARGET_ARCHITECTURE} manifest helper cannot run on a host system processor detected to be "
"${CMAKE_HOST_SYSTEM_PROCESSOR}.")
return()
endif()
set(target_name ${shared_code_target}_VST3) set(target_name ${shared_code_target}_VST3)
get_target_property(product ${target_name} JUCE_PLUGIN_ARTEFACT_FILE) get_target_property(product ${target_name} JUCE_PLUGIN_ARTEFACT_FILE)
@ -1102,14 +1102,17 @@ function(juce_enable_vst3_manifest_step shared_code_target)
get_target_property(target_version_string ${shared_code_target} JUCE_VERSION) get_target_property(target_version_string ${shared_code_target} JUCE_VERSION)
set(ouput_path "${product}/Contents/Resources/moduleinfo.json")
# Use the helper tool to write out the moduleinfo.json # Use the helper tool to write out the moduleinfo.json
add_custom_command(TARGET ${target_name} POST_BUILD add_custom_command(TARGET ${target_name} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "creating ${ouput_path}"
COMMAND ${CMAKE_COMMAND} -E make_directory "${product}/Contents/Resources" COMMAND ${CMAKE_COMMAND} -E make_directory "${product}/Contents/Resources"
COMMAND juce_vst3_helper COMMAND juce_vst3_helper
-create -create
-version "${target_version_string}" -version "${target_version_string}"
-path "${product}" -path "${product}"
-output "${product}/Contents/Resources/moduleinfo.json" -output "${ouput_path}"
VERBATIM) VERBATIM)
set_target_properties(${shared_code_target} PROPERTIES _JUCE_VST3_MANIFEST_STEP_ADDED TRUE) set_target_properties(${shared_code_target} PROPERTIES _JUCE_VST3_MANIFEST_STEP_ADDED TRUE)
@ -1194,7 +1197,21 @@ function(_juce_set_plugin_target_properties shared_code_target kind)
XCODE_ATTRIBUTE_LIBRARY_STYLE Bundle XCODE_ATTRIBUTE_LIBRARY_STYLE Bundle
XCODE_ATTRIBUTE_GENERATE_PKGINFO_FILE YES) XCODE_ATTRIBUTE_GENERATE_PKGINFO_FILE YES)
_juce_create_windows_package(${shared_code_target} ${target_name} vst3 "" x86-win x86_64-win) if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
if(JUCE_TARGET_ARCHITECTURE STREQUAL "x86_64")
set(windows_arch "x86_64")
elseif(JUCE_TARGET_ARCHITECTURE STREQUAL "i386")
set(windows_arch "x86")
elseif(JUCE_TARGET_ARCHITECTURE STREQUAL "arm64ec")
set(windows_arch "arm64ec")
elseif(JUCE_TARGET_ARCHITECTURE STREQUAL "aarch64")
set(windows_arch "arm64")
else()
message(FATAL_ERROR "Unsupported target architecture for VST3: ${JUCE_TARGET_ARCHITECTURE}")
endif()
_juce_create_windows_package(${shared_code_target} ${target_name} vst3 "" "${windows_arch}-win")
endif()
set(output_path "${products_folder}/${product_name}.vst3") set(output_path "${products_folder}/${product_name}.vst3")
@ -1262,7 +1279,18 @@ function(_juce_set_plugin_target_properties shared_code_target kind)
_juce_init_bundled_aax_sdk() _juce_init_bundled_aax_sdk()
get_target_property(default_icon juce_aax_sdk INTERFACE_JUCE_AAX_DEFAULT_ICON) get_target_property(default_icon juce_aax_sdk INTERFACE_JUCE_AAX_DEFAULT_ICON)
_juce_create_windows_package(${shared_code_target} ${target_name} aaxplugin "${default_icon}" Win32 x64)
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
if(JUCE_TARGET_ARCHITECTURE STREQUAL "x86_64")
set(windows_arch "x64")
elseif(JUCE_TARGET_ARCHITECTURE STREQUAL "i386")
set(windows_arch "Win32")
else()
message(FATAL_ERROR "Unsupported target architecture for AAX: ${JUCE_TARGET_ARCHITECTURE}")
endif()
_juce_create_windows_package(${shared_code_target} ${target_name} aaxplugin "${default_icon}" "${windows_arch}")
endif()
set(output_path "${products_folder}/${product_name}.aaxplugin") set(output_path "${products_folder}/${product_name}.aaxplugin")
_juce_set_copy_properties(${shared_code_target} ${target_name} "${output_path}" JUCE_AAX_COPY_DIR) _juce_set_copy_properties(${shared_code_target} ${target_name} "${output_path}" JUCE_AAX_COPY_DIR)
@ -1300,6 +1328,11 @@ function(_juce_set_plugin_target_properties shared_code_target kind)
JUCE_UNITY_COPY_DIR) JUCE_UNITY_COPY_DIR)
endif() endif()
elseif(kind STREQUAL "LV2") elseif(kind STREQUAL "LV2")
if (CMAKE_SYSTEM_NAME STREQUAL "Windows" AND NOT JUCE_WINDOWS_HELPERS_CAN_RUN)
message(FATAL_ERROR "You cannot build a ${JUCE_TARGET_ARCHITECTURE} LV2 plug-in on a host "
"system processor detected to be ${CMAKE_HOST_SYSTEM_PROCESSOR}.")
endif()
set_target_properties(${target_name} PROPERTIES BUNDLE FALSE) set_target_properties(${target_name} PROPERTIES BUNDLE FALSE)
get_target_property(JUCE_LV2URI "${shared_code_target}" JUCE_LV2URI) get_target_property(JUCE_LV2URI "${shared_code_target}" JUCE_LV2URI)
@ -2251,23 +2284,22 @@ function(juce_add_pip header)
else() else()
set(source_main "${JUCE_CMAKE_UTILS_DIR}/PIPAudioProcessor.cpp.in") set(source_main "${JUCE_CMAKE_UTILS_DIR}/PIPAudioProcessor.cpp.in")
set(formats AAX AU AUv3 LV2 Standalone Unity VST3)
# We add VST2 targets too, if the user has set up those SDKs # We add VST2 targets too, if the user has set up those SDKs
set(extra_formats)
if(TARGET juce_vst2_sdk) if(TARGET juce_vst2_sdk)
list(APPEND extra_formats VST) list(APPEND formats VST)
endif() endif()
if(NOT (CMAKE_SYSTEM_NAME MATCHES ".*BSD")) if(CMAKE_SYSTEM_NAME STREQUAL "Windows" AND NOT JUCE_WINDOWS_HELPERS_CAN_RUN)
list(APPEND extra_formats VST3) list(REMOVE_ITEM formats LV2)
endif() endif()
# Standalone plugins might want to access the mic # Standalone plugins might want to access the mic
list(APPEND extra_target_args MICROPHONE_PERMISSION_ENABLED TRUE) list(APPEND extra_target_args MICROPHONE_PERMISSION_ENABLED TRUE)
juce_add_plugin(${JUCE_PIP_NAME} juce_add_plugin(${JUCE_PIP_NAME}
FORMATS AU AUv3 LV2 Standalone Unity AAX ${extra_formats} FORMATS ${formats}
${extra_target_args}) ${extra_target_args})
endif() endif()
elseif(pip_kind STREQUAL "Component") elseif(pip_kind STREQUAL "Component")

View file

@ -32,21 +32,20 @@
============================================================================== ==============================================================================
*/ */
#if defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(_M_ARM) || defined(_M_ARM64) || defined(__aarch64__) || defined(__ARM64__) #if defined(_M_ARM64EC)
#error JUCE_ARCH arm64ec
#if defined(_M_ARM64) || defined(__aarch64__) || defined(__ARM64__) #elif defined(_M_ARM64) || defined(__aarch64__) || defined(__ARM64__)
#error JUCE_ARCH aarch64 #error JUCE_ARCH aarch64
#elif (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM == 8) || defined(__ARMv8__) || defined(__ARMv8_A__) #elif (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM == 8) || defined(__ARMv8__) || defined(__ARMv8_A__)
#error JUCE_ARCH armv8l #error JUCE_ARCH armv8l
#elif (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM == 7) || defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) || defined(_ARM_ARCH_7) || defined(__CORE_CORTEXA__) #elif (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM == 7) || defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) || defined(_ARM_ARCH_7) || defined(__CORE_CORTEXA__)
#error JUCE_ARCH armv7l #error JUCE_ARCH armv7l
#elif (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM == 6) || defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6M__) #elif (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM == 6) || defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6M__)
#error JUCE_ARCH armv6l #error JUCE_ARCH armv6l
#elif (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM == 5) || defined(__ARM_ARCH_5TEJ__) #elif (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM == 5) || defined(__ARM_ARCH_5TEJ__)
#error JUCE_ARCH armv5l #error JUCE_ARCH armv5l
#else #elif defined(__arm__) || defined(_M_ARM)
#error JUCE_ARCH arm #error JUCE_ARCH arm
#endif
#elif defined(__i386) || defined(__i386__) || defined(_M_IX86) #elif defined(__i386) || defined(__i386__) || defined(_M_IX86)

View file

@ -8466,23 +8466,22 @@ static const unsigned char temp_binary_data_66[] =
" ==============================================================================\r\n" " ==============================================================================\r\n"
"*/\r\n" "*/\r\n"
"\r\n" "\r\n"
"#if defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(_M_ARM) || defined(_M_ARM64) || defined(__aarch64__) || defined(__ARM64__)\r\n" "#if defined(_M_ARM64EC)\r\n"
"\r\n" " #error JUCE_ARCH arm64ec\r\n"
" #if defined(_M_ARM64) || defined(__aarch64__) || defined(__ARM64__)\r\n" "#elif defined(_M_ARM64) || defined(__aarch64__) || defined(__ARM64__)\r\n"
" #error JUCE_ARCH aarch64\r\n" " #error JUCE_ARCH aarch64\r\n"
" #elif (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM == 8) || defined(__ARMv8__) || defined(__ARMv8_A__)\r\n" "#elif (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM == 8) || defined(__ARMv8__) || defined(__ARMv8_A__)\r\n"
" #error JUCE_ARCH armv8l\r\n" " #error JUCE_ARCH armv8l\r\n"
" #elif (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM == 7) || defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) || defined(_ARM_ARCH_7) || defined(__CORE_CORTEX" "#elif (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM == 7) || defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) || defined(_ARM_ARCH_7) || defined(__CORE_CORTEXA_"
"A__)\r\n" "_)\r\n"
" #error JUCE_ARCH armv7l\r\n" " #error JUCE_ARCH armv7l\r\n"
" #elif (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM == 6) || defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_A" "#elif (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM == 6) || defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARC"
"RCH_6M__)\r\n" "H_6M__)\r\n"
" #error JUCE_ARCH armv6l\r\n" " #error JUCE_ARCH armv6l\r\n"
" #elif (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM == 5) || defined(__ARM_ARCH_5TEJ__)\r\n" "#elif (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM == 5) || defined(__ARM_ARCH_5TEJ__)\r\n"
" #error JUCE_ARCH armv5l\r\n" " #error JUCE_ARCH armv5l\r\n"
" #else\r\n" "#elif defined(__arm__) || defined(_M_ARM)\r\n"
" #error JUCE_ARCH arm\r\n" " #error JUCE_ARCH arm\r\n"
" #endif\r\n"
"\r\n" "\r\n"
"#elif defined(__i386) || defined(__i386__) || defined(_M_IX86)\r\n" "#elif defined(__i386) || defined(__i386__) || defined(_M_IX86)\r\n"
"\r\n" "\r\n"
@ -9051,7 +9050,7 @@ const char* getNamedResource (const char* resourceNameUTF8, int& numBytes)
case 0x0b16e320: numBytes = 517; return jucer_PIPTemplate_h; case 0x0b16e320: numBytes = 517; return jucer_PIPTemplate_h;
case 0x763d39dc: numBytes = 1050; return colourscheme_dark_xml; case 0x763d39dc: numBytes = 1050; return colourscheme_dark_xml;
case 0xe8b08520: numBytes = 1050; return colourscheme_light_xml; case 0xe8b08520: numBytes = 1050; return colourscheme_light_xml;
case 0x7c03d519: numBytes = 3658; return juce_runtime_arch_detection_cpp; case 0x7c03d519: numBytes = 3575; return juce_runtime_arch_detection_cpp;
case 0x295b6f43: numBytes = 1865; return juce_LinuxSubprocessHelper_cpp; case 0x295b6f43: numBytes = 1865; return juce_LinuxSubprocessHelper_cpp;
case 0xef269d3a: numBytes = 12997; return juce_SimpleBinaryBuilder_cpp; case 0xef269d3a: numBytes = 12997; return juce_SimpleBinaryBuilder_cpp;
default: break; default: break;

View file

@ -207,7 +207,7 @@ namespace BinaryData
const int colourscheme_light_xmlSize = 1050; const int colourscheme_light_xmlSize = 1050;
extern const char* juce_runtime_arch_detection_cpp; extern const char* juce_runtime_arch_detection_cpp;
const int juce_runtime_arch_detection_cppSize = 3658; const int juce_runtime_arch_detection_cppSize = 3575;
extern const char* juce_LinuxSubprocessHelper_cpp; extern const char* juce_LinuxSubprocessHelper_cpp;
const int juce_LinuxSubprocessHelper_cppSize = 1865; const int juce_LinuxSubprocessHelper_cppSize = 1865;