Skip to content

[bug] x86 build reports CMAKE_SYSTEM_PROCESSOR=AMD64 and not i386 #4061

@KUGA2

Description

@KUGA2

Describe the bug

Hi,

When buidling a x86 project (Have seen it on windows but based on my research probably also on other OS-es), the CMAKE_SYSTEM_NAME reports a 64 bit architecture.

Reason is this code exception here. CMAKE_SYSTEM_NAME is not set, therefore processor is neither set by conan nor by CMake internas. Note that CMake does only try to find the real TARGET processor name when CMAKE_SYSTEM_NAME is set, but always uses CMAKE_HOST_SYSTEM_PROCESSOR when it is not set.

This does not affect compilation results, but decisions made based on that variable (e.g. folder names).

Workaround:

  • Set CMAKE_SYSTEM_NAME in profile or toolchain e.g: tools.cmake.cmaketoolchain:system_name=Windows
  • (Optional) Disable CMAKE_CROSSCOPILING. Otherwise CMake will not try to execute your created binaries. See add_custom_command

Btw, a little rant about jargon. I dislike the conan build/host naming. It is really counterintuitive when coming from CMake only projects... Example:

conan cmake
arch_build CMAKE_HOST_SYSTEM_PROCESSOR
arch_host CMAKE_SYSTEM_PROCESSOR

How to reproduce it

Run this example project and a windows x86 profile:

conanfile.py

from conan import ConanFile
from conan.tools.cmake import CMake, cmake_layout

class Recipe(ConanFile):
    name = "cmake_test"
    version = "1.0"
    settings = "os", "build_type"
    generators = "CMakeToolchain"
    
    def layout(self):
        cmake_layout(self)
        
    def build(self):
        cmake = CMake(self)
        cmake.configure()

CMakeLists.txt

cmake_minimum_required(VERSION 3.15)
project(foo LANGUAGES NONE)
message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")

profile

[settings]
arch=x86
os=Windows
...

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions