CMakeIOSInstallCombined: Enforce disjoint architecture sets

Starting with Xcode 12 the arm64 architecture is supported
as an iOS device as well as simulator architecture.

But the fat macho file format does not distinguish by SDK,
only by architecture. That makes lipo (rightfully) complain
that it cannot add both architectures to a single file.

To work around we make sure that both SDKs are built for a
disjoint set of architectures. If an architecture is present
for both SDKs we prefer the currently configured one.

The log output has been extended to reflect that:

```
[iOS combined] Architectures (iphoneos): arm64 arm64e armv7 armv7s
[iOS combined] Architectures (iphonesimulator): arm64 arm64e i386 x86_64
[iOS combined] Architectures (iphonesimulator) after pruning: i386 x86_64
```
diff --git a/Help/prop_tgt/IOS_INSTALL_COMBINED.rst b/Help/prop_tgt/IOS_INSTALL_COMBINED.rst
index 23a86e6..92d60dc 100644
--- a/Help/prop_tgt/IOS_INSTALL_COMBINED.rst
+++ b/Help/prop_tgt/IOS_INSTALL_COMBINED.rst
@@ -10,4 +10,10 @@
 set. But if this property is set to true then the target will at install time
 also be built for the corresponding SDK and combined into one library.
 
+.. note::
+
+  If a selected architecture is available for both: device SDK and simulator
+  SDK it will be built for the SDK selected by :variable:`CMAKE_OSX_SYSROOT`
+  and removed from the corresponding SDK.
+
 This feature requires at least Xcode version 6.
diff --git a/Modules/CMakeIOSInstallCombined.cmake b/Modules/CMakeIOSInstallCombined.cmake
index 418bafd..44bb622 100644
--- a/Modules/CMakeIOSInstallCombined.cmake
+++ b/Modules/CMakeIOSInstallCombined.cmake
@@ -80,6 +80,17 @@
   cmake_policy(POP)
 endfunction()
 
+# Make both arch lists a disjoint set by preferring the current SDK
+# (starting with Xcode 12 arm64 is available as device and simulator arch on iOS)
+function(_ios_install_combined_prune_common_archs corr_sdk corr_archs_var this_archs_var)
+  list(REMOVE_ITEM ${corr_archs_var} ${${this_archs_var}})
+
+  string(REPLACE ";" " " printable "${${corr_archs_var}}")
+  _ios_install_combined_message("Architectures (${corr_sdk}) after pruning: ${printable}")
+
+  set("${corr_archs_var}" "${${corr_archs_var}}" PARENT_SCOPE)
+endfunction()
+
 # Final target can contain more architectures that specified by SDK. This
 # function will run 'lipo -info' and parse output. Result will be returned
 # as a CMake list.
@@ -266,8 +277,9 @@
   _ios_install_combined_detect_sdks(this_sdk corr_sdk)
 
   # Get architectures of the target
-  _ios_install_combined_get_valid_archs("${corr_sdk}" corr_valid_archs)
   _ios_install_combined_get_valid_archs("${this_sdk}" this_valid_archs)
+  _ios_install_combined_get_valid_archs("${corr_sdk}" corr_valid_archs)
+  _ios_install_combined_prune_common_archs("${corr_sdk}" corr_valid_archs this_valid_archs)
 
   # Return if there are no valid architectures for the SDK.
   # (note that library already installed)