Skip to content

Commit

Permalink
CMake: Add risky workaround for archiving dSYMs with an Xcode project
Browse files Browse the repository at this point in the history
CMake by default generates an Xcode project with an overridden
CONFIGURATION_BUILD_DIR Xcode attribute pointing to an absolute path
build dir.

Due to a bug in Xcode, that causes dSYMs not to be included in an
xcarchive after invoking the Xcode archiving task.

This can be worked around by re-setting the CONFIGURATION_BUILD_DIR
attribute to have the value "$(inherited)". That ensures that Xcode
places the dSYMs into an expected location, that can then be included
in an xcarchive.

Unfortunately overriding CONFIGURATION_BUILD_DIR breaks certain CMake
build path preconditions, which can result in broken behavior like
$<TARGET_FILE:app> genex evaluation not working, as well as ignoring
of the CMAKE_RUNTIME_OUTPUT_DIRECTORY property.

So modifying the CONFIGURATION_BUILD_DIR can only be done as an
opt-in, where the project developer knows the risks and can decide if
it will affect the project.

The project can opt into the risky fix by setting the
QT_USE_RISKY_DSYM_ARCHIVING_WORKAROUND cmake variable to ON before
creating any targets using qt_add_executable.

If Xcode fixes this bug in the future, we can make the variable a
no-op when we detect a new enough Xcode version.

Pick-to: 6.7 6.8
Task-number: QTBUG-126866
Change-Id: I37e8dee569fc45654f149219b8933769ed237fda
Reviewed-by:  Alexey Edelev <[email protected]>
  • Loading branch information
alcroito committed Jul 15, 2024
1 parent 7ccf30a commit ff1ba4f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cmake/QtPublicAppleHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,19 @@ function(_qt_internal_set_xcode_generate_debugging_symbols target)
endif()
endfunction()

# CMake generates a project where this setting is set to an absolute path build dir.
# Provide an opt-in to work around an Xcode issue where archiving does not find the project dSYMs
# unless the configuration build dir starts with $(BUILD_DIR) or is set to $(inherited).
# It is an opt-in, because it breaks certain CMake behavior like $<TARGET_FILE:${target}> genex
# evaluation as well as ignoring the value of CMAKE_RUNTIME_OUTPUT_DIRECTORY.
# So projects have to do it at their own risk.
function(_qt_internal_set_xcode_configuration_build_dir target)
if(QT_USE_RISKY_DSYM_ARCHIVING_WORKAROUND)
set_target_properties("${target}" PROPERTIES
XCODE_ATTRIBUTE_CONFIGURATION_BUILD_DIR "$(inherited)")
endif()
endfunction()

function(_qt_internal_set_xcode_bundle_display_name target)
# We want the value of CFBundleDisplayName to be ${PRODUCT_NAME}, but we can't put that
# into the Info.plist.in template file directly, because the implicit configure_file(Info.plist)
Expand Down

0 comments on commit ff1ba4f

Please sign in to comment.