[bug] x86 build reports CMAKE_SYSTEM_PROCESSOR=AMD64 and not i386
- Dominant language
- C++
- Stars
- 125
- Forks
- 382
- Avg merge
- 22h 39m
- Merged PRs (30d)
- 21
Description
### 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](https://github.com/conan-io/conan/blob/709ef11aee236bf8e2165c4af86f3da6a1af9235/conan/tools/cmake/toolchain/blocks.py#L1018C1-L1018C73). 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](https://github.com/Kitware/CMake/blob/master/Modules/CMakeDetermineSystem.cmake#L156), 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](https://cmake.org/cmake/help/latest/command/add_custom_command.html)
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
...
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.