Use a simpler workaround for the broken iOS archive build

With 6.4 beta2 it seems to be enough to just build a normal Release
before doing the actual xcode archive build.
This is an issue in cmake, so chances of this getting fixed anytime
soon are slim: QTBUG-105006
This commit is contained in:
Robert Griebl
2022-07-15 23:54:16 +02:00
parent 979f1a74b4
commit 0641789bf9
2 changed files with 1 additions and 76 deletions

View File

@@ -226,18 +226,6 @@ qt_add_resources(${PROJECT_NAME} brickstore_qrc PREFIX / FILES
# message(STATUS "${_variableName}=${${_variableName}}")
#endforeach()
# Workaround for https://stackoverflow.com/questions/30318941/cmake-generated-xcode-project-release-build-works-but-archive-fails-on-linker
if (IOS AND FIX_IOS_ARCHIVE_BUILD)
message(STATUS "Applying workaround for iOS archive builds")
# for the static libs, we can force a common folder
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/out/library)
# for the object libs, we have to link all .o to the correct folder
# but we can't: https://gitlab.kitware.com/cmake/cmake/-/issues/23644
# we have to use a custom script for the archive custom target -- see below
endif()
include_directories(3rdparty)
add_subdirectory(3rdparty)
@@ -557,19 +545,10 @@ elseif (LINUX)
elseif (IOS)
# the idea here comes from https://github.com/OlivierLDff/QtIosCMake/blob/master/AddQtIosApp.cmake
set(IOS_ARCH ${CMAKE_OSX_ARCHITECTURES})
if (NOT IOS_ARCH)
set(IOS_ARCH ${CMAKE_XCODE_ARCHS})
endif()
add_custom_target(archive
DEPENDS ${PROJECT_NAME} ## we need to build twice! see QTBUG-105006
VERBATIM
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
# workaround for broken archive build (see above).
# a PRE_LINK custom command detecting the missing .o files dynamically would be nicer,
# but cmake/xcode has a bug and runs PRE_LINK command *after* linking.
COMMAND ${CMAKE_SOURCE_DIR}/scripts/fix-ios-archive-build.sh
Release ${CMAKE_OSX_SYSROOT} ${IOS_ARCH}
COMMAND xcodebuild
-project ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.xcodeproj
-configuration Release

View File

@@ -1,54 +0,0 @@
#!/bin/zsh
buildType="$1"
targetType="$2"
arch="$3"
echo "Fixing iOS archive build"
echo " current dir : $PWD"
echo " build type : $buildType"
echo " target type : $targetType"
echo " architecture: $arch"
derivedData="derivedData/ArchiveIntermediates/BrickStore/IntermediateBuildFilesPath"
echo " derived dir: $derivedData"
echo
echo " created links:"
#cd $derivedData
#for i in $(find */*/*_module_{resources,qmlcache}*(N) -name "*.o"); do
# j=$(echo $i | sed -e 's,.*/([^_]*)_module_.*,\1,')
# dst="../../../../src/$j/$i"
# echo " $PWD/$i --> $dst"
# mkdir -p $(dirname $dst)
# ln -sf $PWD/$i $dst
#done
buildModules=('BrickLink/bricklink' 'BrickStore/common' 'LDraw/ldraw' 'Mobile/mobile')
files=('@bm@_module_resources_1.build/Objects-normal/@arch@/mocs_compilation.o' \
'@bm@_module_resources_1.build/Objects-normal/@arch@/qrc_qmake_@BM@.o' \
'@bm@_module_qmlcache.build/Objects-normal/@arch@/mocs_compilation.o' \
'@bm@_module_qmlcache.build/Objects-normal/@arch@/@bm@_module_qmlcache_loader.o' \
'@bm@_module_resources_2.build/Objects-normal/@arch@/mocs_compilation.o' \
'@bm@_module_resources_2.build/Objects-normal/@arch@/qrc_@bm@_module_raw_qml_0.o')
for buildModule in ${buildModules}; do
BM=$(echo $buildModule | cut -d / -f 1)
bm=$(echo $buildModule | cut -d / -f 2)
for file in ${files}; do
f=$(echo $file | sed -e "s,@BM@,${BM},g" -e "s,@bm@,${bm},g" -e "s,@arch@,${arch},g")
common="BrickStore.build/${buildType}-${targetType}/${f}"
src="${derivedData}/${common}"
dst="src/${bm}/${common}"
echo " $src --> $dst"
mkdir -p "$(dirname $dst)"
ln -sf "$PWD/$src" "$dst"
done
done