diff --git a/ios.toolchain.cmake b/ios.toolchain.cmake index db2a327..1a415f2 100644 --- a/ios.toolchain.cmake +++ b/ios.toolchain.cmake @@ -724,18 +724,24 @@ endforeach() # CMake 3.14+ support building for iOS, watchOS, and tvOS out of the box. if(MODERN_CMAKE) if(SDK_NAME MATCHES "iphone") - set(CMAKE_SYSTEM_NAME iOS) + set(TOOLCHAIN_SYSTEM_NAME iOS) elseif(SDK_NAME MATCHES "xros") - set(CMAKE_SYSTEM_NAME visionOS) + set(TOOLCHAIN_SYSTEM_NAME visionOS) elseif(SDK_NAME MATCHES "xrsimulator") - set(CMAKE_SYSTEM_NAME visionOS) + set(TOOLCHAIN_SYSTEM_NAME visionOS) elseif(SDK_NAME MATCHES "macosx") - set(CMAKE_SYSTEM_NAME Darwin) + set(TOOLCHAIN_SYSTEM_NAME Darwin) elseif(SDK_NAME MATCHES "appletv") - set(CMAKE_SYSTEM_NAME tvOS) + set(TOOLCHAIN_SYSTEM_NAME tvOS) elseif(SDK_NAME MATCHES "watch") - set(CMAKE_SYSTEM_NAME watchOS) + set(TOOLCHAIN_SYSTEM_NAME watchOS) endif() + + # This is done because simply setting CMAKE_SYSTEM_NAME already enables CMAKE_CROSSCOMPILING, which is undesirable when building on mac for mac. + if(NOT ${CMAKE_HOST_SYSTEM_NAME} STREQUAL ${TOOLCHAIN_SYSTEM_NAME}) + set(CMAKE_SYSTEM_NAME ${TOOLCHAIN_SYSTEM_NAME}) + endif() + # Provide flags for a combined FAT library build on newer CMake versions if(PLATFORM_INT MATCHES ".*COMBINED") set(CMAKE_IOS_INSTALL_COMBINED YES)