pytorch / cpuinfo

CPU INFOrmation library (x86/x86-64/ARM/ARM64, Linux/Windows/Android/macOS/iOS)
BSD 2-Clause "Simplified" License
990 stars 310 forks source link

Enable tvOS and watchOS #147

Closed wangkuiyi closed 1 year ago

wangkuiyi commented 1 year ago

I realized that we need this when I was building the OpenXLA/IREE runtime for tvOS and watchOS.

  1. Before this change, the CMakeLists.txt file uses CMake built-in variable IOS, which is equivalent to CMAKE_SYSTEM_NAME STREQUAL "iOS", to tell if it is building for Apple mobile platforms. This trick prevents CMake from recognizing tvOS and watchOS.

    This pull requests changes the use of IOS into set(APPLE_SYSTEM CMAKE_SYSTEM_NAME MATCHES "^(Darwin|iOS|tvOS|watchOS)").

  2. Before this change, the CMakeLists.txt assumes that Apple's ARM64 platform has the name "arm64". However, M2 chip has the name "arm64e". This pull request changes MATCHES "arm64" into MATCHES "arm64.*".

wconstab commented 1 year ago

@malfet anything else we need to check besides CI? (unfamiliar with cpuinfo lib)

wangkuiyi commented 1 year ago

@wconstab @malfet - I verified that the change works on macOS M2 cross-compiling for macOS, iOS, iOS simulator, tvOS, and tvOS simulator with x86_64, arm64, and arm64e (M2).

I do not have macOS-x86_64, Linux, Windows, or Android. So I will have to rely on CI for these platforms.

malfet commented 1 year ago

Ok, Windows and linter failures does not happen on trunk, so looks like this change is doing something unexpected, looking...

Well, SET command only take literals in Cmake, isn't it, and MATCHES binary tests can only be used in IF() condition.