Find_package - MSVC - Standard Architecture not defined.

I am working with a few packages and noticed that the CMAKE find_package is fundamentally broken with MSVC. From what I can tell the following variables are not defined:

  • CMAKE_LIBRARY_ARCHITECTURE
  • CMAKE_C_LIBRARY_ARCHITECTURE
  • CMAKE_CXX_LIBRARY_ARCHITECTURE

What is defined however is the following:

  • MSVC_C_ARCHITECTURE_ID (Internal variable)
  • MSVC_CXX_ARCHITECTURE_ID (Internal variable)
  • CMAKE_C_ARCHITECTURE_ID
  • CMAKE_CXX_ARCHITECTURE_ID

I expect the values for the missing variable to match the variables that are already defined.

CMake 3.7 - The documentation for find_pacakge shows 3 entries for windows that involve “arch”.

CMake 4.3 - The documentation for find_package still includes 3 entries for windows involving “arch”

Note 1: I noticed this issue with CMAKE v3.31.6 that is included with msvc, and the relevant configuration files (cmake-msvc.cmake, cmake-msvc-c.cmake and cmake-msvc-cxx.cmake) do not appear to be updated with anything that sets the missing variable.

Note 2: fixing this could be useful for searching for packages implementing the common package specification on windows.

For reference, the CMAKE_<LANG>_LIBRARY_ARCHITECTURE documentation states:

If the <LANG> compiler passes to the linker an architecture-specific system library search directory such as <prefix>/lib/<arch> this variable contains the <arch> name if/as detected by CMake.

This models the toolchain’s builtin arch-specific library directories, and was created for debian-style multi-arch environments.

MSVC arch-specific library directories have not been considered before AFAIK. I’ve opened CMake Issue 27731 to propose it.