53f3654f4d1e — Chris Cannam 8 days ago
We can actually specify an old OS version perfectly well in the universal cross file, and it'll work for both slices (the ARM one will just get 11 instead). So do that, and document it. Also print out the target in the config summary.
4 files changed, 37 insertions(+), 31 deletions(-)

M README.md
M cross/macos-universal.txt
M cross/macos-x86_64.txt
M meson.build
M README.md +7 -13
@@ 258,17 258,11 @@ this:
 $ meson build --cross-file cross/macos-universal.txt && ninja -C build
 ```
 
-However, the resulting binary will be marked as loadable on macOS 11+
-only, even for Intel, which is probably not what you want (ideally the
-Intel slice would support older versions of the OS). A Makefile that
-handles this explicitly is also provided:
-
-```
-$ make -f otherbuilds/Makefile.macos-universal
-```
-
-This produces only a static library, but it's a universal binary that
-is compatible with macOS 10.7 onwards on the Intel side.
+Note that the universal cross file also sets the minimum OS version to
+the earliest supported macOS versions for both architectures. (Note
+that actual compatibility will also depend on how any dependent
+libraries have been compiled.)  You can edit this in the
+`cross/macos-universal.txt` file if you want a specific target.
 
 See "FFT and resampler selection" below for further build options.
 

          
@@ 284,7 278,7 @@ commercial terms.
 Ensure the Xcode command-line tools are installed, and
 
 ```
-$ meson build_ios --cross-file cross/ios.txt && ninja -C build
+$ meson build_ios --cross-file cross/ios.txt && ninja -C build_ios
 ```
 
 The output files will be found in the `build_ios` directory.

          
@@ 292,7 286,7 @@ The output files will be found in the `b
 To build for the simulator,
 
 ```
-$ meson build_sim --cross-file cross/ios-simulator.txt && ninja -C build
+$ meson build_sim --cross-file cross/ios-simulator.txt && ninja -C build_sim
 ```
 
 The output files will be found in the `build_sim` directory.

          
M cross/macos-universal.txt +3 -3
@@ 14,8 14,8 @@ strip = 'strip'
 pkgconfig = 'pkg-config'
 
 [built-in options]
-c_args = ['-arch', 'arm64', '-arch', 'x86_64']
-cpp_args = ['-arch', 'arm64', '-arch', 'x86_64']
-cpp_link_args = ['-arch', 'arm64', '-arch', 'x86_64']
+c_args = ['-arch', 'arm64', '-arch', 'x86_64', '-mmacosx-version-min=10.7']
+cpp_args = ['-arch', 'arm64', '-arch', 'x86_64', '-stdlib=libc++', '-mmacosx-version-min=10.7']
+cpp_link_args = ['-arch', 'arm64', '-arch', 'x86_64', '-stdlib=libc++', '-mmacosx-version-min=10.7']
 
 

          
M cross/macos-x86_64.txt +2 -2
@@ 15,6 15,6 @@ pkgconfig = 'pkg-config'
 
 [built-in options]
 c_args = ['-arch', 'x86_64']
-cpp_args = ['-arch', 'x86_64']
-cpp_link_args = ['-arch', 'x86_64']
+cpp_args = ['-arch', 'x86_64', '-stdlib=libc++']
+cpp_link_args = ['-arch', 'x86_64', '-stdlib=libc++']
 

          
M meson.build +25 -13
@@ 327,31 327,43 @@ if system == 'darwin'
     '-exported_symbols_list', meson.source_root() / 'vamp/vamp-plugin.list'
   ]
 
-  have_version_min = false
-  foreach arg: get_option('cpp_args')
-    if arg.contains('version-min')
-      have_version_min = true
-    endif
-  endforeach
-
   if architecture == 'aarch64'
     arch_flags += [
       '-arch', 'arm64',
     ]
-    if not have_version_min
-      arch_flags += [ '-mmacosx-version-min=11' ]
-    endif
   elif architecture == 'x86_64'
     arch_flags += [
       '-arch', 'x86_64',
     ]
-    if not have_version_min
-      arch_flags += [ '-mmacosx-version-min=10.13' ]
-    endif
   else # begin architecture != 'aarch64' or 'x86_64'
     error('Build for architecture ' + architecture + ' is not supported on this platform')
   endif # end architecture
 
+  have_version_min = false
+  foreach arg: get_option('cpp_args')
+    if arg.contains('version-min')
+      have_version_min = true
+      bits = arg.split('=')
+      if bits.length() > 1
+	config_summary += { 'Target OS': bits[1] + '+' }
+      else
+	config_summary += { 'Target OS': '(unknown)' }
+      endif
+    endif
+  endforeach
+
+  if not have_version_min
+    message('Using default minimum target OS version')
+    message('(consider specifying this in cross-file if earlier target is desired)')
+    if architecture == 'aarch64'
+      arch_flags += [ '-mmacosx-version-min=11' ]
+      config_summary += { 'Target OS': '11+' }
+    else 
+      arch_flags += [ '-mmacosx-version-min=10.13' ]
+      config_summary += { 'Target OS': '10.13+' }
+    endif
+  endif
+
 elif system == 'windows'
   feature_defines += ['-D_WIN32', '-DNOMINMAX', '-D_USE_MATH_DEFINES', '-DGETOPT_API=']
   if cpp.get_id() == 'msvc'