[gdal-dev] iOS patch for GDAL 3.5 requires modification for Mac Catalyst
Hi GDAL devs, A few months ago, a patch to GDAL 3.5 was developed so that building with CMAKE would run correctly for iOS builds. The patch is below. I am now extending my iOS app to use Mac Catalyst (for those who don’t know, this is an Apple technology to enable apps developed for iOS to also run on macOS (both ARM and Intel), and for the Mac version to also be extended to include macOS-only functionality, such as menu bars, etc). I have found that when building for Mac Catalyst, the build failed in exactly the same way that it used to fail for iOS before applying the patch (below). The errors are due to (as the patch comment says): tests detect 64 symbols for iOS, which are not available at build time. So I modified the patched file further to replace this line: if (${CMAKE_SYSTEM_NAME} MATCHES "iOS”) ...with this: if (${CMAKE_SYSTEM_NAME} MATCHES “iOS” OR ${CMAKE_SYSTEM_NAME} MATCHES “Darwin”) ...and now the Mac Catalyst build works correctly (for both Mac Catalyst x86_64 AND Mac Catalyst arm64). HOWEVER, I do not know if this might adversely affect direct (non-catalyst) “normal” macOS builds (as I am not doing any such builds myself). Is anybody able to verify if this change would be a problem for macOS. If not, can this change be included in future builds of GDAL, or if it would be problematic for “normal” macOS, is there some way to modify the cmake config to check explicitly for Mac Catalyst, as opposed to “normal” macOS? Cheers, Nik. START OF PATCH —— --- orig/configure.cmake2022-05-11 00:03:37.0 +1000 +++ patched/configure.cmake 2022-07-06 18:54:48.0 +1000 @@ -41,6 +41,7 @@ check_type_size("int" SIZEOF_INT) check_type_size("unsigned long" SIZEOF_UNSIGNED_LONG) check_type_size("void*" SIZEOF_VOIDP) +check_type_size("size_t" SIZEOF_SIZE_T) if (MSVC) set(HAVE_VSNPRINTF 1) @@ -116,6 +117,13 @@ " HAVE_5ARGS_MREMAP) + check_c_source_compiles( +" +#include +int main() { pthread_atfork(0,0,0); 0; } +" +HAVE_PTHREAD_ATFORK) + check_include_file("sys/stat.h" HAVE_SYS_STAT_H) if (${CMAKE_SYSTEM} MATCHES "Linux") check_include_file("linux/fs.h" HAVE_LINUX_FS_H) @@ -233,6 +241,27 @@ set(VSI_FTRUNCATE64 "ftruncate") endif () + # For some reason, above tests detect 64 symbols for iOS, which are not + # available at build time. + if (${CMAKE_SYSTEM_NAME} MATCHES "iOS") +set(VSI_FOPEN64 "fopen") +set(VSI_FTRUNCATE64 "ftruncate") +set(VSI_FTELL64 "ftell") +set(VSI_FSEEK64 "fseek") +set(VSI_STAT64 "stat") +set(VSI_STAT64_T "stat") +unset(HAVE_FOPEN64) +unset(HAVE_FOPEN64 CACHE) +unset(HAVE_FTRUNCATE64) +unset(HAVE_FTRUNCATE64 CACHE) +unset(HAVE_FTELL64) +unset(HAVE_FTELL64 CACHE) +unset(HAVE_FSEEK64) +unset(HAVE_FSEEK64 CACHE) +unset(HAVE_STATVFS64) +unset(HAVE_STATVFS64 CACHE) + endif() + set(UNIX_STDIO_64 TRUE) set(INCLUDE_XLOCALE_H) @@ -313,4 +342,4 @@ set(MACOSX_FRAMEWORK OFF) endif () -# vim: ts=4 sw=4 sts=4 et +# vim: ts=4 sw=4 sts=4 et \ No newline at end of file —— END OF PATCH NIK SANDS Line Tamer | Time Traveller | Space Cadet ___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] iOS patch for GDAL 3.5 requires modification for Mac Catalyst
Nik, I've prepared a PR with your suggested fix in https://github.com/OSGeo/gdal/pull/6282 It passes fine on existing MacOS continuous integration jobs we have. It would be good if people that have access to a bit ancient MacOSX (not sure how ancient it should be...), or with 32-bit builds, could check if that PR doesn't prevent using data files > 4 GB. Even Le 31/08/2022 à 01:07, Nik Sands a écrit : Hi GDAL devs, A few months ago, a patch to GDAL 3.5 was developed so that building with CMAKE would run correctly for iOS builds. The patch is below. I am now extending my iOS app to use Mac Catalyst (for those who don’t know, this is an Apple technology to enable apps developed for iOS to also run on macOS (both ARM and Intel), and for the Mac version to also be extended to include macOS-only functionality, such as menu bars, etc). I have found that when building for Mac Catalyst, the build failed in exactly the same way that it used to fail for iOS before applying the patch (below). The errors are due to (as the patch comment says): tests detect 64 symbols for iOS, which are not available at build time. So I modified the patched file further to replace this line: if (${CMAKE_SYSTEM_NAME} MATCHES "iOS”) ...with this: if (${CMAKE_SYSTEM_NAME} MATCHES “iOS” OR ${CMAKE_SYSTEM_NAME} MATCHES “Darwin”) ...and now the Mac Catalyst build works correctly (for both Mac Catalyst x86_64 AND Mac Catalyst arm64). HOWEVER, I do not know if this might adversely affect direct (non-catalyst) “normal” macOS builds (as I am not doing any such builds myself). Is anybody able to verify if this change would be a problem for macOS. If not, can this change be included in future builds of GDAL, or if it would be problematic for “normal” macOS, is there some way to modify the cmake config to check explicitly for Mac Catalyst, as opposed to “normal” macOS? Cheers, Nik. START OF PATCH —— --- orig/configure.cmake2022-05-11 00:03:37.0 +1000 +++ patched/configure.cmake 2022-07-06 18:54:48.0 +1000 @@ -41,6 +41,7 @@ check_type_size("int" SIZEOF_INT) check_type_size("unsigned long" SIZEOF_UNSIGNED_LONG) check_type_size("void*" SIZEOF_VOIDP) +check_type_size("size_t" SIZEOF_SIZE_T) if (MSVC) set(HAVE_VSNPRINTF 1) @@ -116,6 +117,13 @@ " HAVE_5ARGS_MREMAP) + check_c_source_compiles( +" +#include +int main() { pthread_atfork(0,0,0); 0; } +" +HAVE_PTHREAD_ATFORK) + check_include_file("sys/stat.h" HAVE_SYS_STAT_H) if (${CMAKE_SYSTEM} MATCHES "Linux") check_include_file("linux/fs.h" HAVE_LINUX_FS_H) @@ -233,6 +241,27 @@ set(VSI_FTRUNCATE64 "ftruncate") endif () + # For some reason, above tests detect 64 symbols for iOS, which are not + # available at build time. + if (${CMAKE_SYSTEM_NAME} MATCHES "iOS") +set(VSI_FOPEN64 "fopen") +set(VSI_FTRUNCATE64 "ftruncate") +set(VSI_FTELL64 "ftell") +set(VSI_FSEEK64 "fseek") +set(VSI_STAT64 "stat") +set(VSI_STAT64_T "stat") +unset(HAVE_FOPEN64) +unset(HAVE_FOPEN64 CACHE) +unset(HAVE_FTRUNCATE64) +unset(HAVE_FTRUNCATE64 CACHE) +unset(HAVE_FTELL64) +unset(HAVE_FTELL64 CACHE) +unset(HAVE_FSEEK64) +unset(HAVE_FSEEK64 CACHE) +unset(HAVE_STATVFS64) +unset(HAVE_STATVFS64 CACHE) + endif() + set(UNIX_STDIO_64 TRUE) set(INCLUDE_XLOCALE_H) @@ -313,4 +342,4 @@ set(MACOSX_FRAMEWORK OFF) endif () -# vim: ts=4 sw=4 sts=4 et +# vim: ts=4 sw=4 sts=4 et \ No newline at end of file —— END OF PATCH NIK SANDS Line Tamer | Time Traveller | Space Cadet ___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev -- http://www.spatialys.com My software is free, but my time generally not. ___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] iOS patch for GDAL 3.5 requires modification for Mac Catalyst
Hi, The patch at the end of my reply builds & tests ok on my environment (macOS 12.5.1 + arm64). Are you using https://github.com/leetal/ios-cmake or do newer versions of CMake now have support for Catalyst? (from https://gitlab.kitware.com/cmake/cmake/-/issues/20132 it seems not) How do the varios combinations of CMAKE_SYSTEM_NAME=Darwin|iOS, APPLE, UNIX, etc work under Catalyst? Rob :) diff --git a/cmake/helpers/configure.cmake b/cmake/helpers/configure.cmake index 277f1ab2a9..a91f72aa04 100644 --- a/cmake/helpers/configure.cmake +++ b/cmake/helpers/configure.cmake @@ -247,7 +247,7 @@ else () # For some reason, above tests detect 64 symbols for iOS, which are not # available at build time. - if (${CMAKE_SYSTEM_NAME} MATCHES "iOS") + if (${CMAKE_SYSTEM_NAME} MATCHES “iOS” OR ${CMAKE_SYSTEM_NAME} MATCHES “Darwin”) set(VSI_FOPEN64 "fopen") set(VSI_FTRUNCATE64 "ftruncate") set(VSI_FTELL64 "ftell") ___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] iOS patch for GDAL 3.5 requires modification for Mac Catalyst
Thanks Rob and Even, Rob - yes, I am using the CMAKE as per your link. I have documented my entire process here: https://gis.stackexchange.com/questions/434514/build-gdal-3-x-for-ios Although I’ve not yet updated it for the update to the patch file. - NIK SANDS Line Tamer | Time Traveller | Space Cadet > On 1 Sep 2022, at 6:57 am, Robert Coup wrote: > > > Hi, > > The patch at the end of my reply builds & tests ok on my environment (macOS > 12.5.1 + arm64). > > Are you using https://github.com/leetal/ios-cmake or do newer versions of > CMake now have support for Catalyst? (from > https://gitlab.kitware.com/cmake/cmake/-/issues/20132 it seems not) > > How do the varios combinations of CMAKE_SYSTEM_NAME=Darwin|iOS, APPLE, UNIX, > etc work under Catalyst? > > Rob :) > > diff --git a/cmake/helpers/configure.cmake b/cmake/helpers/configure.cmake > index 277f1ab2a9..a91f72aa04 100644 > --- a/cmake/helpers/configure.cmake > +++ b/cmake/helpers/configure.cmake > @@ -247,7 +247,7 @@ else () > ># For some reason, above tests detect 64 symbols for iOS, which are not ># available at build time. > - if (${CMAKE_SYSTEM_NAME} MATCHES "iOS") > + if (${CMAKE_SYSTEM_NAME} MATCHES “iOS” OR ${CMAKE_SYSTEM_NAME} MATCHES > “Darwin”) > set(VSI_FOPEN64 "fopen") > set(VSI_FTRUNCATE64 "ftruncate") > set(VSI_FTELL64 "ftell") > ___ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev