pytorch / cpuinfo

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

CPUINFO_SUPPORTED_PLATFORM not set on OSX as CMAKE_SYSTEM_PROCESSOR is not set #203

Open Timen opened 7 months ago

Timen commented 7 months ago

CMAKE_SYSTEM_PROCESSOR is not set by cmake on apple platforms which causes this warning:

   MESSAGE(WARNING
      "Target processor architecture is not specified. "
      "cpuinfo will compile, but cpuinfo_initialize() will always fail.")

at this line: https://github.com/pytorch/cpuinfo/blob/ef634603954d88d2643d5809011288b890ac126e/CMakeLists.txt#L90

There is actually a check if we are building for iOS that causes this warning to not be emitted and CPUINFO_SUPPORTED_PLATFORM be set to true, however this is not the case on OSX, is this on purpose?

prashanthswami commented 7 months ago

Just throwing in my two cents, I'm not entirely sure of the history of the line you've referenced. It looks like they were trying to fix the iOS build but the context of what was broken is lost.

Looking at CMake documentation, CMAKE_SYSTEM_PROCESSOR should be defined if you're not cross-compiling. I'm assuming that means you are and thus need a "a CMAKE_TOOLCHAIN_FILE should set the CMAKE_SYSTEM_PROCESSOR variable to match target architecture". Arguably, it may be the case that iOS needs this as well.

Perhaps you can provide some details of how you're configuring your build here for the maintainers?