What are the possible values of CMAKE_SYSTEM_PROCESSOR?

Viewed 2315

In CMake, what are the different possible values of CMAKE_SYSTEM_PROCESSOR? At least, the values for common processor families by AMD, Intel, Apple, Qualcomm and such?

I couldn't find this information in the CMake documentation.

1 Answers

According to the documentation, "when not cross-compiling, this variable has the same value as the CMAKE_HOST_SYSTEM_PROCESSOR variable". In the former scenario, the variable is set by the toolchain file, which I assume is what you're interested in doing.

In the latter case, the documentation says that CMAKE_HOST_SYSTEM_PROCESSOR is determined by inspecting the environment in the following way:

  • On Windows, the value of the PROCESSOR_ARCHITECTURE environment variable is used.
  • On macOS, the value of uname -m is used by default. However, since this might vary based on whether you're using x86 or ARM CMake, version 3.19.2+ will use the value of CMAKE_APPLE_SILICON_PROCESSOR (either CMake or environment variable) instead, if it is set. It also normalizes Power Macintosh to powerpc.
    • As far as I am aware, the possible values here are x86_64, arm64, and powerpc.
  • On OpenBSD, it uses the arch -s command.
    • Not sure what the full list is here. Unfortunately, the man page doesn't have anything to say about this.
  • On Linux and related systems (Cygwin, MSYS, Android, GNU), it uses uname -m
  • Otherwise, it looks for the uname command and tries uname -p first. If it returns a non-zero exit status, it resorts to uname -m
    • No telling what this could be.

But what really matters is how CMake will use the value of CMAKE_SYSTEM_PROCESSOR. Here are the functions I'm aware of:

  • The default value of CPACK_SYSTEM_NAME is ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}.
  • The language modules Modules/CMake<LANG>Information.cmake all optionally include platform modules suffixed with -${CMAKE_SYSTEM_PROCESSOR}.cmake
    • In most cases, no such modules exist. On Android, very many platform modules exist with processor-specific variants.
  • The FindJNI module uses it to guide its search
  • It is passed to ARMClang via --mcpu (compile) and --cpu (link)
Related