From ac7028219399320b441d9e22d17b27de4272a9c2 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sun, 10 Apr 2022 19:50:19 -1000 Subject: [PATCH] macOS: build googlemaps plugin as fat binary I couldn't make this to work as a single pass build, so we again do a dual pass and manually assemble the dylib. This is then copied to a sane spot which required another attempt to copy it in the CMakeLists.txt - which I added comments to in order to make sense of the weirdness. Signed-off-by: Dirk Hohndel --- CMakeLists.txt | 5 +++++ scripts/build.sh | 19 +++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a4ba5837d..3d5a8297f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -580,8 +580,13 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") endif() if(MAPSUPPORT) install(CODE "execute_process(COMMAND mkdir -p ${PLUGINDIR}/geoservices)") + # this is really weird. We first try a plugin that ended up in the Qt install prefix + # then we try one that's in that odd broken install location that the qmake file results in (that includes the QT_INSTALL_PREFIX after our INSTALL_ROOT + # and finally, for fat binaries, we copy the one that's in the 'logical' spot under the INSTALL_ROOT + # this should cover all cases and always get us the correct library install(CODE "execute_process(COMMAND cp ${QT_INSTALL_PREFIX}/plugins/geoservices/libqtgeoservices_googlemaps.dylib ${PLUGINDIR}/geoservices ERROR_QUIET)") install(CODE "execute_process(COMMAND cp ${CMAKE_SOURCE_DIR}/../install-root/${QT_INSTALL_PREFIX}/plugins/geoservices/libqtgeoservices_googlemaps.dylib ${PLUGINDIR}/geoservices ERROR_QUIET)") + install(CODE "execute_process(COMMAND cp ${CMAKE_SOURCE_DIR}/../install-root/plugins/geoservices/libqtgeoservices_googlemaps.dylib ${PLUGINDIR}/geoservices ERROR_QUIET)") endif() # this will fail is macdeployqt isn't in the PATH - that seemed to happen in the past, but not recently # also, on M1 macOS systems macdeployqt throws a ton of (apparently harmless) errors. Warn the unsuspecting developer diff --git a/scripts/build.sh b/scripts/build.sh index 1e481a12c..2240760da 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -559,7 +559,8 @@ if [ "$QUICK" != "1" ] && [ "$BUILD_DESKTOP$BUILD_MOBILE" != "" ] && ( [[ $QT_VE if [ "$PLATFORM" = Darwin ] && [[ $QT_VERSION == 6* ]]; then # since we are currently building QtLocation from source, we don't have a way to easily install # the private headers... so this is a bit of a hack to get those for googlemaps... - $QMAKE "INCLUDEPATH=$INSTALL_ROOT/../qtlocation/build/include/QtLocation/6.3.0" ../googlemaps.pro + # regardless of whether we do a fat build or not, let's do the 'native' build here + $QMAKE "INCLUDEPATH=$INSTALL_ROOT/../qtlocation/build/include/QtLocation/6.3.0" QMAKE_APPLE_DEVICE_ARCHS=$(arch) ../googlemaps.pro else $QMAKE "INCLUDEPATH=$INSTALL_ROOT/include" ../googlemaps.pro fi @@ -571,7 +572,21 @@ if [ "$QUICK" != "1" ] && [ "$BUILD_DESKTOP$BUILD_MOBILE" != "" ] && ( [[ $QT_VE cat Makefile.bak | sed -e 's/std=c++1z/std=c++11/g ; s/-Wdate-time//' > Makefile fi make -j4 - make install + if [ "$PLATFORM" = Darwin ] && [[ $QT_VERSION == 6* ]] && [[ $ARCHS == *" "* ]] ; then + # we can't build fat binaries directly here, so let's do it in two steps + # above we build the 'native' binary, now build the other one + OTHERARCH=${ARCHS//$(arch)/} + OTHERARCH=${OTHERARCH// /} + mkdir -p ../build-$OTHERARCH + cd ../build-$OTHERARCH + $QMAKE "INCLUDEPATH=$INSTALL_ROOT/../qtlocation/build/include/QtLocation/6.3.0" QMAKE_APPLE_DEVICE_ARCHS=$OTHERARCH ../googlemaps.pro + make -j4 + # now combine them into one .dylib + mkdir -p "$INSTALL_ROOT"/plugins/geoservices + lipo -create ./libqtgeoservices_googlemaps.dylib ../build/libqtgeoservices_googlemaps.dylib -output "$INSTALL_ROOT"/plugins/geoservices/libqtgeoservices_googlemaps.dylib + else + make install + fi popd fi