cmake-conan
cmake-conan copied to clipboard
Detecting target architecture for gcc when calling conan_cmake_run()
To preface, I'm not sure if this a shortcoming of conan_cmake_run()
or if I'm using it incorrectly / not as intended.
I'm using MSYS2
environment on Windows 10 (64-bit) for building a C++ application. MSYS2
provides a 32- and 64-bit environment with separate packages (compiler, CMake, etc.) for each environment. I want to preform both a 32- and 64-bit build of this application. For the 32-bit build, I run the build from the 32-bit MSYS2
environment so the 32-bit tools are picked up and 64-bit from the 64-bit environment. I'm using conan_cmake_run()
release v0.15.
However, when running conan_cmake_run()
, it detects arch=x86_64
in both cases, leading to build errors down the line. I'm wondering if this would also be the case when using 64-bit gcc
with -m32
flag.
I have implemented a workaround where I explicitly pass SETTINGS arch=${TARGET_ARCHITECTURE}
to conan_cmake_run()
and I set TARGET_ARCHITECTURE
in my CMakeLists.txt
based on CMAKE_SIZEOF_VOID_P
.
I also looked at the conan_cmake_run()
implementation an noticed that there is some code for automatic target architecture detection for Visual Studio. So I'm wondering if anything similar could be implemented for gcc
and if not, what the proper way to handle this in the CMakeLists.txt
would be.
Hi @wrightsg,
Thanks a lot for reporting.
Yes, for this msys2 cross-compilation case Conan will detect x86_64
that is getting from a platform.machine()
call.
Probably the best way of approaching this is what you did, setting the arch explicitly as an argument.
Anyway we'll check if some more specific autodetection can be implemented.