Browse Source

CMake: Automatically set archiving-related properties when generating for Xcode

tags/2021-05-28
reuk 4 years ago
parent
commit
f68ee25b52
2 changed files with 35 additions and 36 deletions
  1. +9
    -35
      docs/CMake API.md
  2. +26
    -1
      extras/Build/CMake/JUCEUtils.cmake

+ 9
- 35
docs/CMake API.md View File

@@ -122,41 +122,15 @@ provisioning profiles, which is achieved by passing the `-allowProvisioningUpdat
#### Archiving for iOS

CMake's out-of-the-box archiving behaviour doesn't always work as expected, especially for targets
that depend on static libraries (such as targets added with `juce_add_binary_data`). Xcode may
generate these libraries into a 'DerivedData' directory, but then omit this directory from the
library search paths later in the build.

If the "Product -> Archive" action isn't working, the following steps may help correct the issue:

- On your static library, explicitly set the `ARCHIVE_OUTPUT_DIRECTORY` property.
```
set_target_properties(my_static_lib_target PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "./")
```
- Now, the Archive build should complete without linker errors, but the archived product may still
be hidden in the Organizer window. To fix this issue, set the following properties on the target
representing the actual iOS app. If your target was added with `juce_add_gui_app`, pass the same
target name. Otherwise, if your target was added with `juce_add_plugin` you may need to append
`_Standalone` to the target name, to specify the standalone plugin target.
```
set_target_properties(my_ios_app_target PROPERTIES
XCODE_ATTRIBUTE_INSTALL_PATH "$(LOCAL_APPS_DIR)"
XCODE_ATTRIBUTE_SKIP_INSTALL "NO")
```

To archive an AUv3 plugin, `XCODE_ATTRIBUTE_INSTALL_PATH` must point to the PlugIns directory of the
final app bundle but only for the AUv3 target. In code, that might look like this:

set_target_properties(my_plugin_Standalone PROPERTIES
XCODE_ATTRIBUTE_INSTALL_PATH "$(LOCAL_APPS_DIR)"
XCODE_ATTRIBUTE_SKIP_INSTALL "NO")

get_target_property(output_name my_plugin_Standalone OUTPUT_NAME)

# On iOS, the AUv3 should go in <bundle_dir>/PlugIns
# On macOS, the AUv3 should go in <bundle_dir>/Contents/PlugIns
set_target_properties(my_plugin_AUv3 PROPERTIES
XCODE_ATTRIBUTE_INSTALL_PATH "$(LOCAL_APPS_DIR)/${output_name}.app/PlugIns"
XCODE_ATTRIBUTE_SKIP_INSTALL "NO")
that depend on custom static libraries. Xcode may generate these libraries into a 'DerivedData'
directory, but then omit this directory from the library search paths later in the build.

If the "Product -> Archive" action isn't working due to missing staticlibs, try setting the
`ARCHIVE_OUTPUT_DIRECTORY` property explicitly:

set_target_properties(my_static_lib_target PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "./")

Note that the static library produced by `juce_add_binary_data` automatically sets this property.

### Building universal binaries for macOS



+ 26
- 1
extras/Build/CMake/JUCEUtils.cmake View File

@@ -879,6 +879,11 @@ function(juce_add_binary_data target)
target_include_directories(${target} INTERFACE ${juce_binary_data_folder})
target_compile_features(${target} PRIVATE cxx_std_11)

# This fixes an issue where Xcode is unable to find binary data during archive.
if(CMAKE_GENERATOR STREQUAL "Xcode")
set_target_properties(${target} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "./")
endif()

if(JUCE_ARG_HEADER_NAME STREQUAL "BinaryData.h")
target_compile_definitions(${target} INTERFACE JUCE_TARGET_HAS_BINARY_DATA=1)
endif()
@@ -1155,6 +1160,26 @@ function(_juce_configure_bundle source_target dest_target)
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER
$<TARGET_PROPERTY:${source_target},JUCE_BUNDLE_ID>)
endif()

if(CMAKE_GENERATOR STREQUAL "Xcode")
get_target_property(product_name ${source_target} JUCE_PRODUCT_NAME)

set(install_path "$(LOCAL_APPS_DIR)")

if(juce_kind_string STREQUAL "AUv3 AppExtension")
set(install_path "${install_path}/${product_name}.app")

if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
set(install_path "${install_path}/PlugIns")
else()
set(install_path "${install_path}/Contents/PlugIns")
endif()
endif()

set_target_properties(${dest_target} PROPERTIES
XCODE_ATTRIBUTE_INSTALL_PATH "${install_path}"
XCODE_ATTRIBUTE_SKIP_INSTALL "NO")
endif()
endfunction()

function(_juce_add_resources_rc source_target dest_target)
@@ -2176,7 +2201,7 @@ function(juce_add_pip header)
list(APPEND extra_target_args MICROPHONE_PERMISSION_ENABLED TRUE)

juce_add_plugin(${JUCE_PIP_NAME}
FORMATS AU AUv3 VST3 Unity Standalone ${extra_formats}
FORMATS AU AUv3 VST3 Standalone ${extra_formats}
${extra_target_args})
elseif(pip_kind STREQUAL "Component")
set(source_main "${JUCE_CMAKE_UTILS_DIR}/PIPComponent.cpp.in")


Loading…
Cancel
Save